Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch tip-167 Excluding Merge-Ins
This is equivalent to a diff from 32a9cba0 to aed03337
2022-09-27
| ||
10:42 | Merge 8.7. Alphabetize options Closed-Leaf check-in: aed03337 user: jan.nijtmans tags: tip-167 | |
10:32 | Don't use Tcl_SaveResult() any more check-in: 89b215ec user: jan.nijtmans tags: trunk, main | |
2022-09-26
| ||
19:11 | Merge 8.7 check-in: d7e4c723 user: jan.nijtmans tags: tip-167 | |
2020-10-27
| ||
07:08 | Rename "trunk" to "main". Add "trunk" propagating tag for backwards compatibility check-in: 0f77b70d user: jan.nijtmans tags: trunk, main | |
01:25 | Merge 8.6 Closed-Leaf check-in: 32a9cba0 user: marc_culler tags: trunk | |
2020-10-26
| ||
08:58 | Merge 8.6 check-in: 88e0ce57 user: jan.nijtmans tags: trunk | |
2020-10-25
| ||
20:11 | Adjustment for Sierra. Closed-Leaf check-in: 77a51c32 user: culler tags: bug-5cc72e002c | |
Changes to .fossil-settings/ignore-glob.
︙ | ︙ | |||
16 17 18 19 20 21 22 | */Makefile */autom4te.cache */config.cache */config.log */config.status */tkConfig.sh */wish* | | | > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | */Makefile */autom4te.cache */config.cache */config.log */config.status */tkConfig.sh */wish* */tktest */versions.vc */version.vc */libtk.vfs */libtk*.zip */tkUuid.h html macosx/configure win/Debug* win/Release* win/*.manifest win/nmhlp-out.txt win/nmakehlp.out |
︙ | ︙ |
Added .github/ISSUE_TEMPLATE.md.
> > > | 1 2 3 | Important Note ========== Please do not file issues with Tk on Github. They are unlikely to be noticed in a timely fashion. Tk issues are hosted in the [tk fossil repository on core.tcl-lang.org](https://core.tcl-lang.org/tk/tktnew); please post them there. |
Added .github/PULL_REQUEST_TEMPLATE.md.
> > > | 1 2 3 | Important Note ========== Please do not file pull requests with Tk on Github. They are unlikely to be noticed in a timely fashion. Tk issues (including patches) are hosted in the [tk fossil repository on core.tcl-lang.org](https://core.tcl-lang.org/tk/tktnew); please post them there. |
Added .github/workflows/linux-build.yml.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | name: Linux on: [push] permissions: contents: read defaults: run: shell: bash working-directory: tk/unix env: ERROR_ON_FAILURES: 1 jobs: build: runs-on: ubuntu-22.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@v3 with: path: tk - name: Checkout Tcl uses: actions/checkout@v3 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" --disable-zipfs >> $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-no' }} uses: actions/upload-artifact@v2 with: name: Tk ${{ env.VERSION }} Source distribution (snapshot) path: | /tmp/dist/tk* !/tmp/dist/tk*/html/** - name: Upload Documentation Distribution if: ${{ env.BUILD_CONFIG_ID == 'gcc-no' }} uses: actions/upload-artifact@v2 with: name: Tk ${{ env.VERSION }} HTML documentation (snapshot) path: /tmp/dist/tk*/html test: runs-on: ubuntu-20.04 strategy: matrix: compiler: - "gcc" cfgopt: - "" - "--enable-symbols" steps: - name: Checkout uses: actions/checkout@v3 with: path: tk - name: Setup Environment (compiler=${{ matrix.compiler }}) run: | sudo apt-get install tcl8.6-dev libxss-dev xvfb libicu-dev mkdir "$HOME/install dir" touch tk/doc/man.macros tk/generic/tkStubInit.c echo "CFGOPT=$CFGOPT --with-tcl=/usr/lib/tcl8.6 --disable-zipfs" >> $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/linux-with-tcl8-build.yml.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | name: Linux (with Tcl 8.7) on: [push] permissions: contents: read defaults: run: shell: bash working-directory: tk/unix env: ERROR_ON_FAILURES: 1 jobs: build: runs-on: ubuntu-22.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@v3 with: path: tk - name: Checkout Tcl uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-branch path: tcl - name: Setup Environment (compiler=${{ matrix.compiler }}) run: | sudo apt-get install libxss-dev mkdir "$HOME/install dir" touch tk/doc/man.macros tk/generic/tkStubInit.c echo "CFGOPT=$CFGOPT" >> $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 and Build Tcl run: | ./configure ${CFGOPT} "--prefix=$HOME/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 working-directory: tcl/unix - name: Configure (opts=${{ matrix.cfgopt }}) run: | ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--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 (snapshot) 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 (snapshot) path: /tmp/dist/tk*/html test: runs-on: ubuntu-20.04 strategy: matrix: compiler: - "gcc" cfgopt: - "" - "--enable-symbols" steps: - name: Checkout uses: actions/checkout@v3 with: path: tk - name: Checkout Tcl uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-branch path: tcl - name: Setup Environment (compiler=${{ matrix.compiler }}) run: | sudo apt-get install libxss-dev xvfb libicu-dev mkdir "$HOME/install dir" touch tk/doc/man.macros tk/generic/tkStubInit.c echo "CFGOPT=$CFGOPT" >> $GITHUB_ENV echo "CC=$COMPILER" >> $GITHUB_ENV working-directory: "." env: CFGOPT: ${{ matrix.cfgopt }} COMPILER: ${{ matrix.compiler }} - name: Configure and Build Tcl run: | ./configure ${CFGOPT} "--prefix=$HOME/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 working-directory: tcl/unix - name: Configure ${{ matrix.cfgopt }} run: | ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--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/linux-with-tcl9-build.yml.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | name: Linux (with Tcl 9.0) on: [push] permissions: contents: read defaults: run: shell: bash working-directory: tk/unix env: ERROR_ON_FAILURES: 1 jobs: build: runs-on: ubuntu-22.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@v3 with: path: tk - name: Checkout Tcl uses: actions/checkout@v3 with: repository: tcltk/tcl ref: main path: tcl - name: Setup Environment (compiler=${{ matrix.compiler }}) run: | sudo apt-get install libxss-dev mkdir "$HOME/install dir" touch tk/doc/man.macros tk/generic/tkStubInit.c echo "CFGOPT=$CFGOPT" >> $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 and Build Tcl run: | ./configure ${CFGOPT} "--prefix=$HOME/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 working-directory: tcl/unix - name: Configure (opts=${{ matrix.cfgopt }}) run: | ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--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 test: runs-on: ubuntu-20.04 strategy: matrix: compiler: - "gcc" cfgopt: - "" - "--enable-symbols" steps: - name: Checkout uses: actions/checkout@v3 with: path: tk - name: Checkout Tcl uses: actions/checkout@v3 with: repository: tcltk/tcl ref: main path: tcl - name: Setup Environment (compiler=${{ matrix.compiler }}) run: | sudo apt-get install libxss-dev xvfb libicu-dev mkdir "$HOME/install dir" touch tk/doc/man.macros tk/generic/tkStubInit.c echo "CFGOPT=$CFGOPT" >> $GITHUB_ENV echo "CC=$COMPILER" >> $GITHUB_ENV working-directory: "." env: CFGOPT: ${{ matrix.cfgopt }} COMPILER: ${{ matrix.compiler }} - name: Configure and Build Tcl run: | ./configure ${CFGOPT} "--prefix=$HOME/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 working-directory: tcl/unix - name: Configure ${{ matrix.cfgopt }} run: | ./configure $CFGOPT --with-tcl=$TCL_CONFIG_PATH "--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.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | name: macOS on: [push] permissions: contents: read env: ERROR_ON_FAILURES: 1 jobs: xcode: runs-on: macos-11 defaults: run: shell: bash working-directory: tk/macosx steps: - name: Check out Tk uses: actions/checkout@v3 with: path: tk - name: Check out Tcl uses: actions/checkout@v3 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 } - name: Run Tests run: | make test | tee out.txt nmatches=$( grep -c "Failed 0" out.txt ) if [ $nmatches -lt 4 ] then echo "::error::Failure during Test" exit 1 fi clang: runs-on: macos-11 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@v3 with: path: tk - name: Check out Tcl uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-6-branch path: tcl - name: Prepare checked out repositories env: SET_DISPLAY: ${{ contains(matrix.options, '--disable-aqua') }} run: | touch tkStubInit.c mkdir "$HOME/install dir" echo "USE_XVFB=$SET_DISPLAY" >> $GITHUB_ENV working-directory: tk/generic - name: Add X11 (if required) if: ${{ env.USE_XVFB == 'true' }} run: | brew install --cask xquartz sudo /opt/X11/libexec/privileged_startx || 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" --disable-xft || { 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 { echo Xvfb not used, this is a --enable-aqua build } fi ( runXvfb :0; make test-classic; exit $? ) | tee out-classic.txt || { echo "::error::Failure during Test (classic)" exit 1 } ( runXvfb :0; make test-ttk; exit $? ) | tee out-ttk.txt || { echo "::error::Failure during Test (ttk)" exit 1 } cat out-classic.txt | grep -q "Failed 0" || { echo "::error::Failure in classic test results" exit 1 } cat out-ttk.txt | grep -q "Failed 0" || { echo "::error::Failure in ttk test results" exit 1 } - name: Carry out trial installation run: | make install || { cat config.log echo "::error::Failure during Install" exit 1 } |
Added .github/workflows/onefiledist.yml.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | name: Build Binaries on: [push] permissions: contents: read jobs: linux: name: Linux runs-on: ubuntu-20.04 defaults: run: shell: bash env: CC: gcc CFGOPT: --disable-symbols --disable-shared steps: - name: Checkout Tk uses: actions/checkout@v3 with: path: tk - name: Checkout Tcl 8.7 uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-branch path: tcl - name: Setup Environment run: | sudo apt-get install libxss-dev 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 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: Package run: | cp bin/wish8.7 ${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 }}_snapshot - name: Upload uses: actions/upload-artifact@v3 with: name: Wish ${{ env.TCL_PATCHLEVEL }} Linux single-file build (snapshot) path: ${{ env.INST_DIR }}/*.tar - name: Describe Installation Zip Contents if: ${{ always() }} run: | unzip -l wish${{ env.TCL_PATCHLEVEL }}_snapshot || true working-directory: ${{ env.INST_DIR }} macos: name: macOS runs-on: macos-11 defaults: run: shell: bash env: CC: gcc CFGOPT: --disable-symbols --disable-shared --enable-64bit steps: - name: Checkout Tk uses: actions/checkout@v3 with: path: tk - name: Checkout Tcl 8.7 uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-branch path: tcl - name: Checkout create-dmg uses: actions/checkout@v3 with: repository: create-dmg/create-dmg ref: v1.0.8 path: create-dmg - name: Setup Environment run: | mkdir -p 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 echo "CFLAGS=-arch x86_64 -arch arm64e" >> $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 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: Package run: | cp ../tk/unix/wish contents/${BUILD_NAME} chmod +x contents/${BUILD_NAME} cat > contents/README.txt <<EOF This is a single-file executable developer preview of Tcl/Tk $TCL_PATCHLEVEL It is not intended as an official release at all, so it is unsigned and unnotarized. Use strictly at your own risk. To run it, you need to copy the executable out and run: xattr -d com.apple.quarantine ${BUILD_NAME} to mark the executable as runnable on your machine. EOF $CREATE_DMG \ --volname "TclTk $TCL_PATCHLEVEL (snapshot)" \ --window-pos 200 120 \ --window-size 800 400 \ "TclTk-$TCL_PATCHLEVEL-(snapshot).dmg" \ "contents/" working-directory: ${{ env.INST_DIR }} env: BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_snapshot - name: Upload uses: actions/upload-artifact@v3 with: name: Wish ${{ env.TCL_PATCHLEVEL }} macOS single-file build (snapshot) path: ${{ env.INST_DIR }}/*.dmg win: name: Windows runs-on: windows-latest defaults: run: shell: msys2 {0} env: CC: gcc CFGOPT: --disable-symbols --disable-shared steps: - name: Install MSYS2 uses: msys2/setup-msys2@v2 with: msystem: MINGW64 install: git mingw-w64-x86_64-toolchain make zip - name: Checkout Tk uses: actions/checkout@v3 with: path: tk - name: Checkout Tcl 8.7 uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-branch path: tcl - name: Setup Environment run: | mkdir -p install/combined 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/win - name: Build & Install Tcl run: | make binaries libraries install $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: Package run: | cp ${TK_BIN} combined/${BUILD_NAME}.exe working-directory: install env: BUILD_NAME: wish${{ env.TCL_PATCHLEVEL }}_snapshot - name: Upload uses: actions/upload-artifact@v3 with: name: Wish ${{ env.TCL_PATCHLEVEL }} Windows single-file build (snapshot) path: install/combined/wish${{ env.TCL_PATCHLEVEL }}_snapshot.exe |
Added .github/workflows/win-build.yml.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | name: Windows on: [push] permissions: contents: read 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@v3 with: path: tk - name: Checkout uses: actions/checkout@v3 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: msys2 {0} working-directory: win strategy: matrix: symbols: - "no" - "mem" - "all" steps: - name: Install MSYS2 uses: msys2/setup-msys2@v2 with: msystem: MINGW64 install: git mingw-w64-x86_64-toolchain make zip - name: Checkout uses: actions/checkout@v3 - name: Checkout uses: actions/checkout@v3 with: repository: tcltk/tcl ref: core-8-6-branch path: tcl - 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 } |
Changes to .gitignore.
︙ | ︙ | |||
22 23 24 25 26 27 28 | config.status config.status.lineno html manifest.uuid _FOSSIL_ */tkConfig.sh */wish* | | | | > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | config.status config.status.lineno html manifest.uuid _FOSSIL_ */tkConfig.sh */wish* */tktest */versions.vc */version.vc */libtk.vfs */libtk*.zip */tkUuid.h libtommath/bn.ilg libtommath/bn.ind libtommath/pretty.build libtommath/tommath.src libtommath/*.log libtommath/*.pdf libtommath/*.pl |
︙ | ︙ |
Changes to .travis.yml.
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 | - gcc-mingw-w64 - gcc-mingw-w64-base - gcc-mingw-w64-i686 - gcc-mingw-w64-x86-64 - gcc-multilib - tcl8.6-dev - libx11-dev - xvfb homebrew: packages: - tcl-tk | > > > > > | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | - gcc-mingw-w64 - gcc-mingw-w64-base - gcc-mingw-w64-i686 - gcc-mingw-w64-x86-64 - gcc-multilib - tcl8.6-dev - libx11-dev - libnotify-dev - libglib2.0-dev - libxss-dev - xvfb homebrew: packages: - tcl-tk - libnotify - glib # casks: # - xquartz jobs: include: # Testing on Linux GCC - name: "Linux/GCC/Shared" os: linux dist: focal services: |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | dist: focal services: - xvfb compiler: gcc env: - BUILD_DIR=unix - CFGOPT="--disable-xft" script: *x11gui - name: "Linux/GCC/Shared/bionic" os: linux dist: bionic services: - xvfb compiler: gcc | > > > > > > > > > > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | dist: focal services: - xvfb compiler: gcc env: - BUILD_DIR=unix - CFGOPT="--disable-xft" 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 |
︙ | ︙ | |||
177 178 179 180 181 182 183 | - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include" - name: "macOS/Clang++/Xcode 12/Shared" os: osx 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" | < < < < < < < < < < < < < < < < | | | | | | < < < < < < < < < < < < | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - CFGOPT="--with-tcl=/usr/local/opt/tcl-tk/lib --enable-aqua CFLAGS=-I/usr/local/opt/tcl-tk/include" - name: "macOS/Clang++/Xcode 12/Shared" os: osx 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/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" - name: "macOS/Xcode 12/Debug" os: osx 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" # - 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 # - BUILD_DIR=win # - VCDIR="/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build" |
︙ | ︙ | |||
288 289 290 291 292 293 294 295 296 297 298 | - cd ${BUILD_DIR} install: - mkdir "$HOME/install dir" - ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1) script: - make all tktest - make install cache: directories: - $HOME/AppData/Local/Temp/chocolatey - $HOME/AppData/Local/Apps/Tcl86 | > > > > > > > > | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | - cd ${BUILD_DIR} install: - mkdir "$HOME/install dir" - ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 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 |
Changes to ChangeLog.
︙ | ︙ | |||
3199 3200 3201 3202 3203 3204 3205 | * library/demos/mclist.tcl: Added support for arrow indicators to show which way a column is being sorted. Corrected determination of which fonts to use for measurements. 2009-03-25 Jan Nijtmans <[email protected]> * doc/wish.1: Bring doc and demos in line with | | | 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 | * library/demos/mclist.tcl: Added support for arrow indicators to show which way a column is being sorted. Corrected determination of which fonts to use for measurements. 2009-03-25 Jan Nijtmans <[email protected]> * doc/wish.1: Bring doc and demos in line with * library/demos/hello: https://wiki.tcl-lang.org/page/exec+magic * library/demos/rmt * library/demos/square * library/demos/tcolor * library/demos/timer * library/demos/widget * win/tkWinMenu.c: Eliminate a few compiler warnings on mingw * win/ttkWinXPTheme.c: Spacing |
︙ | ︙ |
Changes to README.md.
1 2 | # README: Tk | | > > > > > > > > > | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # README: Tk This is the **Tk 8.7a6** 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) [](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-6-branch) [](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-6-branch) [](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-6-branch) <br> 8.7 (in development, daily build)) [](https://github.com/tcltk/tk/actions?query=workflow%3A%22Linux%22+branch%3Amain) [](https://github.com/tcltk/tk/actions?query=workflow%3A%22Windows%22+branch%3Amain) [](https://github.com/tcltk/tk/actions?query=workflow%3A%22macOS%22+branch%3Amain) ## <a id="intro">1.</a> Introduction This directory contains the sources and documentation for Tk, a cross-platform GUI toolkit implemented with the Tcl scripting language. For details on features, incompatibilities, and potential problems with this release, see [the Tcl/Tk 8.7 Web page](https://www.tcl-lang.org/software/tcltk/8.7.html) 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 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 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. ## <a id="tcl">2.</a> See Tcl README.md Please see the README.md file that comes with the associated Tcl release |
︙ | ︙ |
Changes to changes.
︙ | ︙ | |||
7433 7434 7435 7436 7437 7438 7439 | 2017-03-21 (TIP 442) display text in a progressbar (zaumseil) 2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans) 2017-08-28 (TIP 166) Extended color notation for alpha channel (bachmann) | | | 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 | 2017-03-21 (TIP 442) display text in a progressbar (zaumseil) 2017-04-13 \u escaped content in msg files converted to true utf-8 (nijtmans) 2017-08-28 (TIP 166) Extended color notation for alpha channel (bachmann) --- Released 8.7a1, September 8, 2017 --- https://core.tcl-lang.org/tk/ for details 2017-08-24 (bug)[f1a3ca] Memory leak in [text] B-tree (edhume3) 2017-08-24 (bug)[ee40fd] Report [console] init errors (the) 2017-08-24 (bug)[3295446] Improve history visibility in [console] (goth) |
︙ | ︙ | |||
7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 | 2019-11-17 [90d555] workaround NSFontManager bad selections (culler) 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 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) *** POTENTIAL INCOMPATIBILITY *** 2017-12-07 [TIP 487] End support for pre-XP Windows (nijtmans) 2018-03-04 [TIP 489] New subcommand [$canvas image] (pitcher,vogel) 2018-05-13 [TIP 496] New options -placeholder* for entries (zaumseil,vogel) 2018-09-23 [TIP 517] New option -activerelief for menus (vogel) 2018-11-03 [TIP 512] Deprecate stub for Tk_MainEx() (nijtmans) 2018-11-06 [TIP 415] New option -height for [$canvas create arc] (geard) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 | 2019-11-17 [90d555] workaround NSFontManager bad selections (culler) 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)[40e4bf] 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 2021-01-04 (bug)[19fb7a] Mac: [tk_messageBox] use proper icons (ericwb,culler) 2021-01-11 (bug)[7beaed] ttk::bindMouseWheel syntax error (nemethi) 2021-01-15 (new) support 4 new keycodes: CodeInput, SingleCandidate, MultipleCandidate, PreviousCandidate (nijtmans) 2021-01-18 (new) Portable keycodes: OE, oe, Ydiaeresis (nijtmans) 2021-01-27 (bug)[bdcab8] Mac crash on non-BMP menu label (nab,culler) 2021-02-07 (bug)[9e1312] <Enter> to parent after child destroyed (leunissen) 2021-02-10 (bug)[d3cd4c] more robust notebook processing (nemethi) 2021-02-25 (bug)[234ee4] crash in [clipboard get] invalid encoding (nijtmans) 2021-02-25 (bug)[be9cad] Poor trace housekeeping -> tkwait segfault (michael) 2021-03-02 (bug)[1626ed] Mac: crash with dead key as menu accelerator (culler) 2021-03-22 (bug)[9b6065] restore Tcl [update], see window-2.12 (leunissen) 2021-04-07 (bug)[58222c] Mac: entry and spinbox bg colors (chavez,culler) 2021-04-18 (bug)[34db75,ea876b] cursor motion in peer text (vogel) 2021-04-26 (bug)[c97464] memleak in TkpDrawAngledChars (nab,culler) 2021-04-29 Mac: explicit backing CALayer to fix rendering issues (culler) 2021-05-02 Mac: respect key repeat system setting (culler) 2021-05-10 (bug)[171ba7] crash when grab and focus are not coordinated (culler) 2021-05-24 crash due to failed transient record housekeeping (culler) 2021-05-25 (bug)[7bda98] Mac: <Double-1> bindings fire twice on app activation 2021-06-03 (bug)[4401d3] Mac: improved support of pixel formats (chavez,culler) 2021-06-03 (bug)[8ecc3e] Mac: window exposed by Mission Control (chavez,culler) 2021-06-04 (bug)[099109] segfault reusing a container toplevel (culler) 2021-06-22 (bug)[4efbfe] static package init order in wish (werner) 2021-09-21 (bug)[033886] Win: hang in font loading (e-paine,vogel) 2021-10-14 (bug)[8ebed3] multi-thread safety in Xft use (werner) 2021-10-22 (new)[TIP 608] New virtual event <<TkWorldChanged>> (griffin) 2021-10-27 (bug) file dialog compatibility with Mac OS 12 (culler) 2021-10-29 (bug) Mac: stop crash when non-Tk windows go full screen (werner) 2021-10-30 (bug)[6ea0b3] Mac: grab from menu makes dead window (culler) - Released 8.6.12, Nov 5, 2021 - 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) *** POTENTIAL INCOMPATIBILITY *** 2017-12-07 [TIP 487] End support for pre-XP Windows (nijtmans) 2018-03-04 [TIP 489] New subcommand [$canvas image] (pitcher,vogel) 2018-05-13 [TIP 496] New options -placeholder* for entries (zaumseil,vogel) 2018-09-23 [TIP 517] New option -activerelief for menus (vogel) 2018-11-03 [TIP 512] Deprecate stub for Tk_MainEx() (nijtmans) 2018-11-06 [TIP 415] New option -height for [$canvas create arc] (geard) 2018-11-06 [TIP 518] New event <<NoManagedChild>> (oehlmann) 2019-04-14 [TIP 164] New subcommand [$canvas rotate] (fellows) 2019-04-14 [TIP 507] New photo image format 'svg' (zaumseil) 2019-04-14 [TIP 483] Record more configuration items (cassoff) 2019-04-14 [TIP 482] Record configured directory for demos (cassoff) 2019-05-25 [TIP 262] New frame options -backgroundimage, -tile (fellows) 2019-06-15 [TIP 528] Deprecate Tk_Offset() (nijtmans) 2019-08-19 [TIP 545] Revised options for photo image format 'svg' (oehlmann) --- Released 8.7a3, November 25, 2019 --- https://core.tcl-lang.org/tk/ for details Changes to 8.7a5 include all changes to the 8.6 line through 8.6.11, plus the following, which focuses on the high-level feature changes in this changeset (new minor version) rather than bug fixes: 2020-02-22 [TIP 565] Gracefully ignore non-existent tags in canvas raise/lower 2020-02-22 [TIP 564] Specify ttk font sizes in points on X11 2020-02-24 [TIP 563] Scrollwheel on Horizontal Scrollbar Scrolls Without Shift too 2020-02-28 [TIP 557] C++ support 2020-03-12 (bug)[355180] solve XKeycodeToKeysym deprecation *** POTENTIAL INCOMPATIBILITY -- Tk 8.7 now requires X11R6 *** 2020-03-18 [TIP 569] Eliminate comments that serve lint 2020-05-17 [d87dc2] Remove TkMacOSXGetStringObjFromCFString() 2020-05-24 [TIP 574] Add a 'tag delete' command to the ttk::treeview widget 2020-06-27 (bug)[50ed1e] spinbox with duplicate values 2020-07-03 [TIP 578] Death to TCL_DBGX 2020-08-23 (bug)[bb85d2] valgrind on TIP 489 2020-08024 (bug)[d30c21] default colors for TIP 496 2020-09-02 [TIP 580] Export Tk_GetDoublePixelsFromObj and 5 more 2020-10-21 [TIP 474] Uniform mouse wheel events 2020-11-15 [TIP 584] Better introspection for ttk 2020-11-16 [TIP 588] Unicode for (X11) keysyms 2020-12-03 [TIP 590] Recommend lowercase package names 2020-12-09 (bug)[d6e9b4] SVG memory overflow 2020-12-11 [TIP 591] Rotate ttk::notebook window with mousewheel on tab 2020-12-12 [TIP 325] System tray and system notification 2021-01-08 [TIP 592] End support: Windows XP, Server 2003, Vista, Server 2008 2021-01-08 (bug)[822330] Prevent buffer overflow in SVG image. 2021-01-28 (bug)[237971] 'end' argument to [$canvas insert] 2021-02-25 (bug)[be9cad] crash in [tkwait] 2021-02-27 [TIP 529] Add metadata dictionary property to tk photo image 2021-03-02 (bug)[1626ed] Aqua crash: dead keys as meny accelerator 2021-03-29 (bug)[9b6065] Restore Tcl [update] when Tk is destroyed 2021-04-08 (bug)[58222c] background colors 2021-04-09 [TIP 595] Unicode-aware/case-sensitive Loadable Library handling 2021-04-21 (bug)[cde766] update scrollbars on treeview 2021-04-26 (bug)[c97464] memleak in aqua fonts 2021-05-02 (bug)[2ecb09] Follow Mac OSX Key-repeat setting 2021-05-03 (bug)[8a5086] ttk::entry issue 2021-05-22 (bug)[3e3360] bind substitution %S 2021-05-25 (bug)[7bda98] aqua: double click bind with changing focus - Released 8.7a5, Jun 18, 2021 --- https://core.tcl-lang.org/tcl/ for details - |
Changes to doc/3DBorder.3.
1 2 3 4 5 6 7 8 9 10 11 | '\" '\" Copyright (c) 1990-1993 The Regents of the University of California. '\" Copyright (c) 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. '\" .TH Tk_Alloc3DBorderFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME | | > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | '\" '\" Copyright (c) 1990-1993 The Regents of the University of California. '\" Copyright (c) 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. '\" .TH Tk_Alloc3DBorderFromObj 3 8.1 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_Alloc3DBorderFromObj, Tk_ClipDrawableToRect, Tk_DrawHighlightBorder, Tk_Get3DBorder, fBTk_Get3DBorderColors, Tk_Get3DBorderFromObj, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorderFromObj, Tk_Free3DBorder \- draw borders with three-dimensional appearance .SH SYNOPSIS .nf \fB#include <tk.h>\fR .sp Tk_3DBorder \fBTk_Alloc3DBorderFromObj(\fIinterp, tkwin, objPtr\fB)\fR .sp void \fBTk_ClipDrawableToRect(\fIdisplay, drawable, x, y, width, height\fB)\fR .sp void \fBTk_DrawHighlightBorder(\fItkwin, fgGC, bgGC, highlightWidth, drawable\fB)\fR .sp Tk_3DBorder \fBTk_Get3DBorder(\fIinterp, tkwin, colorName\fB)\fR .sp void \fBTk_Get3DBorderColors(\fIborder, bgColorPtr, darkColorPtr, lightColorPtr\fB)\fR .sp Tk_3DBorder \fBTk_Get3DBorderFromObj(\fItkwin, objPtr\fB)\fR .sp void \fBTk_Draw3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR .sp void |
︙ | ︙ | |||
86 87 88 89 90 91 92 93 94 95 96 97 98 99 | Width of rectangle describing border or bevel, in pixels. .AP int height in Height of rectangle describing border or bevel, in pixels. .AP int borderWidth in Width of border in pixels. Positive means border is inside rectangle given by \fIx\fR, \fIy\fR, \fIwidth\fR, \fIheight\fR, negative means border is outside rectangle. .AP int relief in Indicates 3-D position of interior of value relative to exterior; should be \fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, \fBTK_RELIEF_GROOVE\fR, \fBTK_RELIEF_SOLID\fR, or \fBTK_RELIEF_RIDGE\fR (may also be \fBTK_RELIEF_FLAT\fR for \fBTk_Fill3DRectangle\fR). .AP XPoint *pointPtr in Pointer to array of points describing the set of vertices in a polygon. | > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | Width of rectangle describing border or bevel, in pixels. .AP int height in Height of rectangle describing border or bevel, in pixels. .AP int borderWidth in Width of border in pixels. Positive means border is inside rectangle given by \fIx\fR, \fIy\fR, \fIwidth\fR, \fIheight\fR, negative means border is outside rectangle. .AP int highlightWidth in Width of ring around the outside of the widget if the widget has received the input focus. .AP int relief in Indicates 3-D position of interior of value relative to exterior; should be \fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, \fBTK_RELIEF_GROOVE\fR, \fBTK_RELIEF_SOLID\fR, or \fBTK_RELIEF_RIDGE\fR (may also be \fBTK_RELIEF_FLAT\fR for \fBTk_Fill3DRectangle\fR). .AP XPoint *pointPtr in Pointer to array of points describing the set of vertices in a polygon. |
︙ | ︙ | |||
129 130 131 132 133 134 135 136 137 138 139 140 141 142 | right than the top. .AP int topBevel in Non-zero means this bevel forms the top side of the value; zero means it forms the bottom side. .AP int which in Specifies which of the border's graphics contexts is desired. Must be \fBTK_3D_FLAT_GC\fR, \fBTK_3D_LIGHT_GC\fR, or \fBTK_3D_DARK_GC\fR. .BE .SH DESCRIPTION .PP These procedures provide facilities for drawing window borders in a way that produces a three-dimensional appearance. \fBTk_Alloc3DBorderFromObj\fR allocates colors and Pixmaps needed to draw a border in the window | > > > > > > > > > > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | right than the top. .AP int topBevel in Non-zero means this bevel forms the top side of the value; zero means it forms the bottom side. .AP int which in Specifies which of the border's graphics contexts is desired. Must be \fBTK_3D_FLAT_GC\fR, \fBTK_3D_LIGHT_GC\fR, or \fBTK_3D_DARK_GC\fR. .AP XColor *bgColorPtr out Pointer to location in which to store the background color of the given border. .AP XColor *darkColorPtr out Pointer to location in which to store the color for darker areas of the given border. .AP XColor *lightColorPtr out Pointer to location in which to store the color for lighter areas of the given border. .AP GC fgGC in Foreground X graphics context. .AP GC fgGC in Background X graphics context. .BE .SH DESCRIPTION .PP These procedures provide facilities for drawing window borders in a way that produces a three-dimensional appearance. \fBTk_Alloc3DBorderFromObj\fR allocates colors and Pixmaps needed to draw a border in the window |
︙ | ︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | for the border (e.g. a bogus color name was given) then NULL is returned and an error message is left as the result of interpreter \fIinterp\fR. If it returns successfully, \fBTk_Alloc3DBorderFromObj\fR caches information about the return value in \fIobjPtr\fR, which speeds up future calls to \fBTk_Alloc3DBorderFromObj\fR with the same \fIobjPtr\fR and \fItkwin\fR. .PP \fBTk_Get3DBorder\fR is identical to \fBTk_Alloc3DBorderFromObj\fR except that the color is specified with a string instead of a value. This prevents \fBTk_Get3DBorder\fR from caching the return value, so \fBTk_Get3DBorder\fR is less efficient than \fBTk_Alloc3DBorderFromObj\fR. .PP \fBTk_Get3DBorderFromObj\fR returns the token for an existing border, given the window and color name used to create the border. \fBTk_Get3DBorderFromObj\fR does not actually create the border; it must already have been created with a previous call to \fBTk_Alloc3DBorderFromObj\fR or \fBTk_Get3DBorder\fR. The return value is cached in \fIobjPtr\fR, which speeds up | > > > > > > > > > > > > > | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | for the border (e.g. a bogus color name was given) then NULL is returned and an error message is left as the result of interpreter \fIinterp\fR. If it returns successfully, \fBTk_Alloc3DBorderFromObj\fR caches information about the return value in \fIobjPtr\fR, which speeds up future calls to \fBTk_Alloc3DBorderFromObj\fR with the same \fIobjPtr\fR and \fItkwin\fR. .PP \fBTk_ClipDrawableToRect\fR will clip all drawing into the drawable d to the given rectangle. If width or height are negative, reset to no clipping. Subsequent drawing into d is offset and clipped as specified. The function is only used when \fBTK_NO_DOUBLE_BUFFERING\fR is specified at compile time. .PP \fBTk_DrawHighlightBorder\fR draws a rectangular ring around the outside of a widget to indicate that it has received the input focus. On the Macintosh, this puts a 1 pixel border in the bgGC color between the widget and the focus ring, except in the case where highlightWidth is 1, in which case the border is left out. For proper Mac L&F, use highlightWidth of 3. .PP \fBTk_Get3DBorder\fR is identical to \fBTk_Alloc3DBorderFromObj\fR except that the color is specified with a string instead of a value. This prevents \fBTk_Get3DBorder\fR from caching the return value, so \fBTk_Get3DBorder\fR is less efficient than \fBTk_Alloc3DBorderFromObj\fR. .PP \fBTk_Get3DBorderColors\fR returns the used colors of the given border. .PP \fBTk_Get3DBorderFromObj\fR returns the token for an existing border, given the window and color name used to create the border. \fBTk_Get3DBorderFromObj\fR does not actually create the border; it must already have been created with a previous call to \fBTk_Alloc3DBorderFromObj\fR or \fBTk_Get3DBorder\fR. The return value is cached in \fIobjPtr\fR, which speeds up |
︙ | ︙ |
Changes to doc/AddOption.3.
1 | '\" | | > > > > > > > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_AddOption 3 "" Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_AddOption \- Add an option to the option database .SH SYNOPSIS .nf \fB#include <tk.h>\fR .sp void \fBTk_AddOption\fR(\fItkwin, name, value, priority\fR) .sp void \fBTk_GetSystemDefault\fR(\fItkwin, dbName, className\fR) .SH ARGUMENTS .AP Tk_Window tkwin in Token for window. .AP "const char" *name in Multi-element name of option. .AP "const char" *value in Value of option. .AP "const char" *dbName in The option database name. .AP "const char" *className in The name of the option class. .AP int priority in Overall priority level to use for option. .BE .SH DESCRIPTION .PP \fBTk_AddOption\fR is invoked to add an option to the database associated with \fItkwin\fR's main window. \fIName\fR contains the option being specified and consists of names and/or classes separated by asterisks or dots, in the usual X format. \fIValue\fR contains the text string to associate with \fIname\fR; this value will be returned in calls to \fBTk_GetOption\fR. \fIPriority\fR specifies the priority of the value; when options are queried using \fBTk_GetOption\fR, the value with the highest priority is returned. \fIPriority\fR must be between 0 and \fBTK_MAX_PRIO\fR. Some common priority values are: .IP 20 Used for default values hard-coded into widgets. .IP 40 Used for options specified in application-specific startup files. .IP 60 Used for options specified in user-specific defaults files, such as \fB.Xdefaults\fR, resource databases loaded into the X server, or user-specific startup files. .IP 80 Used for options specified interactively after the application starts running. \fBTk_GetSystemDefault\fR return a Tk_Uid string representation of the given \fIdbname\fR and \fIclassName\fR of a configuration option. Returns NULL if there are no system defaults that match this pair. .SH KEYWORDS class, name, option, add |
Changes to doc/CrtPhImgFmt.3.
1 2 3 4 5 6 7 8 9 10 11 | '\" '\" Copyright (c) 1994 The Australian National University '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" Author: Paul Mackerras ([email protected]), '\" Department of Computer Science, '\" Australian National University. '\" | | > > > > | > > > > | > > > > > | | | | > | | | | | | | | > | | > > | > > | > > | | | > > | > > > | > > > | | > | > | | > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | '\" '\" Copyright (c) 1994 The Australian National University '\" Copyright (c) 1994-1997 Sun Microsystems, Inc. '\" '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" '\" Author: Paul Mackerras ([email protected]), '\" Department of Computer Science, '\" Australian National University. '\" .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 <tk.h>\fR .sp .VS 8.7 \fBTk_CreatePhotoImageFormatVersion3\fR(\fIformatVersion3Ptr\fR) .VE 8.7 .sp \fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR) .SH ARGUMENTS .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_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 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 \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_PhotoImageFormatVersion3 { const char *\fIname\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 implemented, the corresponding pointer in the Tk_PhotoImageFormat structure should be set to NULL. The handler must provide the \fIfileMatchProc\fR procedure if it provides the \fIfileReadProc\fR 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_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_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_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 suitable for reading data from a given string. \fIformatPtr->stringMatchProc\fR must match the following prototype: .CS 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_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. .SS FILEREADPROC .PP \fIformatPtr->fileReadProc\fR provides the address of a procedure for Tk to call to read data from an image file into a photo image. \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, 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, 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 value given for the \fB\-format\fR option, or NULL if the option was not specified. The image data in the file, 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 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 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, 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 \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. \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, 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 Tk_PhotoImageBlock structure pointed to by \fIblockPtr\fR; see the manual page FindPhoto(3) for details. The \fIfileName\fR argument points to the string giving the name of the file in which to write 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. 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 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 Tk_PhotoImageBlock structure pointed to by \fIblockPtr\fR; see the manual page FindPhoto(3) for details. The data for the string should be put in the interpreter \fIinterp\fR result. The \fIformat\fR argument contains the 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 <tk.h>\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 those days may still contain code that defines extended Tk photo image formats using the old interface. The Tk header file will still support |
︙ | ︙ |
Changes to doc/GetHINSTANCE.3.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_GetHISTANCE 3 "" Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_GetHINSTANCE \- retrieve the global application instance handle |
︙ | ︙ |
Changes to doc/GetHWND.3.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH HWND 3 8.0 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_GetHWND, Tk_AttachHWND \- manage interactions between the Windows handle and an X window |
︙ | ︙ |
Changes to doc/Grab.3.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_Grab 3 "" Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_Grab, Tk_Ungrab \- manipulate grab state in an application |
︙ | ︙ |
Changes to doc/HWNDToWindow.3.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_HWNDToWindow 3 "" Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_HWNDToWindow \- Find Tk's window information for a Windows window |
︙ | ︙ |
Changes to doc/Inactive.3.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH Tk_GetUserInactiveTime 3 8.5 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_GetUserInactiveTime, Tk_ResetUserInactiveTime \- discover user inactivity time |
︙ | ︙ |
Changes to doc/MainWin.3.
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | .SH SYNOPSIS .nf \fB#include <tk.h>\fR .sp Tk_Window \fBTk_MainWindow\fR(\fIinterp\fR) .sp int \fBTk_GetNumMainWindows\fR() .SH ARGUMENTS .AS Tcl_Interp *pathName .AP Tcl_Interp *interp in/out Interpreter associated with the application. .BE .SH DESCRIPTION .PP A main window is a special kind of toplevel window used as the outermost window in an application. .PP If \fIinterp\fR is associated with a Tk application then \fBTk_MainWindow\fR returns the application's main window. If there is no Tk application associated with \fIinterp\fR then \fBTk_MainWindow\fR returns NULL and leaves an error message in interpreter \fIinterp\fR's result. .PP \fBTk_GetNumMainWindows\fR returns a count of the number of main windows currently open in the current thread. .SH KEYWORDS application, main window | > > > > > > > > > > > > > > > > > > > > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | .SH SYNOPSIS .nf \fB#include <tk.h>\fR .sp Tk_Window \fBTk_MainWindow\fR(\fIinterp\fR) .sp void \fBTk_SetMainMenubar\fR(\fIinterp, tkwin, menuName\fR) .sp void \fBTk_SetWindowMenubar\fR(\fIinterp, tkwin, oldMenuName, menuName\fR) .sp int \fBTk_GetNumMainWindows\fR() .SH ARGUMENTS .AS Tcl_Interp *pathName .AP Tcl_Interp *interp in/out Interpreter associated with the application. .AP Tk_Window tkwin in Token for main window. .AP const char *menuName in The name of the new menubar that the toplevel needs to be set to. NULL means that their is no menu now. .AP const char *oldMenuName in The name of the menubar previously set in this toplevel. NULL means no menu was set previously. .BE .SH DESCRIPTION .PP A main window is a special kind of toplevel window used as the outermost window in an application. .PP If \fIinterp\fR is associated with a Tk application then \fBTk_MainWindow\fR returns the application's main window. If there is no Tk application associated with \fIinterp\fR then \fBTk_MainWindow\fR returns NULL and leaves an error message in interpreter \fIinterp\fR's result. .PP \fBTk_GetNumMainWindows\fR returns a count of the number of main windows currently open in the current thread. \fBTk_SetMainMenubar\fR Called when a toplevel widget is brought to front. On the Macintosh, sets up the menubar that goes accross the top of the main monitor. On other platforms, nothing is necessary. \fBTk_SetWindowMenubar\fR associates a menu with a window. The old menu clones for the menubar are thrown away, and a handler is set up to allocate the new ones. .SH KEYWORDS application, main window |
Changes to doc/SetOptions.3.
︙ | ︙ | |||
329 330 331 332 333 334 335 | the \fIclientData\fR field of the Tk_OptionSpec, then it is indicated explicitly; if not mentioned, the type requires neither \fItkwin\fR nor \fIclientData\fR. .TP \fBTK_OPTION_ANCHOR\fR The value must be a standard anchor position such as \fBne\fR or \fBcenter\fR. The internal form is a Tk_Anchor value like the ones | | > > | > > > > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | the \fIclientData\fR field of the Tk_OptionSpec, then it is indicated explicitly; if not mentioned, the type requires neither \fItkwin\fR nor \fIclientData\fR. .TP \fBTK_OPTION_ANCHOR\fR The value must be a standard anchor position such as \fBne\fR or \fBcenter\fR. The internal form is a Tk_Anchor value like the ones returned by \fBTk_GetAnchorFromObj\fR. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if the empty string is specified as the value for the option, the integer relief value is set to \fBTK_ANCHOR_NULL\fR. .TP \fBTK_OPTION_BITMAP\fR The value must be a standard Tk bitmap name. The internal form is a Pixmap token like the ones returned by \fBTk_AllocBitmapFromObj\fR. This option type requires \fItkwin\fR to be supplied to procedures such as \fBTk_SetOptions\fR, and it supports the \fBTK_OPTION_NULL_OK\fR flag. .TP \fBTK_OPTION_BOOLEAN\fR The value must be a standard boolean value such as \fBtrue\fR or \fBno\fR. The internal form is an integer with value 0 or 1. Note: if the \fIobjOffset\fR field is not used then information about the original value of this option will be lost. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal representation is set to -1. .TP \fBTK_OPTION_BORDER\fR The value must be a standard color name such as \fBred\fR or \fB#ff8080\fR. The internal form is a Tk_3DBorder token like the ones returned by \fBTk_Alloc3DBorderFromObj\fR. This option type requires \fItkwin\fR to be supplied to procedures such as \fBTk_SetOptions\fR, and it supports the \fBTK_OPTION_NULL_OK\fR flag. |
︙ | ︙ | |||
373 374 375 376 377 378 379 | clientData field of the entry points to a structure defining the new option type. See the section \fBCUSTOM OPTION TYPES\fR below for details. .TP \fBTK_OPTION_DOUBLE\fR The string value must be a floating-point number in the format accepted by \fBstrtol\fR. The internal form is a C \fBdouble\fR value. This option type supports the \fBTK_OPTION_NULL_OK\fR | | | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | clientData field of the entry points to a structure defining the new option type. See the section \fBCUSTOM OPTION TYPES\fR below for details. .TP \fBTK_OPTION_DOUBLE\fR The string value must be a floating-point number in the format accepted by \fBstrtol\fR. The internal form is a C \fBdouble\fR value. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal representation is set to NaN. .TP \fBTK_OPTION_END\fR Marks the end of the template. There must be a Tk_OptionSpec structure with \fItype\fR \fBTK_OPTION_END\fR at the end of each template. If the \fIclientData\fR field of this structure is not NULL, then it points to an additional array of Tk_OptionSpec's, which is itself terminated by another \fBTK_OPTION_END\fR entry. Templates may be chained arbitrarily |
︙ | ︙ | |||
395 396 397 398 399 400 401 | This option type requires \fItkwin\fR to be supplied to procedures such as \fBTk_SetOptions\fR, and it supports the \fBTK_OPTION_NULL_OK\fR flag. .TP \fBTK_OPTION_INT\fR The string value must be an integer in the format accepted by \fBstrtol\fR (e.g. \fB0\fR and \fB0x\fR prefixes may be used to specify octal or hexadecimal numbers, respectively). The internal | | > | > > | | | | 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | This option type requires \fItkwin\fR to be supplied to procedures such as \fBTk_SetOptions\fR, and it supports the \fBTK_OPTION_NULL_OK\fR flag. .TP \fBTK_OPTION_INT\fR The string value must be an integer in the format accepted by \fBstrtol\fR (e.g. \fB0\fR and \fB0x\fR prefixes may be used to specify octal or hexadecimal numbers, respectively). The internal form is a C \fBint\fR value. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal representation is set to INT_MIN. .TP \fBTK_OPTION_JUSTIFY\fR The value must be a standard justification value such as \fBleft\fR. The internal form is a Tk_Justify like the values returned by \fBTk_GetJustifyFromObj\fR. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if the empty string is specified as the value for the option, the integer relief value is set to \fBTK_JUSTIFY_NULL\fR. .TP \fBTK_OPTION_PIXELS\fR The value must specify a screen distance such as \fB2i\fR or \fB6.4\fR. The internal form is an integer value giving a distance in pixels, like the values returned by \fBTk_GetPixelsFromObj\fR. Note: if the \fIobjOffset\fR field is not used then information about the original value of this option will be lost. See \fBOBJOFFSET VS. INTERNALOFFSET\fR below for details. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal representation is set to INT_MIN. .TP \fBTK_OPTION_RELIEF\fR The value must be standard relief such as \fBraised\fR. The internal form is an integer relief value such as \fBTK_RELIEF_RAISED\fR. This option type supports the \fBTK_OPTION_NULL_OK\fR flag; if a NULL value is set, the internal representation is set to \fBTK_RELIEF_NULL\fR. .TP \fBTK_OPTION_STRING\fR The value may be any string. The internal form is a (char *) pointer that points to a dynamically allocated copy of the value. This option type supports the \fBTK_OPTION_NULL_OK\fR flag. .TP \fBTK_OPTION_STRING_TABLE\fR |
︙ | ︙ |
Changes to doc/TextLayout.3.
︙ | ︙ | |||
104 105 106 107 108 109 110 | The index of the first character to draw from the given text layout. The number 0 means to draw from the beginning. .AP int lastChar in The index of the last character up to which to draw. The character specified by \fIlastChar\fR itself will not be drawn. A number less than 0 means to draw all characters in the text layout. .AP int underline in | | > | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | The index of the first character to draw from the given text layout. The number 0 means to draw from the beginning. .AP int lastChar in The index of the last character up to which to draw. The character specified by \fIlastChar\fR itself will not be drawn. A number less than 0 means to draw all characters in the text layout. .AP int underline in Index of the single character to underline in the text layout, or a negative number counting backwards from the end of the string. Any out-of-range number (e.g. INT_MIN) means no underline. .AP int index in The index of the character whose bounding box is desired. The bounding box is computed with respect to the upper-left hand corner of the text layout. .AP int "*xPtr, *yPtr" out Filled with the upper-left hand corner, in pixels, of the bounding box for the character specified by \fIindex\fR. Either or both \fIxPtr\fR and \fIyPtr\fR may be NULL, in which case the corresponding value |
︙ | ︙ |
Added doc/WinUtil.3.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | '\" '\" Copyright (c) 1990-1993 The Regents of the University of California. '\" Copyright (c) 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. '\" .TH Tk_ConfigureWindow 3 4.0 Tk "Tk Library Procedures" .so man.macros .BS .SH NAME Tk_GetOtherWindow, Tk_MakeContainer, Tk_MakeWindow, Tk_UseWindow \- window utility functions .SH SYNOPSIS .nf \fB#include <tk.h>\fR .sp Tk_Window \fBTk_GetOtherWindow(\fItkwin\fB)\fR .sp \fBTk_MakeContainer(\fItkwin\fB)\fR .sp \fBTk_MakeWindow(\fItkwin, parent\fB)\fR .sp int \fBTk_UseWindow(\fIinterp, tkwin, string\fB)\fR .SH ARGUMENTS .AS XSetWindowAttributes borderWidth .AP Tcl_Interp * interp in Interpreter associated with the application. .AP Tk_Window tkwin in Token for window. .AP Window parent in Parent window. .AP "const char" *string in String identifying an X window to use for \fItkwin\fR; must be an integer value. .BE .SH DESCRIPTION .PP If both the container and embedded window are in the same process, \fBTk_GetOtherWindow\fR will return either one, given the other. If winPtr is a container, the return value is the token for the embedded window, and vice versa. If the "other" window isn't in this process, NULL is returned. .PP \fBTk_MakeContainer\fR is called to indicate that a particular window will be a container for an embedded application. This changes certain aspects of the window's behavior, such as whether it will receive events anymore. .PP \fBTk_MakeWindow\fR creates an actual window system window object based on the current attributes of the specified TkWindow. It returns the handle to the new window, or None on failure. .PP \fBTk_UseWindow\fR causes a Tk window to use a given X window as its parent window, rather than the root window for the screen. It is invoked by an embedded application to specify the window in which it is embedded. .PP The return value is normally TCL_OK. If an error occurs (such as string not being a valid window spec), then the return value is TCL_ERROR and an error message is left in the interp's result if interp is non-NULL. .PP .SH KEYWORDS parent, window |
Changes to doc/bind.n.
1 2 3 | '\" '\" Copyright (c) 1990 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. | | | 1 2 3 4 5 6 7 8 9 10 11 | '\" '\" Copyright (c) 1990 The Regents of the University of California. '\" Copyright (c) 1994-1996 Sun Microsystems, Inc. '\" 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" .so man.macros .BS |
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 | the window. Although the \fBbindtags\fR command may be used to assign an arbitrary set of binding tags to a window, the default binding tags provide the following behavior: .IP \(bu 3 If a tag is the name of an internal window the binding applies to that window. .IP \(bu 3 If the tag is the name of a toplevel window the binding applies to the toplevel window and all its internal windows. .IP \(bu 3 | > > > < < < | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | the window. Although the \fBbindtags\fR command may be used to assign an arbitrary set of binding tags to a window, the default binding tags provide the following behavior: .IP \(bu 3 If a tag is the name of an internal window the binding applies to that window. .IP \(bu 3 If the tag is the name of a class of widgets, such as \fBButton\fR, the binding applies to all widgets in that class. .IP \(bu 3 If the tag is the name of a toplevel window the binding applies to the toplevel window and all its internal windows. .IP \(bu 3 If \fItag\fR has the value \fBall\fR, the binding applies to all windows in the application. .SH "EVENT PATTERNS" .PP The \fIsequence\fR argument specifies a sequence of one or more event patterns, with optional white space between the patterns. Each event pattern may |
︙ | ︙ | |||
102 103 104 105 106 107 108 | .SS "MODIFIERS" .PP Modifiers consist of any of the following values: .DS .ta 6c \fBControl\fR \fBMod1\fR, \fBM1\fR, \fBCommand\fR \fBAlt\fR \fBMod2\fR, \fBM2\fR, \fBOption\fR | | | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | .SS "MODIFIERS" .PP Modifiers consist of any of the following values: .DS .ta 6c \fBControl\fR \fBMod1\fR, \fBM1\fR, \fBCommand\fR \fBAlt\fR \fBMod2\fR, \fBM2\fR, \fBOption\fR \fBShift\fR \fBMod3\fR, \fBM3\fR, \fBNum\fR \fBLock\fR \fBMod4\fR, \fBM4\fR, \fBFn\fR \fBExtended\fR \fBMod5\fR, \fBM5\fR \fBButton1\fR, \fBB1\fR \fBMeta\fR, \fBM\fR \fBButton2\fR, \fBB2\fR \fBDouble\fR \fBButton3\fR, \fBB3\fR \fBTriple\fR \fBButton4\fR, \fBB4\fR \fBQuadruple\fR \fBButton5\fR, \fBB5\fR .DE |
︙ | ︙ | |||
145 146 147 148 149 150 151 | times, and also place a time and space requirement on the sequence: for a sequence of events to match a \fBDouble\fR, \fBTriple\fR or \fBQuadruple\fR pattern, all of the events must occur close together in time and without substantial mouse motion in between. For example, \fB<Double\-Button\-1>\fR is equivalent to \fB<Button\-1><Button\-1>\fR with the extra time and space requirement. .PP | | | | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | times, and also place a time and space requirement on the sequence: for a sequence of events to match a \fBDouble\fR, \fBTriple\fR or \fBQuadruple\fR pattern, all of the events must occur close together in time and without substantial mouse motion in between. For example, \fB<Double\-Button\-1>\fR is equivalent to \fB<Button\-1><Button\-1>\fR with the extra time and space requirement. .PP The \fBCommand\fR, \fBOption\fR, \fBNum\fR and \fBFn\fRmodifiers are equivalents of \fBMod1\fR up to \fBMod4\fR, they correspond to Macintosh-specific modifier keys. .PP The \fBExtended\fR modifier is, at present, specific to Windows. It appears on events that are associated with the keys on the .QW "extended keyboard" . On a US keyboard, the extended keys include the \fBAlt\fR and \fBControl\fR keys at the right of the keyboard, the cursor keys in the cluster to the left of the numeric pad, the \fBNumLock\fR key, |
︙ | ︙ |
Changes to doc/canvas.n.
︙ | ︙ | |||
1252 1253 1254 1255 1256 1257 1258 | \fB\-fill \fIcolor\fR .TP \fB\-activefill \fIcolor\fR .TP \fB\-disabledfill \fIcolor\fR . Specifies the color to be used to fill item's area. | | > | 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | \fB\-fill \fIcolor\fR .TP \fB\-activefill \fIcolor\fR .TP \fB\-disabledfill \fIcolor\fR . Specifies the color to be used to fill item's area. in its normal, active, and disabled states. The even-odd fill rule is used. \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR. For the line item, it specifies the color of the line drawn. For the text item, it specifies the foreground color of the text. If \fIcolor\fR is an empty string (the default for all canvas items except line and text), then the item will not be filled. .TP \fB\-outline \fIcolor\fR |
︙ | ︙ | |||
1760 1761 1762 1763 1764 1765 1766 | and third, and so on. Straight-line segments can be generated within a curve by duplicating the end-points of the desired line segment. If the smoothing method is \fBraw\fR, this indicates that the polygon should also be drawn as a curve but where the list of coordinates is such that the first coordinate pair (and every third coordinate pair thereafter) is a knot point on a cubic Bezier curve, and the other coordinates are control points on the cubic Bezier curve. Straight | | | 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 | and third, and so on. Straight-line segments can be generated within a curve by duplicating the end-points of the desired line segment. If the smoothing method is \fBraw\fR, this indicates that the polygon should also be drawn as a curve but where the list of coordinates is such that the first coordinate pair (and every third coordinate pair thereafter) is a knot point on a cubic Bezier curve, and the other coordinates are control points on the cubic Bezier curve. Straight line segments can be generated within a curve by making control points equal to their neighbouring knot points. If the last point is not the second point of a pair of control points, the point is repeated (one or two times) so that it also becomes the second point of a pair of control points (the associated knot point will be the first control point). .TP \fB\-splinesteps \fInumber\fR Specifies the degree of smoothness desired for curves: each spline |
︙ | ︙ |
Changes to doc/chooseDirectory.n.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH tk_chooseDirectory n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME |
︙ | ︙ |
Changes to doc/colors.n.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" Copyright (c) 2003 ActiveState Corporation. '\" Copyright (c) 2006-2007 Daniel A. Steffen <[email protected]> '\" Copyright (c) 2008 Donal K. Fellows '\" .TH colors n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS |
︙ | ︙ |
Changes to doc/console.n.
︙ | ︙ | |||
19 20 21 22 23 24 25 | and output on the standard I/O channels on platforms that do not have a real console. It is implemented as a separate interpreter with the 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 | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | and output on the standard I/O channels on platforms that do not have a real console. It is implemented as a separate interpreter with the 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" , as a conventional terminal is expected to be present in that case. 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. |
︙ | ︙ |
Changes to doc/cursors.n.
1 | '\" | | | 1 2 3 4 5 6 7 8 9 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" '\" Copyright (c) 2006-2007 Daniel A. Steffen <[email protected]> '\" .TH cursors n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS |
︙ | ︙ |
Changes to doc/event.n.
︙ | ︙ | |||
338 339 340 341 342 343 344 345 346 347 348 349 350 351 | This is sent to a text widget when the selection in the widget is changed. .TP \fB<<ThemeChanged>>\fR This is sent to all widgets when the ttk theme changed. The ttk widgets listen to this event and redisplay themselves when it fires. The legacy widgets ignore this event. .TP \fB<<TraverseIn>>\fR This is sent to a widget when the focus enters the widget because of a user-driven .QW "tab to widget" action. .TP | > > > > > > > > > | 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | This is sent to a text widget when the selection in the widget is changed. .TP \fB<<ThemeChanged>>\fR This is sent to all widgets when the ttk theme changed. The ttk widgets listen to this event and redisplay themselves when it fires. The legacy widgets ignore this event. .TP \fB<<TkWorldChanged>>\fR . This event is sent to all widgets when a font is changed, for example, by the use of [font configure]. The user_data field (%d) will have the value "FontChanged". For other system wide changes, this event will be sent to all widgets, and the user_data field will indicate the cause of the change. NOTE: all tk and ttk widgets already handle this event internally. .TP \fB<<TraverseIn>>\fR This is sent to a widget when the focus enters the widget because of a user-driven .QW "tab to widget" action. .TP |
︙ | ︙ |
Changes to doc/grid.n.
︙ | ︙ | |||
307 308 309 310 311 312 313 | is returned, most recently managed first. \fIOption\fR can be either \fB\-row\fR or \fB\-column\fR which 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? . | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | is returned, most recently managed first. \fIOption\fR can be either \fB\-row\fR or \fB\-column\fR which 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 content. This permits content to be rearranged, added, or removed without the need to explicitly specify row and column information. |
︙ | ︙ |
Changes to doc/keysyms.n.
1 | '\" | | | | > > | | | | < | | | | | < | | > | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | '\" '\" Copyright (c) 1998-2000 Scriptics Corporation. '\" All rights reserved. '\" .TH keysyms n 8.3 Tk "Tk Built-In Commands" .so man.macros .BS '\" Note: do not modify the .SH NAME line immediately below! .SH NAME keysyms \- keysyms recognized by Tk .BE .SH DESCRIPTION .PP Tk recognizes many keysyms when specifying key bindings (e.g., .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 of a particular keysym is dependent on the configuration of the keyboard modifier map. This list shows keysyms along with their decimal and hexadecimal values. .PP .CS space 32 0x20 ! (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 minus 45 0x2D . (period) 46 0x2E / (slash) 47 0x2F 0 48 0x30 1 49 0x31 2 50 0x32 3 51 0x33 4 52 0x34 5 53 0x35 6 54 0x36 7 55 0x37 8 56 0x38 9 57 0x39 : (colon) 58 0x3A semicolon 59 0x3B less 60 0x3C = (equal) 61 0x3D greater 62 0x3E ? (question) 63 0x3F @ (at) 64 0x40 A 65 0x41 B 66 0x42 C 67 0x43 D 68 0x44 E 69 0x45 F 70 0x46 G 71 0x47 |
︙ | ︙ | |||
81 82 83 84 85 86 87 | W 87 0x57 X 88 0x58 Y 89 0x59 Z 90 0x5A bracketleft 91 0x5B backslash 92 0x5C bracketright 93 0x5D | | > | < | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | W 87 0x57 X 88 0x58 Y 89 0x59 Z 90 0x5A bracketleft 91 0x5B backslash 92 0x5C bracketright 93 0x5D ^ (asciicircum) 94 0x5E _ (underscore) 95 0x5F ` (grave) 96 0x60 a 97 0x61 b 98 0x62 c 99 0x63 d 100 0x64 e 101 0x65 f 102 0x66 g 103 0x67 |
︙ | ︙ | |||
111 112 113 114 115 116 117 | u 117 0x75 v 118 0x76 w 119 0x77 x 120 0x78 y 121 0x79 z 122 0x7A braceleft 123 0x7B | | | < | | | < < | | | | | > | > > < | | < | | | | | < | | | < | < > | | | | > > | > > < | | | | | < | | | | | | | | | | | | > | | > < | < | | > | | | | < | | > | | | | | < | | > > | | < | | | | < | | | | | | | | | > | | | > > > < < | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | u 117 0x75 v 118 0x76 w 119 0x77 x 120 0x78 y 121 0x79 z 122 0x7A braceleft 123 0x7B | (bar) 124 0x7C braceright 125 0x7D ~ (asciitilde) 126 0x7E nobreakspace 160 0xA0 \(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 \(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 Zcaron 430 0x1AE Zabovedot 431 0x1AF aogonek 433 0x1B1 ogonek 434 0x1B2 lstroke 435 0x1B3 lcaron 437 0x1B5 sacute 438 0x1B6 |
︙ | ︙ | |||
390 391 392 393 394 395 396 397 398 399 400 401 402 403 | kana_RU 1241 0x4D9 kana_RE 1242 0x4DA kana_RO 1243 0x4DB kana_WA 1244 0x4DC kana_N 1245 0x4DD voicedsound 1246 0x4DE semivoicedsound 1247 0x4DF Arabic_comma 1452 0x5AC Arabic_semicolon 1467 0x5BB Arabic_question_mark 1471 0x5BF Arabic_hamza 1473 0x5C1 Arabic_maddaonalef 1474 0x5C2 Arabic_hamzaonalef 1475 0x5C3 Arabic_hamzaonwaw 1476 0x5C4 | > > | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | kana_RU 1241 0x4D9 kana_RE 1242 0x4DA 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 Arabic_hamzaonalef 1475 0x5C3 Arabic_hamzaonwaw 1476 0x5C4 |
︙ | ︙ | |||
425 426 427 428 429 430 431 | Arabic_ghain 1498 0x5DA Arabic_tatweel 1504 0x5E0 Arabic_feh 1505 0x5E1 Arabic_qaf 1506 0x5E2 Arabic_kaf 1507 0x5E3 Arabic_lam 1508 0x5E4 Arabic_meem 1509 0x5E5 | < < | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | Arabic_ghain 1498 0x5DA Arabic_tatweel 1504 0x5E0 Arabic_feh 1505 0x5E1 Arabic_qaf 1506 0x5E2 Arabic_kaf 1507 0x5E3 Arabic_lam 1508 0x5E4 Arabic_meem 1509 0x5E5 Arabic_noon 1510 0x5E6 Arabic_ha 1511 0x5E7 Arabic_waw 1512 0x5E8 Arabic_alefmaksura 1513 0x5E9 Arabic_yeh 1514 0x5EA Arabic_fathatan 1515 0x5EB Arabic_dammatan 1516 0x5EC |
︙ | ︙ | |||
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | Cyrillic_CHE 1790 0x6FE Cyrillic_HARDSIGN 1791 0x6FF Greek_ALPHAaccent 1953 0x7A1 Greek_EPSILONaccent 1954 0x7A2 Greek_ETAaccent 1955 0x7A3 Greek_IOTAaccent 1956 0x7A4 Greek_IOTAdieresis 1957 0x7A5 Greek_OMICRONaccent 1959 0x7A7 Greek_UPSILONaccent 1960 0x7A8 Greek_UPSILONdieresis 1961 0x7A9 Greek_OMEGAaccent 1963 0x7AB Greek_accentdieresis 1966 0x7AE Greek_horizbar 1967 0x7AF Greek_alphaaccent 1969 0x7B1 Greek_epsilonaccent 1970 0x7B2 Greek_etaaccent 1971 0x7B3 Greek_iotaaccent 1972 0x7B4 | > > | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | Cyrillic_CHE 1790 0x6FE Cyrillic_HARDSIGN 1791 0x6FF 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 Greek_etaaccent 1971 0x7B3 Greek_iotaaccent 1972 0x7B4 |
︙ | ︙ | |||
606 607 608 609 610 611 612 613 614 615 616 617 618 619 | Greek_finalsmallsigma 2035 0x7F3 Greek_tau 2036 0x7F4 Greek_upsilon 2037 0x7F5 Greek_phi 2038 0x7F6 Greek_chi 2039 0x7F7 Greek_psi 2040 0x7F8 Greek_omega 2041 0x7F9 leftradical 2209 0x8A1 topleftradical 2210 0x8A2 horizconnector 2211 0x8A3 topintegral 2212 0x8A4 botintegral 2213 0x8A5 vertconnector 2214 0x8A6 topleftsqbracket 2215 0x8A7 | > > | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | Greek_finalsmallsigma 2035 0x7F3 Greek_tau 2036 0x7F4 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 vertconnector 2214 0x8A6 topleftsqbracket 2215 0x8A7 |
︙ | ︙ | |||
629 630 631 632 633 634 635 | topleftsummation 2225 0x8B1 botleftsummation 2226 0x8B2 topvertsummationconnector 2227 0x8B3 botvertsummationconnector 2228 0x8B4 toprightsummation 2229 0x8B5 botrightsummation 2230 0x8B6 rightmiddlesummation 2231 0x8B7 | < < | 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | topleftsummation 2225 0x8B1 botleftsummation 2226 0x8B2 topvertsummationconnector 2227 0x8B3 botvertsummationconnector 2228 0x8B4 toprightsummation 2229 0x8B5 botrightsummation 2230 0x8B6 rightmiddlesummation 2231 0x8B7 lessthanequal 2236 0x8BC notequal 2237 0x8BD greaterthanequal 2238 0x8BE integral 2239 0x8BF therefore 2240 0x8C0 variation 2241 0x8C1 infinity 2242 0x8C2 |
︙ | ︙ | |||
812 813 814 815 816 817 818 819 820 821 822 823 824 825 | hebrew_pe 3316 0xCF4 hebrew_finalzade 3317 0xCF5 hebrew_zade 3318 0xCF6 hebrew_qoph 3319 0xCF7 hebrew_resh 3320 0xCF8 hebrew_shin 3321 0xCF9 hebrew_taw 3322 0xCFA Thai_kokai 3489 0xDA1 Thai_khokhai 3490 0xDA2 Thai_khokhuat 3491 0xDA3 Thai_khokhwai 3492 0xDA4 Thai_khokhon 3493 0xDA5 Thai_khorakhang 3494 0xDA6 Thai_ngongu 3495 0xDA7 | > > | 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | hebrew_pe 3316 0xCF4 hebrew_finalzade 3317 0xCF5 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 Thai_khorakhang 3494 0xDA6 Thai_ngongu 3495 0xDA7 |
︙ | ︙ | |||
990 991 992 993 994 995 996 | Hangul_J_PanSios 3832 0xEF8 Hangul_J_KkogjiDalrinIeung 3833 0xEF9 Hangul_J_YeorinHieuh 3834 0xEFA Korean_Won 3839 0xEFF OE 5052 0x13BC oe 5053 0x13BD Ydiaeresis 5054 0x13BE | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < > > | 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | Hangul_J_PanSios 3832 0xEF8 Hangul_J_KkogjiDalrinIeung 3833 0xEF9 Hangul_J_YeorinHieuh 3834 0xEFA Korean_Won 3839 0xEFF OE 5052 0x13BC oe 5053 0x13BD Ydiaeresis 5054 0x13BE \(eu (EuroSign) 8364 0x20AC .CE .CS ISO_Lock 65025 0xFE01 ISO_Level2_Latch 65026 0xFE02 ISO_Level3_Shift 65027 0xFE03 ISO_Level3_Latch 65028 0xFE04 ISO_Level3_Lock 65029 0xFE05 ISO_Group_Latch 65030 0xFE06 ISO_Group_Lock 65031 0xFE07 |
︙ | ︙ | |||
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 | Pointer_Drag3 65271 0xFEF7 Pointer_Drag4 65272 0xFEF8 Pointer_EnableKeys 65273 0xFEF9 Pointer_Accelerate 65274 0xFEFA Pointer_DfltBtnNext 65275 0xFEFB Pointer_DfltBtnPrev 65276 0xFEFC Pointer_Drag5 65277 0xFEFD BackSpace 65288 0xFF08 Tab 65289 0xFF09 Linefeed 65290 0xFF0A Clear 65291 0xFF0B Return 65293 0xFF0D Pause 65299 0xFF13 Scroll_Lock 65300 0xFF14 | > > | 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 | Pointer_Drag3 65271 0xFEF7 Pointer_Drag4 65272 0xFEF8 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 Pause 65299 0xFF13 Scroll_Lock 65300 0xFF14 |
︙ | ︙ | |||
1211 1212 1213 1214 1215 1216 1217 | Up 65362 0xFF52 Right 65363 0xFF53 Down 65364 0xFF54 Prior 65365 0xFF55 Next 65366 0xFF56 End 65367 0xFF57 Begin 65368 0xFF58 | < < < < < | | 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 | Up 65362 0xFF52 Right 65363 0xFF53 Down 65364 0xFF54 Prior 65365 0xFF55 Next 65366 0xFF56 End 65367 0xFF57 Begin 65368 0xFF58 Select 65376 0xFF60 Print 65377 0xFF61 Execute 65378 0xFF62 Insert 65379 0xFF63 Undo 65381 0xFF65 Redo 65382 0xFF66 Menu (App) 65383 0xFF67 Find 65384 0xFF68 Cancel 65385 0xFF69 Help 65386 0xFF6A Break 65387 0xFF6B Mode_switch 65406 0xFF7E Num_Lock 65407 0xFF7F KP_Space 65408 0xFF80 |
︙ | ︙ | |||
1309 1310 1311 1312 1313 1314 1315 | Control_R 65508 0xFFE4 Caps_Lock 65509 0xFFE5 Shift_Lock 65510 0xFFE6 Meta_L 65511 0xFFE7 Meta_R 65512 0xFFE8 Alt_L 65513 0xFFE9 Alt_R 65514 0xFFEA | | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 | Control_R 65508 0xFFE4 Caps_Lock 65509 0xFFE5 Shift_Lock 65510 0xFFE6 Meta_L 65511 0xFFE7 Meta_R 65512 0xFFE8 Alt_L 65513 0xFFE9 Alt_R 65514 0xFFEA 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 braille_dot_4 65524 0xFFF4 braille_dot_5 65525 0xFFF5 braille_dot_6 65526 0xFFF6 braille_dot_7 65527 0xFFF7 braille_dot_8 65528 0xFFF8 braille_dot_9 65529 0xFFF9 braille_dot_10 65530 0xFFFA Delete 65535 0xFFFF .CE .CS SunFA_Grave 268828416 0x1005FF00 SunFA_Circum 268828417 0x1005FF01 SunFA_Tilde 268828418 0x1005FF02 SunFA_Acute 268828419 0x1005FF03 SunFA_Diaeresis 268828420 0x1005FF04 SunFA_Cedilla 268828421 0x1005FF05 SunF36 268828432 0x1005FF10 |
︙ | ︙ | |||
2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 | SunAudioLowerVolume 268828535 0x1005FF77 SunAudioMute 268828536 0x1005FF78 SunAudioRaiseVolume 268828537 0x1005FF79 SunVideoDegauss 268828538 0x1005FF7A SunVideoLowerBrightness 268828539 0x1005FF7B SunVideoRaiseBrightness 268828540 0x1005FF7C SunPowerSwitchShift 268828541 0x1005FF7D XF86Switch_VT_1 269024769 0x1008FE01 XF86Switch_VT_2 269024770 0x1008FE02 XF86Switch_VT_3 269024771 0x1008FE03 XF86Switch_VT_4 269024772 0x1008FE04 XF86Switch_VT_5 269024773 0x1008FE05 XF86Switch_VT_6 269024774 0x1008FE06 XF86Switch_VT_7 269024775 0x1008FE07 XF86Switch_VT_8 269024776 0x1008FE08 XF86Switch_VT_9 269024777 0x1008FE09 XF86Switch_VT_10 269024778 0x1008FE0A XF86Switch_VT_11 269024779 0x1008FE0B XF86Switch_VT_12 269024780 0x1008FE0C XF86Ungrab 269024800 0x1008FE20 XF86ClearGrab 269024801 0x1008FE21 XF86Next_VMode 269024802 0x1008FE22 XF86Prev_VMode 269024803 0x1008FE23 XF86LogWindowTree 269024804 0x1008FE24 XF86LogGrabInfo 269024805 0x1008FE25 XF86ModeLock 269025025 0x1008FF01 | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 | SunAudioLowerVolume 268828535 0x1005FF77 SunAudioMute 268828536 0x1005FF78 SunAudioRaiseVolume 268828537 0x1005FF79 SunVideoDegauss 268828538 0x1005FF7A SunVideoLowerBrightness 268828539 0x1005FF7B SunVideoRaiseBrightness 268828540 0x1005FF7C SunPowerSwitchShift 268828541 0x1005FF7D XF86BrightnessAuto 268964084 0x100810F4 XF86DisplayOff 268964085 0x100810F5 XF86Info 268964198 0x10081166 XF86AspectRatio 268964215 0x10081177 XF86DVD 268964229 0x10081185 XF86Audio 268964232 0x10081188 XF86ChannelUp 268964242 0x10081192 XF86ChannelDown 268964243 0x10081193 XF86Break 268964251 0x1008119B XF86VideoPhone 268964256 0x100811A0 XF86ZoomReset 268964260 0x100811A4 XF86Editor 268964262 0x100811A6 XF86GraphicsEditor 268964264 0x100811A8 XF86Presentation 268964265 0x100811A9 XF86Database 268964266 0x100811AA XF86Voicemail 268964268 0x100811AC XF86Addressbook 268964269 0x100811AD XF86DisplayToggle 268964271 0x100811AF XF86SpellCheck 268964272 0x100811B0 XF86ContextMenu 268964278 0x100811B6 XF86MediaRepeat 268964279 0x100811B7 XF8610ChannelsUp 268964280 0x100811B8 XF8610ChannelsDown 268964281 0x100811B9 XF86Images 268964282 0x100811BA XF86NotificationCenter 268964284 0x100811BC XF86PickupPhone 268964285 0x100811BD XF86HangupPhone 268964286 0x100811BE XF86Fn 268964304 0x100811D0 XF86Fn_Esc 268964305 0x100811D1 XF86FnRightShift 268964325 0x100811E5 XF86Numeric0 268964352 0x10081200 XF86Numeric1 268964353 0x10081201 XF86Numeric2 268964354 0x10081202 XF86Numeric3 268964355 0x10081203 XF86Numeric4 268964356 0x10081204 XF86Numeric5 268964357 0x10081205 XF86Numeric6 268964358 0x10081206 XF86Numeric7 268964359 0x10081207 XF86Numeric8 268964360 0x10081208 XF86Numeric9 268964361 0x10081209 XF86NumericStar 268964362 0x1008120A XF86NumericPound 268964363 0x1008120B XF86NumericA 268964364 0x1008120C XF86NumericB 268964365 0x1008120D XF86NumericC 268964366 0x1008120E XF86NumericD 268964367 0x1008120F XF86CameraFocus 268964368 0x10081210 XF86WPSButton 268964369 0x10081211 XF86CameraZoomIn 268964373 0x10081215 XF86CameraZoomOut 268964374 0x10081216 XF86CameraUp 268964375 0x10081217 XF86CameraDown 268964376 0x10081218 XF86CameraLeft 268964377 0x10081219 XF86CameraRight 268964378 0x1008121A XF86AttendantOn 268964379 0x1008121B XF86AttendantOff 268964380 0x1008121C XF86AttendantToggle 268964381 0x1008121D XF86LightsToggle 268964382 0x1008121E XF86ALSToggle 268964400 0x10081230 XF86Buttonconfig 268964416 0x10081240 XF86Taskmanager 268964417 0x10081241 XF86Journal 268964418 0x10081242 XF86ControlPanel 268964419 0x10081243 XF86AppSelect 268964420 0x10081244 XF86Screensaver 268964421 0x10081245 XF86VoiceCommand 268964422 0x10081246 XF86Assistant 268964423 0x10081247 XF86EmojiPicker 268964425 0x10081249 XF86Dictate 268964426 0x1008124A XF86BrightnessMin 268964432 0x10081250 XF86BrightnessMax 268964433 0x10081251 XF86KbdInputAssistPrev 268964448 0x10081260 XF86KbdInputAssistNext 268964449 0x10081261 XF86KbdInputAssistPrevgroup 268964450 0x10081262 XF86KbdInputAssistNextgroup 268964451 0x10081263 XF86KbdInputAssistAccept 268964452 0x10081264 XF86KbdInputAssistCancel 268964453 0x10081265 XF86RightUp 268964454 0x10081266 XF86RightDown 268964455 0x10081267 XF86LeftUp 268964456 0x10081268 XF86LeftDown 268964457 0x10081269 XF86RootMenu 268964458 0x1008126A XF86MediaTopMenu 268964459 0x1008126B XF86Numeric11 268964460 0x1008126C XF86Numeric12 268964461 0x1008126D XF86AudioDesc 268964462 0x1008126E XF863DMode 268964463 0x1008126F XF86NextFavorite 268964464 0x10081270 XF86StopRecord 268964465 0x10081271 XF86PauseRecord 268964466 0x10081272 XF86VOD 268964467 0x10081273 XF86Unmute 268964468 0x10081274 XF86FastReverse 268964469 0x10081275 XF86SlowReverse 268964470 0x10081276 XF86Data 268964471 0x10081277 XF86OnScreenKeyboard 268964472 0x10081278 XF86PrivacyScreenToggle 268964473 0x10081279 XF86SelectiveScreenshot 268964474 0x1008127A XF86Macro1 268964496 0x10081290 XF86Macro2 268964497 0x10081291 XF86Macro3 268964498 0x10081292 XF86Macro4 268964499 0x10081293 XF86Macro5 268964500 0x10081294 XF86Macro6 268964501 0x10081295 XF86Macro7 268964502 0x10081296 XF86Macro8 268964503 0x10081297 XF86Macro9 268964504 0x10081298 XF86Macro10 268964505 0x10081299 XF86Macro11 268964506 0x1008129A XF86Macro12 268964507 0x1008129B XF86Macro13 268964508 0x1008129C XF86Macro14 268964509 0x1008129D XF86Macro15 268964510 0x1008129E XF86Macro16 268964511 0x1008129F XF86Macro17 268964512 0x100812A0 XF86Macro18 268964513 0x100812A1 XF86Macro19 268964514 0x100812A2 XF86Macro20 268964515 0x100812A3 XF86Macro21 268964516 0x100812A4 XF86Macro22 268964517 0x100812A5 XF86Macro23 268964518 0x100812A6 XF86Macro24 268964519 0x100812A7 XF86Macro25 268964520 0x100812A8 XF86Macro26 268964521 0x100812A9 XF86Macro27 268964522 0x100812AA XF86Macro28 268964523 0x100812AB XF86Macro29 268964524 0x100812AC XF86Macro30 268964525 0x100812AD XF86MacroRecordStart 268964528 0x100812B0 XF86MacroRecordStop 268964529 0x100812B1 XF86MacroPresetCycle 268964530 0x100812B2 XF86MacroPreset1 268964531 0x100812B3 XF86MacroPreset2 268964532 0x100812B4 XF86MacroPreset3 268964533 0x100812B5 XF86KbdLcdMenu1 268964536 0x100812B8 XF86KbdLcdMenu2 268964537 0x100812B9 XF86KbdLcdMenu3 268964538 0x100812BA XF86KbdLcdMenu4 268964539 0x100812BB XF86KbdLcdMenu5 268964540 0x100812BC XF86Switch_VT_1 269024769 0x1008FE01 XF86Switch_VT_2 269024770 0x1008FE02 XF86Switch_VT_3 269024771 0x1008FE03 XF86Switch_VT_4 269024772 0x1008FE04 XF86Switch_VT_5 269024773 0x1008FE05 XF86Switch_VT_6 269024774 0x1008FE06 XF86Switch_VT_7 269024775 0x1008FE07 XF86Switch_VT_8 269024776 0x1008FE08 XF86Switch_VT_9 269024777 0x1008FE09 XF86Switch_VT_10 269024778 0x1008FE0A XF86Switch_VT_11 269024779 0x1008FE0B XF86Switch_VT_12 269024780 0x1008FE0C .CE .CS XF86Ungrab 269024800 0x1008FE20 XF86ClearGrab 269024801 0x1008FE21 XF86Next_VMode 269024802 0x1008FE22 XF86Prev_VMode 269024803 0x1008FE23 XF86LogWindowTree 269024804 0x1008FE24 XF86LogGrabInfo 269024805 0x1008FE25 XF86ModeLock 269025025 0x1008FF01 |
︙ | ︙ | |||
2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 | XF86TouchpadOff 269025201 0x1008FFB1 XF86AudioMicMute 269025202 0x1008FFB2 XF86Keyboard 269025203 0x1008FFB3 XF86WWAN 269025204 0x1008FFB4 XF86RFKill 269025205 0x1008FFB5 XF86AudioPreset 269025206 0x1008FFB6 XF86RotationLockToggle 269025207 0x1008FFB7 .CE .SH "SEE ALSO" bind(n), event(n) .SH KEYWORDS bind, binding, event, keysym '\" Local Variables: '\" mode: nroff '\" End: | > | 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 | XF86TouchpadOff 269025201 0x1008FFB1 XF86AudioMicMute 269025202 0x1008FFB2 XF86Keyboard 269025203 0x1008FFB3 XF86WWAN 269025204 0x1008FFB4 XF86RFKill 269025205 0x1008FFB5 XF86AudioPreset 269025206 0x1008FFB6 XF86RotationLockToggle 269025207 0x1008FFB7 XF86FullScreen 269025208 0x1008FFB8 .CE .SH "SEE ALSO" bind(n), event(n) .SH KEYWORDS bind, binding, event, keysym '\" Local Variables: '\" mode: nroff '\" End: |
Changes to doc/listbox.n.
︙ | ︙ | |||
559 560 561 562 563 564 565 | extend the selection to the active element just as if button 1 had been pressed with the Shift key down. .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] | | | 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | extend the selection to the active element just as if button 1 had been pressed with the Shift key down. .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-/ 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. .IP [19] The F16 key (labelled Copy on many Sun workstations) or Meta-w |
︙ | ︙ |
Changes to doc/menu.n.
︙ | ︙ | |||
36 37 38 39 40 41 42 | .OP \-tearoff tearOff TearOff This option must have a proper boolean value (default is false), 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. | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | .OP \-tearoff tearOff TearOff This option must have a proper boolean value (default is false), 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/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 by the name of the menu window, followed by a space, followed by the name of the name of the torn off menu window. For example, if the option's value is .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/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 was invoked. .OP \-type type Type |
︙ | ︙ | |||
312 313 314 315 316 317 318 | indicator of which entry of the menu to operate on. These indicators are called \fIindex\fRes and may be specified in any of the following forms: .TP 12 \fBactive\fR . Indicates the entry that is currently active. If no entry is | | | | | > > > > | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | indicator of which entry of the menu to operate on. These indicators are called \fIindex\fRes and may be specified in any of the following forms: .TP 12 \fBactive\fR . Indicates the entry that is currently active. If no entry is active then this form is equivalent to \fB{}\fR. This form may not be abbreviated. .TP 12 \fBend\fR . Indicates the bottommost entry in the menu. If there are no entries in the menu then this form is equivalent to \fB{}\fR. This form may not be abbreviated. .TP 12 \fBlast\fR . Same as \fBend\fR. .TP 12 \fB{}\fR . Indicates .QW "no entry at all" ; this is used most commonly with the \fBactivate\fR option to deactivate all the entries in the menu. In most cases the specification of \fB{}\fR causes nothing to happen in the widget command. .TP 12 \fBnone\fR . Same as \fB{}\fR This form may not be abbreviated. .TP 12 \fB@\fInumber\fR . In this form, \fInumber\fR is treated as a y-coordinate in the menu's window; the entry closest to that y-coordinate is used. For example, |
︙ | ︙ | |||
367 368 369 370 371 372 373 | The following widget commands are possible for menu widgets: .TP \fIpathName \fBactivate \fIindex\fR . Change the state of the entry indicated by \fIindex\fR to \fBactive\fR and redisplay it using its active colors. Any previously-active entry is deactivated. If \fIindex\fR | | | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | The following widget commands are possible for menu widgets: .TP \fIpathName \fBactivate \fIindex\fR . Change the state of the entry indicated by \fIindex\fR to \fBactive\fR and redisplay it using its active colors. Any previously-active entry is deactivated. If \fIindex\fR is specified as \fB{}\fR or \fBnone\fR, or if the specified entry is disabled, then the menu ends up with no active entry. Returns an empty string. .TP \fIpathName \fBadd \fItype \fR?\fIoption value option value ...\fR? . Add a new entry to the bottom of the menu. The new entry's type is given by \fItype\fR and must be one of \fBcascade\fR, |
︙ | ︙ | |||
443 444 445 446 447 448 449 | If no \fIoptions\fR are specified, returns a list describing the current options for entry \fIindex\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). .TP \fIpathName \fBindex \fIindex\fR . Returns the numerical index corresponding to \fIindex\fR, or | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 | If no \fIoptions\fR are specified, returns a list describing the current options for entry \fIindex\fR (see \fBTk_ConfigureInfo\fR for information on the format of this list). .TP \fIpathName \fBindex \fIindex\fR . Returns the numerical index corresponding to \fIindex\fR, or \fB{}\fR if \fIindex\fR was specified as \fB{}\fR or \fBnone\fR. .TP \fIpathName \fBinsert \fIindex type \fR?\fIoption value option value ...\fR? . Same as the \fBadd\fR widget command except that it inserts the new entry just before the entry given by \fIindex\fR, instead of appending to the end of the menu. The \fItype\fR, \fIoption\fR, and \fIvalue\fR arguments have the same interpretation as for the \fBadd\fR widget |
︙ | ︙ | |||
519 520 521 522 523 524 525 | .SH "MENU ENTRY OPTIONS" The following options are allowed on menu entries. Most options are not supported by all entry types. .TP \fB\-activebackground \fIvalue\fR . Specifies a background color to use for displaying this entry when it | | | | > | | | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 | .SH "MENU ENTRY OPTIONS" The following options are allowed on menu entries. Most options are not supported by all entry types. .TP \fB\-activebackground \fIvalue\fR . Specifies a background color to use for displaying this entry when it 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. 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 . Specifies a string to display at the right side of the menu entry. Normally describes an accelerator keystroke sequence that may be used to invoke the same function as the menu entry. This is a display option, it does not actually set the corresponding binding (which can be achieved using the \fBbind\fR command). This option is not available for separator or tear-off entries. .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). 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 . Specifies a bitmap to display in the menu instead of a textual label, in any of the forms accepted by \fBTk_GetBitmap\fR. This option overrides the \fB\-label\fR option (as controlled by the \fB\-compound\fR option) but may be reset to an empty string to enable a textual label to be displayed. If a \fB\-image\fR option has been specified, it overrides \fB\-bitmap\fR. This option is not available for separator or tear-off entries. .TP \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/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. Not available for separator or tear-off entries. .TP |
︙ | ︙ | |||
599 600 601 602 603 604 605 | the \fB\-font\fR option for the overall menu is used. This option is not available for separator or tear-off entries. .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). | > | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | the \fB\-font\fR option for the overall menu is used. This option is not available for separator or tear-off entries. .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). 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 . Specifies whether the standard margins should be drawn for this menu entry. This is useful when creating palette with images in them, i.e., |
︙ | ︙ |
Changes to doc/menubutton.n.
︙ | ︙ | |||
20 21 22 23 24 25 26 | \-background \-highlightbackground \-takefocus \-bitmap \-highlightcolor \-text \-borderwidth \-highlightthickness \-textvariable \-cursor \-image \-underline \-compound \-justify \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | \-background \-highlightbackground \-takefocus \-bitmap \-highlightcolor \-text \-borderwidth \-highlightthickness \-textvariable \-cursor \-image \-underline \-compound \-justify \-wraplength .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-direction direction Direction Specifies where the menu is going to be popup up. \fBabove\fR tries to pop the menu above the menubutton. \fBbelow\fR tries to pop the menu below the menubutton. \fBleft\fR tries to pop the menu to the left of the menubutton. \fBright\fR tries to pop the menu to the right of the menu button. \fBflush\fR pops the menu directly over the menubutton. In the case of \fBabove\fR or \fBbelow\fR, the direction will be reversed if the menu would show offscreen. |
︙ | ︙ |
Changes to doc/messageBox.n.
︙ | ︙ | |||
62 63 64 65 66 67 68 | \fB\-parent\fR \fIwindow\fR . Makes \fIwindow\fR the logical parent of the message box. The message box is displayed on top of its parent window. .TP \fB\-title\fR \fItitleString\fR . | | < | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | \fB\-parent\fR \fIwindow\fR . Makes \fIwindow\fR the logical parent of the message box. The message box is displayed on top of its parent window. .TP \fB\-title\fR \fItitleString\fR . Specifies a string to display as the title of the message box. The default value is an empty string. .TP \fB\-type\fR \fIpredefinedType\fR . Arranges for a predefined set of buttons to be displayed. The following values are possible for \fIpredefinedType\fR: .RS .TP 18 |
︙ | ︙ |
Changes to doc/pack.n.
︙ | ︙ | |||
162 163 164 165 166 167 168 | 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 \fIwindow\fR has no content then an empty string is returned. .TP \fBpack slaves \fIwindow\fR . | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | 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 \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 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 container for each content and the content's position in the packing list. |
︙ | ︙ |
Changes to doc/photo.n.
︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | .TP \fB\-height \fInumber\fR . 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. .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 colormaps of the windows where it is displayed. The \fIpalette-spec\fR string may be either a single decimal number, | > > > > > > > > > > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | .TP \fB\-height \fInumber\fR . 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 colormaps of the windows where it is displayed. The \fIpalette-spec\fR string may be either a single decimal number, |
︙ | ︙ | |||
142 143 144 145 146 147 148 | .PP The following commands are possible for photo images: .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 | | | 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | .PP The following commands are possible for photo images: .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. 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. \fIOption\fR may have any of the values accepted by the \fBimage create\fR \fBphoto\fR command. |
︙ | ︙ | |||
165 166 167 168 169 170 171 172 173 174 175 176 177 178 | one named option (this list will be identical to the corresponding sublist of the value returned if no \fIoption\fR is specified). If 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. .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 pixel zooming and/or subsampling. If no options are specified, this command copies the whole of \fIsourceImage\fR into \fIimageName\fR, | > > > > | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | one named option (this list will be identical to the corresponding sublist of the value returned if no \fIoption\fR is specified). If 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 pixel zooming and/or subsampling. If no options are specified, this command copies the whole of \fIsourceImage\fR into \fIimageName\fR, |
︙ | ︙ | |||
283 284 285 286 287 288 289 | and excluding x2,y2. The default, if this option is not given, is the whole image. .TP \fB\-grayscale\fR . If this options is specified, the data will not contain color information. All pixel data will be transformed into grayscale. | < > > > > > > > > > > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 | and excluding x2,y2. The default, if this option is not given, is the whole image. .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 \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 option is specified, the returned list will have a fourth element representing the alpha value of the pixel as an integer between 0 and |
︙ | ︙ | |||
318 319 320 321 322 323 324 325 326 327 328 329 330 331 | arguments to be passed to the format handler. Specifically, only image file format handlers whose names begin with \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. .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 copied. The default position is (0,0). If \fIx2\fR,\fIy2\fR is given and \fIdata\fR is not large enough to cover the rectangle specified by | > > > > > > > > > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | arguments to be passed to the format handler. Specifically, only image file format handlers whose names begin with \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 copied. The default position is (0,0). If \fIx2\fR,\fIy2\fR is given and \fIdata\fR is not large enough to cover the rectangle specified by |
︙ | ︙ | |||
363 364 365 366 367 368 369 370 371 372 373 374 375 376 | Specifies a rectangular sub-region of the image file data to be copied to the destination image. If only \fIx1\fR and \fIy1\fR are 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. .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 is at the bottom-right corner of the \fIimageName\fR. This option will not affect the width or height of the image if the user has | > > > > > > > > > | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 | Specifies a rectangular sub-region of the image file data to be copied to the destination image. If only \fIx1\fR and \fIy1\fR are 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 is at the bottom-right corner of the \fIimageName\fR. This option will not affect the width or height of the image if the user has |
︙ | ︙ | |||
456 457 458 459 460 461 462 463 464 465 466 467 468 469 | diagonally opposite corners of the rectangular region. The default, if this option is not given, is the whole image. .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 .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 a list of these handlers. Handlers are added to the list by registering them with a call to \fBTk_CreatePhotoImageFormat\fR. The | > > > > > > > > > > | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 | diagonally opposite corners of the rectangular region. The default, if this option is not given, is the whole image. .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 a list of these handlers. Handlers are added to the list by registering them with a call to \fBTk_CreatePhotoImageFormat\fR. The |
︙ | ︙ | |||
678 679 680 681 682 683 684 685 686 687 688 689 690 691 | The user can exercise some control over the number of colors that a photo image uses with the \fB\-palette\fR configuration option. If 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. .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. .SH EXAMPLE .PP | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 | The user can exercise some control over the number of colors that a photo image uses with the \fB\-palette\fR configuration option. If 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. .SH EXAMPLE .PP |
︙ | ︙ |
Changes to doc/place.n.
︙ | ︙ | |||
193 194 195 196 197 198 199 | .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 . | | | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | .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 . 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" |
︙ | ︙ |
Added doc/print.n.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | .\" Text automatically generated by txt2man '\" '\" Copyright (c) 2021 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 print n "" Tk "Tk Built-in Commands" .so man.macros .SH NAME print \- Print canvas and text widgets using native dialogs and APIs. .SH SYNOPSIS \fBtk print \fIwindow\fR . .SH DESCRIPTION .PP The \fBtk print\fR command posts a dialog that allows users to print output from the \fBcanvas\fR and \fBtext\fR widgets. The printing will be done using platform-native APIs and dialogs where available. .PP The \fBcanvas\fR widget has long supported PostScript export and both PostScript and text files can be sent directly to a printer on Unix-like systems using the .QW "lp" and .QW "lpr" Unix commands, and the \fBtk print\fR command does not supersede that functionality; it builds on it. The \fBtk print\fR command is a fuller implementation that uses native dialogs on macOS and Windows, and a Tk-based dialog that provides parallel functionality on X11. .SH PLATFORM NOTES .TP \fBmacOS\fR . The Mac implementation uses native print dialogs and relies on the underlying Common Unix Printing System (CUPS) to render text output from the text widget and PostScript output from the canvas widget to the printer, to a PDF file, or a PostScript file. .TP \fBWindows\fR . The Windows implementation is based on the GDI (Graphics Device Interface) API. Because there are slight differences in how GDI and Tk's \fBcanvas\fR widget display graphics, printed output from the \fBcanvas\fR on Windows may not be identical to screen rendering. .TP \fBX11\fR . The X11 implementation uses a Tk GUI to configure print jobs for sending to a printer via the .QW "lpr" or .QW "lp" commands. While these commands have a large number of parameters for configuring print jobs, printers vary widely in how they support these parameters. As a result, only printer selection and number of copies are configured as arguments to the print command; many aspects of print rendering, such as grayscale or color for the canvas, are instead configured when PostScript is generated. .SH "SEE ALSO" canvas(n), text(n), tk(n) .SH KEYWORDS print, output, graphics, text, canvas |
Changes to doc/spinbox.n.
︙ | ︙ | |||
220 221 222 223 224 225 226 | associated \fB\-textvariable\fR during validation, as that can cause the spinbox widget to become out of sync with the \fB\-textvariable\fR. .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 | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | associated \fB\-textvariable\fR during validation, as that can cause the spinbox widget to become out of sync with the \fB\-textvariable\fR. .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 \-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 Moreover, forced validation is performed when invoking any spinbutton of the spinbox. If the validation script returns false in this situation, |
︙ | ︙ |
Added doc/sysnotify.n.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | .\" 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: .PP .CS tk sysnotify "Alert" \e "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 will request permission from the user to authorize notifications. This must be activated in Apple's System Preferences Notifications section. .RS .PP If deploying an application using the standalone version of Wish.app, setting the bundle ID in the applications Info.plist file to begin with .QW \fBcom\fR seems necessary for notifications to work. Using a different prefix for the bundle ID, such as something like .QW \fBtk.tcl.tkchat\fR , will cause notifications to silently fail. .RE .TP \fBWindows\fR . The image is taken from the system tray, i.e., \fBsysnotify\fR can only be called when a \fBsystray\fR was installed. . .SH KEYWORDS notify, alert |
Added doc/systray.n.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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 <Button-1> and <Button-3>. .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 |
Changes to doc/text.n.
︙ | ︙ | |||
843 844 845 846 847 848 849 850 851 852 853 854 855 856 | .IP [3] If the selection is claimed away by another application or by another window within this application, then the \fBsel\fR tag will be removed from all characters in the text. .IP [4] Whenever the \fBsel\fR tag range changes a virtual event \fB<<Selection>>\fR is generated. .PP The \fBsel\fR tag is automatically defined when a text widget is created, and it may not be deleted with the .QW "\fIpathName \fBtag delete\fR" widget command. Furthermore, the \fB\-selectbackground\fR, \fB\-selectborderwidth\fR, and \fB\-selectforeground\fR options for the text widget are tied to the \fB\-background\fR, \fB\-borderwidth\fR, and | > > > | 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | .IP [3] If the selection is claimed away by another application or by another window within this application, then the \fBsel\fR tag will be removed from all characters in the text. .IP [4] Whenever the \fBsel\fR tag range changes a virtual event \fB<<Selection>>\fR is generated. It might also be generated when selection is affected but not actually changed. Further, multiple selection changes could happen before events can be processed leading to multiple events with the same visible selection. .PP The \fBsel\fR tag is automatically defined when a text widget is created, and it may not be deleted with the .QW "\fIpathName \fBtag delete\fR" widget command. Furthermore, the \fB\-selectbackground\fR, \fB\-selectborderwidth\fR, and \fB\-selectforeground\fR options for the text widget are tied to the \fB\-background\fR, \fB\-borderwidth\fR, and |
︙ | ︙ | |||
1348 1349 1350 1351 1352 1353 1354 | 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 ...\fR? . This command is used to manipulate embedded images. The behavior of the | | | 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 | 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 ...\fR? . This command is used to manipulate embedded images. The behavior of the 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 . Returns the value of a configuration option for an embedded image. \fIIndex\fR identifies the embedded image, and \fIoption\fR specifies a particular |
︙ | ︙ | |||
1730 1731 1732 1733 1734 1735 1736 | \fIsequence\fR (an error occurs if there is no such binding). If both \fIscript\fR and \fIsequence\fR are omitted then the command returns a list of all the sequences for which bindings have been defined for \fItagName\fR. .RS .PP The only events for which bindings may be specified are those related to the mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButton\fR, | | > | | > | | 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | \fIsequence\fR (an error occurs if there is no such binding). If both \fIscript\fR and \fIsequence\fR are omitted then the command returns a list of all the sequences for which bindings have been defined for \fItagName\fR. .RS .PP The only events for which bindings may be specified are those related to the mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR, \fBButton\fR, \fBMotion\fR, and \fBKey\fR) or virtual events. Mouse and keyboard event bindings for a text widget respectively use the \fBcurrent\fR and \fBinsert\fR marks described under \fBMARKS\fR above. An \fBEnter\fR event triggers for a tag when the tag first becomes present on the current character, and a \fBLeave\fR event triggers for a tag when it ceases to be present on the current character. \fBEnter\fR and \fBLeave\fR events can happen either because the \fBcurrent\fR mark moved or because the character at that position changed. Note that these events are different than \fBEnter\fR and \fBLeave\fR events for windows. Mouse events are directed to the current character, while keyboard events are directed to the insert character. If a virtual event is used in a binding, that binding can trigger only if the virtual event is defined by an underlying mouse-related or keyboard-related event. .PP It is possible for the current character to have multiple tags, and for each of them to have a binding for a particular event sequence. When this occurs, one binding is invoked for each tag, in order from lowest-priority to highest priority. If there are multiple matching bindings for a single tag, then the |
︙ | ︙ | |||
2029 2030 2031 2032 2033 2034 2035 | Tk automatically creates class bindings for texts that give them the following default behavior. In the descriptions below, .QW word is dependent on the value of the \fBtcl_wordchars\fR variable. See \fBtclvars\fR(n). .IP [1] | | | 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 | Tk automatically creates class bindings for texts that give them the following default behavior. In the descriptions below, .QW word is dependent on the value of the \fBtcl_wordchars\fR variable. See \fBtclvars\fR(n). .IP [1] Clicking mouse button 1 positions the insertion cursor at the closest edge of the character underneath the mouse cursor, sets the input focus to this widget, and clears any selection in the widget. Dragging with mouse button 1 strokes out a selection between the insertion cursor and the character under the mouse. .IP [2] Double-clicking with mouse button 1 selects the word under the mouse and positions the insertion cursor at the start of the word. Dragging after a |
︙ | ︙ |
Changes to doc/tk.n.
︙ | ︙ | |||
81 82 83 84 85 86 87 88 89 90 91 92 93 94 | inactivity time is forbidden in safe interpreters and will throw an error if tried. .RE .TP \fBtk fontchooser \fIsubcommand\fR ... Controls the Tk font selection dialog. For more details see the \fBfontchooser\fR manual page. .TP \fBtk scaling \fR?\fB\-displayof \fIwindow\fR? ?\fInumber\fR? . Sets and queries the current scaling factor used by Tk to convert between physical units (for example, points, inches, or millimeters) and pixels. The \fInumber\fR argument is a floating point number that specifies the number of pixels per point on \fIwindow\fR's display. If the \fIwindow\fR argument is | > > > > > > > | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | inactivity time is forbidden in safe interpreters and will throw an error if tried. .RE .TP \fBtk fontchooser \fIsubcommand\fR ... Controls the Tk font selection dialog. For more details see the \fBfontchooser\fR manual page. .TP \fBtk print \fIwindow\fR . The \fBtk print\fR command posts a dialog that allows users to print output from the \fBcanvas\fR and \fBtext\fR widgets. The printing will be done using platform-native APIs and dialogs where available. For more details see the \fBprint\fR manual page. .TP \fBtk scaling \fR?\fB\-displayof \fIwindow\fR? ?\fInumber\fR? . Sets and queries the current scaling factor used by Tk to convert between physical units (for example, points, inches, or millimeters) and pixels. The \fInumber\fR argument is a floating point number that specifies the number of pixels per point on \fIwindow\fR's display. If the \fIwindow\fR argument is |
︙ | ︙ | |||
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | factor is set when the application starts, based on properties of the installed monitor, but it can be changed at any time. Measurements made 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 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 feature is only significant on X. If XIM support is not available, this will always return 0. If the \fIwindow\fR argument is omitted, it defaults to the main window. If the \fIboolean\fR argument is omitted, the current state is returned. This is turned on by default for the main display. .TP \fBtk windowingsystem\fR . 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" | > > > > > > > > > > > > | | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | factor is set when the application starts, based on properties of the installed monitor, but it can be changed at any time. Measurements made 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 \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 \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 feature is only significant on X. If XIM support is not available, this will always return 0. If the \fIwindow\fR argument is omitted, it defaults to the main window. If the \fIboolean\fR argument is omitted, the current state is returned. This is turned on by default for the main display. .TP \fBtk windowingsystem\fR . 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), print(n), send(n), sysnotify(n), systray(n), winfo(n) .SH KEYWORDS application name, print, send, sysnotify, systray '\" Local Variables: '\" mode: nroff '\" End: |
Deleted doc/tk4.0.ps.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to doc/tk_mac.n.
︙ | ︙ | |||
214 215 216 217 218 219 220 | .SH "ADDITIONAL DIALOGS" .PP The Aqua/Mac OS X defines additional dialogs that applications should support. .TP \fB::tk::mac::standardAboutPanel\fR . | | | | > > > > | < > > > | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | .SH "ADDITIONAL DIALOGS" .PP 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 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 \fB::tk::mac::useCompatibilityMetrics \fIboolean\fR . |
︙ | ︙ |
Changes to doc/tkvars.n.
︙ | ︙ | |||
22 23 24 25 26 27 28 | This variable holds the file name for a directory containing a library of Tcl scripts related to Tk. These scripts include an initialization file that is normally processed whenever a Tk application starts up, plus other files containing procedures that implement default behaviors for widgets. .RS .PP | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | This variable holds the file name for a directory containing a library of Tcl scripts related to Tk. These scripts include an initialization file that is normally processed whenever a Tk application starts up, plus other files containing procedures that implement default behaviors for widgets. .RS .PP The initial value of \fBtk_library\fR is set when Tk is added to an interpreter; this is done by searching several different directories until one is found that contains an appropriate Tk startup script. If the \fBTK_LIBRARY\fR environment variable exists, then the directory it names is checked first. If \fBTK_LIBRARY\fR is not set or does not refer to an appropriate directory, then Tk checks several other directories based on a compiled-in default location, the location of the Tcl library directory, |
︙ | ︙ | |||
46 47 48 49 50 51 52 | Contains a dot-separated sequence of decimal integers giving the current patch level for Tk. 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 | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | Contains a dot-separated sequence of decimal integers giving the current patch level for Tk. 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" . .RE .TP \fBtk_strictMotif\fR . This variable is set to zero by default. If an application sets it to one, then Tk attempts to adhere as closely as possible to Motif look-and-feel standards. |
︙ | ︙ |
Changes to doc/toplevel.n.
︙ | ︙ | |||
36 37 38 39 40 41 42 | been created with the \fBimage create\fR command. If specified as the empty string, no image will be displayed. .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 | | > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | been created with the \fBimage create\fR command. If specified as the empty string, no image will be displayed. .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. 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 created for the window and its children, or the name of another window (which must be on the same screen and have the same visual |
︙ | ︙ |
Changes to doc/ttk_button.n.
︙ | ︙ | |||
44 45 46 47 48 49 50 | .\" .OP \-foreground foreground Foreground .\" .OP \-font font Font .\" .OP \-anchor anchor Anchor .\" .OP \-relief relief Relief .SH "WIDGET COMMAND" .PP In addition to the standard | | > > | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | .\" .OP \-foreground foreground Foreground .\" .OP \-font font Font .\" .OP \-anchor anchor Anchor .\" .OP \-relief relief Relief .SH "WIDGET COMMAND" .PP In addition to the standard \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 \fBTtk::button\fR widgets support the \fBToolbutton\fR style in all standard themes, which is useful for creating widgets for toolbars. |
︙ | ︙ |
Changes to doc/ttk_checkbutton.n.
︙ | ︙ | |||
33 34 35 36 37 38 39 | when the widget is selected. Defaults to \fB1\fR. .OP \-variable variable Variable 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 | | > > | < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | when the widget is selected. Defaults to \fB1\fR. .OP \-variable variable Variable 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 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 to the \fB\-offvalue\fR and deselects the widget; otherwise, sets the \fB\-variable\fR to the \fB\-onvalue\fR |
︙ | ︙ |
Changes to doc/ttk_combobox.n.
︙ | ︙ | |||
51 52 53 54 55 56 57 | .OP \-values values Values Specifies the list of values to display in the drop-down listbox. .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 | | < | < > | < < | < < < < < < < < < < < < < | < < < < < < < | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | .OP \-values values Values Specifies the list of values to display in the drop-down listbox. .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 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 the last element of the list). 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 \fBset\fR \fIvalue\fR Sets the value of the combobox to \fIvalue\fR. .PP The combobox widget also supports the following \fBttk::entry\fR widget commands: .DS .ta 5.5c 11c \fBbbox\fR \fBdelete\fR \fBicursor\fR \fBindex\fR \fBinsert\fR \fBselection\fR \fBxview\fR .DE .SH "VIRTUAL EVENTS" .PP The combobox widget generates a \fB<<ComboboxSelected>>\fR virtual event when the user selects an element from the list of values. If the selection action unposts the listbox, this event is delivered after the listbox is unposted. .SH "STYLING OPTIONS" |
︙ | ︙ |
Changes to doc/ttk_entry.n.
︙ | ︙ | |||
135 136 137 138 139 140 141 | .QW \fBe\fR or .QW \fBsel.l\fR . In general, out-of-range indices are automatically rounded to the nearest legal value. .SH "WIDGET COMMAND" .PP | > > > > | < < < < < < < < < < < < < < < < | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | .QW \fBe\fR or .QW \fBsel.l\fR . In general, out-of-range indices are automatically rounded to the nearest legal value. .SH "WIDGET COMMAND" .PP 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 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 \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 one to delete. If \fIlast\fR is not specified it defaults to \fIfirst\fR+1, i.e. a single character is deleted. This command returns the empty string. .TP \fIpathName \fBget\fR 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 \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 \fBselection \fIoption arg\fR This command is used to adjust the selection within an entry. It has several forms, depending on \fIoption\fR: .RS .TP \fIpathName \fBselection clear\fR |
︙ | ︙ | |||
207 208 209 210 211 212 213 | \fIpathName \fBselection range \fIstart\fR \fIend\fR Sets the selection to include the characters starting with 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 | < < < < < < < < < < < < | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | \fIpathName \fBselection range \fIstart\fR \fIend\fR Sets the selection to include the characters starting with 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 \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. .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" .PP There are two main validation modes: \fIprevalidation\fR, |
︙ | ︙ |
Changes to doc/ttk_frame.n.
︙ | ︙ | |||
31 32 33 34 35 36 37 | Defaults to \fBflat\fR. .OP \-width width Width 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 | | | > | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | Defaults to \fBflat\fR. .OP \-width width Width 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 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 over the \fBframe\fR widget's \fB\-width\fR and \fB\-height\fR options. \fBpack propagate\fR and \fBgrid propagate\fR can be used |
︙ | ︙ |
Changes to doc/ttk_image.n.
︙ | ︙ | |||
75 76 77 78 79 80 81 82 83 84 85 86 87 | or vertically (\fB\-sticky ns\fR), subregions of the image are replicated to fill the parcel based on the \fB\-border\fR option. The \fB\-border\fR divides the image into 9 regions: four fixed corners, top and left edges (which may be tiled horizontally), left and right edges (which may be tiled vertically), and the central area (which may be tiled in both directions). .SH "EXAMPLE" .PP .CS set img1 [image create photo \-file button.png] set img2 [image create photo \-file button-pressed.png] set img3 [image create photo \-file button-active.png] | > > > | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | or vertically (\fB\-sticky ns\fR), subregions of the image are replicated to fill the parcel based on the \fB\-border\fR option. The \fB\-border\fR divides the image into 9 regions: four fixed corners, top and left edges (which may be tiled horizontally), left and right edges (which may be tiled vertically), and the central area (which may be tiled in both directions). .PP An image element that is not meant to claim any space (for example when used as a background image) should use \fB\-width 0\fR and \fB\-height 0\fR. .SH "EXAMPLE" .PP .CS set img1 [image create photo \-file button.png] set img2 [image create photo \-file button-pressed.png] set img3 [image create photo \-file button-active.png] ttk::style element create Button.button image \e [list $img1 pressed $img2 active $img3] \e \-border {2 4} \-sticky we .CE .SH "SEE ALSO" ttk::intro(n), ttk::style(n), ttk_vsapi(n), image(n), photo(n) .SH KEYWORDS style, theme, appearance, pixmap theme, image |
︙ | ︙ |
Changes to doc/ttk_label.n.
︙ | ︙ | |||
38 39 40 41 42 43 44 | Specifies the maximum line length (in pixels). 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 "WIDGET COMMAND" .PP | | | > | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | Specifies the maximum line length (in pixels). 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 "WIDGET COMMAND" .PP 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. .PP \fBTLabel\fP styling options configurable with \fBttk::style\fP |
︙ | ︙ |
Changes to doc/ttk_labelframe.n.
︙ | ︙ | |||
58 59 60 61 62 63 64 | The underlined character is used for mnemonic activation. Mnemonic activation for a \fBttk::labelframe\fR 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 | | | > | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | The underlined character is used for mnemonic activation. Mnemonic activation for a \fBttk::labelframe\fR 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 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. .PP Dynamic states: \fBdisabled\fP, \fBreadonly\fP. |
︙ | ︙ |
Changes to doc/ttk_menubutton.n.
︙ | ︙ | |||
34 35 36 37 38 39 40 | To be on the safe side, the menu ought to be a direct child of the menubutton. .\" not documented: may go away: .\" .OP \-anchor anchor Anchor .\" .OP \-padding padding Pad .SH "WIDGET COMMAND" .PP | | | > | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | To be on the safe side, the menu ought to be a direct child of the menubutton. .\" not documented: may go away: .\" .OP \-anchor anchor Anchor .\" .OP \-padding padding Pad .SH "WIDGET COMMAND" .PP 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" .PP The class name for a \fBttk::menubutton\fP is \fBTMenubutton\fP. |
︙ | ︙ |
Changes to doc/ttk_notebook.n.
︙ | ︙ | |||
98 99 100 101 102 103 104 105 106 107 108 109 110 111 | .IP \(bu The literal string .QW \fBend\fR , which returns the number of tabs (only valid for .QW "\fIpathname \fBindex\fR" ). .SH "WIDGET COMMAND" .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 | > > > > > > < < < < < < | 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | .IP \(bu The literal string .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 \fBforget \fItabid\fR Removes the tab specified by \fItabid\fR, unmaps and unmanages the associated window. .TP \fIpathname \fBhide \fItabid\fR Hides the tab specified by \fItabid\fR. The tab will not be displayed, but the associated window |
︙ | ︙ | |||
147 148 149 150 151 152 153 | Inserts a pane at the specified position. \fIpos\fR is either the string \fBend\fR, an integer index, 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 | < < < < < < | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | Inserts a pane at the specified position. \fIpos\fR is either the string \fBend\fR, an integer index, 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 \fBselect\fR ?\fItabid\fR? Selects the specified tab. 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 \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, returns the value of that \fIoption\fR. Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs. |
︙ | ︙ |
Changes to doc/ttk_panedwindow.n.
︙ | ︙ | |||
44 45 46 47 48 49 50 | .SH "PANE OPTIONS" The following options may be specified for each pane: .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" | > > | > | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | .SH "PANE OPTIONS" The following options may be specified for each pane: .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" .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 \fIpathname \fBforget \fIpane\fR Removes the specified subpane from the widget. |
︙ | ︙ | |||
102 103 104 105 106 107 108 | Sash positions are further constrained to be between 0 and the total size of the widget. .\" 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. | < < < < < < < < | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | Sash positions are further constrained to be between 0 and the total size of the widget. .\" 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. .SH "VIRTUAL EVENTS" .PP The panedwindow widget generates an \fB<<EnteredChild>>\fR virtual event on LeaveNotify/NotifyInferior events, because Tk does not execute binding scripts for <Leave> events when the pointer crosses from a parent to a child. The panedwindow widget needs to know when that happens. .SH "STYLING OPTIONS" |
︙ | ︙ |
Changes to doc/ttk_progressbar.n.
︙ | ︙ | |||
62 63 64 65 66 67 68 | .OP \-variable variable Variable The name of a global Tcl variable which is linked to the \fB\-value\fR. 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 | < | < < | < < | < | < < | < < < | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | .OP \-variable variable Variable The name of a global Tcl variable which is linked to the \fB\-value\fR. 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 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 \fBstep\fR ?\fIamount\fR? Increments the \fB\-value\fR by \fIamount\fR. \fIamount\fR defaults to 1.0 if omitted. .TP \fIpathName \fBstop\fR Stop autoincrement mode: cancels any recurring timer event initiated by \fIpathName \fBstart\fR. |
︙ | ︙ |
Changes to doc/ttk_radiobutton.n.
︙ | ︙ | |||
33 34 35 36 37 38 39 | when the widget is selected. .OP \-variable variable Variable 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 | | > > | < | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | when the widget is selected. .OP \-variable variable Variable 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 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 string if no \fB\-command\fR is specified. .\" Missing: select, deselect. Useful? |
︙ | ︙ |
Changes to doc/ttk_scale.n.
︙ | ︙ | |||
47 48 49 50 51 52 53 | .OP \-variable variable Variable Specifies the name of a global variable to link to the scale. Whenever the 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 | < | < < > > | < < < | < < < < < < < < < < < < < < < | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | .OP \-variable variable Variable Specifies the name of a global variable to link to the scale. Whenever the 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 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 \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. .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 The class name for a \fBttk::scale\fP is \fBTScale\fP. .PP Dynamic states: \fBactive\fP. .PP \fBTScale\fP styling options configurable with \fBttk::style\fP are: .PP \fB\-background\fP \fIcolor\fP .br \fB\-borderwidth\fP \fIamount\fP .br \fB\-darkcolor\fP \fIcolor\fP |
︙ | ︙ |
Changes to doc/ttk_scrollbar.n.
︙ | ︙ | |||
43 44 45 46 47 48 49 | or \fByview\fR (for vertical scrollbars). .RE .OP \-orient orient Orient One of \fBhorizontal\fR or \fBvertical\fR. Specifies the orientation of the scrollbar. .SH "WIDGET COMMAND" .PP | < | < < | > | > < < < < < < < < < < | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | or \fByview\fR (for vertical scrollbars). .RE .OP \-orient orient Orient One of \fBhorizontal\fR or \fBvertical\fR. Specifies the orientation of the scrollbar. .SH "WIDGET COMMAND" .PP 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 \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. .SH "INTERNAL COMMANDS" .PP The following widget commands are used internally by the \fBTScrollbar\fP widget class bindings. .TP \fIpathName \fBdelta \fIdeltaX deltaY\fR Returns a real number indicating the fractional change in |
︙ | ︙ |
Changes to doc/ttk_separator.n.
︙ | ︙ | |||
22 23 24 25 26 27 28 | .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-orient orient Orient One of \fBhorizontal\fR or \fBvertical\fR. Specifies the orientation of the separator. .SH "WIDGET COMMAND" .PP | | | > | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | .SE .SH "WIDGET-SPECIFIC OPTIONS" .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 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 \fBTSeparator\fP styling options configurable with \fBttk::style\fP are: |
︙ | ︙ |
Changes to doc/ttk_sizegrip.n.
︙ | ︙ | |||
19 20 21 22 23 24 25 | by pressing and dragging the grip. .SO ttk_widget \-class \-cursor \-style \-takefocus .SE .SH "WIDGET COMMAND" .PP | | | > | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | by pressing and dragging the grip. .SO ttk_widget \-class \-cursor \-style \-takefocus .SE .SH "WIDGET COMMAND" .PP 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 the built-in grip will just mask the widget. .SH EXAMPLES |
︙ | ︙ |
Changes to doc/ttk_style.n.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ttk::style \- Manipulate style database .SH SYNOPSIS \fBttk::style\fR \fIoption\fR ?\fIargs\fR? .BE .SH NOTES .PP See also the Tcl'2004 conference presentation, | | > > > > > > > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | ttk::style \- Manipulate style database .SH SYNOPSIS \fBttk::style\fR \fIoption\fR ?\fIargs\fR? .BE .SH NOTES .PP See also the Tcl'2004 conference presentation, available at http://tktable.sourceforge.net/tile/tile-tcl2004.pdf .SH DEFINITIONS .PP Each widget is assigned a \fIstyle\fR, which specifies the set of elements making up the widget and how they are arranged, along with dynamic and default settings for element options. 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. 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 |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 | \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 map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR? | > | > > > > > > > > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | \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 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 |
︙ | ︙ |
Changes to doc/ttk_treeview.n.
︙ | ︙ | |||
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | If set to \fBextended\fR (the default), multiple items may be selected. If \fBbrowse\fR, only a single item will be selected at a time. If \fBnone\fR, the selection will not be changed. .PP Note that application code and tag bindings can set the selection however they wish, regardless of the value of \fB\-selectmode\fR. .RE .OP \-show show Show A list containing zero or more of the following values, specifying which elements of the tree to display. .RS .IP \fBtree\fR Display tree labels in column #0. .IP \fBheadings\fR Display the heading row. .PP | > > > | > > > > > > > > > > > > > > > > < | > > > | > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | If set to \fBextended\fR (the default), multiple items may be selected. If \fBbrowse\fR, only a single item will be selected at a time. If \fBnone\fR, the selection will not be changed. .PP Note that application code and tag bindings can set the selection however they wish, regardless of the value of \fB\-selectmode\fR. .RE .OP \-selecttype selectType SelectType Controls how the built-in class bindings manage the selection. One of \fBitem\fR or \fBcell\fR. .OP \-show show Show A list containing zero or more of the following values, specifying which elements of the tree to display. .RS .IP \fBtree\fR Display tree labels in column #0. .IP \fBheadings\fR Display the heading row. .PP The default is \fBtree headings\fR. .PP \fBNOTE:\fR Column #0 always refers to the tree column, even if \fB\-show tree\fR is not specified. .RE .OP \-striped striped Striped Boolean specifying zebra striped item coloring. Note: Striped items uses the \fB\-stripedbackground\fR option if set by the theme or a tag. If not supported by the current theme, it will not show. .OP \-titlecolumns titleColumns TitleColumns Number of display columns at the left that should not be scrolled. The tree column counts, even if \fB\-show tree\fR is not specified. Thus for value N of this option, column #N is the first one that is scrollable. Default is 0. .OP \-titleitems titleItems TitleItems Number of items at the top that should not be vertically scrolled. Default is 0. .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. If the \fIitem\fR is not visible (i.e., if it is a descendant of a closed item or is vertically scrolled offscreen), returns the empty list. If \fIcolumn\fR is specified and is not hidden (by the \fB\-displaycolumns\fR option), returns the bounding box of that cell within \fIitem\fR (even if the cell is horizontally scrolled offscreen). .TP \fIpathname \fBcellselection\fR ?\fIselop arg ...\fR? Manages cell selection. Cell selection is independent from item selection handled by the \fBselection\fR command. A cell is given by a list of two elements, item and column. For the rectangle versions of commands, the cells must be in displayed columns. Any change to \fB\-columns\fR clears the cell selection. A \fIcellList\fR argument may be a single cell or a list of cells. If \fIselop\fR is not specified, returns the list of selected cells. Otherwise, \fIselop\fR is one of the following: .RS .TP \fIpathname \fBcellselection set \fIcellList\fR \fIcellList\fR becomes the new cell selection. .TP \fIpathname \fBcellselection set \fIfirstCell\fR \fIlastCell\fR The rectangle defined becomes the new cell selection. .TP \fIpathname \fBcellselection add \fIcellList\fR Add \fIcellList\fR to the cell selection .TP \fIpathname \fBcellselection add \fIfirstCell\fR \fIlastCell\fR The rectangle defined is added to the cell selection. .TP \fIpathname \fBcellselection remove \fIcellList\fR Remove \fIcellList\fR from the cell selection .TP \fIpathname \fBcellselection remove \fIfirstCell\fR \fIlastCell\fR The rectangle defined is removed from the cell selection. .TP \fIpathname \fBcellselection toggle \fIcellList\fR Toggle the cell selection state of each cell in \fIcellList\fR. .TP \fIpathname \fBcellselection toggle \fIfirstCell\fR \fIlastCell\fR Toggle the cell selection state of each cell in the rectangle defined. .RE .TP \fIpathname \fBchildren \fIitem\fR ?\fInewchildren\fR? If \fInewchildren\fR is not specified, returns the list of children belonging to \fIitem\fR. .RS .PP If \fInewchildren\fR is specified, replaces \fIitem\fR's child list |
︙ | ︙ | |||
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | The following options may be set on each column: .RS .TP \fB\-id \fIname\fR The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] returns the data column associated with display column #\fIn\fR. .TP \fB\-anchor \fIanchor\fR Specifies how the text in this column should be aligned with respect to the cell. \fIAnchor\fR is one of \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR. .TP \fB\-minwidth \fIminwidth\fR The minimum width of the column in pixels. The treeview widget will not make the column any smaller than \fB\-minwidth\fR when the widget is resized or the user drags a | > | > > > > | | < < < | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | The following options may be set on each column: .RS .TP \fB\-id \fIname\fR The column name. This is a read-only option. For example, [\fI$pathname \fBcolumn #\fIn \fB\-id\fR] returns the data column associated with display column #\fIn\fR. The tree column has -id \fB#0\fR. .TP \fB\-anchor \fIanchor\fR Specifies how the text in this column should be aligned with respect to the cell. \fIAnchor\fR is one of \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR, \fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR. .TP \fB\-minwidth \fIminwidth\fR The minimum width of the column in pixels. The treeview widget will not make the column any smaller than \fB\-minwidth\fR when the widget is resized or the user drags a heading column separator. Default is 20 pixels. .TP \fB\-separator \fIboolean\fR Specifies whether or not a column separator should be drawn to the right of the column. Default is false. .TP \fB\-stretch \fIboolean\fR Specifies whether or not the column width should be adjusted when the widget is resized or the user drags a heading column separator. \fIBoolean\fR may have any of the forms accepted by \fBTcl_GetBoolean\fR. By default columns are stretchable. .TP \fB\-width \fIwidth\fR The width of the column in pixels. Default is 200 pixels. The specified column width may be changed by Tk in order to honor \fB\-stretch\fR and/or \fB\-minwidth\fR, or when the widget is resized or the user drags a heading column separator. .PP Use \fIpathname column #0\fR to configure the tree column. .RE .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 \fIpathname \fBdetach \fIitemList\fR Unlinks all of the specified items in \fIitemList\fR from the tree. |
︙ | ︙ | |||
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | will return the display column identifier of the heading to left of the separator. .IP tree The tree area. .IP cell A data cell. .RE \fIpathname \fBidentify item \fIx y\fR Returns the item ID of the item at position \fIy\fR. .TP \fIpathname \fBidentify column \fIx y\fR Returns the display column identifier of the cell at position \fIx\fR. The tree column has ID \fB#0\fR. .TP \fIpathname \fBidentify element \fIx y\fR The element at position \fIx,y\fR. .TP \fIpathname \fBidentify row \fIx y\fR Obsolescent synonym for \fIpathname \fBidentify item\fR. .PP See \fBCOLUMN IDENTIFIERS\fR for a discussion of display columns | > > > > > | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | will return the display column identifier of the heading to left of the separator. .IP tree The tree area. .IP cell A data cell. .RE .TP \fIpathname \fBidentify item \fIx y\fR Returns the item ID of the item at position \fIy\fR. .TP \fIpathname \fBidentify column \fIx y\fR Returns the display column identifier of the cell at position \fIx\fR. The tree column has ID \fB#0\fR. .TP \fIpathname \fBidentify cell \fIx y\fR Returns the cell identifier of the cell at position \fIx y\fR. A cell identifier is a list of item ID and column ID. .TP \fIpathname \fBidentify element \fIx y\fR The element at position \fIx,y\fR. .TP \fIpathname \fBidentify row \fIx y\fR Obsolescent synonym for \fIpathname \fBidentify item\fR. .PP See \fBCOLUMN IDENTIFIERS\fR for a discussion of display columns |
︙ | ︙ | |||
268 269 270 271 272 273 274 | .RS .PP \fIpathname \fBinsert\fR returns the item identifier of the newly created item. See \fBITEM OPTIONS\fR for the list of available options. .RE .TP | < < < | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | .RS .PP \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 \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, returns the value of that option. Otherwise, the item's options are updated with the specified values. |
︙ | ︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 322 | \fIpathname \fBsee \fIitem\fR Ensure that \fIitem\fR is visible: sets all of \fIitem\fR's ancestors to \fB\-open true\fR, and scrolls the widget if necessary so that \fIitem\fR is within the visible portion of the tree. .TP \fIpathname \fBselection\fR ?\fIselop itemList\fR? If \fIselop\fR is not specified, returns the list of selected items. Otherwise, \fIselop\fR is one of the following: .RS .TP \fIpathname \fBselection set \fIitemList\fR \fIitemList\fR becomes the new selection. .TP | > > | 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | \fIpathname \fBsee \fIitem\fR Ensure that \fIitem\fR is visible: sets all of \fIitem\fR's ancestors to \fB\-open true\fR, and scrolls the widget if necessary so that \fIitem\fR is within the visible portion of the tree. .TP \fIpathname \fBselection\fR ?\fIselop itemList\fR? Manages item selection. Item selection is independent from cell selection handled by the \fBcellselection\fR command. If \fIselop\fR is not specified, returns the list of selected items. Otherwise, \fIselop\fR is one of the following: .RS .TP \fIpathname \fBselection set \fIitemList\fR \fIitemList\fR becomes the new selection. .TP |
︙ | ︙ | |||
334 335 336 337 338 339 340 | With one argument, returns a dictionary of column/value pairs for the specified \fIitem\fR. 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 | < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < | | > > | | > > > | > > > > | | | | < | | > > > > > > | > > > | > | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | With one argument, returns a dictionary of column/value pairs for the specified \fIitem\fR. 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 \fBtag \fIargs...\fR Manages tags. Tags can be set on items as well as on cells. The set of tags is shared between items and cells. However item tagging is independent from cell tagging (for instance adding a tag on an item does not also add this tag on the cells in that item). Cell tags take precedence over item tags when drawing. The following subcommands are supported: .RS .TP \fIpathName \fBtag add \fItag items\fR Adds the specified \fItag\fR to each of the listed \fIitems\fR. If \fItag\fR is already present for a particular item, then the \fB\-tags\fR for that item are unchanged. .TP \fIpathName \fBtag bind \fItagName \fR?\fIsequence\fR? ?\fIscript\fR? Add a Tk binding script for the event sequence \fIsequence\fR to the tag \fItagName\fR. When an X event is delivered to an item, binding scripts for each of the item's \fB\-tags\fR are evaluated in order as per \fIbindtags(n)\fR. If the event can be associated with a cell (i.e. mouse events) any bindings for the cell's \fB\-tags\fR are evaluated as well. .RS .PP \fB<Key>\fR, \fB<KeyRelease>\fR, and virtual events are sent to the focus item. \fB<Button>\fR, \fB<ButtonRelease>\fR, and \fB<Motion>\fR events are sent to the item under the mouse pointer. No other event types are supported. .PP The binding \fIscript\fR undergoes \fB%\fR-substitutions before evaluation; see \fBbind(n)\fR for details. .RE .TP \fIpathName \fBtag cell \fIsubcmd...\fR Manages tags on individual cells. A \fIcellList\fR argument may be a single cell or a list of cells. .RS .TP \fIpathName \fBtag cell add \fItag cellList\fR Adds the specified \fItag\fR to each of the listed \fIcellList\fR. If \fItag\fR is already present for a particular cell, then the tag list for that cell is unchanged. .TP \fIpathName \fBtag cell has \fItagName\fR ?\fIcell\fR? If \fIcell\fR is specified, returns 1 or 0 depending on whether the specified cell has the named tag. Otherwise, returns a list of all cells which have the specified tag. .TP \fIpathName \fBtag cell remove \fItag\fR ?\fIcellList\fR? Removes the specified \fItag\fR from each of the listed \fIcellList\fR. If \fIcellList\fR is omitted, removes \fItag\fR from each cell in the tree. .RE .TP \fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue option value...\fR? Query or modify the options for the specified \fItagName\fR. If one or more \fIoption/value\fR pairs are specified, sets the value of those options for the specified tag. If a single \fIoption\fR is specified, returns the value of that option (or the empty string if the option has not been specified for \fItagName\fR). With no additional arguments, returns a dictionary of the option settings for \fItagName\fR. See \fBTAG OPTIONS\fR for the list of available options. .TP \fIpathName \fBtag delete \fItagName\fR Deletes all tag information for the \fItagName\fR argument. The command removes the tag from all items and cells in the widget and also deletes any other information associated with the tag, such as bindings and display information. The command returns an empty string. .TP \fIpathName \fBtag has \fItagName\fR ?\fIitem\fR? If \fIitem\fR is specified, returns 1 or 0 depending on whether the specified item has the named tag. Otherwise, returns a list of all items which have the specified tag. .TP \fIpathName \fBtag names\fR Returns a list of all tags used by the widget. .TP \fIpathName \fBtag remove \fItag\fR ?\fIitems\fR? 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 .SH "ITEM OPTIONS" .PP The following item options may be specified for items in the \fBinsert\fR and \fBitem\fR widget commands. .IP \fB\-text\fR The textual label to display for the item in the tree column. .IP \fB\-height\fR The height for the item, in integer multiples of \fB\-rowheight\fP. Default is 1. .IP \fB\-image\fR A Tk image, displayed next to the label in the tree column, placed according to \fB-imageanchor\fR. .IP \fB\-imageanchor\fR Specifies how the \fB-image\fR is displayed relative to the text. Default is \fBw\fR. One of the standard Tk anchor values. .IP \fB\-values\fR The list of values associated with the item. .RS .PP Each item should have the same number of values as the \fB\-columns\fR widget option. If there are fewer values than columns, the remaining values are assumed empty. If there are more values than columns, the extra values are ignored. .RE .IP \fB\-hidden\fR A boolean value indicating whether this item should be displayed (\fB\-hidden false\fR) or hidden (\fB\-hidden true\fR). If a parent is hidden, all its decendants are hidden too. .IP \fB\-open\fR A boolean value indicating whether the item's children should be displayed (\fB\-open true\fR) or hidden (\fB\-open false\fR). .IP \fB\-tags\fR A list of tags associated with this item. .SH "TAG OPTIONS" .PP The following options may be specified on tags: .IP \fB\-foreground\fR Specifies the text foreground color. .IP \fB\-background\fR Specifies the cell or item background color. .IP \fB\-font\fR Specifies the font to use when drawing text. .IP \fB\-image\fR Specifies the cell or item image. .IP \fB\-imageanchor\fR Specifies the cell or item image anchor. .IP \fB\-padding\fR Specifies the cell padding. A data cell will have a default padding of {4 0} .IP \fB\-stripedbackground\fR Specifies the cell or item background color for alternate lines, if \fB\-striped\fR is true. .PP .\" .PP .\" \fI(@@@ TODO: sort out order of precedence for options)\fR .PP Tags on cells have precedence over tags on items. Then, tag priority is decided by the creation order: tags created first receive higher priority. An item's options, like \fB\-image\fR and \fB\-imageanchor\fR, have priority over tags. .SH "IMAGES" The -image option on an item, and on an item tag, controls the image next to the label in the tree column. Other cells can have images through the cell tag -image option. .SH "COLUMN IDENTIFIERS" .PP Column identifiers take any of the following forms: .IP \(bu A symbolic name from the list of \fB\-columns\fR. .IP \(bu An integer \fIn\fR, specifying the \fIn\fRth data column. |
︙ | ︙ | |||
473 474 475 476 477 478 479 | If \fB\-displaycolumns\fR is not set, then data column \fIn\fR is displayed in display column \fB#\fIn+1\fR. Again, \fBcolumn #0 always refers to the tree column\fR. .SH "VIRTUAL EVENTS" .PP The treeview widget generates the following virtual events. .IP <<TreeviewSelect>> | | > > > | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | If \fB\-displaycolumns\fR is not set, then data column \fIn\fR is displayed in display column \fB#\fIn+1\fR. Again, \fBcolumn #0 always refers to the tree column\fR. .SH "VIRTUAL EVENTS" .PP The treeview widget generates the following virtual events. .IP <<TreeviewSelect>> Generated whenever the selection or cellselection changes. It might also be generated when selection is affected but not actually changed. Further, multiple selection changes could happen before events can be processed leading to multiple events with the same visible selection. .IP <<TreeviewOpen>> Generated just before setting the focus item to \fB\-open true\fR. .IP <<TreeviewClose>> Generated just after setting the focus item to \fB\-open false\fR. .PP The \fBfocus\fR and \fBselection\fR widget commands can be used to determine the affected item or items. |
︙ | ︙ | |||
504 505 506 507 508 509 510 | .br \fB\-fieldbackground\fP \fIcolor\fP .br \fB\-font\fP \fIfont\fP .br \fB\-foreground\fP \fIcolor\fP .br | > > | > | > | > > | | < < < > > > | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | .br \fB\-fieldbackground\fP \fIcolor\fP .br \fB\-font\fP \fIfont\fP .br \fB\-foreground\fP \fIcolor\fP .br \fB\-columnseparatorwidth\fP \fIpixels\fP .br \fB\-rowheight\fP \fIpixels\fP .RS This is the standard height for an item. If \fB\-rowheight\fP is not set by the style, it is set by measuring an item and a cell layout with the style's settings. This thus picks up the font and any focus ring or padding from the theme's layout. The \fB\-rowheight\fP may need to be set to make sure that a row is large enough to contain any images. .PP Example of how to set \fB\-rowheight\fP, adapting to a font in a similar way to how the default value is set: .RE .PP .CS ttk::style configure Treeview \\ \-rowheight [expr {[font metrics \fIfont\fP \-linespace] + 2}] .CE .br \fB\-stripedbackground\fP \fIcolor\fP .PP \fBHeading\fP styling options configurable with \fBttk::style\fP are: .PP \fB\-background\fP \fIcolor\fP .br \fB\-font\fP \fIfont\fP |
︙ | ︙ |
Changes to doc/ttk_widget.n.
︙ | ︙ | |||
79 80 81 82 83 84 85 | See also \fB\-justify\fR (for widgets supporting this option). .OP \-compound compound Compound Specifies how to display the image relative to the text, in the case both \fB\-text\fR and \fB\-image\fR are present. If set to the empty string (the default), the rules described in the "Elements" section of \fIttk::intro(n)\fR explain which value is actually used. | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | See also \fB\-justify\fR (for widgets supporting this option). .OP \-compound compound Compound Specifies how to display the image relative to the text, in the case both \fB\-text\fR and \fB\-image\fR are present. If set to the empty string (the default), the rules described in the "Elements" section of \fIttk::intro(n)\fR explain which value is actually used. The other valid values are: .RS .IP text Display text only. .IP image Display image only. .IP center Display text centered on top of image. |
︙ | ︙ | |||
170 171 172 173 174 175 176 | This is a write-only option: setting it changes the widget state, but the \fBstate\fR widget command does not affect the \fB\-state\fR option. .SH COMMANDS .TP \fIpathName \fBcget \fIoption\fR | < < < | > < < > > > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | This is a write-only option: setting it changes the widget state, 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. If \fIoption\fR is specified with no \fIvalue\fR, then the command returns a list describing the named option: the elements of the list are the option name, database name, database class, default value, and current value. .\" 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 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 Returns a new state spec indicating which flags were changed: .CS set changes [\fIpathName \fRstate \fIspec\fR] \fIpathName \fRstate $changes .CE 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 .TP \fIpathName \fBxview\fR |
︙ | ︙ |
Changes to doc/wm.n.
︙ | ︙ | |||
116 117 118 119 120 121 122 | Makes the window content area transparent and turns off the window shadow. For the transparency to be effective, the toplevel background needs to be set to a color with some alpha, e.g. .QW systemTransparent . .PP On X11, the following attributes may be set. These are not supported by all window managers, and will have no effect under older WMs. | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | Makes the window content area transparent and turns off the window shadow. For the transparency to be effective, the toplevel background needs to be set to a color with some alpha, e.g. .QW systemTransparent . .PP On X11, the following attributes may be set. These are not supported by all window managers, and will have no effect under older WMs. .\" See https://www.freedesktop.org/wiki/Specifications/wm-spec/ .TP \fB\-type\fR .VS 8.6 Requests that the window should be interpreted by the window manager as being of the specified type(s). This may cause the window to be decorated in a different way or otherwise managed differently, though exactly what happens is entirely up to the window manager. A list of types may be used, in order of |
︙ | ︙ | |||
402 403 404 405 406 407 408 409 410 411 412 413 414 415 | a group of related windows. The window manager may use this information, for example, to unmap all of the windows in a group when the group's leader is iconified. \fIPathName\fR may be specified as an empty string to remove \fIwindow\fR from any group association. If \fIpathName\fR is specified then the command returns an empty string; otherwise it returns the path name of \fIwindow\fR's current group leader, or an empty string if \fIwindow\fR is not part of any group. .TP \fBwm iconbitmap \fIwindow\fR ?\fIbitmap\fR? . If \fIbitmap\fR is specified, then it names a bitmap in the standard forms accepted by Tk (see the \fBTk_GetBitmap\fR manual entry for details). This bitmap is passed to the window manager to be displayed in \fIwindow\fR's icon, and the command returns an empty string. If | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | a group of related windows. The window manager may use this information, for example, to unmap all of the windows in a group when the group's leader is iconified. \fIPathName\fR may be specified as an empty string to remove \fIwindow\fR from any group association. If \fIpathName\fR is specified then the command returns an empty string; otherwise it returns the path name of \fIwindow\fR's current group leader, or an empty string if \fIwindow\fR is not part of any group. .TP \fBwm iconbadge \fIwindow\fR \fIbadge\fR . Sets a badge for the icon of the \fIwindow\fR. The badge can be a positive integer number, for instance the number of new or unread messages, or an exclamation point denoting attention needed. If the badge is an empty string, the badge image is removed from the application icon. Managing these changes through bindings, such as <FocusIn>, is the responsibility of the developer. .RS .PP On X11, for this command to work, the variable \fB::tk::icons::base_icon($window)\fR must be set to the image that is being used for the window icon of $window. On Windows and X11, the iconphoto images work best at 32x32 or a similar dimension, as the badge images are provided by Tk and drawn to overlay the icon images using native (Windows) API's or Tk rendering. On macOS, the icon badge is rendered by a system API and is not provided by Tk. The icon image itself should be higher-resolution, preferably 512 pixels, to avoid being blurry. .PP The icon badge is intended for display in the Dock (macOS), taskbar (Windows) or app panel (X11). On macOS, the last badge called will be displayed in the Dock, regardless of how many different icon badges may be assigned to different windows. On Windows, the taskbar display depends on whether the taskbar buttons are combined or not (this is an OS setting available to the user): if combined the behavior is the same as on macOS, otherwise each button in the taskbar shows the badge it was assigned. Badge display on macOS is configured in the system preferences. App panel display behavior on X11 will depend on the window manager and/or desktop environment. .RE .TP \fBwm iconbitmap \fIwindow\fR ?\fIbitmap\fR? . If \fIbitmap\fR is specified, then it names a bitmap in the standard forms accepted by Tk (see the \fBTk_GetBitmap\fR manual entry for details). This bitmap is passed to the window manager to be displayed in \fIwindow\fR's icon, and the command returns an empty string. If |
︙ | ︙ | |||
477 478 479 480 481 482 483 | reflected to the titlebar icons. Multiple images are accepted to allow different images sizes (e.g., 16x16 and 32x32) to be provided. The window manager may scale provided icons to an appropriate size. .RS .PP On Windows, the images are packed into a Windows icon structure. This will override an ico specified to \fBwm iconbitmap\fR, and | | | > | 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | reflected to the titlebar icons. Multiple images are accepted to allow different images sizes (e.g., 16x16 and 32x32) to be provided. The window manager may scale provided icons to an appropriate size. .RS .PP On Windows, the images are packed into a Windows icon structure. This will override an ico specified to \fBwm iconbitmap\fR, and vice versa. This command sets the taskbar icon for the window. .PP On X, the images are arranged into the _NET_WM_ICON X property, which most modern window managers support. A \fBwm iconbitmap\fR may exist simultaneously. It is recommended to use not more than 2 icons, placing the larger icon first. This command also sets the panel icon for the application if the window manager or desktop environment supports it. .PP On Macintosh, the first image called is loaded into an OSX-native icon format, and becomes the application icon in dialogs, the Dock, and other contexts. At the script level the command will accept only the first image passed in the parameters as support for multiple sizes/resolutions on macOS is outside Tk's scope. Developers should use the largest icon they can support |
︙ | ︙ | |||
603 604 605 606 607 608 609 | as equivalent to \fBprogram\fR. Tk will automatically set the position source to \fBuser\fR when a \fBwm geometry\fR command is invoked, unless the source has been set explicitly to \fBprogram\fR. .TP \fBwm protocol \fIwindow\fR ?\fIname\fR? ?\fIcommand\fR? . | | < | | | < < > > | | | > | | | | > | | < | | | < | > > | > > | > > > > | > > | > > | > | > | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | as equivalent to \fBprogram\fR. Tk will automatically set the position source to \fBuser\fR when a \fBwm geometry\fR command is invoked, unless the source has been set explicitly to \fBprogram\fR. .TP \fBwm protocol \fIwindow\fR ?\fIname\fR? ?\fIcommand\fR? . This command is used to manage window manager protocols. The \fIname\fR argument in the \fBwm protocol\fR command is the name of an atom corresponding to a window manager protocol. Examples include \fBWM_DELETE_WINDOW\fR or \fBWM_SAVE_YOURSELF\fR or \fBWM_TAKE_FOCUS\fR. .RS .PP A \fIwindow manager protocol\fR is a class of messages sent from a window manager to a Tk application outside of the normal event processing system. The main example is the \fBWM_DELETE_WINDOW\fR protocol; these messages are sent when the user clicks the close widget in the title bar of a window. Handlers for window manager protocols are installed with the \fBwm protocol\fR command. As a rule, if no handler has been installed for a protocol by the \fBwm protocol\fR command then all messages of that protocol are ignored. The \fBWM_DELETE_WINDOW\fR protocol is an exception to this rule. At start-up Tk installs a handler for this protocol, which responds by destroying the window. The \fBwm protocol\fR command can be used to replace this default handler by one which responds differently. .RE .RS .PP The list of available window manager protocols depends on the window manager, but all window managers supported by Tk provide \fBWM_DELETE_WINDOW\fR. On the Windows platform, a \fBWM_SAVE_YOURSELF\fR message is sent on user logout or system restart. .RE .RS .PP If both \fIname\fR and \fIcommand\fR are specified, then \fIcommand\fR becomes the handler for the protocol specified by \fIname\fR. The atom for \fIname\fR will be added to \fIwindow\fR's \fBWM_PROTOCOLS\fR property to tell the window manager that the application has a handler for the protocol specified by \fIname\fR, and \fIcommand\fR will be invoked in the future whenever the window manager sends a message of that protocol to the Tk application. In this case the \fBwm protocol\fR command returns an empty string. If \fIname\fR is specified but \fIcommand\fR is not, then the current handler for \fIname\fR is returned, or an empty string if there is no handler defined for \fIname\fR (as a special case, the default handler for \fBWM_DELETE_WINDOW\fR is not returned). If \fIcommand\fR is specified as an empty string then the atom for \fIname\fR is removed from the \fBWM_PROTOCOLS\fR property of \fIwindow\fR and the handler is destroyed; an empty string is returned. Lastly, if neither \fIname\fR nor \fIcommand\fR is specified, the \fBwm protocol\fR command returns a list of all of the protocols for which handlers are currently defined for \fIwindow\fR. .RE .TP \fBwm resizable \fIwindow\fR ?\fIwidth height\fR? . This command controls whether or not the user may interactively resize a top-level window. If \fIwidth\fR and \fIheight\fR are specified, they are boolean values that determine whether the |
︙ | ︙ |
Changes to generic/ks_names.h.
︙ | ︙ | |||
16 17 18 19 20 21 22 | { "Linefeed", 0xFF0A }, { "Clear", 0xFF0B }, { "Return", 0xFF0D }, { "Pause", 0xFF13 }, { "Scroll_Lock", 0xFF14 }, { "Sys_Req", 0xFF15 }, { "Escape", 0xFF1B }, | < < < < < > > > > > > | > > > > > | | > < < < > > > > > > > > > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | { "Linefeed", 0xFF0A }, { "Clear", 0xFF0B }, { "Return", 0xFF0D }, { "Pause", 0xFF13 }, { "Scroll_Lock", 0xFF14 }, { "Sys_Req", 0xFF15 }, { "Escape", 0xFF1B }, { "Multi_key", 0xFF20 }, { "Kanji", 0xFF21 }, { "Muhenkan", 0xFF22 }, { "Henkan_Mode", 0xFF23 }, { "Henkan", 0xFF23 }, { "Romaji", 0xFF24 }, { "Hiragana", 0xFF25 }, { "Katakana", 0xFF26 }, { "Hiragana_Katakana", 0xFF27 }, { "Zenkaku", 0xFF28 }, { "Hankaku", 0xFF29 }, { "Zenkaku_Hankaku", 0xFF2A }, { "Touroku", 0xFF2B }, { "Massyo", 0xFF2C }, { "Kana_Lock", 0xFF2D }, { "Kana_Shift", 0xFF2E }, { "Eisu_Shift", 0xFF2F }, { "Eisu_toggle", 0xFF30 }, { "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 }, { "Prior", 0xFF55 }, { "Page_Up", 0xFF55 }, { "Next", 0xFF56 }, { "Page_Down", 0xFF56 }, { "End", 0xFF57 }, { "Begin", 0xFF58 }, { "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 }, { "KP_F2", 0xFF92 }, { "KP_F3", 0xFF93 }, |
︙ | ︙ | |||
90 91 92 93 94 95 96 | { "KP_Page_Up", 0xFF9A }, { "KP_Next", 0xFF9B }, { "KP_Page_Down", 0xFF9B }, { "KP_End", 0xFF9C }, { "KP_Begin", 0xFF9D }, { "KP_Insert", 0xFF9E }, { "KP_Delete", 0xFF9F }, | < > | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | { "KP_Page_Up", 0xFF9A }, { "KP_Next", 0xFF9B }, { "KP_Page_Down", 0xFF9B }, { "KP_End", 0xFF9C }, { "KP_Begin", 0xFF9D }, { "KP_Insert", 0xFF9E }, { "KP_Delete", 0xFF9F }, { "KP_Multiply", 0xFFAA }, { "KP_Add", 0xFFAB }, { "KP_Separator", 0xFFAC }, { "KP_Subtract", 0xFFAD }, { "KP_Decimal", 0xFFAE }, { "KP_Divide", 0xFFAF }, { "KP_0", 0xFFB0 }, { "KP_1", 0xFFB1 }, { "KP_2", 0xFFB2 }, { "KP_3", 0xFFB3 }, { "KP_4", 0xFFB4 }, { "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 }, { "F6", 0xFFC3 }, { "F7", 0xFFC4 }, |
︙ | ︙ | |||
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | { "Caps_Lock", 0xFFE5 }, { "Shift_Lock", 0xFFE6 }, { "Meta_L", 0xFFE7 }, { "Meta_R", 0xFFE8 }, { "Alt_L", 0xFFE9 }, { "Alt_R", 0xFFEA }, { "Super_L", 0xFFEB }, { "Super_R", 0xFFEC }, { "Hyper_L", 0xFFED }, { "Hyper_R", 0xFFEE }, { "ISO_Lock", 0xFE01 }, { "ISO_Level2_Latch", 0xFE02 }, { "ISO_Level3_Shift", 0xFE03 }, { "ISO_Level3_Latch", 0xFE04 }, { "ISO_Level3_Lock", 0xFE05 }, | > > > > > > > > > > > > > > > > > < < < < > > > | 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | { "Caps_Lock", 0xFFE5 }, { "Shift_Lock", 0xFFE6 }, { "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_Group_Latch", 0xFE06 }, { "ISO_Group_Lock", 0xFE07 }, { "ISO_Next_Group", 0xFE08 }, { "ISO_Next_Group_Lock", 0xFE09 }, { "ISO_Prev_Group", 0xFE0A }, { "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 }, { "ISO_Partial_Space_Left", 0xFE25 }, { "ISO_Partial_Space_Right", 0xFE26 }, |
︙ | ︙ | |||
256 257 258 259 260 261 262 | { "dead_belowcircumflex", 0xFE69 }, { "dead_belowtilde", 0xFE6A }, { "dead_belowbreve", 0xFE6B }, { "dead_belowdiaeresis", 0xFE6C }, { "dead_invertedbreve", 0xFE6D }, { "dead_belowcomma", 0xFE6E }, { "dead_currency", 0xFE6F }, | | > > | > > > > | | > > > > > > > > > > > < < < < < < < < < < < | 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | { "dead_belowcircumflex", 0xFE69 }, { "dead_belowtilde", 0xFE6A }, { "dead_belowbreve", 0xFE6B }, { "dead_belowdiaeresis", 0xFE6C }, { "dead_invertedbreve", 0xFE6D }, { "dead_belowcomma", 0xFE6E }, { "dead_currency", 0xFE6F }, { "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 }, { "dead_I", 0xFE85 }, { "dead_o", 0xFE86 }, { "dead_O", 0xFE87 }, { "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 }, { "Pointer_Left", 0xFEE0 }, { "Pointer_Right", 0xFEE1 }, { "Pointer_Up", 0xFEE2 }, { "Pointer_Down", 0xFEE3 }, { "Pointer_UpLeft", 0xFEE4 }, { "Pointer_UpRight", 0xFEE5 }, { "Pointer_DownLeft", 0xFEE6 }, |
︙ | ︙ | |||
314 315 316 317 318 319 320 | { "Pointer_DblClick4", 0xFEF2 }, { "Pointer_DblClick5", 0xFEF3 }, { "Pointer_Drag_Dflt", 0xFEF4 }, { "Pointer_Drag1", 0xFEF5 }, { "Pointer_Drag2", 0xFEF6 }, { "Pointer_Drag3", 0xFEF7 }, { "Pointer_Drag4", 0xFEF8 }, | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | { "Pointer_DblClick4", 0xFEF2 }, { "Pointer_DblClick5", 0xFEF3 }, { "Pointer_Drag_Dflt", 0xFEF4 }, { "Pointer_Drag1", 0xFEF5 }, { "Pointer_Drag2", 0xFEF6 }, { "Pointer_Drag3", 0xFEF7 }, { "Pointer_Drag4", 0xFEF8 }, { "Pointer_EnableKeys", 0xFEF9 }, { "Pointer_Accelerate", 0xFEFA }, { "Pointer_DfltBtnNext", 0xFEFB }, { "Pointer_DfltBtnPrev", 0xFEFC }, { "Pointer_Drag5", 0xFEFD }, { "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 }, { "3", 0x33 }, { "4", 0x34 }, { "5", 0x35 }, { "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 }, { "D", 0x44 }, { "E", 0x45 }, |
︙ | ︙ | |||
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | { "T", 0x54 }, { "U", 0x55 }, { "V", 0x56 }, { "W", 0x57 }, { "X", 0x58 }, { "Y", 0x59 }, { "Z", 0x5A }, { "bracketleft", 0x5B }, { "backslash", 0x5C }, { "bracketright", 0x5D }, { "asciicircum", 0x5E }, { "underscore", 0x5F }, { "grave", 0x60 }, { "quoteleft", 0x60 }, { "a", 0x61 }, { "b", 0x62 }, { "c", 0x63 }, | > > | 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | { "T", 0x54 }, { "U", 0x55 }, { "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 }, { "b", 0x62 }, { "c", 0x63 }, |
︙ | ︙ | |||
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | { "t", 0x74 }, { "u", 0x75 }, { "v", 0x76 }, { "w", 0x77 }, { "x", 0x78 }, { "y", 0x79 }, { "z", 0x7A }, { "braceleft", 0x7B }, { "bar", 0x7C }, { "braceright", 0x7D }, { "asciitilde", 0x7E }, { "nobreakspace", 0xA0 }, { "exclamdown", 0xA1 }, { "cent", 0xA2 }, { "sterling", 0xA3 }, { "currency", 0xA4 }, { "yen", 0xA5 }, { "brokenbar", 0xA6 }, { "section", 0xA7 }, | > > > > > > | 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | { "t", 0x74 }, { "u", 0x75 }, { "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 }, { "brokenbar", 0xA6 }, { "section", 0xA7 }, |
︙ | ︙ | |||
546 547 548 549 550 551 552 | { "ograve", 0xF2 }, { "oacute", 0xF3 }, { "ocircumflex", 0xF4 }, { "otilde", 0xF5 }, { "odiaeresis", 0xF6 }, { "division", 0xF7 }, { "oslash", 0xF8 }, | < < < > | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | { "ograve", 0xF2 }, { "oacute", 0xF3 }, { "ocircumflex", 0xF4 }, { "otilde", 0xF5 }, { "odiaeresis", 0xF6 }, { "division", 0xF7 }, { "oslash", 0xF8 }, { "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 }, { "Scaron", 0x1A9 }, { "Scedilla", 0x1AA }, |
︙ | ︙ | |||
676 677 678 679 680 681 682 | { "imacron", 0x3EF }, { "ncedilla", 0x3F1 }, { "omacron", 0x3F2 }, { "kcedilla", 0x3F3 }, { "uogonek", 0x3F9 }, { "utilde", 0x3FD }, { "umacron", 0x3FE }, | < < < < < < < < < < < < < < < < < < < < < < < < < < | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 | { "imacron", 0x3EF }, { "ncedilla", 0x3F1 }, { "omacron", 0x3F2 }, { "kcedilla", 0x3F3 }, { "uogonek", 0x3F9 }, { "utilde", 0x3FD }, { "umacron", 0x3FE }, { "OE", 0x13BC }, { "oe", 0x13BD }, { "Ydiaeresis", 0x13BE }, { "overline", 0x47E }, { "kana_fullstop", 0x4A1 }, { "kana_openingbracket", 0x4A2 }, { "kana_closingbracket", 0x4A3 }, |
︙ | ︙ | |||
784 785 786 787 788 789 790 | { "kana_RU", 0x4D9 }, { "kana_RE", 0x4DA }, { "kana_RO", 0x4DB }, { "kana_WA", 0x4DC }, { "kana_N", 0x4DD }, { "voicedsound", 0x4DE }, { "semivoicedsound", 0x4DF }, | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 | { "kana_RU", 0x4D9 }, { "kana_RE", 0x4DA }, { "kana_RO", 0x4DB }, { "kana_WA", 0x4DC }, { "kana_N", 0x4DD }, { "voicedsound", 0x4DE }, { "semivoicedsound", 0x4DF }, { "Arabic_comma", 0x5AC }, { "Arabic_semicolon", 0x5BB }, { "Arabic_question_mark", 0x5BF }, { "Arabic_hamza", 0x5C1 }, { "Arabic_maddaonalef", 0x5C2 }, { "Arabic_hamzaonalef", 0x5C3 }, { "Arabic_hamzaonwaw", 0x5C4 }, { "Arabic_hamzaunderalef", 0x5C5 }, |
︙ | ︙ | |||
864 865 866 867 868 869 870 | { "Arabic_dammatan", 0x5EC }, { "Arabic_kasratan", 0x5ED }, { "Arabic_fatha", 0x5EE }, { "Arabic_damma", 0x5EF }, { "Arabic_kasra", 0x5F0 }, { "Arabic_shadda", 0x5F1 }, { "Arabic_sukun", 0x5F2 }, | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 823 824 825 826 827 828 829 830 831 832 833 834 835 836 | { "Arabic_dammatan", 0x5EC }, { "Arabic_kasratan", 0x5ED }, { "Arabic_fatha", 0x5EE }, { "Arabic_damma", 0x5EF }, { "Arabic_kasra", 0x5F0 }, { "Arabic_shadda", 0x5F1 }, { "Arabic_sukun", 0x5F2 }, { "Serbian_dje", 0x6A1 }, { "Macedonia_gje", 0x6A2 }, { "Cyrillic_io", 0x6A3 }, { "Ukrainian_ie", 0x6A4 }, #ifndef TK_NO_DEPRECATED { "Ukranian_je", 0x6A4 }, #endif |
︙ | ︙ | |||
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | { "Cyrillic_CHE", 0x6FE }, { "Cyrillic_HARDSIGN", 0x6FF }, { "Greek_ALPHAaccent", 0x7A1 }, { "Greek_EPSILONaccent", 0x7A2 }, { "Greek_ETAaccent", 0x7A3 }, { "Greek_IOTAaccent", 0x7A4 }, { "Greek_IOTAdieresis", 0x7A5 }, { "Greek_IOTAdiaeresis", 0x7A5 }, { "Greek_IOTAaccentdiaeresis", 0x7A6 }, { "Greek_OMICRONaccent", 0x7A7 }, { "Greek_UPSILONaccent", 0x7A8 }, { "Greek_UPSILONdieresis", 0x7A9 }, { "Greek_UPSILONaccentdieresis", 0x7AA }, { "Greek_OMEGAaccent", 0x7AB }, { "Greek_accentdieresis", 0x7AE }, | > > | 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | { "Cyrillic_CHE", 0x6FE }, { "Cyrillic_HARDSIGN", 0x6FF }, { "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 }, { "Greek_OMEGAaccent", 0x7AB }, { "Greek_accentdieresis", 0x7AE }, |
︙ | ︙ | |||
1121 1122 1123 1124 1125 1126 1127 | { "Greek_finalsmallsigma", 0x7F3 }, { "Greek_tau", 0x7F4 }, { "Greek_upsilon", 0x7F5 }, { "Greek_phi", 0x7F6 }, { "Greek_chi", 0x7F7 }, { "Greek_psi", 0x7F8 }, { "Greek_omega", 0x7F9 }, | < | 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | { "Greek_finalsmallsigma", 0x7F3 }, { "Greek_tau", 0x7F4 }, { "Greek_upsilon", 0x7F5 }, { "Greek_phi", 0x7F6 }, { "Greek_chi", 0x7F7 }, { "Greek_psi", 0x7F8 }, { "Greek_omega", 0x7F9 }, { "leftradical", 0x8A1 }, { "topleftradical", 0x8A2 }, { "horizconnector", 0x8A3 }, { "topintegral", 0x8A4 }, { "botintegral", 0x8A5 }, { "vertconnector", 0x8A6 }, { "topleftsqbracket", 0x8A7 }, |
︙ | ︙ | |||
1359 1360 1361 1362 1363 1364 1365 | #endif { "hebrew_resh", 0xCF8 }, { "hebrew_shin", 0xCF9 }, { "hebrew_taw", 0xCFA }, #ifndef TK_NO_DEPRECATED { "hebrew_taf", 0xCFA }, #endif | < | 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 | #endif { "hebrew_resh", 0xCF8 }, { "hebrew_shin", 0xCF9 }, { "hebrew_taw", 0xCFA }, #ifndef TK_NO_DEPRECATED { "hebrew_taf", 0xCFA }, #endif { "Thai_kokai", 0xDA1 }, { "Thai_khokhai", 0xDA2 }, { "Thai_khokhuat", 0xDA3 }, { "Thai_khokhwai", 0xDA4 }, { "Thai_khokhon", 0xDA5 }, { "Thai_khorakhang", 0xDA6 }, { "Thai_ngongu", 0xDA7 }, |
︙ | ︙ | |||
1444 1445 1446 1447 1448 1449 1450 | { "Thai_leksam", 0xDF3 }, { "Thai_leksi", 0xDF4 }, { "Thai_lekha", 0xDF5 }, { "Thai_lekhok", 0xDF6 }, { "Thai_lekchet", 0xDF7 }, { "Thai_lekpaet", 0xDF8 }, { "Thai_lekkao", 0xDF9 }, | < < < < < < < < < < < < < < < < | 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | { "Thai_leksam", 0xDF3 }, { "Thai_leksi", 0xDF4 }, { "Thai_lekha", 0xDF5 }, { "Thai_lekhok", 0xDF6 }, { "Thai_lekchet", 0xDF7 }, { "Thai_lekpaet", 0xDF8 }, { "Thai_lekkao", 0xDF9 }, { "Hangul_Kiyeog", 0xEA1 }, { "Hangul_SsangKiyeog", 0xEA2 }, { "Hangul_KiyeogSios", 0xEA3 }, { "Hangul_Nieun", 0xEA4 }, { "Hangul_NieunJieuj", 0xEA5 }, { "Hangul_NieunHieuh", 0xEA6 }, { "Hangul_Dikeud", 0xEA7 }, |
︙ | ︙ | |||
1551 1552 1553 1554 1555 1556 1557 | { "Hangul_YeorinHieuh", 0xEF5 }, { "Hangul_AraeA", 0xEF6 }, { "Hangul_AraeAE", 0xEF7 }, { "Hangul_J_PanSios", 0xEF8 }, { "Hangul_J_KkogjiDalrinIeung", 0xEF9 }, { "Hangul_J_YeorinHieuh", 0xEFA }, { "Korean_Won", 0xEFF }, | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 | { "Hangul_YeorinHieuh", 0xEF5 }, { "Hangul_AraeA", 0xEF6 }, { "Hangul_AraeAE", 0xEF7 }, { "Hangul_J_PanSios", 0xEF8 }, { "Hangul_J_KkogjiDalrinIeung", 0xEF9 }, { "Hangul_J_YeorinHieuh", 0xEFA }, { "Korean_Won", 0xEFF }, { "XF86ModeLock", 0x1008FF01 }, { "XF86MonBrightnessUp", 0x1008FF02 }, { "XF86MonBrightnessDown", 0x1008FF03 }, { "XF86KbdLightOnOff", 0x1008FF04 }, { "XF86KbdBrightnessUp", 0x1008FF05 }, { "XF86KbdBrightnessDown", 0x1008FF06 }, { "XF86MonBrightnessCycle", 0x1008FF07 }, |
︙ | ︙ | |||
2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 | { "XF86TouchpadOff", 0x1008FFB1 }, { "XF86AudioMicMute", 0x1008FFB2 }, { "XF86Keyboard", 0x1008FFB3 }, { "XF86WWAN", 0x1008FFB4 }, { "XF86RFKill", 0x1008FFB5 }, { "XF86AudioPreset", 0x1008FFB6 }, { "XF86RotationLockToggle", 0x1008FFB7 }, { "XF86Switch_VT_1", 0x1008FE01 }, { "XF86Switch_VT_2", 0x1008FE02 }, { "XF86Switch_VT_3", 0x1008FE03 }, { "XF86Switch_VT_4", 0x1008FE04 }, { "XF86Switch_VT_5", 0x1008FE05 }, { "XF86Switch_VT_6", 0x1008FE06 }, { "XF86Switch_VT_7", 0x1008FE07 }, { "XF86Switch_VT_8", 0x1008FE08 }, { "XF86Switch_VT_9", 0x1008FE09 }, { "XF86Switch_VT_10", 0x1008FE0A }, { "XF86Switch_VT_11", 0x1008FE0B }, { "XF86Switch_VT_12", 0x1008FE0C }, { "XF86Ungrab", 0x1008FE20 }, { "XF86ClearGrab", 0x1008FE21 }, { "XF86Next_VMode", 0x1008FE22 }, { "XF86Prev_VMode", 0x1008FE23 }, { "XF86LogWindowTree", 0x1008FE24 }, { "XF86LogGrabInfo", 0x1008FE25 }, { "SunFA_Grave", 0x1005FF00 }, { "SunFA_Circum", 0x1005FF01 }, { "SunFA_Tilde", 0x1005FF02 }, { "SunFA_Acute", 0x1005FF03 }, { "SunFA_Diaeresis", 0x1005FF04 }, { "SunFA_Cedilla", 0x1005FF05 }, { "SunF36", 0x1005FF10 }, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 | { "XF86TouchpadOff", 0x1008FFB1 }, { "XF86AudioMicMute", 0x1008FFB2 }, { "XF86Keyboard", 0x1008FFB3 }, { "XF86WWAN", 0x1008FFB4 }, { "XF86RFKill", 0x1008FFB5 }, { "XF86AudioPreset", 0x1008FFB6 }, { "XF86RotationLockToggle", 0x1008FFB7 }, { "XF86FullScreen", 0x1008FFB8 }, { "XF86Switch_VT_1", 0x1008FE01 }, { "XF86Switch_VT_2", 0x1008FE02 }, { "XF86Switch_VT_3", 0x1008FE03 }, { "XF86Switch_VT_4", 0x1008FE04 }, { "XF86Switch_VT_5", 0x1008FE05 }, { "XF86Switch_VT_6", 0x1008FE06 }, { "XF86Switch_VT_7", 0x1008FE07 }, { "XF86Switch_VT_8", 0x1008FE08 }, { "XF86Switch_VT_9", 0x1008FE09 }, { "XF86Switch_VT_10", 0x1008FE0A }, { "XF86Switch_VT_11", 0x1008FE0B }, { "XF86Switch_VT_12", 0x1008FE0C }, { "XF86Ungrab", 0x1008FE20 }, { "XF86ClearGrab", 0x1008FE21 }, { "XF86Next_VMode", 0x1008FE22 }, { "XF86Prev_VMode", 0x1008FE23 }, { "XF86LogWindowTree", 0x1008FE24 }, { "XF86LogGrabInfo", 0x1008FE25 }, { "XF86BrightnessAuto", 0x100810F4 }, { "XF86DisplayOff", 0x100810F5 }, { "XF86Info", 0x10081166 }, { "XF86AspectRatio", 0x10081177 }, { "XF86DVD", 0x10081185 }, { "XF86Audio", 0x10081188 }, { "XF86ChannelUp", 0x10081192 }, { "XF86ChannelDown", 0x10081193 }, { "XF86Break", 0x1008119B }, { "XF86VideoPhone", 0x100811A0 }, { "XF86ZoomReset", 0x100811A4 }, { "XF86Editor", 0x100811A6 }, { "XF86GraphicsEditor", 0x100811A8 }, { "XF86Presentation", 0x100811A9 }, { "XF86Database", 0x100811AA }, { "XF86Voicemail", 0x100811AC }, { "XF86Addressbook", 0x100811AD }, { "XF86DisplayToggle", 0x100811AF }, { "XF86SpellCheck", 0x100811B0 }, { "XF86ContextMenu", 0x100811B6 }, { "XF86MediaRepeat", 0x100811B7 }, { "XF8610ChannelsUp", 0x100811B8 }, { "XF8610ChannelsDown", 0x100811B9 }, { "XF86Images", 0x100811BA }, { "XF86NotificationCenter", 0x100811BC }, { "XF86PickupPhone", 0x100811BD }, { "XF86HangupPhone", 0x100811BE }, { "XF86Fn", 0x100811D0 }, { "XF86Fn_Esc", 0x100811D1 }, { "XF86FnRightShift", 0x100811E5 }, { "XF86Numeric0", 0x10081200 }, { "XF86Numeric1", 0x10081201 }, { "XF86Numeric2", 0x10081202 }, { "XF86Numeric3", 0x10081203 }, { "XF86Numeric4", 0x10081204 }, { "XF86Numeric5", 0x10081205 }, { "XF86Numeric6", 0x10081206 }, { "XF86Numeric7", 0x10081207 }, { "XF86Numeric8", 0x10081208 }, { "XF86Numeric9", 0x10081209 }, { "XF86NumericStar", 0x1008120A }, { "XF86NumericPound", 0x1008120B }, { "XF86NumericA", 0x1008120C }, { "XF86NumericB", 0x1008120D }, { "XF86NumericC", 0x1008120E }, { "XF86NumericD", 0x1008120F }, { "XF86CameraFocus", 0x10081210 }, { "XF86WPSButton", 0x10081211 }, { "XF86CameraZoomIn", 0x10081215 }, { "XF86CameraZoomOut", 0x10081216 }, { "XF86CameraUp", 0x10081217 }, { "XF86CameraDown", 0x10081218 }, { "XF86CameraLeft", 0x10081219 }, { "XF86CameraRight", 0x1008121A }, { "XF86AttendantOn", 0x1008121B }, { "XF86AttendantOff", 0x1008121C }, { "XF86AttendantToggle", 0x1008121D }, { "XF86LightsToggle", 0x1008121E }, { "XF86ALSToggle", 0x10081230 }, { "XF86Buttonconfig", 0x10081240 }, { "XF86Taskmanager", 0x10081241 }, { "XF86Journal", 0x10081242 }, { "XF86ControlPanel", 0x10081243 }, { "XF86AppSelect", 0x10081244 }, { "XF86Screensaver", 0x10081245 }, { "XF86VoiceCommand", 0x10081246 }, { "XF86Assistant", 0x10081247 }, { "XF86EmojiPicker", 0x10081249 }, { "XF86Dictate", 0x1008124A }, { "XF86BrightnessMin", 0x10081250 }, { "XF86BrightnessMax", 0x10081251 }, { "XF86KbdInputAssistPrev", 0x10081260 }, { "XF86KbdInputAssistNext", 0x10081261 }, { "XF86KbdInputAssistPrevgroup", 0x10081262 }, { "XF86KbdInputAssistNextgroup", 0x10081263 }, { "XF86KbdInputAssistAccept", 0x10081264 }, { "XF86KbdInputAssistCancel", 0x10081265 }, { "XF86RightUp", 0x10081266 }, { "XF86RightDown", 0x10081267 }, { "XF86LeftUp", 0x10081268 }, { "XF86LeftDown", 0x10081269 }, { "XF86RootMenu", 0x1008126A }, { "XF86MediaTopMenu", 0x1008126B }, { "XF86Numeric11", 0x1008126C }, { "XF86Numeric12", 0x1008126D }, { "XF86AudioDesc", 0x1008126E }, { "XF863DMode", 0x1008126F }, { "XF86NextFavorite", 0x10081270 }, { "XF86StopRecord", 0x10081271 }, { "XF86PauseRecord", 0x10081272 }, { "XF86VOD", 0x10081273 }, { "XF86Unmute", 0x10081274 }, { "XF86FastReverse", 0x10081275 }, { "XF86SlowReverse", 0x10081276 }, { "XF86Data", 0x10081277 }, { "XF86OnScreenKeyboard", 0x10081278 }, { "XF86PrivacyScreenToggle", 0x10081279 }, { "XF86SelectiveScreenshot", 0x1008127A }, { "XF86Macro1", 0x10081290 }, { "XF86Macro2", 0x10081291 }, { "XF86Macro3", 0x10081292 }, { "XF86Macro4", 0x10081293 }, { "XF86Macro5", 0x10081294 }, { "XF86Macro6", 0x10081295 }, { "XF86Macro7", 0x10081296 }, { "XF86Macro8", 0x10081297 }, { "XF86Macro9", 0x10081298 }, { "XF86Macro10", 0x10081299 }, { "XF86Macro11", 0x1008129A }, { "XF86Macro12", 0x1008129B }, { "XF86Macro13", 0x1008129C }, { "XF86Macro14", 0x1008129D }, { "XF86Macro15", 0x1008129E }, { "XF86Macro16", 0x1008129F }, { "XF86Macro17", 0x100812A0 }, { "XF86Macro18", 0x100812A1 }, { "XF86Macro19", 0x100812A2 }, { "XF86Macro20", 0x100812A3 }, { "XF86Macro21", 0x100812A4 }, { "XF86Macro22", 0x100812A5 }, { "XF86Macro23", 0x100812A6 }, { "XF86Macro24", 0x100812A7 }, { "XF86Macro25", 0x100812A8 }, { "XF86Macro26", 0x100812A9 }, { "XF86Macro27", 0x100812AA }, { "XF86Macro28", 0x100812AB }, { "XF86Macro29", 0x100812AC }, { "XF86Macro30", 0x100812AD }, { "XF86MacroRecordStart", 0x100812B0 }, { "XF86MacroRecordStop", 0x100812B1 }, { "XF86MacroPresetCycle", 0x100812B2 }, { "XF86MacroPreset1", 0x100812B3 }, { "XF86MacroPreset2", 0x100812B4 }, { "XF86MacroPreset3", 0x100812B5 }, { "XF86KbdLcdMenu1", 0x100812B8 }, { "XF86KbdLcdMenu2", 0x100812B9 }, { "XF86KbdLcdMenu3", 0x100812BA }, { "XF86KbdLcdMenu4", 0x100812BB }, { "XF86KbdLcdMenu5", 0x100812BC }, { "SunFA_Grave", 0x1005FF00 }, { "SunFA_Circum", 0x1005FF01 }, { "SunFA_Tilde", 0x1005FF02 }, { "SunFA_Acute", 0x1005FF03 }, { "SunFA_Diaeresis", 0x1005FF04 }, { "SunFA_Cedilla", 0x1005FF05 }, { "SunF36", 0x1005FF10 }, |
︙ | ︙ |
Changes to generic/nanosvg.h.
︙ | ︙ | |||
29 30 31 32 33 34 35 | #ifndef NANOSVG_H #define NANOSVG_H #ifdef __cplusplus extern "C" { #endif | | < > | < > | < > | | < > | | < > | | < > | > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #ifndef NANOSVG_H #define NANOSVG_H #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 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 SVG NSVGimage* image; image = nsvgParseFromFile("test.svg", "px", 96); printf("size: %f x %f\n", image->width, image->height); |
︙ | ︙ | |||
81 82 83 84 85 86 87 | #define NANOSVG_realloc realloc #endif #ifndef NANOSVG_free #define NANOSVG_free free #endif | | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #define NANOSVG_realloc realloc #endif #ifndef NANOSVG_free #define NANOSVG_free free #endif /* 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) #define acosf(a) (float)acos(a) #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 defined(_MSC_VER) && (_MSC_VER == 1400) #define fabsf(a) (float)fabs(a) #endif enum NSVGpaintType { NSVG_PAINT_NONE = 0, NSVG_PAINT_COLOR = 1, |
︙ | ︙ | |||
156 157 158 159 160 161 162 | unsigned int color; NSVGgradient* gradient; }; } NSVGpaint; typedef struct NSVGpath { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < < > | | | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | unsigned int color; NSVGgradient* gradient; }; } 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. */ } 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. */ } 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. */ } NSVGimage; /* 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. */ NANOSVG_SCOPE NSVGimage* nsvgParse(char* input, const char* units, float dpi); /* Deletes list of paths. */ NANOSVG_SCOPE void nsvgDelete(NSVGimage* image); #ifdef __cplusplus } #endif #ifdef NANOSVG_IMPLEMENTATION #include <string.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #define NSVG_PI (3.14159265358979323846264338327f) #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 #define NSVG_ALIGN_MEET 1 #define NSVG_ALIGN_SLICE 2 #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 */ #ifdef __cplusplus #define NSVG_INLINE inline #else #define NSVG_INLINE #endif #if !defined(strtoll) /* old MSVC versions do not have strtoll() */ #define strtoll _strtoi64 #endif #else #define NSVG_INLINE inline #endif |
︙ | ︙ | |||
255 256 257 258 259 260 261 | return c >= '0' && c <= '9'; } 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; } | | | | | | | | | | | | | | | | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | return c >= '0' && c <= '9'; } 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 */ #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 */ while (*s && nsvg__isspace(*s)) s++; if (!*s) return; if (contentCb) (*contentCb)(ud, s); } static void nsvg__parseElement(char* s, void (*startelCb)(void* ud, const char* el, const char** attr), void (*endelCb)(void* ud, const char* el), void* ud) { const char* attr[NSVG_XML_MAX_ATTRIBS]; int nattr = 0; char* cbname; int start = 0; int end = 0; char quote; /* Skip white space after the '<' */ while (*s && nsvg__isspace(*s)) s++; /* Check if the tag is end tag */ if (*s == '/') { s++; end = 1; } else { start = 1; } /* Skip comments, data and preprocessor stuff. */ if (!*s || *s == '?' || *s == '!') return; /* Get tag name */ cbname = s; while (*s && !nsvg__isspace(*s)) s++; if (*s) { *s++ = '\0'; } /* Get attribs */ while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) { char* name = NULL; char* value = NULL; /* 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. */ while (*s && !nsvg__isspace(*s) && *s != '=') s++; if (*s) { *s++ = '\0'; } /* 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. */ value = s; while (*s && *s != quote) s++; if (*s) { *s++ = '\0'; } /* Store only well formed attributes */ if (name && value) { attr[nattr++] = name; attr[nattr++] = value; } } /* List terminator */ attr[nattr++] = 0; attr[nattr++] = 0; /* Call callbacks. */ if (start && startelCb) (*startelCb)(ud, cbname, attr); if (end && endelCb) (*endelCb)(ud, cbname); } NANOSVG_SCOPE int nsvg__parseXML(char* input, void (*startelCb)(void* ud, const char* el, const char** attr), void (*endelCb)(void* ud, const char* el), void (*contentCb)(void* ud, const char* s), void* ud) { char* s = input; char* mark = s; int state = NSVG_XML_CONTENT; while (*s) { if (*s == '<' && state == NSVG_XML_CONTENT) { /* 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. */ *s++ = '\0'; nsvg__parseContent(mark, contentCb, ud); nsvg__parseElement(mark, startelCb, endelCb, ud); mark = s; state = NSVG_XML_CONTENT; } else { s++; |
︙ | ︙ | |||
611 612 613 614 615 616 617 | int i, j, count; double roots[2], a, b, c, b2ac, t, v; float* v0 = &curve[0]; float* v1 = &curve[2]; float* v2 = &curve[4]; float* v3 = &curve[6]; | | | | | | 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | int i, j, count; double roots[2], a, b, c, b2ac, t, v; float* v0 = &curve[0]; float* v1 = &curve[2]; float* v2 = &curve[4]; float* v3 = &curve[6]; /* 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. */ if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds)) return; /* 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; if (fabs(a) < NSVG_EPSILON) { if (fabs(b) > NSVG_EPSILON) { |
︙ | ︙ | |||
664 665 666 667 668 669 670 | if (p == NULL) goto error; memset(p, 0, sizeof(NSVGparser)); p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage)); if (p->image == NULL) goto error; memset(p->image, 0, sizeof(NSVGimage)); | | | 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | if (p == NULL) goto error; memset(p, 0, sizeof(NSVGparser)); p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage)); if (p->image == NULL) goto error; memset(p->image, 0, sizeof(NSVGimage)); /* 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; p->attr[0].fillOpacity = 1; p->attr[0].strokeOpacity = 1; |
︙ | ︙ | |||
850 851 852 853 854 855 856 | case NSVG_UNITS_PX: return c.value; case NSVG_UNITS_PT: return c.value / 72.0f * p->dpi; 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; | | | 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | case NSVG_UNITS_PX: return c.value; case NSVG_UNITS_PT: return c.value / 72.0f * p->dpi; 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_PERCENT: return orig + c.value / 100.0f * length; default: return c.value; } return c.value; } static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id) |
︙ | ︙ | |||
884 885 886 887 888 889 890 | float ox, oy, sw, sh, sl; int nstops = 0; int refIter; data = nsvg__findGradientData(p, id); if (data == NULL) return NULL; | | | | | | | | 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 | 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. */ ref = data; refIter = 0; while (ref != NULL) { NSVGgradientData* nextRef = NULL; if (stops == NULL && ref->stops != NULL) { stops = ref->stops; nstops = ref->nstops; break; } 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. */ if (data->units == NSVG_OBJECT_SPACE) { ox = localBounds[0]; oy = localBounds[1]; sw = localBounds[2] - localBounds[0]; sh = localBounds[3] - localBounds[1]; } else { ox = nsvg__actualOrigX(p); oy = nsvg__actualOrigY(p); sw = nsvg__actualWidth(p); sh = nsvg__actualHeight(p); } sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f); if (data->type == NSVG_PAINT_LINEAR_GRADIENT) { 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 */ 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; } else { float cx, cy, fx, fy, r; 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 */ 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; } |
︙ | ︙ | |||
1026 1027 1028 1029 1030 1031 1032 | shape->miterLimit = attr->miterLimit; shape->fillRule = attr->fillRule; shape->opacity = attr->opacity; shape->paths = p->plist; p->plist = NULL; | | | | | | | 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 | shape->miterLimit = attr->miterLimit; shape->fillRule = attr->fillRule; shape->opacity = attr->opacity; shape->paths = p->plist; p->plist = NULL; /* 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) { shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]); 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 */ 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; shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24; } else if (attr->hasFill == 2) { float inv[6], localBounds[4]; nsvg__xformInverse(inv, attr->xform); nsvg__getLocalBounds(localBounds, shape, inv); shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type); if (shape->fill.gradient == NULL) { shape->fill.type = NSVG_PAINT_NONE; } } /* 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; shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24; } else if (attr->hasStroke == 2) { float inv[6], localBounds[4]; nsvg__xformInverse(inv, attr->xform); nsvg__getLocalBounds(localBounds, shape, inv); 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 */ shape->flags = ((attr->visible & NSVG_VIS_DISPLAY) && (attr->visible & NSVG_VIS_VISIBLE) ? NSVG_FLAGS_VISIBLE : 0x00); /* Add to tail */ if (p->image->shapes == NULL) p->image->shapes = shape; else p->shapesTail->next = shape; p->shapesTail = shape; return; |
︙ | ︙ | |||
1101 1102 1103 1104 1105 1106 1107 | if (p->npts < 4) return; if (closed) nsvg__lineTo(p, p->pts[0], p->pts[1]); | | | | | 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 | 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)); 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. */ 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 */ 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]; path->bounds[1] = bounds[1]; path->bounds[2] = bounds[2]; |
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | error: if (path != NULL) { if (path->pts != NULL) NANOSVG_free(path->pts); NANOSVG_free(path); } } | | | | | | | | | | | | | | | | | | | | < < < < < < | < > | < < > > | < < < < | > > > > > | > > > > > | | > > > > > | > > > > > > > > > | > > > > > > > > > > > > > > > | < > | > > > > > > | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 | error: if (path != NULL) { 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. */ static double nsvg__atof(const char* s) { char* cur = (char*)s; char* end = NULL; double res = 0.0, sign = 1.0; #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 */ if (*cur == '+') { cur++; } else if (*cur == '-') { sign = -1; cur++; } /* Parse integer part */ if (nsvg__isdigit(*cur)) { /* 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) { res = (double)intPart; hasIntPart = 1; cur = end; } } /* Parse fractional part. */ if (*cur == '.') { cur++; /* Skip '.' */ if (nsvg__isdigit(*cur)) { /* 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) { res += (double)fracPart / pow(10.0, (double)(end - cur)); hasFracPart = 1; cur = end; } } } /* A valid number should have integer or fractional part. */ if (!hasIntPart && !hasFracPart) return 0.0; /* Parse optional exponent */ if (*cur == 'e' || *cur == 'E') { int expPart = 0; cur++; /* skip 'E' */ expPart = strtol(cur, &end, 10); /* Parse digit sequence with sign */ if (cur != end) { res *= pow(10.0, (double)expPart); } } return res * sign; } static const char* nsvg__parseNumber(const char* s, char* it, const int size) { const int last = size-1; int i = 0; /* sign */ if (*s == '-' || *s == '+') { if (i < last) it[i++] = *s; s++; } /* integer part */ while (*s && nsvg__isdigit(*s)) { if (i < last) it[i++] = *s; s++; } if (*s == '.') { /* decimal point */ if (i < last) it[i++] = *s; s++; /* fraction part */ while (*s && nsvg__isdigit(*s)) { if (i < last) it[i++] = *s; s++; } } /* exponent */ if (*s == 'e' || *s == 'E') { if (i < last) it[i++] = *s; s++; if (*s == '-' || *s == '+') { if (i < last) it[i++] = *s; s++; } while (*s && nsvg__isdigit(*s)) { if (i < last) it[i++] = *s; s++; } } it[i] = '\0'; return s; } static const char* nsvg__getNextPathItem(const char* s, char* it) { it[0] = '\0'; /* 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 */ it[0] = *s++; it[1] = '\0'; return s; } return s; } static unsigned int nsvg__parseColorHex(const char* str) { unsigned int r=0, g=0, b=0; if (sscanf(str, "#%2x%2x%2x", &r, &g, &b) == 3 ) /* 2 digit hex */ return NSVG_RGB(r, g, b); if (sscanf(str, "#%1x%1x%1x", &r, &g, &b) == 3 ) /* 1 digit hex, e.g. #abc -> 0xccbbaa */ return NSVG_RGB(r*17, g*17, b*17); /* same effect as (r<<4|r), (g<<4|g), .. */ return NSVG_RGB(128, 128, 128); } /* * Parse rgb color. The pointer 'str' must point at "rgb(" (4+ characters). * This function returns gray (rgb(128, 128, 128) == '#808080') on parse errors * for backwards compatibility. Note: other image viewers return black instead. */ static unsigned int nsvg__parseColorRGB(const char* str) { int i; unsigned int rgbi[3]; float rgbf[3]; /* try decimal integers first */ if (sscanf(str, "rgb(%u, %u, %u)", &rgbi[0], &rgbi[1], &rgbi[2]) != 3) { /* integers failed, try percent values (float, locale independent) */ const char delimiter[3] = {',', ',', ')'}; str += 4; /* skip "rgb(" */ for (i = 0; i < 3; i++) { while (*str && (nsvg__isspace(*str))) str++; /* skip leading spaces */ if (*str == '+') str++; /* skip '+' (don't allow '-') */ if (!*str) break; rgbf[i] = nsvg__atof(str); /* * Note 1: it would be great if nsvg__atof() returned how many * bytes it consumed but it doesn't. We need to skip the number, * the '%' character, spaces, and the delimiter ',' or ')'. * * Note 2: The following code does not allow values like "33.%", * i.e. a decimal point w/o fractional part, but this is consistent * with other image viewers, e.g. firefox, chrome, eog, gimp. */ while (*str && nsvg__isdigit(*str)) str++; /* skip integer part */ if (*str == '.') { str++; if (!nsvg__isdigit(*str)) break; /* error: no digit after '.' */ while (*str && nsvg__isdigit(*str)) str++; /* skip fractional part */ } if (*str == '%') str++; else break; while (nsvg__isspace(*str)) str++; if (*str == delimiter[i]) str++; else break; } if (i == 3) { rgbi[0] = roundf(rgbf[0] * 2.55f); rgbi[1] = roundf(rgbf[1] * 2.55f); rgbi[2] = roundf(rgbf[2] * 2.55f); } else { rgbi[0] = rgbi[1] = rgbi[2] = 128; } } /* clip values as the CSS spec requires */ for (i = 0; i < 3; i++) { if (rgbi[i] > 255) rgbi[i] = 255; } return NSVG_RGB(rgbi[0], rgbi[1], rgbi[2]); } typedef struct NSVGNamedColor { const char* name; unsigned int color; } NSVGNamedColor; |
︙ | ︙ | |||
1539 1540 1541 1542 1543 1544 1545 | else if (units[0] == 'e' && units[1] == 'x') return NSVG_UNITS_EX; return NSVG_UNITS_USER; } static int nsvg__isCoordinate(const char* s) { | | | | | 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 | 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]=""; sscanf(str, "%f%s", &coord.value, units); |
︙ | ︙ | |||
1719 1720 1721 1722 1723 1724 1725 | nsvg__xformPremultiply(xform, t); } } static void nsvg__parseUrl(char* id, const char* str) { int i = 0; | | | | | | | | | | | | 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 | nsvg__xformPremultiply(xform, t); } } static void nsvg__parseUrl(char* id, const char* str) { int i = 0; str += 4; /* "url("; */ if (*str && *str == '#') str++; while (i < 63 && *str && *str != ')') { id[i] = *str++; i++; } id[i] = '\0'; } static char nsvg__parseLineCap(const char* str) { if (strcmp(str, "butt") == 0) 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. */ return NSVG_CAP_BUTT; } static char nsvg__parseLineJoin(const char* str) { if (strcmp(str, "miter") == 0) 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. */ 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. */ 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 */ while (*s && (nsvg__isspace(*s) || *s == ',')) s++; /* Advance until whitespace, comma or end. */ while (*s && (!nsvg__isspace(*s) && *s != ',')) { if (n < 63) it[n++] = *s; s++; } it[n++] = '\0'; return s; } static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray) { char item[64]; int count = 0, i; float sum = 0.0f; /* Handle "none" */ if (str[0] == 'n') return 0; /* 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))); } |
︙ | ︙ | |||
1818 1819 1820 1821 1822 1823 1824 | if (!attr) return 0; 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; | | | 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 | if (!attr) return 0; 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 */ } else if (strcmp(name, "visibility") == 0) { if (strcmp(value, "hidden") == 0) { attr->visible &= ~NSVG_VIS_VISIBLE; } else if (strcmp(value, "visible") == 0) { attr->visible |= NSVG_VIS_VISIBLE; } |
︙ | ︙ | |||
1910 1911 1912 1913 1914 1915 1916 | int n; str = start; while (str < end && *str != ':') ++str; val = str; | | | 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 | int n; str = start; while (str < end && *str != ':') ++str; val = str; /* Right Trim */ while (str > start && (*str == ':' || nsvg__isspace(*str))) --str; ++str; n = (int)(str - start); if (n > 511) n = 511; if (n) memcpy(name, start, n); name[n] = 0; |
︙ | ︙ | |||
1935 1936 1937 1938 1939 1940 1941 | static void nsvg__parseStyle(NSVGparser* p, const char* str) { const char* start; const char* end; while (*str) { | | | | 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | static void nsvg__parseStyle(NSVGparser* p, const char* str) { const char* start; const char* end; while (*str) { /* Left Trim */ while(*str && nsvg__isspace(*str)) ++str; start = str; while(*str && *str != ';') ++str; end = str; /* Right Trim */ while (end > start && (*end == ';' || nsvg__isspace(*end))) --end; ++end; nsvg__parseNameValue(p, start, end); if (*str) ++str; } } |
︙ | ︙ | |||
2116 2117 2118 2119 2120 2121 2122 | } else { cx = args[0]; cy = args[1]; x2 = args[2]; y2 = args[3]; } | | | 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 | } else { cx = args[0]; cy = args[1]; x2 = args[2]; y2 = args[3]; } /* 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); nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2); |
︙ | ︙ | |||
2149 2150 2151 2152 2153 2154 2155 | x2 = args[0]; y2 = args[1]; } cx = 2*x1 - *cpx2; cy = 2*y1 - *cpy2; | | | 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 | x2 = args[0]; y2 = args[1]; } cx = 2*x1 - *cpx2; cy = 2*y1 - *cpy2; /* 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); nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2); |
︙ | ︙ | |||
2181 2182 2183 2184 2185 2186 2187 | if (r < -1.0f) r = -1.0f; if (r > 1.0f) r = 1.0f; 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) { | | | | | | | | | | | | | | | | | | | | | | | > > > > > | | | | 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 | if (r < -1.0f) r = -1.0f; if (r > 1.0f) r = 1.0f; 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/) */ 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]; 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 */ y1 = *cpy; if (rel) { /* end point */ x2 = *cpx + args[5]; y2 = *cpy + args[6]; } else { x2 = args[5]; y2 = args[6]; } 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 */ 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' */ 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' */ 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) s = sqrtf(sa / sb); if (fa == fs) s = -s; cxp = s * rx * y1p / ry; cyp = s * -ry * x1p / rx; /* 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. */ 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 */ /* 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. */ 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. */ ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f); hda = (da / (float)ndivs) / 2.0f; /* Fix for ticket #179: division by 0: avoid cotangens around 0 (infinite) */ if ((hda < 1e-3f) && (hda > -1e-3f)) hda *= 0.5f; else hda = (1.0f - cosf(hda)) / sinf(hda); kappa = fabsf(4.0f / 3.0f * hda); if (da < 0.0f) kappa = -kappa; 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 */ if (i > 0) nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y); px = x; py = y; ptanx = tanx; ptany = tany; } |
︙ | ︙ | |||
2340 2341 2342 2343 2344 2345 2346 | 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); | | | | 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 | 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. */ cmd = (cmd == 'm') ? 'l' : 'L'; rargs = nsvg__getArgsPerElement(cmd); cpx2 = cpx; cpy2 = cpy; initPoint = 1; break; case 'l': case 'L': |
︙ | ︙ | |||
2396 2397 2398 2399 2400 2401 2402 | break; } nargs = 0; } } else { cmd = item[0]; if (cmd == 'M' || cmd == 'm') { | | | | | | | | | | | 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 | break; } nargs = 0; } } else { cmd = item[0]; if (cmd == 'M' || cmd == 'm') { /* Commit path. */ if (p->npts > 0) nsvg__addPath(p, closedFlag); /* Start new subpath. */ nsvg__resetPath(p); closedFlag = 0; nargs = 0; } 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. */ if (p->npts > 0) { /* 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. */ 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. */ if (p->npts) nsvg__addPath(p, closedFlag); } nsvg__addShape(p); } static void nsvg__parseRect(NSVGparser* p, const char** attr) { float x = 0.0f; float y = 0.0f; float w = 0.0f; float h = 0.0f; 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])) { if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p)); if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p)); |
︙ | ︙ | |||
2476 2477 2478 2479 2480 2481 2482 | if (rx < 0.00001f || ry < 0.0001f) { 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 { | | | 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 | if (rx < 0.00001f || ry < 0.0001f) { 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 */ 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); nsvg__lineTo(p, x+rx, y+h); nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry); |
︙ | ︙ | |||
2633 2634 2635 2636 2637 2638 2639 | p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); } else if (strcmp(attr[i], "height") == 0) { 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) { | | | | | | 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 | p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f); } else if (strcmp(attr[i], "height") == 0) { 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 */ p->alignType = NSVG_ALIGN_NONE; } else { /* 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 */ 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 */ p->alignType = NSVG_ALIGN_MEET; if (strstr(attr[i + 1], "slice") != 0) p->alignType = NSVG_ALIGN_SLICE; } } } } |
︙ | ︙ | |||
2745 2746 2747 2748 2749 2750 2751 | curAttr->stopColor = 0; curAttr->stopOpacity = 1.0f; for (i = 0; attr[i]; i += 2) { nsvg__parseAttr(p, attr[i], attr[i + 1]); } | | | | 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 | curAttr->stopColor = 0; curAttr->stopOpacity = 1.0f; for (i = 0; attr[i]; i += 2) { nsvg__parseAttr(p, attr[i], attr[i + 1]); } /* 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 */ idx = grad->nstops-1; for (i = 0; i < grad->nstops-1; i++) { if (curAttr->stopOffset < grad->stops[i].offset) { idx = i; break; } } |
︙ | ︙ | |||
2777 2778 2779 2780 2781 2782 2783 | } static void nsvg__startElement(void* ud, const char* el, const char** attr) { NSVGparser* p = (NSVGparser*)ud; if (p->defsFlag) { | | | | 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 | } 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 */ 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) { nsvg__parseGradientStop(p, attr); } return; } 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. */ return; nsvg__pushAttr(p); nsvg__parsePath(p, attr); nsvg__popAttr(p); } else if (strcmp(el, "rect") == 0) { nsvg__pushAttr(p); nsvg__parseRect(p, attr); |
︙ | ︙ | |||
2945 2946 2947 2948 2949 2950 2951 | static float nsvg__viewAlign(float content, float container, int type) { if (type == NSVG_ALIGN_MIN) return 0; else if (type == NSVG_ALIGN_MAX) return container - content; | | | 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 | static float nsvg__viewAlign(float content, float container, int type) { if (type == NSVG_ALIGN_MIN) return 0; else if (type == NSVG_ALIGN_MAX) return container - content; /* mid */ return (container - content) * 0.5f; } static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy) { float t[6]; nsvg__xformSetTranslation(t, tx, ty); |
︙ | ︙ | |||
2967 2968 2969 2970 2971 2972 2973 | { NSVGshape* shape; NSVGpath* path; float tx, ty, sx, sy, us, bounds[4], t[6], avgs; int i; float* pt; | | | 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 | { NSVGshape* shape; NSVGpath* path; float tx, ty, sx, sy, us, bounds[4], t[6], avgs; int i; float* pt; /* 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; } else { p->viewMinx = bounds[0]; |
︙ | ︙ | |||
2995 2996 2997 2998 2999 3000 3001 | if (p->image->height == 0) p->image->height = p->viewHeight; 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; | | | | | | | 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 | if (p->image->height == 0) p->image->height = p->viewHeight; 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 */ us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f); /* Fix aspect ratio */ if (p->alignType == NSVG_ALIGN_MEET) { /* 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 */ 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 */ 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; shape->bounds[1] = (shape->bounds[1] + ty) * sy; shape->bounds[2] = (shape->bounds[2] + tx) * sx; |
︙ | ︙ | |||
3064 3065 3066 3067 3068 3069 3070 | if (p == NULL) { return NULL; } p->dpi = dpi; nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p); | | | 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 | if (p == NULL) { return NULL; } p->dpi = dpi; nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p); /* Scale to viewBox */ nsvg__scaleToViewbox(p, units); ret = p->image; p->image = NULL; nsvg__deleteParser(p); |
︙ | ︙ | |||
3091 3092 3093 3094 3095 3096 3097 | if (!fp) goto error; fseek(fp, 0, SEEK_END); 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; | | | 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 | if (!fp) goto error; fseek(fp, 0, SEEK_END); 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. */ fclose(fp); image = nsvgParse(data, units, dpi); NANOSVG_free(data); return image; error: |
︙ | ︙ | |||
3123 3124 3125 3126 3127 3128 3129 | NANOSVG_free(shape); shape = snext; } NANOSVG_free(image); } #endif | > > | 3163 3164 3165 3166 3167 3168 3169 3170 3171 | NANOSVG_free(shape); shape = snext; } NANOSVG_free(image); } #endif #endif /* NANOSVG_H */ |
Changes to generic/nanosvgrast.h.
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * by Sean Barrett - http://nothings.org/ * */ #ifndef NANOSVGRAST_H #define NANOSVGRAST_H #ifdef __cplusplus extern "C" { #endif #ifndef NANOSVG_SCOPE #define NANOSVG_SCOPE #endif | > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | * by Sean Barrett - http://nothings.org/ * */ #ifndef NANOSVGRAST_H #define NANOSVGRAST_H #include "nanosvg.h" #ifdef __cplusplus extern "C" { #endif #ifndef NANOSVG_SCOPE #define NANOSVG_SCOPE #endif |
︙ | ︙ | |||
55 56 57 58 59 60 61 | struct NSVGrasterizer* rast = nsvgCreateRasterizer(); // Allocate memory for image unsigned char* img = malloc(w*h*4); // Rasterize nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4); */ | | | | | | | | | | | > | < < > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | struct NSVGrasterizer* rast = nsvgCreateRasterizer(); // Allocate memory for image unsigned char* img = malloc(w*h*4); // Rasterize nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4); */ /* 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 NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r, NSVGimage* image, float tx, float ty, float scale, unsigned char* dst, int w, int h, int stride); */ /* Deletes rasterizer context. */ NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*); #ifdef __cplusplus } #endif #ifdef NANOSVGRAST_IMPLEMENTATION #include <math.h> #include <stdlib.h> #include <string.h> #define NSVG__SUBSAMPLES 5 #define NSVG__FIXSHIFT 10 #define NSVG__FIX (1 << NSVG__FIXSHIFT) #define NSVG__FIXMASK (NSVG__FIX-1) #define NSVG__MEMPAGE_SIZE 1024 |
︙ | ︙ | |||
198 199 200 201 202 203 204 | NANOSVG_free(r); } static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur) { NSVGmemPage *newp; | | | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | NANOSVG_free(r); } static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur) { NSVGmemPage *newp; /* If using existing chain, return the next page in chain */ if (cur != NULL && cur->next != NULL) { return cur->next; } /* Alloc new page */ newp = (NSVGmemPage*)NANOSVG_malloc(sizeof(NSVGmemPage)); if (newp == NULL) return NULL; memset(newp, 0, sizeof(NSVGmemPage)); /* Add to linked list */ if (cur != NULL) cur->next = newp; else r->pages = newp; return newp; } |
︙ | ︙ | |||
298 299 300 301 302 303 304 | r->npoints2 = r->npoints; } static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1) { NSVGedge* e; | | | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | r->npoints2 = r->npoints; } static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1) { NSVGedge* e; /* Skip horizontal edges */ if (y0 == y1) return; if (r->nedges+1 > r->cedges) { r->cedges = r->cedges > 0 ? r->cedges * 2 : 64; r->edges = (NSVGedge*)NANOSVG_realloc(r->edges, sizeof(NSVGedge) * r->cedges); if (r->edges == NULL) return; |
︙ | ︙ | |||
384 385 386 387 388 389 390 | static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale) { int i, j; NSVGpath* path; for (path = shape->paths; path != NULL; path = path->next) { r->npoints = 0; | | | | | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale) { int i, j; NSVGpath* path; for (path = shape->paths; path != NULL; path = path->next) { r->npoints = 0; /* 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 */ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0); /* 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); } } enum NSVGpointFlags { |
︙ | ︙ | |||
615 616 617 618 619 620 621 | int divs = (int)ceilf(arc / da); if (divs < 2) divs = 2; return divs; } static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth) { | | | | | | | 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 | int divs = (int)ceilf(arc / da); if (divs < 2) divs = 2; 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. */ 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 */ if (closed) { /* Looping */ p0 = &points[npoints-1]; p1 = &points[0]; s = 0; e = npoints; } else { /* Add cap */ p0 = &points[0]; p1 = &points[1]; s = 1; e = npoints-1; } if (closed) { nsvg__initClosed(&left, &right, p0, p1, lineWidth); firstLeft = left; firstRight = right; } else { /* 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); else if (lineCap == NSVG_CAP_SQUARE) nsvg__squareCap(r, &left, &right, p0, dx, dy, lineWidth, 0); |
︙ | ︙ | |||
667 668 669 670 671 672 673 | } else { nsvg__straightJoin(r, &left, &right, p1, lineWidth); } p0 = p1++; } if (closed) { | | | | | | | | | | | 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 | } else { nsvg__straightJoin(r, &left, &right, p1, lineWidth); } p0 = p1++; } if (closed) { /* 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 */ 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); else if (lineCap == NSVG_CAP_SQUARE) nsvg__squareCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1); else if (lineCap == NSVG_CAP_ROUND) nsvg__roundCap(r, &right, &left, p1, -dx, -dy, lineWidth, ncap, 1); } } static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoin) { int i, j; 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 */ p0->dx = p1->x - p0->x; p0->dy = p1->y - p0->y; p0->len = nsvg__normalize(&p0->dx, &p0->dy); /* Advance */ p0 = p1++; } /* 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 */ 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; if (s2 > 600.0f) { s2 = 600.0f; } p1->dmx *= s2; p1->dmy *= s2; } /* Clear flags, but keep the corner. */ p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0; /* 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. */ 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; } } p0 = p1++; |
︙ | ︙ | |||
752 753 754 755 756 757 758 | NSVGpoint* p0, *p1; float miterLimit = shape->miterLimit; int lineJoin = shape->strokeLineJoin; int lineCap = shape->strokeLineCap; float lineWidth = shape->strokeWidth * scale; for (path = shape->paths; path != NULL; path = path->next) { | | | | | | | | | | | | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 | NSVGpoint* p0, *p1; float miterLimit = shape->miterLimit; int lineJoin = shape->strokeLineJoin; int lineCap = shape->strokeLineCap; float lineWidth = shape->strokeWidth * scale; for (path = shape->paths; path != NULL; path = path->next) { /* 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); } if (r->npoints < 2) continue; closed = path->closed; /* 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]; closed = 1; } if (shape->strokeDashCount > 0) { int idash = 0, dashState = 1; float totalDist = 0, dashLen, allDashLen, dashOffset; NSVGpoint cur; if (closed) nsvg__appendPathPoint(r, r->points[0]); /* Duplicate points -> points2. */ nsvg__duplicatePoints(r); r->npoints = 0; cur = r->points2[0]; nsvg__appendPathPoint(r, cur); /* 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 */ dashOffset = fmodf(shape->strokeDashOffset, allDashLen); if (dashOffset < 0.0f) dashOffset += allDashLen; while (dashOffset > shape->strokeDashArray[idash]) { dashOffset -= shape->strokeDashArray[idash]; idash = (idash + 1) % shape->strokeDashCount; } dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale; for (j = 1; j < r->npoints2; ) { 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 */ 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 */ if (r->npoints > 1 && dashState) { nsvg__prepareStroke(r, miterLimit, lineJoin); nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth); } /* Advance dash pattern */ dashState = !dashState; idash = (idash+1) % shape->strokeDashCount; dashLen = shape->strokeDashArray[idash] * scale; /* Restart */ cur.x = x; cur.y = y; cur.flags = NSVG_PT_CORNER; totalDist = 0.0f; r->npoints = 0; nsvg__appendPathPoint(r, cur); } else { totalDist += dist; cur = r->points2[j]; nsvg__appendPathPoint(r, cur); j++; } } /* 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); } } |
︙ | ︙ | |||
867 868 869 870 871 872 873 | static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float startPoint) { NSVGactiveEdge* z; float dxdy; if (r->freelist != NULL) { | | | | | | | 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float startPoint) { NSVGactiveEdge* z; float dxdy; if (r->freelist != NULL) { /* Restore from freelist. */ z = r->freelist; r->freelist = z->next; } else { /* 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 */ 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->ey = e->y1; z->next = 0; z->dir = e->dir; return z; } |
︙ | ︙ | |||
906 907 908 909 910 911 912 | { int i = x0 >> NSVG__FIXSHIFT; int j = x1 >> NSVG__FIXSHIFT; if (i < *xmin) *xmin = i; if (j > *xmax) *xmax = j; if (i < len && j >= 0) { if (i == j) { | | | | | | | | | | > | | | | | | | | 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 | { int i = x0 >> NSVG__FIXSHIFT; 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 */ scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT)); } else { 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 */ if (j < len) /* add antialiasing for x1 */ scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT)); else j = len; /* clip */ 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 */ static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule) { /* non-zero winding fill */ int x0 = 0, w = 0; if (fillRule == NSVG_FILLRULE_NONZERO) { /* Non-zero */ while (e != NULL) { if (w == 0) { /* 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 (w == 0) nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax); } e = e->next; } } else if (fillRule == NSVG_FILLRULE_EVENODD) { /* Even-odd */ while (e != NULL) { if (w == 0) { /* 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); } e = e->next; } } } static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); } static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { return ((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16) | ((unsigned int)a << 24); } static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u) { int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f); int r = (((c0) & 0xff)*(256-iu) + (((c1) & 0xff)*iu)) >> 8; int g = (((c0>>8) & 0xff)*(256-iu) + (((c1>>8) & 0xff)*iu)) >> 8; |
︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 | cb = (cache->colors[0] >> 16) & 0xff; ca = (cache->colors[0] >> 24) & 0xff; for (i = 0; i < count; i++) { int r,g,b; int a = nsvg__div255((int)cover[0] * ca); int ia = 255 - a; | | | | | | 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | cb = (cache->colors[0] >> 16) & 0xff; ca = (cache->colors[0] >> 24) & 0xff; for (i = 0; i < count; i++) { int r,g,b; int a = nsvg__div255((int)cover[0] * ca); int ia = 255 - a; /* Premultiply */ r = nsvg__div255(cr * a); g = nsvg__div255(cg * a); b = nsvg__div255(cb * a); /* 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]); dst[0] = (unsigned char)r; dst[1] = (unsigned char)g; dst[2] = (unsigned char)b; dst[3] = (unsigned char)a; cover++; dst += 4; } } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) { /* 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; fx = ((float)x - tx) / scale; fy = ((float)y - ty) / scale; |
︙ | ︙ | |||
1052 1053 1054 1055 1056 1057 1058 | cg = (c >> 8) & 0xff; cb = (c >> 16) & 0xff; ca = (c >> 24) & 0xff; a = nsvg__div255((int)cover[0] * ca); ia = 255 - a; | | | | | | | 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 | cg = (c >> 8) & 0xff; cb = (c >> 16) & 0xff; ca = (c >> 24) & 0xff; a = nsvg__div255((int)cover[0] * ca); ia = 255 - a; /* Premultiply */ r = nsvg__div255(cr * a); g = nsvg__div255(cg * a); b = nsvg__div255(cb * a); /* 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]); dst[0] = (unsigned char)r; dst[1] = (unsigned char)g; dst[2] = (unsigned char)b; dst[3] = (unsigned char)a; 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) */ float fx, fy, dx, gx, gy, gd; float* t = cache->xform; int i, cr, cg, cb, ca; unsigned int c; fx = ((float)x - tx) / scale; fy = ((float)y - ty) / scale; |
︙ | ︙ | |||
1099 1100 1101 1102 1103 1104 1105 | cg = (c >> 8) & 0xff; cb = (c >> 16) & 0xff; ca = (c >> 24) & 0xff; a = nsvg__div255((int)cover[0] * ca); ia = 255 - a; | | | | 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | cg = (c >> 8) & 0xff; cb = (c >> 16) & 0xff; ca = (c >> 24) & 0xff; a = nsvg__div255((int)cover[0] * ca); ia = 255 - a; /* Premultiply */ r = nsvg__div255(cr * a); g = nsvg__div255(cg * a); b = nsvg__div255(cb * a); /* 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]); dst[0] = (unsigned char)r; dst[1] = (unsigned char)g; |
︙ | ︙ | |||
1127 1128 1129 1130 1131 1132 1133 | } 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; | | | | | | | | | | | | | | | | | | | | 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 | } 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 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 */ 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 */ while (*step) { NSVGactiveEdge *z = *step; if (z->ey <= scany) { *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 */ } } /* resort the list if needed */ for (;;) { int changed = 0; step = &active; while (*step && (*step)->next) { if ((*step)->x > (*step)->next->x) { NSVGactiveEdge* t = *step; NSVGactiveEdge* q = t->next; t->next = q->next; q->next = t; *step = q; changed = 1; } 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 */ 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 */ if (active == NULL) { active = z; } else if (z->x < active->x) { /* insert at front */ z->next = active; active = z; } else { /* 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 */ z->next = p->next; p->next = z; } } e++; } /* now process all active edges in non-zero fashion */ if (active != NULL) nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule); } /* 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); } } } static void nsvg__unpremultiplyAlpha(unsigned char* image, int w, int h, int stride) { int x,y; /* 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) { row[0] = (unsigned char)(r*255/a); row[1] = (unsigned char)(g*255/a); row[2] = (unsigned char)(b*255/a); } row += 4; } } /* 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) { if (x-1 > 0 && row[-1] != 0) { r += row[-4]; |
︙ | ︙ | |||
1407 1408 1409 1410 1411 1412 1413 | if (shape->fill.type != NSVG_PAINT_NONE) { nsvg__resetPool(r); r->freelist = NULL; r->nedges = 0; nsvg__flattenShape(r, shape, scale); | | | > | | | | | > | | > > | 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 | if (shape->fill.type != NSVG_PAINT_NONE) { nsvg__resetPool(r); r->freelist = NULL; r->nedges = 0; nsvg__flattenShape(r, shape, scale); /* 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 */ if (r->nedges != 0) qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); /* 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) { nsvg__resetPool(r); r->freelist = NULL; r->nedges = 0; nsvg__flattenShapeStroke(r, shape, scale); /* dumpEdges(r, "edge.svg"); */ /* 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 */ if (r->nedges != 0) qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge); /* 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); } } nsvg__unpremultiplyAlpha(dst, w, h, stride); r->bitmap = NULL; r->width = 0; r->height = 0; r->stride = 0; } #endif #endif /* NANOSVGRAST_H */ |
Changes to generic/tk.decls.
1 2 3 4 5 6 7 | # tk.decls -- # # 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. # | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # tk.decls -- # # 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 © 1998-2000 Ajuba Solutions. # Copyright © 2007 Daniel A. Steffen <[email protected]> # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. library tk # Define the tk interface with 3 sub interfaces: |
︙ | ︙ | |||
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | declare 278 { void Tk_SendVirtualEvent(Tk_Window tkwin, const char *eventName, Tcl_Obj *detail) } declare 279 { Tcl_Obj *Tk_FontGetDescription(Tk_Font tkfont) } # Define the platform specific public Tk interface. These functions are # only available on the designated platform. interface tkPlat ################################ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 | 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) } # TIP#606 declare 281 { void Tk_DrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable) } declare 282 { void Tk_SetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName) } declare 283 { void Tk_SetWindowMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName) } declare 284 { void Tk_ClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height) } declare 285 { Tcl_Obj *Tk_GetSystemDefault(Tk_Window tkwin, const char *dbName, const char *className) } declare 286 { int Tk_UseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string) } declare 287 { void Tk_MakeContainer(Tk_Window tkwin) } declare 288 { Tk_Window Tk_GetOtherWindow(Tk_Window tkwin) } declare 289 { void Tk_Get3DBorderColors(Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr, XColor *lightColorPtr) } declare 290 { Window Tk_MakeWindow(Tk_Window tkwin, Window parent) } # Define the platform specific public Tk interface. These functions are # only available on the designated platform. interface tkPlat ################################ |
︙ | ︙ |
Changes to generic/tk.h.
︙ | ︙ | |||
64 65 66 67 68 69 70 | * You may also need to update some of these files when the numbers change for * the version of Tcl that this release of Tk is compiled against. */ #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 7 #define TK_RELEASE_LEVEL TCL_ALPHA_RELEASE | | | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | * You may also need to update some of these files when the numbers change for * the version of Tcl that this release of Tk is compiled against. */ #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 7 #define TK_RELEASE_LEVEL TCL_ALPHA_RELEASE #define TK_RELEASE_SERIAL 6 #define TK_VERSION "8.7" #define TK_PATCH_LEVEL "8.7a6" /* * A special definition used to allow this header file to be included from * windows or mac resource files so that they can obtain version information. * RC_INVOKED is defined by default by the windows RC tool and manually set * for macintosh. * |
︙ | ︙ | |||
90 91 92 93 94 95 96 | # pragma GCC diagnostic ignored "-Wc++-compat" #endif # include <X11/Xlib.h> # ifdef MAC_OSX_TK # include <X11/X.h> # endif #endif | < < | < | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | # pragma GCC diagnostic ignored "-Wc++-compat" #endif # include <X11/Xlib.h> # ifdef MAC_OSX_TK # include <X11/X.h> # endif #endif #include <stddef.h> #ifdef BUILD_tk #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT #else # ifndef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLIMPORT |
︙ | ︙ | |||
167 168 169 170 171 172 173 | TK_OPTION_JUSTIFY, TK_OPTION_ANCHOR, TK_OPTION_SYNONYM, TK_OPTION_PIXELS, TK_OPTION_WINDOW, TK_OPTION_END, TK_OPTION_CUSTOM, | | > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | TK_OPTION_JUSTIFY, TK_OPTION_ANCHOR, TK_OPTION_SYNONYM, TK_OPTION_PIXELS, TK_OPTION_WINDOW, TK_OPTION_END, TK_OPTION_CUSTOM, TK_OPTION_STYLE, TK_OPTION_INDEX } Tk_OptionType; /* * Structures of the following type are used by widgets to specify their * configuration options. Typically each widget has a static array of these * structures, where each element of the array describes a single * configuration option. The array is passed to Tk_CreateOptionTable. |
︙ | ︙ | |||
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | #define TK_NOTIFY_SHARE 20 /* * Enumerated type for describing a point by which to anchor something: */ typedef enum { TK_ANCHOR_N, TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE, TK_ANCHOR_S, TK_ANCHOR_SW, TK_ANCHOR_W, TK_ANCHOR_NW, TK_ANCHOR_CENTER } Tk_Anchor; /* * Enumerated type for describing a style of justification: */ typedef enum { TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER } Tk_Justify; /* * The following structure is used by Tk_GetFontMetrics() to return * information about the properties of a Tk_Font. */ | > > | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | #define TK_NOTIFY_SHARE 20 /* * Enumerated type for describing a point by which to anchor something: */ typedef enum { TK_ANCHOR_NULL = -1, TK_ANCHOR_N, TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE, TK_ANCHOR_S, TK_ANCHOR_SW, TK_ANCHOR_W, TK_ANCHOR_NW, TK_ANCHOR_CENTER } Tk_Anchor; /* * Enumerated type for describing a style of justification: */ typedef enum { TK_JUSTIFY_NULL = -1, TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER } Tk_Justify; /* * The following structure is used by Tk_GetFontMetrics() to return * information about the properties of a Tk_Font. */ |
︙ | ︙ | |||
833 834 835 836 837 838 839 | unsigned long dummy7; /* dirtyAtts */ unsigned int flags; char *dummy8; /* handlerList */ #if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8) XIC dummy9; /* inputContext */ #endif /* TK_USE_INPUT_METHODS */ ClientData *dummy10; /* tagPtr */ | > | | > > > > | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | unsigned long dummy7; /* dirtyAtts */ unsigned int flags; char *dummy8; /* handlerList */ #if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8) XIC dummy9; /* inputContext */ #endif /* TK_USE_INPUT_METHODS */ ClientData *dummy10; /* tagPtr */ #if TCL_MAJOR_VERSION > 8 size_t dummy11; /* numTags */ size_t dummy12; /* optionLevel */ #else int dummy11; int dummy12; #endif char *dummy13; /* selHandlerList */ char *dummy14; /* geomMgrPtr */ ClientData dummy15; /* geomData */ int reqWidth, reqHeight; int internalBorderLeft; char *dummy16; /* wmInfoPtr */ char *dummy17; /* classProcPtr */ |
︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 | Tk_Item *itemPtr, int argc, char **argv); typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int beforeThis, char *string); typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, char *indexString, int *indexPtr); #else typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas, | | | | | 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | Tk_Item *itemPtr, int argc, char **argv); typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, int beforeThis, char *string); typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, char *indexString, int *indexPtr); #else typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[], int flags); typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); #if TCL_MAJOR_VERSION > 8 typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, size_t beforeThis, Tcl_Obj *string); typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Obj *indexString, size_t *indexPtr); #else typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr, |
︙ | ︙ | |||
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 | Tcl_Obj *format, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY); typedef int (Tk_ImageFileWriteProc) (Tcl_Interp *interp, const char *fileName, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); #endif /* USE_OLD_IMAGE */ /* * The following structure represents a particular file format for storing * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image * files of that format to be recognized and read into a photo image. */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 | Tcl_Obj *format, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY); typedef int (Tk_ImageFileWriteProc) (Tcl_Interp *interp, const char *fileName, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr); #endif /* USE_OLD_IMAGE */ /* * The following alternate definitions are used with the Tk8.7 file format * supporting a metadata dict, internal dstring and close file flag */ typedef struct Tk_PhotoImageFormatVersion3 Tk_PhotoImageFormatVersion3; typedef int (Tk_ImageFileMatchProcVersion3) (Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn, int *widthPtr, int *heightPtr, Tcl_Obj *metadataOut); typedef int (Tk_ImageStringMatchProcVersion3) (Tcl_Interp *interp, Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataIn, int *widthPtr, int *heightPtr, Tcl_Obj *metadataOut); typedef int (Tk_ImageFileReadProcVersion3) (Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY, Tcl_Obj *metadataOut); typedef int (Tk_ImageStringReadProcVersion3) (Tcl_Interp *interp, Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataIn, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY, Tcl_Obj *metadataOut); typedef int (Tk_ImageFileWriteProcVersion3) (Tcl_Interp *interp, const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn, Tk_PhotoImageBlock *blockPtr); typedef int (Tk_ImageStringWriteProcVersion3) (Tcl_Interp *interp, Tcl_Obj *format, Tcl_Obj *metadataIn, Tk_PhotoImageBlock *blockPtr); /* * The following structure represents a particular file format for storing * images (e.g., PPM, GIF, JPEG, etc.). It provides information to allow image * files of that format to be recognized and read into a photo image. */ |
︙ | ︙ | |||
1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 | * representation of the data in a photo * image.*/ struct Tk_PhotoImageFormat *nextPtr; /* Next in list of all photo image formats * currently known. Filled in by Tk, not by * image format handler. */ }; /* *---------------------------------------------------------------------- * * Procedure prototypes and structures used for managing styles: * *---------------------------------------------------------------------- | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 | * representation of the data in a photo * image.*/ struct Tk_PhotoImageFormat *nextPtr; /* Next in list of all photo image formats * currently known. Filled in by Tk, not by * image format handler. */ }; /* * The following structure is the same plus added support for the metadata * structure. */ struct Tk_PhotoImageFormatVersion3 { const char *name; /* Name of image file format */ Tk_ImageFileMatchProcVersion3 *fileMatchProc; /* Procedure to call to determine whether an * image file matches this format. */ Tk_ImageStringMatchProcVersion3 *stringMatchProc; /* Procedure to call to determine whether the * data in a string matches this format. */ Tk_ImageFileReadProcVersion3 *fileReadProc; /* Procedure to call to read data from an * image file into a photo image. */ Tk_ImageStringReadProcVersion3 *stringReadProc; /* Procedure to call to read data from a * string into a photo image. */ Tk_ImageFileWriteProcVersion3 *fileWriteProc; /* Procedure to call to write data from a * photo image to a file. */ Tk_ImageStringWriteProcVersion3 *stringWriteProc; /* Procedure to call to obtain a string * representation of the data in a photo * image.*/ struct Tk_PhotoImageFormatVersion3 *nextPtr; /* Next in list of all photo image formats * currently known. Filled in by Tk, not by * image format handler. */ }; /* *---------------------------------------------------------------------- * * Procedure prototypes and structures used for managing styles: * *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to generic/tk3d.c.
1 2 3 4 5 6 | /* * tk3d.c -- * * This module provides procedures to draw borders in the * three-dimensional Motif style. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * tk3d.c -- * * This module provides procedures to draw borders in the * three-dimensional Motif style. * * 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 "tk3d.h" /* * The following table defines the string values for reliefs, which are used * by Tk_GetReliefFromObj. */ const char *const tkReliefStrings[] = { "flat", "groove", "raised", "ridge", "solid", "sunken", NULL }; /* * Forward declarations for functions defined in this file: */ |
︙ | ︙ | |||
619 620 621 622 623 624 625 | int Tk_GetReliefFromObj( Tcl_Interp *interp, /* Used for error reporting. */ Tcl_Obj *objPtr, /* The object we are trying to get the value * from. */ int *resultPtr) /* Where to place the answer. */ { | | | 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | int Tk_GetReliefFromObj( Tcl_Interp *interp, /* Used for error reporting. */ Tcl_Obj *objPtr, /* The object we are trying to get the value * from. */ int *resultPtr) /* Where to place the answer. */ { return Tcl_GetIndexFromObjStruct(interp, objPtr, tkReliefStrings, sizeof(char *), "relief", 0, resultPtr); } /* *---------------------------------------------------------------------- * * Tk_GetRelief -- |
︙ | ︙ | |||
1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 | Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(borderPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } return resultPtr; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 | Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(borderPtr->objRefCount)); Tcl_ListObjAppendElement(NULL, resultPtr, objPtr); } } return resultPtr; } /* *-------------------------------------------------------------- * * Tk_Get3BorderColors -- * * Given a Tk_3DBorder determine its 3 colors. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */ void Tk_Get3DBorderColors( Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr, XColor *lightColorPtr) { if (bgColorPtr) { *bgColorPtr = *((TkBorder *)border)->bgColorPtr; } if (darkColorPtr) { *darkColorPtr = *((TkBorder *) border)->darkColorPtr; } if (lightColorPtr) { *lightColorPtr = *((TkBorder *) border)->lightColorPtr; } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tk3d.h.
1 2 3 4 5 | /* * tk3d.h -- * * Declarations of types and functions shared by the 3d border module. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tk3d.h -- * * Declarations of types and functions shared by the 3d border module. * * 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. */ #ifndef _TK3D #define _TK3D |
︙ | ︙ |
Changes to generic/tkArgv.c.
1 2 3 4 5 6 | /* * tkArgv.c -- * * This file contains a function that handles table-based argv-argc * parsing. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkArgv.c -- * * This file contains a function that handles table-based argv-argc * parsing. * * 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" |
︙ | ︙ |
Changes to generic/tkArray.h.
1 2 3 4 5 6 7 | /* * tkArray.h -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkArray.h -- * * 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 © 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. */ /* * Note that this file will not be included in header files, it is the purpose |
︙ | ︙ |
Changes to generic/tkAtom.c.
1 2 3 4 5 6 7 8 | /* * tkAtom.c -- * * 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). * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkAtom.c -- * * 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 © 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. */ #include "tkInt.h" |
︙ | ︙ |
Changes to generic/tkBind.c.
1 2 3 4 5 6 | /* * tkBind.c -- * * This file provides functions that associate Tcl commands with X events * or sequences of X events. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkBind.c -- * * This file provides functions that associate Tcl commands with X events * or sequences of X events. * * 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. */ #include "tkInt.h" #include "tkDList.h" |
︙ | ︙ | |||
328 329 330 331 332 333 334 | * Compute memory size of struct PatSeq with given pattern size. * The caller must be sure that pattern size is greater than zero. */ #define PATSEQ_MEMSIZE(numPats) (sizeof(PatSeq) + (numPats - 1)*sizeof(TkPattern)) /* * Constants that define how close together two events must be in milliseconds | | | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | * Compute memory size of struct PatSeq with given pattern size. * The caller must be sure that pattern size is greater than zero. */ #define PATSEQ_MEMSIZE(numPats) (sizeof(PatSeq) + (numPats - 1)*sizeof(TkPattern)) /* * Constants that define how close together two events must be in milliseconds * or pixels to be considered close in space or time. */ #define NEARBY_PIXELS 5 #define NEARBY_MS 500 /* * The following structure is used in the nameTable of a virtual event table |
︙ | ︙ | |||
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | #define MULT_CLICKS (DOUBLE|TRIPLE|QUADRUPLE) static const ModInfo modArray[] = { {"Control", ControlMask, 0}, {"Shift", ShiftMask, 0}, {"Lock", LockMask, 0}, {"Meta", META_MASK, 0}, {"M", META_MASK, 0}, {"Alt", ALT_MASK, 0}, {"Extended", EXTENDED_MASK, 0}, {"B1", Button1Mask, 0}, {"Button1", Button1Mask, 0}, {"B2", Button2Mask, 0}, {"Button2", Button2Mask, 0}, {"B3", Button3Mask, 0}, | > > | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | #define MULT_CLICKS (DOUBLE|TRIPLE|QUADRUPLE) 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}, {"Button2", Button2Mask, 0}, {"B3", Button3Mask, 0}, |
︙ | ︙ | |||
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | {"Button7", Button7Mask, 0}, {"B8", Button8Mask, 0}, {"Button8", Button8Mask, 0}, {"B9", Button9Mask, 0}, {"Button9", Button9Mask, 0}, {"Mod1", Mod1Mask, 0}, {"M1", Mod1Mask, 0}, {"Command", Mod1Mask, 0}, {"Mod2", Mod2Mask, 0}, {"M2", Mod2Mask, 0}, {"Option", Mod2Mask, 0}, {"Mod3", Mod3Mask, 0}, {"M3", Mod3Mask, 0}, {"Mod4", Mod4Mask, 0}, {"M4", Mod4Mask, 0}, {"Mod5", Mod5Mask, 0}, {"M5", Mod5Mask, 0}, {"Double", 0, DOUBLE}, {"Triple", 0, TRIPLE}, {"Quadruple", 0, QUADRUPLE}, {"Any", 0, 0}, /* Ignored: historical relic */ | > > > > > > > > > > > > | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | {"Button7", Button7Mask, 0}, {"B8", Button8Mask, 0}, {"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}, {"Num", Mod3Mask, 0}, {"Mod4", Mod4Mask, 0}, {"Fn", Mod4Mask, 0}, {"M4", Mod4Mask, 0}, {"Mod5", Mod5Mask, 0}, {"M5", Mod5Mask, 0}, {"Double", 0, DOUBLE}, {"Triple", 0, TRIPLE}, {"Quadruple", 0, QUADRUPLE}, {"Any", 0, 0}, /* Ignored: historical relic */ |
︙ | ︙ | |||
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | * This is necessary because X doesn't report up events unless you also ask * for down events. Also, X doesn't report button state in motion events * unless you've asked about button events. */ static const EventInfo eventArray[] = { {"Key", KeyPress, KeyPressMask}, {"KeyPress", KeyPress, KeyPressMask}, {"KeyRelease", KeyRelease, KeyPressMask|KeyReleaseMask}, {"Button", ButtonPress, ButtonPressMask}, {"ButtonPress", ButtonPress, ButtonPressMask}, {"ButtonRelease", ButtonRelease, ButtonPressMask|ButtonReleaseMask}, {"Motion", MotionNotify, ButtonPressMask|PointerMotionMask}, {"Enter", EnterNotify, EnterWindowMask}, {"Leave", LeaveNotify, LeaveWindowMask}, {"FocusIn", FocusIn, FocusChangeMask}, {"FocusOut", FocusOut, FocusChangeMask}, {"Expose", Expose, ExposureMask}, | > > > > | 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | * This is necessary because X doesn't report up events unless you also ask * for down events. Also, X doesn't report button state in motion events * 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}, {"FocusOut", FocusOut, FocusChangeMask}, {"Expose", Expose, ExposureMask}, |
︙ | ︙ | |||
798 799 800 801 802 803 804 805 806 807 808 809 810 811 | return (button > 3) ? (button + 4) : button; } static Time CurrentTimeInMilliSecs(void) { Tcl_Time now; Tcl_GetTime(&now); return ((Time) now.sec)*1000 + ((Time) now.usec)/1000; } static Info GetInfo( const PatSeq *psPtr, | > | 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 | return (button > 3) ? (button + 4) : button; } static Time CurrentTimeInMilliSecs(void) { Tcl_Time now; Tcl_GetTime(&now); return ((Time) now.sec)*1000 + ((Time) now.usec)/1000; } static Info GetInfo( const PatSeq *psPtr, |
︙ | ︙ | |||
2990 2991 2992 2993 2994 2995 2996 | snprintf(numStorage, sizeof(numStorage), "%" TCL_LL_MODIFIER "u", unumber); \ string = numStorage; \ } while (1) { char numStorage[TCL_INTEGER_SPACE]; const char *string; | | | | 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 | snprintf(numStorage, sizeof(numStorage), "%" TCL_LL_MODIFIER "u", unumber); \ string = numStorage; \ } while (1) { char numStorage[TCL_INTEGER_SPACE]; const char *string; long long number; /* signed */ unsigned long long unumber; /* unsigned */ /* * Find everything up to the next % character and append it to the * result string. */ for (string = before; *string && *string != '%'; ++string) |
︙ | ︙ | |||
5236 5237 5238 5239 5240 5241 5242 | */ KeySym TkStringToKeysym( const char *name) /* Name of a keysym. */ { #ifdef REDO_KEYSYM_LOOKUP | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | | 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 | */ KeySym TkStringToKeysym( const char *name) /* Name of a keysym. */ { #ifdef REDO_KEYSYM_LOOKUP 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); } if (((unsigned)(name[0]-1) < 0x7F) && !name[1]) { keysym = (unsigned char) name[0]; if (TkKeysymToString(keysym)) { return keysym; } } #endif /* REDO_KEYSYM_LOOKUP */ assert(name); |
︙ | ︙ | |||
5276 5277 5278 5279 5280 5281 5282 | */ const char * TkKeysymToString( KeySym keysym) { #ifdef REDO_KEYSYM_LOOKUP | | > > > > > > > > > > > > > > > > > > > > > > > > < < < | 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 | */ const char * TkKeysymToString( KeySym keysym) { #ifdef REDO_KEYSYM_LOOKUP 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 */ return XKeysymToString(keysym); } /* *---------------------------------------------------------------------- * * TkpGetBindingXEvent -- |
︙ | ︙ |
Changes to generic/tkBitmap.c.
1 2 3 4 5 6 7 | /* * tkBitmap.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkBitmap.c -- * * 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 © 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" |
︙ | ︙ | |||
1010 1011 1012 1013 1014 1015 1016 | * or NULL if unavailable. */ { Tcl_Interp *dummy; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* | | | 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 | * or NULL if unavailable. */ { Tcl_Interp *dummy; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * First initialize the data in the ThreadSpecificData structure, if * needed. */ if (!tsdPtr->initialized) { tsdPtr->initialized = 1; dummy = Tcl_CreateInterp(); Tcl_InitHashTable(&tsdPtr->predefBitmapTable, TCL_STRING_KEYS); |
︙ | ︙ | |||
1165 1166 1167 1168 1169 1170 1171 | } /* *---------------------------------------------------------------------- * * TkGetBitmapPredefTable -- * | | | 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 | } /* *---------------------------------------------------------------------- * * TkGetBitmapPredefTable -- * * This function is used by tkMacOSXBitmap.c to access the thread-specific * predefBitmap table that maps from the names of the predefined bitmaps * to data associated with those bitmaps. It is required because the * table is allocated in thread-local storage and is not visible outside * this file. * Results: * Returns a pointer to the predefined bitmap hash table for the current |
︙ | ︙ |
Changes to generic/tkButton.c.
1 2 3 4 5 6 7 | /* * tkButton.c -- * * This module implements a collection of button-like widgets for the Tk * toolkit. The widgets implemented include buttons, checkbuttons, * radiobuttons, and labels. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkButton.c -- * * This module implements a collection of button-like widgets for the Tk * toolkit. The widgets implemented include buttons, checkbuttons, * radiobuttons, and labels. * * 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 "tkButton.h" |
︙ | ︙ | |||
25 26 27 28 29 30 31 | * Class names for buttons, indexed by one of the type values defined in * tkButton.h. */ static const char *const classNames[] = {"Label", "Button", "Checkbutton", "Radiobutton"}; /* | | < < < < < < < < < | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | * Class names for buttons, indexed by one of the type values defined in * tkButton.h. */ static const char *const classNames[] = {"Label", "Button", "Checkbutton", "Radiobutton"}; /* * The following table defines the legal values for the -default/-state options. * It is used together with the "enum defaultValue/state" declarations in tkButton.h. */ const char *const tkStateStrings[] = { "active", "disabled", "normal", NULL }; /* * The following table defines the legal values for the -compound option. * It is used with the "enum compound" declaration in tkButton.h */ const char *const tkCompoundStrings[] = { "bottom", "center", "left", "none", "right", "top", NULL }; char tkDefButtonHighlightWidth[TCL_INTEGER_SPACE] = DEF_BUTTON_HIGHLIGHT_WIDTH; char tkDefButtonPadx[TCL_INTEGER_SPACE] = DEF_BUTTON_PADX; char tkDefButtonPady[TCL_INTEGER_SPACE] = DEF_BUTTON_PADY; char tkDefButtonBorderWidth[TCL_INTEGER_SPACE] = DEF_BUTTON_BORDER_WIDTH; |
︙ | ︙ | |||
87 88 89 90 91 92 93 | {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", | | | | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0, tkCompoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK, DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_LABEL_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, DEF_BUTTON_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefLabelHighlightWidth, offsetof(TkButton, highlightWidthPtr), offsetof(TkButton, highlightWidth), 0, 0, 0}, |
︙ | ︙ | |||
130 131 132 133 134 135 136 | {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), | | | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_LABEL_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), offsetof(TkButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; |
︙ | ︙ | |||
175 176 177 178 179 180 181 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", | | | | | | | | 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0, tkCompoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-default", "default", "Default", DEF_BUTTON_DEFAULT, TCL_INDEX_NONE, offsetof(TkButton, defaultState), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK, DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, DEF_BUTTON_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), offsetof(TkButton, highlightWidth), 0, 0, 0}, |
︙ | ︙ | |||
231 232 233 234 235 236 237 | DEF_BUTTON_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkButton, repeatDelay), 0, 0, 0}, {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", DEF_BUTTON_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkButton, repeatInterval), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), | | | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | DEF_BUTTON_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkButton, repeatDelay), 0, 0, 0}, {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", DEF_BUTTON_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkButton, repeatInterval), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), offsetof(TkButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; |
︙ | ︙ | |||
276 277 278 279 280 281 282 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", | | | | | | | | | | | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0, tkCompoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK, DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, DEF_BUTTON_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), offsetof(TkButton, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-image", "image", "Image", DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn", DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn), 0, 0, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0}, {TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief", DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0}, {TK_OPTION_STRING, "-offvalue", "offValue", "Value", DEF_BUTTON_OFF_VALUE, offsetof(TkButton, offValuePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-onvalue", "onValue", "Value", DEF_BUTTON_ON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief", DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", tkDefLabelPadx, offsetof(TkButton, padXPtr), offsetof(TkButton, padX), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", "padY", "Pad", tkDefLabelPady, offsetof(TkButton, padYPtr), offsetof(TkButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background", DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder), TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0}, {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage", DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage", DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue", DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr), |
︙ | ︙ | |||
389 390 391 392 393 394 395 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", | | | | | | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr), offsetof(TkButton, borderWidth), 0, 0, 0}, {TK_OPTION_STRING, "-command", "command", "Command", DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0, tkCompoundStrings, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK, DEF_BUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0, DEF_BUTTON_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", tkDefButtonHighlightWidth, offsetof(TkButton, highlightWidthPtr), offsetof(TkButton, highlightWidth), 0, 0, 0}, |
︙ | ︙ | |||
446 447 448 449 450 451 452 | DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder), TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0}, {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage", DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), | | | | | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder), TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0}, {TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage", DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage", DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue", DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0}, {TK_OPTION_STRING, "-value", "value", "Value", DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", DEF_RADIOBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0}, |
︙ | ︙ | |||
683 684 685 686 687 688 689 | butPtr->display = Tk_Display(tkwin); butPtr->interp = interp; butPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(tkwin), ButtonWidgetObjCmd, butPtr, ButtonCmdDeletedProc); butPtr->type = type; butPtr->optionTable = optionTable; butPtr->textPtr = NULL; | | | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | butPtr->display = Tk_Display(tkwin); butPtr->interp = interp; butPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(tkwin), ButtonWidgetObjCmd, butPtr, ButtonCmdDeletedProc); butPtr->type = type; butPtr->optionTable = optionTable; butPtr->textPtr = NULL; butPtr->underline = INT_MIN; butPtr->textVarNamePtr = NULL; butPtr->bitmap = None; butPtr->imagePtr = NULL; butPtr->image = NULL; butPtr->selectImagePtr = NULL; butPtr->selectImage = NULL; butPtr->tristateImagePtr = NULL; |
︙ | ︙ | |||
1622 1623 1624 1625 1626 1627 1628 | * If the variable is being unset, then just re-establish the trace unless * the whole interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { butPtr->flags &= ~(SELECTED | TRISTATED); if (!Tcl_InterpDeleted(interp)) { | | | | 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 | * If the variable is being unset, then just re-establish the trace unless * the whole interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { butPtr->flags &= ~(SELECTED | TRISTATED); if (!Tcl_InterpDeleted(interp)) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonVarProc, probe); if (probe == (void *)butPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * selVarNamePtr, which means it is not unset and not |
︙ | ︙ | |||
1741 1742 1743 1744 1745 1746 1747 | if (!Tcl_InterpDeleted(interp) && butPtr->textVarNamePtr != NULL) { /* * An unset trace on some variable brought us here, but is it * the variable we have stored in butPtr->textVarNamePtr ? */ | | | | 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 | if (!Tcl_InterpDeleted(interp) && butPtr->textVarNamePtr != NULL) { /* * An unset trace on some variable brought us here, but is it * the variable we have stored in butPtr->textVarNamePtr ? */ void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, Tcl_GetString(butPtr->textVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonTextVarProc, probe); if (probe == (void *)butPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * textVarNamePtr, which means it is not unset and not |
︙ | ︙ |
Changes to generic/tkButton.h.
1 2 3 4 5 6 | /* * tkButton.h -- * * Declarations of types and functions used to implement button-like * widgets. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkButton.h -- * * Declarations of types and functions used to implement button-like * widgets. * * 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. */ #ifndef _TKBUTTON #define _TKBUTTON |
︙ | ︙ | |||
63 64 65 66 67 68 69 | /* * Information about what's in the button. */ Tcl_Obj *textPtr; /* Value of -text option: specifies text to * display in button. */ int underline; /* Value of -underline option: specifies index | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /* * Information about what's in the button. */ Tcl_Obj *textPtr; /* Value of -text option: specifies text to * display in button. */ int underline; /* Value of -underline option: specifies index * of character to underline. INT_MIN means don't * underline anything. */ Tcl_Obj *textVarNamePtr; /* Value of -textvariable option: specifies * name of variable or NULL. If non-NULL, * button displays the contents of this * variable. */ Pixmap bitmap; /* Value of -bitmap option. If not None, * specifies bitmap to display and text and |
︙ | ︙ |
Changes to generic/tkCanvArc.c.
1 2 3 4 5 | /* * tkCanvArc.c -- * * This file implements arc items for canvas widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkCanvArc.c -- * * This file implements arc items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ |
Changes to generic/tkCanvBmap.c.
1 2 3 4 5 | /* * tkCanvBmap.c -- * * This file implements bitmap items for canvas widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkCanvBmap.c -- * * This file implements bitmap items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
536 537 538 539 540 541 542 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; | | | 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; default: x -= width/2; y -= height/2; break; } /* * Store the information in the item header. |
︙ | ︙ | |||
941 942 943 944 945 946 947 | case TK_ANCHOR_N: x -= width/2.0; y -= height; break; case TK_ANCHOR_NE: x -= width; y -= height; break; case TK_ANCHOR_E: x -= width; y -= height/2.0; break; case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; | | | 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 | case TK_ANCHOR_N: x -= width/2.0; y -= height; break; case TK_ANCHOR_NE: x -= width; y -= height; break; case TK_ANCHOR_E: x -= width; y -= height/2.0; break; case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; default: x -= width/2.0; y -= height/2.0; break; } /* * Make our working space. */ psObj = Tcl_NewObj(); |
︙ | ︙ |
Changes to generic/tkCanvImg.c.
1 2 3 4 5 | /* * tkCanvImg.c -- * * This file implements image items for canvas widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkCanvImg.c -- * * This file implements image items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
70 71 72 73 74 75 76 | * Prototypes for functions defined in this file: */ static void ImageChangedProc(ClientData clientData, int x, int y, int width, int height, int imgWidth, int imgHeight); static int ImageCoords(Tcl_Interp *interp, | | | | | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | * Prototypes for functions defined in this file: */ static void ImageChangedProc(ClientData clientData, int x, int y, int width, int height, int imgWidth, int imgHeight); static int ImageCoords(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static int ImageToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); static double ImageToPoint(Tk_Canvas canvas, Tk_Item *itemPtr, double *coordPtr); static int ImageToPostscript(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int prepass); static void ComputeImageBbox(Tk_Canvas canvas, ImageItem *imgPtr); static int ConfigureImage(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[], int flags); static int CreateImage(Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static void DeleteImage(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display); static void DisplayImage(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display, Drawable dst, int x, int y, int width, int height); static void RotateImage(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double angleRad); |
︙ | ︙ | |||
487 488 489 490 491 492 493 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; | | | 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; default: x -= width/2; y -= height/2; break; } /* * Store the information in the item header. |
︙ | ︙ | |||
743 744 745 746 747 748 749 | case TK_ANCHOR_N: x -= width/2.0; y -= height; break; case TK_ANCHOR_NE: x -= width; y -= height; break; case TK_ANCHOR_E: x -= width; y -= height/2.0; break; case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; | | | 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 | case TK_ANCHOR_N: x -= width/2.0; y -= height; break; case TK_ANCHOR_NE: x -= width; y -= height; break; case TK_ANCHOR_E: x -= width; y -= height/2.0; break; case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; default: x -= width/2.0; y -= height/2.0; break; } if (!prepass) { Tcl_Obj *psObj = Tcl_GetObjResult(interp); if (Tcl_IsShared(psObj)) { psObj = Tcl_DuplicateObj(psObj); |
︙ | ︙ |
Changes to generic/tkCanvLine.c.
1 2 3 4 5 | /* * tkCanvLine.c -- * * This file implements line items for canvas widgets. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkCanvLine.c -- * * This file implements line items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
956 957 958 959 960 961 962 | Tk_Canvas canvas, /* Canvas containing text item. */ Tk_Item *itemPtr, /* Line item to be modified. */ TkSizeT beforeThis, /* Index before which new coordinates are to * be inserted. */ Tcl_Obj *obj) /* New coordinates to be inserted. */ { LineItem *linePtr = (LineItem *) itemPtr; | | > > > > > > > > | 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | Tk_Canvas canvas, /* Canvas containing text item. */ Tk_Item *itemPtr, /* Line item to be modified. */ TkSizeT beforeThis, /* Index before which new coordinates are to * be inserted. */ Tcl_Obj *obj) /* New coordinates to be inserted. */ { LineItem *linePtr = (LineItem *) itemPtr; int length, oriNumPoints, objc, nbInsPoints, i; double *newCoordPtr, *coordPtr; Tk_State state = itemPtr->state; Tcl_Obj **objv; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } if (!obj || (Tcl_ListObjGetElements(NULL, obj, &objc, &objv) != TCL_OK) || !objc || objc&1) { return; } oriNumPoints = linePtr->numPoints; length = 2*linePtr->numPoints; nbInsPoints = objc / 2; if (beforeThis == TCL_INDEX_NONE) { beforeThis = 0; } if (beforeThis + 1 > (TkSizeT)length + 1) { beforeThis = length; } /* * With arrows, the end points of the line are adjusted so that a thick * line doesn't stick out past the arrowheads (see ConfigureArrows). */ if (linePtr->firstArrowPtr != NULL) { linePtr->coordPtr[0] = linePtr->firstArrowPtr[0]; linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; } if (linePtr->lastArrowPtr != NULL) { linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1]; |
︙ | ︙ | |||
997 998 999 1000 1001 1002 1003 | &newCoordPtr[i + beforeThis]) != TCL_OK) { Tcl_ResetResult(Canvas(canvas)->interp); ckfree(newCoordPtr); return; } } | | | > > < > | | > | | | | > > > > > | | | > > > > > | | | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | > > | | | | 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 | &newCoordPtr[i + beforeThis]) != TCL_OK) { Tcl_ResetResult(Canvas(canvas)->interp); ckfree(newCoordPtr); return; } } for (i=(int)beforeThis; i<length; i++) { newCoordPtr[i+objc] = linePtr->coordPtr[i]; } if (linePtr->coordPtr) { ckfree(linePtr->coordPtr); } linePtr->coordPtr = newCoordPtr; length += objc ; linePtr->numPoints = length / 2; if ((length > 3) && (state != TK_STATE_HIDDEN)) { /* * This is some optimizing code that will result that only the part of * the line that changed (and the objects that are overlapping with * that part) need to be redrawn. A special flag is set that instructs * the general canvas code not to redraw the whole object. If this * flag is not set, the canvas will do the redrawing, otherwise I have * to do it here. * Rationale for the optimization code can be found in Tk ticket * [5fb8145997]. */ itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW; /* * Include one point at left of the left insert position, and one * point at right of the right insert position. */ beforeThis -= 2; objc += 4; if (linePtr->smooth) { if (!strcmp(linePtr->smooth->name, "true")) { /* * Quadratic Bezier splines. A second point must be included at * each side of the insert position. */ beforeThis -= 2; objc += 4; /* * Moreover, if the insert position is the first or last point * of the line, include a third point. */ if ((int)beforeThis == -4) { objc += 2; } if ((int)beforeThis + 4 == length - (objc - 8)) { beforeThis -= 2; objc += 2; } } else if (!strcmp(linePtr->smooth->name, "raw")) { /* * Cubic Bezier splines. See details in ticket [5fb8145997]. */ if (((oriNumPoints - 1) % 3) || (nbInsPoints % 3)) { /* * No optimization for "degenerate" lines or when inserting * something else than a multiple of 3 points. */ itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; } else { beforeThis -= (int)beforeThis % 6; objc += 4; } } else { /* * Custom smoothing method. No optimization is possible. */ itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; } } if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) { if ((int)beforeThis < 0) { beforeThis = 0; } if ((int)beforeThis + objc > length) { objc = length - (int)beforeThis; } itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis]; itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[beforeThis+1]; if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 2)) { /* * Include old first arrow. */ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) { /* * Include old last arrow. */ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } coordPtr = linePtr->coordPtr + beforeThis; for (i=0; i<objc; i+=2) { TkIncludePoint(itemPtr, coordPtr); coordPtr += 2; } } } if (linePtr->firstArrowPtr != NULL) { ckfree(linePtr->firstArrowPtr); linePtr->firstArrowPtr = NULL; } if (linePtr->lastArrowPtr != NULL) { ckfree(linePtr->lastArrowPtr); linePtr->lastArrowPtr = NULL; } if (linePtr->arrow != ARROWS_NONE) { ConfigureArrows(canvas, linePtr); } if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) { double width; int intWidth; if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 2)) { /* * Include new first arrow. */ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) { /* * Include new last arrow. */ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } |
︙ | ︙ | |||
1149 1150 1151 1152 1153 1154 1155 | LineDeleteCoords( Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Item in which to delete characters. */ TkSizeT first, /* Index of first character to delete. */ TkSizeT last) /* Index of last character to delete. */ { LineItem *linePtr = (LineItem *) itemPtr; | | > > | | > > > > > > > | > > > > > | > | > | > > > > > > > | | > > > > | | > > > | | | > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > | > > | | 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 | LineDeleteCoords( Tk_Canvas canvas, /* Canvas containing itemPtr. */ Tk_Item *itemPtr, /* Item in which to delete characters. */ TkSizeT first, /* Index of first character to delete. */ TkSizeT last) /* Index of last character to delete. */ { LineItem *linePtr = (LineItem *) itemPtr; int count, i, first1, last1, nbDelPoints; int oriNumPoints = linePtr->numPoints; int canOptimize = 1; int length = 2*linePtr->numPoints; double *coordPtr; Tk_State state = itemPtr->state; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } first &= -2; /* If odd, make it even. */ last &= -2; if ((int)first < 0) { first = 0; } if ((int)last >= length) { last = length - 2; } if ((int)first > (int)last) { return; } /* * With arrows, the end points of the line are adjusted so that a thick * line doesn't stick out past the arrowheads (see ConfigureArrows). */ if (linePtr->firstArrowPtr != NULL) { linePtr->coordPtr[0] = linePtr->firstArrowPtr[0]; linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; } if (linePtr->lastArrowPtr != NULL) { linePtr->coordPtr[length-2] = linePtr->lastArrowPtr[0]; linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1]; } first1 = first; last1 = last; nbDelPoints = (last - first) / 2 + 1; /* * Include one point at left of the left delete position, and one * point at right of the right delete position. */ first1 -= 2; last1 += 2; if (linePtr->smooth) { if (!strcmp(linePtr->smooth->name, "true")) { /* * Quadratic Bezier splines. A second point must be included at * each side of the delete position. */ first1 -= 2; last1 += 2; /* * If the delete position is the first or last point of the line, * include a third point. */ if (first1 == -4) { last1 += 2; } if (last1 - 4 == length - 2) { first1 -= 2; } } else if (!strcmp(linePtr->smooth->name, "raw")) { /* * Cubic Bezier splines. See details in ticket [5fb8145997]. */ if (((oriNumPoints - 1) % 3) || (nbDelPoints % 3)) { /* * No optimization for "degenerate" lines or when deleting * something else than a multiple of 3 points. */ canOptimize = 0; } else { first1 -= first1 % 6; last1 = last + 6 - last % 6; } } else { /* * Custom smoothing method. No optimization is possible. */ canOptimize = 0; } } if (first1 < 0) { first1 = 0; } if (last1 >= length) { last1 = length - 2; } if (canOptimize && ((first1 >= 2) || (last1 < length-2))) { /* * This is some optimizing code that will result that only the part of * the line that changed (and the objects that are overlapping with * that part) need to be redrawn. A special flag is set that instructs * the general canvas code not to redraw the whole object. If this * flag is set, the redrawing has to be done here, otherwise the * general Canvas code will take care of it. * Rationale for the optimization code can be found in Tk ticket * [5fb8145997]. */ itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW; itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[first1]; itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[first1+1]; if ((linePtr->firstArrowPtr != NULL) && (first1 < 2)) { /* * Include old first arrow. */ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } if ((linePtr->lastArrowPtr != NULL) && (last1 >= length - 2)) { /* * Include old last arrow. */ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); |
︙ | ︙ | |||
1255 1256 1257 1258 1259 1260 1261 | if (linePtr->arrow != ARROWS_NONE) { ConfigureArrows(canvas, linePtr); } if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) { double width; int intWidth; | | | | | 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 | if (linePtr->arrow != ARROWS_NONE) { ConfigureArrows(canvas, linePtr); } if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) { double width; int intWidth; if ((linePtr->firstArrowPtr != NULL) && (first1 < 2)) { /* * Include new first arrow. */ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } if ((linePtr->lastArrowPtr != NULL) && (last1 >= length - 2)) { /* * Include new last arrow. */ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW; i++, coordPtr += 2) { TkIncludePoint(itemPtr, coordPtr); } } |
︙ | ︙ | |||
1744 1745 1746 1747 1748 1749 1750 | TkSizeT *indexPtr) /* Where to store converted index. */ { TkSizeT idx, length; LineItem *linePtr = (LineItem *) itemPtr; const char *string; (void)canvas; | | | | 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 | TkSizeT *indexPtr) /* Where to store converted index. */ { TkSizeT idx, length; LineItem *linePtr = (LineItem *) itemPtr; const char *string; (void)canvas; if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 1, &idx)) { if (idx == TCL_INDEX_NONE) { idx = 0; } else if (idx > (2*(TkSizeT)linePtr->numPoints)) { idx = 2*linePtr->numPoints; } else { idx &= (TkSizeT)-2; /* If index is odd, make it even. */ } *indexPtr = idx; return TCL_OK; } string = Tcl_GetStringFromObj(obj, &length); if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; char *end; const char *p; |
︙ | ︙ | |||
1932 1933 1934 1935 1936 1937 1938 | char *recordPtr, /* Pointer to item record in which to store * arrow information. */ TkSizeT offset) /* Offset of shape information in widget * record. */ { LineItem *linePtr = (LineItem *) recordPtr; double a, b, c; | | | 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 | char *recordPtr, /* Pointer to item record in which to store * arrow information. */ TkSizeT offset) /* Offset of shape information in widget * record. */ { LineItem *linePtr = (LineItem *) recordPtr; double a, b, c; TkSizeT argc; const char **argv = NULL; if ((size_t)offset != offsetof(LineItem, arrowShapeA)) { Tcl_Panic("ParseArrowShape received bogus offset"); } if (Tcl_SplitList(interp, (char *) value, &argc, &argv) != TCL_OK) { |
︙ | ︙ |
Changes to generic/tkCanvPoly.c.
1 2 3 4 5 | /* * tkCanvPoly.c -- * * This file implements polygon items for canvas widgets. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkCanvPoly.c -- * * This file implements polygon items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
1017 1018 1019 1020 1021 1022 1023 | Tk_Canvas canvas, /* Canvas containing text item. */ Tk_Item *itemPtr, /* Line item to be modified. */ TkSizeT beforeThis, /* Index before which new coordinates are to * be inserted. */ Tcl_Obj *obj) /* New coordinates to be inserted. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; | | > > | 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 | Tk_Canvas canvas, /* Canvas containing text item. */ Tk_Item *itemPtr, /* Line item to be modified. */ TkSizeT beforeThis, /* Index before which new coordinates are to * be inserted. */ Tcl_Obj *obj) /* New coordinates to be inserted. */ { PolygonItem *polyPtr = (PolygonItem *) itemPtr; int length, oriNumPoints, objc, nbInsPoints, i; Tcl_Obj **objv; double *newCoordPtr; Tk_State state = itemPtr->state; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } if (!obj || (Tcl_ListObjGetElements(NULL, obj, &objc, &objv) != TCL_OK) || !objc || objc&1) { return; } oriNumPoints = polyPtr->numPoints - polyPtr->autoClosed; length = 2*(polyPtr->numPoints - polyPtr->autoClosed); nbInsPoints = objc / 2; while ((int)beforeThis > length) { beforeThis -= length; } while ((int)beforeThis < 0) { beforeThis += length; } newCoordPtr = (double *)ckalloc(sizeof(double) * (length + 2 + objc)); |
︙ | ︙ | |||
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 | /* * This is some optimizing code that will result that only the part of * the polygon that changed (and the objects that are overlapping with * that part) need to be redrawn. A special flag is set that instructs * the general canvas code not to redraw the whole object. If this * flag is not set, the canvas will do the redrawing, otherwise I have * to do it here. */ double width; int j; itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW; /* * The header elements that normally are used for the bounding box, * are now used to calculate the bounding box for only the part that * has to be redrawn. That doesn't matter, because afterwards the * bounding box has to be re-calculated anyway. */ itemPtr->x1 = itemPtr->x2 = (int) polyPtr->coordPtr[beforeThis]; itemPtr->y1 = itemPtr->y2 = (int) polyPtr->coordPtr[beforeThis+1]; beforeThis -= 2; objc += 4; if (polyPtr->smooth) { | > > > > > > > > > | | | > > > > > | > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | > | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 | /* * This is some optimizing code that will result that only the part of * the polygon that changed (and the objects that are overlapping with * that part) need to be redrawn. A special flag is set that instructs * the general canvas code not to redraw the whole object. If this * flag is not set, the canvas will do the redrawing, otherwise I have * to do it here. * Rationale for the optimization code can be found in Tk ticket * [5fb8145997]. */ double width; int j; itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW; /* * The header elements that normally are used for the bounding box, * are now used to calculate the bounding box for only the part that * has to be redrawn. That doesn't matter, because afterwards the * bounding box has to be re-calculated anyway. */ itemPtr->x1 = itemPtr->x2 = (int) polyPtr->coordPtr[beforeThis]; itemPtr->y1 = itemPtr->y2 = (int) polyPtr->coordPtr[beforeThis+1]; beforeThis -= 2; objc += 4; if (polyPtr->smooth) { if (!strcmp(polyPtr->smooth->name, "true")) { /* * Quadratic Bezier splines. */ beforeThis -= 2; objc += 4; } else if (!strcmp(polyPtr->smooth->name, "raw")) { /* * Cubic Bezier splines. */ if ((oriNumPoints % 3) || (nbInsPoints % 3)) { /* * No optimization for "degenerate" polygons or when inserting * something else than a multiple of 3 points. */ itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; } else { beforeThis -= abs((int)beforeThis) % 6; objc += 4; } } else { /* * Custom smoothing method. No optimization is possible. */ itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW; } } if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) { /* * Be careful; beforeThis could now be negative */ for (i=(int)beforeThis; i<(int)beforeThis+objc; i+=2) { j = i; if (j < 0) { j += length; } else if (j >= length) { j -= length; } TkIncludePoint(itemPtr, polyPtr->coordPtr+j); } width = polyPtr->outline.width; if (Canvas(canvas)->currentItemPtr == itemPtr) { if (polyPtr->outline.activeWidth > width) { width = polyPtr->outline.activeWidth; } } else if (state == TK_STATE_DISABLED) { if (polyPtr->outline.disabledWidth > 0.0) { width = polyPtr->outline.disabledWidth; } } itemPtr->x1 -= (int) width; itemPtr->y1 -= (int) width; itemPtr->x2 += (int) width; itemPtr->y2 += (int) width; Tk_CanvasEventuallyRedraw(canvas, itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2); } } ComputePolygonBbox(canvas, polyPtr); } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 | PolygonItem *polyPtr = (PolygonItem *) itemPtr; const char *string; TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed); if (TCL_OK == TkGetIntForIndex(obj, (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) { if (idx == TCL_INDEX_NONE) { idx = 0; } else { idx = (idx & (TkSizeT)-2) % count; } *indexPtr = idx; return TCL_OK; } | > > | | 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 | PolygonItem *polyPtr = (PolygonItem *) itemPtr; const char *string; TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed); if (TCL_OK == TkGetIntForIndex(obj, (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) { if (idx == TCL_INDEX_NONE) { idx = 0; } else if (idx >= INT_MAX - ((INT_MAX) % count)) { idx = count; } else { idx = (idx & (TkSizeT)-2) % count; } *indexPtr = idx; return TCL_OK; } string = Tcl_GetStringFromObj(obj, &length); if (string[0] == '@') { int i; double x, y, bestDist, dist, *coordPtr; char *end; const char *p; |
︙ | ︙ |
Changes to generic/tkCanvPs.c.
1 2 3 4 5 6 7 | /* * tkCanvPs.c -- * * This module provides Postscript output support for canvases, including * the "postscript" widget command plus a few utility functions used for * generating Postscript. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkCanvPs.c -- * * This module provides Postscript output support for canvases, including * the "postscript" widget command plus a few utility functions used for * generating Postscript. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
281 282 283 284 285 286 287 | } switch (psInfo.pageAnchor) { case TK_ANCHOR_NW: case TK_ANCHOR_W: case TK_ANCHOR_SW: deltaX = 0; break; | < < < < < > > > < < < < < > > > | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | } switch (psInfo.pageAnchor) { case TK_ANCHOR_NW: case TK_ANCHOR_W: case TK_ANCHOR_SW: deltaX = 0; break; case TK_ANCHOR_NE: case TK_ANCHOR_E: case TK_ANCHOR_SE: deltaX = -psInfo.width; break; default: deltaX = -psInfo.width/2; break; } switch (psInfo.pageAnchor) { case TK_ANCHOR_NW: case TK_ANCHOR_N: case TK_ANCHOR_NE: deltaY = - psInfo.height; break; case TK_ANCHOR_SW: case TK_ANCHOR_S: case TK_ANCHOR_SE: deltaY = 0; break; default: deltaY = -psInfo.height/2; break; } if (psInfo.colorMode == NULL) { psInfo.colorLevel = 2; } else { length = strlen(psInfo.colorMode); if (strncmp(psInfo.colorMode, "monochrome", length) == 0) { |
︙ | ︙ | |||
899 900 901 902 903 904 905 906 907 908 909 910 911 912 | XGetGeometry(Tk_Display(tkwin), bitmap, &dummyRoot, (int *) &dummyX, (int *) &dummyY, (unsigned int *) &totalWidth, (unsigned int *) &totalHeight, &dummyBorderwidth, &dummyDepth); imagePtr = XGetImage(Tk_Display(tkwin), bitmap, 0, 0, totalWidth, totalHeight, 1, XYPixmap); Tcl_AppendToObj(psObj, "<", -1); mask = 0x80; value = 0; charsInLine = 0; lastX = startX + width - 1; lastY = startY + height - 1; for (y = lastY; y >= startY; y--) { | > > > > > > > > > > > > | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | XGetGeometry(Tk_Display(tkwin), bitmap, &dummyRoot, (int *) &dummyX, (int *) &dummyY, (unsigned int *) &totalWidth, (unsigned int *) &totalHeight, &dummyBorderwidth, &dummyDepth); imagePtr = XGetImage(Tk_Display(tkwin), bitmap, 0, 0, totalWidth, totalHeight, 1, XYPixmap); if (!imagePtr) { /* * The XGetImage() function is apparently not implemented on this * system. Just skip the pixels, the Postscript will still be * syntactically correct. */ Tcl_AppendToObj(psObj, "<>", -1); return; } Tcl_AppendToObj(psObj, "<", -1); mask = 0x80; value = 0; charsInLine = 0; lastX = startX + width - 1; lastY = startY + height - 1; for (y = lastY; y >= startY; y--) { |
︙ | ︙ |
Changes to generic/tkCanvText.c.
1 2 3 4 5 | /* * tkCanvText.c -- * * This file implements text items for canvas widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkCanvText.c -- * * This file implements text items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
49 50 51 52 53 54 55 | Pixmap stipple; /* Stipple bitmap for text, or None. */ Pixmap activeStipple; /* Stipple bitmap for text, or None. */ Pixmap disabledStipple; /* Stipple bitmap for text, or None. */ char *text; /* Text for item (malloc-ed). */ int width; /* Width of lines for word-wrap, pixels. Zero * means no word-wrap. */ int underline; /* Index of character to put underline beneath | | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | Pixmap stipple; /* Stipple bitmap for text, or None. */ Pixmap activeStipple; /* Stipple bitmap for text, or None. */ Pixmap disabledStipple; /* Stipple bitmap for text, or None. */ char *text; /* Text for item (malloc-ed). */ int width; /* Width of lines for word-wrap, pixels. Zero * means no word-wrap. */ int underline; /* Index of character to put underline beneath * or INT_MIN for no underlining. */ double angle; /* What angle, in degrees, to draw the text * at. */ /* * Fields whose values are derived from the current values of the * configuration settings above. */ |
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 101 | }; static const Tk_CustomOption tagsOption = { TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL }; static const Tk_CustomOption offsetOption = { TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE) }; static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_COLOR, "-activefill", NULL, NULL, NULL, offsetof(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_BITMAP, "-activestipple", NULL, NULL, NULL, offsetof(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_ANCHOR, "-anchor", NULL, NULL, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | }; static const Tk_CustomOption tagsOption = { TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL }; static const Tk_CustomOption offsetOption = { TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE) }; static int UnderlineParseProc( ClientData dummy, /* Not used.*/ Tcl_Interp *interp, /* Used for reporting errors. */ Tk_Window tkwin, /* Window containing canvas widget. */ const char *value, /* Value of option. */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset) /* Offset into item (ignored). */ { int *underlinePtr = (int *) (widgRec + offset); Tcl_Obj obj; int code; TkSizeT underline; (void)dummy; (void)tkwin; if (value == NULL || *value == 0) { *underlinePtr = INT_MIN; /* No underline */ return TCL_OK; } obj.refCount = 1; obj.bytes = (char *)value; obj.length = strlen(value); obj.typePtr = NULL; code = TkGetIntForIndex(&obj, TCL_INDEX_END, 0, &underline); if (code == TCL_OK) { if (underline == TCL_INDEX_NONE) { underline = INT_MIN; } else if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { underline++; } else if (underline >= INT_MAX) { underline = INT_MAX; } *underlinePtr = underline; } else { Tcl_AppendResult(interp, "bad index \"", value, "\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL); } return code; } const char * UnderlinePrintProc( ClientData dummy, /* Ignored. */ Tk_Window tkwin, /* Window containing canvas widget. */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset, /* Pointer to record for item. */ Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with * information about how to reclaim storage * for return string. */ { int underline = *(int *)(widgRec + offset); char *p; (void)dummy; (void)tkwin; if (underline == INT_MIN) { #if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9 p = (char *)"-1"; #else p = (char *)""; #endif *freeProcPtr = TCL_STATIC; return p; } else if (underline == INT_MAX) { p = (char *)"end+1"; *freeProcPtr = TCL_STATIC; return p; } else if (underline == -1) { p = (char *)"end"; *freeProcPtr = TCL_STATIC; return p; } p = (char *)ckalloc(32); if (underline < 0) { sprintf(p, "end%d", underline); } else { sprintf(p, "%d", underline); } *freeProcPtr = TCL_DYNAMIC; return p; } static const Tk_CustomOption underlineOption = { UnderlineParseProc, UnderlinePrintProc, NULL }; static const Tk_ConfigSpec configSpecs[] = { {TK_CONFIG_COLOR, "-activefill", NULL, NULL, NULL, offsetof(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_BITMAP, "-activestipple", NULL, NULL, NULL, offsetof(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_ANCHOR, "-anchor", NULL, NULL, |
︙ | ︙ | |||
119 120 121 122 123 124 125 | NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption}, {TK_CONFIG_BITMAP, "-stipple", NULL, NULL, NULL, offsetof(TextItem, stipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-tags", NULL, NULL, NULL, 0, TK_CONFIG_NULL_OK, &tagsOption}, {TK_CONFIG_STRING, "-text", NULL, NULL, "", offsetof(TextItem, text), 0, NULL}, | | | | | | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption}, {TK_CONFIG_BITMAP, "-stipple", NULL, NULL, NULL, offsetof(TextItem, stipple), TK_CONFIG_NULL_OK, NULL}, {TK_CONFIG_CUSTOM, "-tags", NULL, NULL, NULL, 0, TK_CONFIG_NULL_OK, &tagsOption}, {TK_CONFIG_STRING, "-text", NULL, NULL, "", offsetof(TextItem, text), 0, NULL}, {TK_CONFIG_CUSTOM, "-underline", NULL, NULL, NULL, offsetof(TextItem, underline), TK_CONFIG_NULL_OK, &underlineOption}, {TK_CONFIG_PIXELS, "-width", NULL, NULL, "0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL}, {TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL} }; /* * Prototypes for functions defined in this file: */ static void ComputeTextBbox(Tk_Canvas canvas, TextItem *textPtr); static int ConfigureText(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int argc, Tcl_Obj *const objv[], int flags); static int CreateText(Tcl_Interp *interp, Tk_Canvas canvas, struct Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static void DeleteText(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display); static void DisplayCanvText(Tk_Canvas canvas, Tk_Item *itemPtr, Display *display, Drawable dst, int x, int y, int width, int height); static TkSizeT GetSelText(Tk_Canvas canvas, Tk_Item *itemPtr, TkSizeT offset, char *buffer, TkSizeT maxBytes); static int GetTextIndex(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Obj *obj, TkSizeT *indexPtr); static void ScaleText(Tk_Canvas canvas, Tk_Item *itemPtr, double originX, double originY, double scaleX, double scaleY); static void SetTextCursor(Tk_Canvas canvas, Tk_Item *itemPtr, TkSizeT index); static int TextCoords(Tcl_Interp *interp, Tk_Canvas canvas, Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]); static void TextDeleteChars(Tk_Canvas canvas, Tk_Item *itemPtr, TkSizeT first, TkSizeT last); static void TextInsert(Tk_Canvas canvas, Tk_Item *itemPtr, TkSizeT beforeThis, Tcl_Obj *obj); static int TextToArea(Tk_Canvas canvas, Tk_Item *itemPtr, double *rectPtr); static double TextToPoint(Tk_Canvas canvas, |
︙ | ︙ | |||
260 261 262 263 264 265 266 | textPtr->tkfont = NULL; textPtr->justify = TK_JUSTIFY_LEFT; textPtr->stipple = None; textPtr->activeStipple = None; textPtr->disabledStipple = None; textPtr->text = NULL; textPtr->width = 0; | | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | textPtr->tkfont = NULL; textPtr->justify = TK_JUSTIFY_LEFT; textPtr->stipple = None; textPtr->activeStipple = None; textPtr->disabledStipple = None; textPtr->text = NULL; textPtr->width = 0; textPtr->underline = INT_MIN; textPtr->angle = 0.0; textPtr->numChars = 0; textPtr->numBytes = 0; textPtr->textLayout = NULL; textPtr->actualWidth = 0; textPtr->drawOrigin[0] = textPtr->drawOrigin[1] = 0.0; |
︙ | ︙ | |||
561 562 563 564 565 566 567 | * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ static void DeleteText( | | < | 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | * Resources associated with itemPtr are released. * *-------------------------------------------------------------- */ static void DeleteText( TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */ Tk_Item *itemPtr, /* Item that is being deleted. */ Display *display) /* Display containing window for canvas. */ { TextItem *textPtr = (TextItem *) itemPtr; if (textPtr->color != NULL) { Tk_FreeColor(textPtr->color); } if (textPtr->activeColor != NULL) { Tk_FreeColor(textPtr->activeColor); } |
︙ | ︙ | |||
629 630 631 632 633 634 635 | static void ComputeTextBbox( Tk_Canvas canvas, /* Canvas that contains item. */ TextItem *textPtr) /* Item whose bbox is to be recomputed. */ { Tk_CanvasTextInfo *textInfoPtr; | | | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | static void ComputeTextBbox( Tk_Canvas canvas, /* Canvas that contains item. */ TextItem *textPtr) /* Item whose bbox is to be recomputed. */ { Tk_CanvasTextInfo *textInfoPtr; int width, height, fudge, i; Tk_State state = textPtr->header.state; double x[4], y[4], dx[4], dy[4], sinA, cosA, tmp; if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } |
︙ | ︙ | |||
651 652 653 654 655 656 657 | } /* * Use overall geometry information to compute the top-left corner of the * bounding box for the text item. */ | < < | | | < | | < < < | | | | < | < < < | | | 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 | } /* * Use overall geometry information to compute the top-left corner of the * bounding box for the text item. */ for (i=0 ; i<4 ; i++) { dx[i] = dy[i] = 0.0; } switch (textPtr->anchor) { case TK_ANCHOR_NW: case TK_ANCHOR_N: case TK_ANCHOR_NE: break; case TK_ANCHOR_SW: case TK_ANCHOR_S: case TK_ANCHOR_SE: for (i=0 ; i<4 ; i++) { dy[i] = -height; } break; default: for (i=0 ; i<4 ; i++) { dy[i] = -height / 2; } break; } switch (textPtr->anchor) { case TK_ANCHOR_NW: case TK_ANCHOR_W: case TK_ANCHOR_SW: break; case TK_ANCHOR_NE: case TK_ANCHOR_E: case TK_ANCHOR_SE: for (i=0 ; i<4 ; i++) { dx[i] = -width; } break; default: for (i=0 ; i<4 ; i++) { dx[i] = -width / 2; } break; } textPtr->actualWidth = width; sinA = textPtr->sine; |
︙ | ︙ | |||
1016 1017 1018 1019 1020 1021 1022 | TextItem *textPtr = (TextItem *) itemPtr; int byteIndex, charsAdded; TkSizeT byteCount; char *newStr, *text; const char *string; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; | | | 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 | TextItem *textPtr = (TextItem *) itemPtr; int byteIndex, charsAdded; TkSizeT byteCount; char *newStr, *text; const char *string; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; string = Tcl_GetStringFromObj(obj, &byteCount); text = textPtr->text; if (index == TCL_INDEX_NONE) { index = 0; } if (index + 1 > textPtr->numChars + 1) { |
︙ | ︙ | |||
1395 1396 1397 1398 1399 1400 1401 | } else if (idx > textPtr->numChars) { idx = textPtr->numChars; } *indexPtr = idx; return TCL_OK; } | | | 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 | } else if (idx > textPtr->numChars) { idx = textPtr->numChars; } *indexPtr = idx; return TCL_OK; } string = Tcl_GetStringFromObj(obj, &length); c = string[0]; if ((c == 'i') && (strncmp(string, "insert", length) == 0)) { *indexPtr = textPtr->insertPos; } else if ((c == 's') && (length >= 5) && (strncmp(string, "sel.first", length) == 0)) { |
︙ | ︙ | |||
1641 1642 1643 1644 1645 1646 1647 | if (stipple != None) { Tcl_ResetResult(interp); Tk_CanvasPsStipple(interp, canvas, stipple); Tcl_AppendPrintfToObj(psObj, "/StippleText {\n %s} bind def\n", Tcl_GetString(Tcl_GetObjResult(interp))); } | < | < > | 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 | if (stipple != None) { Tcl_ResetResult(interp); Tk_CanvasPsStipple(interp, canvas, stipple); Tcl_AppendPrintfToObj(psObj, "/StippleText {\n %s} bind def\n", Tcl_GetString(Tcl_GetObjResult(interp))); } switch (textPtr->anchor) { case TK_ANCHOR_NW: x = 0; y = 0; break; case TK_ANCHOR_N: x = 1; y = 0; break; case TK_ANCHOR_NE: x = 2; y = 0; break; case TK_ANCHOR_E: x = 2; y = 1; break; case TK_ANCHOR_SE: x = 2; y = 2; break; case TK_ANCHOR_S: x = 1; y = 2; break; case TK_ANCHOR_SW: x = 0; y = 2; break; case TK_ANCHOR_W: x = 0; y = 1; break; default: x = 1; y = 1; break; } switch (textPtr->justify) { case TK_JUSTIFY_CENTER: justify = "0.5"; break; case TK_JUSTIFY_RIGHT: justify = "1"; break; default: justify = "0"; break; } Tk_GetFontMetrics(textPtr->tkfont, &fm); Tcl_AppendPrintfToObj(psObj, "%.15g %.15g %.15g [\n", textPtr->angle, textPtr->x, Tk_CanvasPsY(canvas, textPtr->y)); Tcl_ResetResult(interp); |
︙ | ︙ |
Changes to generic/tkCanvUtil.c.
1 2 3 4 5 6 | /* * tkCanvUtil.c -- * * This file contains a collection of utility functions used by the * implementations of various canvas item types. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkCanvUtil.c -- * * This file contains a collection of utility functions used by the * implementations of various canvas item types. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
407 408 409 410 411 412 413 | Tcl_Interp *interp, /* Used for reporting errors. */ Tk_Window tkwin, /* Window containing canvas widget. */ const char *value, /* Value of option (list of tag names). */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset) /* Offset into item (ignored). */ { Tk_Item *itemPtr = (Tk_Item *) widgRec; | | | | | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | Tcl_Interp *interp, /* Used for reporting errors. */ Tk_Window tkwin, /* Window containing canvas widget. */ const char *value, /* Value of option (list of tag names). */ char *widgRec, /* Pointer to record for item. */ TkSizeT offset) /* Offset into item (ignored). */ { Tk_Item *itemPtr = (Tk_Item *) widgRec; TkSizeT argc, i; const char **argv; Tk_Uid *newPtr; (void)dummy; (void)tkwin; (void)offset; /* * Break the value up into the individual tag names. */ if (Tcl_SplitList(interp, value, &argc, &argv) != TCL_OK) { return TCL_ERROR; } /* * Make sure that there's enough space in the item to hold the tag names. */ if (itemPtr->tagSpace < argc) { newPtr = (Tk_Uid *)ckalloc(argc * sizeof(Tk_Uid)); for (i = itemPtr->numTags - 1; i != TCL_INDEX_NONE; i--) { newPtr[i] = itemPtr->tagPtr[i]; } if (itemPtr->tagPtr != itemPtr->staticTagSpace) { ckfree(itemPtr->tagPtr); } itemPtr->tagPtr = newPtr; itemPtr->tagSpace = argc; |
︙ | ︙ | |||
770 771 772 773 774 775 776 | */ if (methods == NULL) { methods = InitSmoothMethods(interp); } /* | | | 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 | */ if (methods == NULL) { methods = InitSmoothMethods(interp); } /* * Backward compatibility hack. */ if (strncmp(value, "bezier", length) == 0) { smooth = &tkBezierSmoothMethod; } /* |
︙ | ︙ |
Changes to generic/tkCanvWind.c.
1 2 3 4 5 | /* * tkCanvWind.c -- * * This file implements window items for canvas widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkCanvWind.c -- * * This file implements window items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
514 515 516 517 518 519 520 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; | | | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; default: x -= width/2; y -= height/2; break; } /* * Store the information in the item header. |
︙ | ︙ | |||
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | (void)regionY; (void)regionWidth; (void)regionHeight; if (winItemPtr->tkwin == NULL) { return; } if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } /* * A drawable of None is used by the canvas UnmapNotify handler * to indicate that we should no longer display ourselves. */ if (state == TK_STATE_HIDDEN || drawable == None) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } return; } Tk_CanvasWindowCoords(canvas, (double) winItemPtr->header.x1, (double) winItemPtr->header.y1, &x, &y); width = winItemPtr->header.x2 - winItemPtr->header.x1; height = winItemPtr->header.y2 - winItemPtr->header.y1; | > > > > | 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | (void)regionY; (void)regionWidth; (void)regionHeight; if (winItemPtr->tkwin == NULL) { return; } Tcl_Preserve(canvas); if (state == TK_STATE_NULL) { state = Canvas(canvas)->canvas_state; } /* * A drawable of None is used by the canvas UnmapNotify handler * to indicate that we should no longer display ourselves. */ if (state == TK_STATE_HIDDEN || drawable == None) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } Tcl_Release(canvas); return; } Tk_CanvasWindowCoords(canvas, (double) winItemPtr->header.x1, (double) winItemPtr->header.y1, &x, &y); width = winItemPtr->header.x2 - winItemPtr->header.x1; height = winItemPtr->header.y2 - winItemPtr->header.y1; |
︙ | ︙ | |||
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | if (((x + width) <= 0) || ((y + height) <= 0) || (x >= Tk_Width(canvasTkwin)) || (y >= Tk_Height(canvasTkwin))) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } return; } /* * Reposition and map the window (but in different ways depending on * whether the canvas is the window's parent). */ if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { if ((x != Tk_X(winItemPtr->tkwin)) || (y != Tk_Y(winItemPtr->tkwin)) || (width != Tk_Width(winItemPtr->tkwin)) || (height != Tk_Height(winItemPtr->tkwin))) { Tk_MoveResizeWindow(winItemPtr->tkwin, x, y, width, height); } | > > > | > > > | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 | if (((x + width) <= 0) || ((y + height) <= 0) || (x >= Tk_Width(canvasTkwin)) || (y >= Tk_Height(canvasTkwin))) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin); } Tcl_Release(canvas); return; } /* * Reposition and map the window (but in different ways depending on * whether the canvas is the window's parent). */ if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { if ((x != Tk_X(winItemPtr->tkwin)) || (y != Tk_Y(winItemPtr->tkwin)) || (width != Tk_Width(winItemPtr->tkwin)) || (height != Tk_Height(winItemPtr->tkwin))) { Tk_MoveResizeWindow(winItemPtr->tkwin, x, y, width, height); } if (winItemPtr->tkwin) { Tk_MapWindow(winItemPtr->tkwin); } } else { Tk_MaintainGeometry(winItemPtr->tkwin, canvasTkwin, x, y, width, height); } Tcl_Release(canvas); } /* *-------------------------------------------------------------- * * WinItemToPoint -- * |
︙ | ︙ | |||
822 823 824 825 826 827 828 | case TK_ANCHOR_N: x -= width/2.0; y -= height; break; case TK_ANCHOR_NE: x -= width; y -= height; break; case TK_ANCHOR_E: x -= width; y -= height/2.0; break; case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; | | | 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | case TK_ANCHOR_N: x -= width/2.0; y -= height; break; case TK_ANCHOR_NE: x -= width; y -= height; break; case TK_ANCHOR_E: x -= width; y -= height/2.0; break; case TK_ANCHOR_SE: x -= width; break; case TK_ANCHOR_S: x -= width/2.0; break; case TK_ANCHOR_SW: break; case TK_ANCHOR_W: y -= height/2.0; break; default: x -= width/2.0; y -= height/2.0; break; } return CanvasPsWindow(interp, tkwin, canvas, x, y, width, height); } static int CanvasPsWindow( |
︙ | ︙ |
Changes to generic/tkCanvas.c.
1 2 3 4 5 6 7 | /* * tkCanvas.c -- * * 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. * | | | | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * tkCanvas.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkCanvas.h" #include "default.h" #include "tkPort.h" #ifdef MAC_OSX_TK #include "tkMacOSXInt.h" #endif /* * See tkCanvas.h for key data structures used to implement canvases. */ /* * The structure defined below is used to keep track of a tag search in |
︙ | ︙ | |||
212 213 214 215 216 217 218 | static Tcl_ThreadDataKey dataKey; static SearchUids * GetStaticUids(void); /* * Prototypes for functions defined later in this file: */ | | | | | | | | | | | | | | | | | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | static Tcl_ThreadDataKey dataKey; static SearchUids * GetStaticUids(void); /* * Prototypes for functions defined later in this file: */ static void CanvasBindProc(void *clientData, XEvent *eventPtr); static void CanvasBlinkProc(void *clientData); static void CanvasCmdDeletedProc(void *clientData); static void CanvasDoEvent(TkCanvas *canvasPtr, XEvent *eventPtr); static void CanvasEventProc(void *clientData, XEvent *eventPtr); static TkSizeT CanvasFetchSelection(void *clientData, TkSizeT offset, char *buffer, TkSizeT maxBytes); static Tk_Item * CanvasFindClosest(TkCanvas *canvasPtr, double coords[2]); static void CanvasFocusProc(TkCanvas *canvasPtr, int gotFocus); static void CanvasLostSelection(void *clientData); static void CanvasSelectTo(TkCanvas *canvasPtr, Tk_Item *itemPtr, TkSizeT index); static void CanvasSetOrigin(TkCanvas *canvasPtr, int xOrigin, int yOrigin); static void CanvasUpdateScrollbars(TkCanvas *canvasPtr); static int CanvasWidgetCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv); static void CanvasWorldChanged(void *instanceData); static int ConfigureCanvas(Tcl_Interp *interp, TkCanvas *canvasPtr, int objc, Tcl_Obj *const *objv, int flags); static void DefaultRotateImplementation(TkCanvas *canvasPtr, Tk_Item *itemPtr, double x, double y, double angleRadians); static void DestroyCanvas(void *memPtr); static int DrawCanvas(Tcl_Interp *interp, void *clientData, Tk_PhotoHandle photohandle, int subsample, int zoom); static void DisplayCanvas(void *clientData); static void DoItem(Tcl_Obj *accumObj, Tk_Item *itemPtr, Tk_Uid tag); static void EventuallyRedrawItem(TkCanvas *canvasPtr, Tk_Item *itemPtr); static int FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr, int objc, Tcl_Obj *const *objv, Tcl_Obj *newTagObj, int first, TagSearch **searchPtrPtr); static int FindArea(Tcl_Interp *interp, TkCanvas *canvasPtr, Tcl_Obj *const *objv, Tk_Uid uid, int enclosed); static double GridAlign(double coord, double spacing); static const char** TkGetStringsFromObjs(int objc, Tcl_Obj *const *objv); static void InitCanvas(void); static void PickCurrentItem(TkCanvas *canvasPtr, XEvent *eventPtr); static Tcl_Obj * ScrollFractions(int screen1, int screen2, int object1, int object2); static int RelinkItems(TkCanvas *canvasPtr, Tcl_Obj *tag, Tk_Item *prevPtr, TagSearch **searchPtrPtr); static void TagSearchExprInit(TagSearchExpr **exprPtrPtr); |
︙ | ︙ | |||
595 596 597 598 599 600 601 | DefaultRotateImplementation( TkCanvas *canvasPtr, Tk_Item *itemPtr, double x, double y, double angleRadians) { | > | | 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | DefaultRotateImplementation( TkCanvas *canvasPtr, Tk_Item *itemPtr, double x, double y, double angleRadians) { TkSizeT i, objc; int ok = 1; Tcl_Obj **objv, **newObjv; double *coordv; double s = sin(angleRadians); double c = cos(angleRadians); Tcl_Interp *interp = canvasPtr->interp; /* |
︙ | ︙ | |||
675 676 677 678 679 680 681 | * See the user documentation. * *-------------------------------------------------------------- */ int Tk_CanvasObjCmd( | | | | | | | | 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | * See the user documentation. * *-------------------------------------------------------------- */ int Tk_CanvasObjCmd( void *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 = (Tk_Window)clientData; TkCanvas *canvasPtr; Tk_Window newWin; if (typeList == NULL) { InitCanvas(); } if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?"); return TCL_ERROR; } newWin = Tk_CreateWindowFromPath(interp,tkwin,Tcl_GetString(objv[1]),NULL); if (newWin == NULL) { return TCL_ERROR; } /* * Initialize fields that won't be initialized by ConfigureCanvas, or * which ConfigureCanvas expects to have reasonable values (e.g. resource |
︙ | ︙ | |||
791 792 793 794 795 796 797 | CanvasEventProc, canvasPtr); Tk_CreateEventHandler(canvasPtr->tkwin, KeyPressMask|KeyReleaseMask |ButtonPressMask|ButtonReleaseMask|EnterWindowMask |LeaveWindowMask|PointerMotionMask|VirtualEventMask, CanvasBindProc, canvasPtr); Tk_CreateSelHandler(canvasPtr->tkwin, XA_PRIMARY, XA_STRING, CanvasFetchSelection, canvasPtr, XA_STRING); | | | 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | CanvasEventProc, canvasPtr); Tk_CreateEventHandler(canvasPtr->tkwin, KeyPressMask|KeyReleaseMask |ButtonPressMask|ButtonReleaseMask|EnterWindowMask |LeaveWindowMask|PointerMotionMask|VirtualEventMask, CanvasBindProc, canvasPtr); Tk_CreateSelHandler(canvasPtr->tkwin, XA_PRIMARY, XA_STRING, CanvasFetchSelection, canvasPtr, XA_STRING); if (ConfigureCanvas(interp, canvasPtr, objc-2, objv+2, 0) != TCL_OK) { goto error; } Tcl_SetObjResult(interp, Tk_NewWindowObj(canvasPtr->tkwin)); return TCL_OK; error: |
︙ | ︙ | |||
823 824 825 826 827 828 829 | * See the user documentation. * *-------------------------------------------------------------- */ static int CanvasWidgetCmd( | | | 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 | * See the user documentation. * *-------------------------------------------------------------- */ static int CanvasWidgetCmd( void *clientData, /* Information about canvas widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; int c, result; Tk_Item *itemPtr = NULL; /* Initialization needed only to prevent |
︙ | ︙ | |||
1253 1254 1255 1256 1257 1258 1259 | TkSizeT length; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?"); result = TCL_ERROR; goto done; } | | | 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 | TkSizeT length; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?"); result = TCL_ERROR; goto done; } 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 * impossible. */ |
︙ | ︙ | |||
1438 1439 1440 1441 1442 1443 1444 | } } } break; } case CANV_DTAG: { Tk_Uid tag; | | | | 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | } } } break; } case CANV_DTAG: { Tk_Uid tag; TkSizeT i; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?tagToDelete?"); result = TCL_ERROR; goto done; } if (objc == 4) { tag = Tk_GetUid(Tcl_GetString(objv[3])); } else { tag = Tk_GetUid(Tcl_GetString(objv[2])); } FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) { for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) { if (itemPtr->tagPtr[i] == tag) { /* * Don't shuffle the tags sequence: memmove the tags. */ memmove((void *)(itemPtr->tagPtr + i), |
︙ | ︙ | |||
1914 1915 1916 1917 1918 1919 1920 | canvasPtr->flags |= REPICK_NEEDED; } break; } case CANV_SCAN: { int x, y, gain = 10; static const char *const optionStrings[] = { | | | | | | 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 | canvasPtr->flags |= REPICK_NEEDED; } break; } case CANV_SCAN: { int x, y, gain = 10; static const char *const optionStrings[] = { "dragto", "mark", NULL }; 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, &idx) != TCL_OK) { result = TCL_ERROR; } else if ((objc != 5) && (objc + idx != 6)) { Tcl_WrongNumArgs(interp, 3, objv, idx?"x y":"x y ?gain?"); 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 (idx) { canvasPtr->scanX = x; canvasPtr->scanXOrigin = canvasPtr->xOrigin; canvasPtr->scanY = y; canvasPtr->scanYOrigin = canvasPtr->yOrigin; } else { int newXOrigin, newYOrigin, tmp; |
︙ | ︙ | |||
2379 2380 2381 2382 2383 2384 2385 | */ canvasPtr->scrollX1 = 0; canvasPtr->scrollY1 = 0; canvasPtr->scrollX2 = 0; canvasPtr->scrollY2 = 0; if (canvasPtr->regionString != NULL) { | | | 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 | */ canvasPtr->scrollX1 = 0; canvasPtr->scrollY1 = 0; canvasPtr->scrollX2 = 0; canvasPtr->scrollY2 = 0; if (canvasPtr->regionString != NULL) { TkSizeT argc2; const char **argv2; if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString, &argc2, &argv2) != TCL_OK) { return TCL_ERROR; } if (argc2 != 4) { |
︙ | ︙ | |||
2461 2462 2463 2464 2465 2466 2467 | * to be redisplayed. * *---------------------------------------------------------------------- */ static void CanvasWorldChanged( | | | 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 | * to be redisplayed. * *---------------------------------------------------------------------- */ static void CanvasWorldChanged( void *instanceData) /* Information about widget. */ { TkCanvas *canvasPtr = (TkCanvas *)instanceData; Tk_Item *itemPtr; itemPtr = canvasPtr->firstItemPtr; for ( ; itemPtr != NULL; itemPtr = itemPtr->nextPtr) { if (ItemConfigure(canvasPtr, itemPtr, 0, NULL) != TCL_OK) { |
︙ | ︙ | |||
2571 2572 2573 2574 2575 2576 2577 | #define BYTE_SWAP16(n) ((((unsigned short)n)>>8) | (((unsigned short)n)<<8)) #define BYTE_SWAP32(n) (((n>>24)&0x000000FF) | ((n<<8)&0x00FF0000) | ((n>>8)&0x0000FF00) | ((n<<24)&0xFF000000)) static int DrawCanvas( Tcl_Interp *interp, /* As passed to the widget command, and we will leave errors here */ | | | 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 | #define BYTE_SWAP16(n) ((((unsigned short)n)>>8) | (((unsigned short)n)<<8)) #define BYTE_SWAP32(n) (((n>>24)&0x000000FF) | ((n<<8)&0x00FF0000) | ((n>>8)&0x0000FF00) | ((n<<24)&0xFF000000)) static int DrawCanvas( Tcl_Interp *interp, /* As passed to the widget command, and we will leave errors here */ void *clientData, Tk_PhotoHandle photohandle, /* The photo we are rendering into */ int subsample, /* If either subsample or zoom are not 1 then we call Tk_PhotoPutZoomedBlock() */ int zoom) { TkCanvas *canvasPtr = (TkCanvas *)clientData; Tk_Window tkwin; Display *displayPtr; |
︙ | ︙ | |||
2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 | * use memcpy() instead of the slow pixel or line copy. */ blockPtr.width = cWidth; blockPtr.height = cHeight; blockPtr.pixelSize = 4; blockPtr.pitch = blockPtr.pixelSize * blockPtr.width; blockPtr.offset[0] = 0; blockPtr.offset[1] = 1; blockPtr.offset[2] = 2; blockPtr.offset[3] = 3; blockPtr.pixelPtr = (unsigned char *)ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width); /* * Now convert the image data pixel by pixel from XImage to 32bit RGBA * format suitable for Tk_PhotoPutBlock(). */ | > > > > > > > > > | 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 | * use memcpy() instead of the slow pixel or line copy. */ blockPtr.width = cWidth; blockPtr.height = cHeight; blockPtr.pixelSize = 4; blockPtr.pitch = blockPtr.pixelSize * blockPtr.width; #ifdef TK_XGETIMAGE_USES_ABGR32 blockPtr.offset[0] = 1; blockPtr.offset[1] = 2; blockPtr.offset[2] = 3; blockPtr.offset[3] = 0; #else blockPtr.offset[0] = 0; blockPtr.offset[1] = 1; blockPtr.offset[2] = 2; blockPtr.offset[3] = 3; #endif blockPtr.pixelPtr = (unsigned char *)ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width); /* * Now convert the image data pixel by pixel from XImage to 32bit RGBA * format suitable for Tk_PhotoPutBlock(). */ |
︙ | ︙ | |||
2844 2845 2846 2847 2848 2849 2850 | #ifdef DEBUG_DRAWCANVAS Tcl_AppendResult(interp, " {", NULL); #endif for(x = 0; x < blockPtr.width; ++x) { unsigned int pixel = 0; | | | 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 | #ifdef DEBUG_DRAWCANVAS Tcl_AppendResult(interp, " {", NULL); #endif for(x = 0; x < blockPtr.width; ++x) { unsigned int pixel = 0; int pixel_offset = blockPtr.pitch * y + blockPtr.pixelSize * x; switch (ximagePtr->bits_per_pixel) { /* * Get an 8 bit pixel from the XImage. */ case 8 : |
︙ | ︙ | |||
2897 2898 2899 2900 2901 2902 2903 | * quad. However the visual mask is a 32bit ABGR quad. And * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad. * If the visual mask was correct there would be no need to * swap anything here. */ #ifdef _WIN32 | | > | > | > | > > > > > > | > > > > > > > > | | | | > > > > > > > | 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 | * quad. However the visual mask is a 32bit ABGR quad. And * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad. * If the visual mask was correct there would be no need to * swap anything here. */ #ifdef _WIN32 #define R_OFFSET blockPtr.offset[2] #define G_OFFSET blockPtr.offset[1] #define B_OFFSET blockPtr.offset[0] #define A_OFFSET blockPtr.offset[3] #else #define R_OFFSET blockPtr.offset[0] #define G_OFFSET blockPtr.offset[1] #define B_OFFSET blockPtr.offset[2] #define A_OFFSET blockPtr.offset[3] #endif #ifdef TK_XGETIMAGE_USES_ABGR32 #define COPY_PIXEL (ximagePtr->bits_per_pixel == 32) #else #define COPY_PIXEL 0 #endif if (COPY_PIXEL) { /* * This platform packs pixels in RGBA byte order, as expected * by Tk_PhotoPutBlock() so we can just copy the pixel as an int. */ *((unsigned int *) (blockPtr.pixelPtr + pixel_offset)) = pixel; } else { blockPtr.pixelPtr[pixel_offset + R_OFFSET] = (unsigned char)((pixel & visualPtr->red_mask) >> rshift); blockPtr.pixelPtr[pixel_offset + G_OFFSET] = (unsigned char)((pixel & visualPtr->green_mask) >> gshift); blockPtr.pixelPtr[pixel_offset + B_OFFSET] = (unsigned char)((pixel & visualPtr->blue_mask) >> bshift); blockPtr.pixelPtr[pixel_offset + A_OFFSET] = 0xFF; } #ifdef DEBUG_DRAWCANVAS fprintf(stderr, "Converted pixel %x to %hhx %hhx %hhx %hhx \n", pixel, blockPtr.pixelPtr[pixel_offset + 0], blockPtr.pixelPtr[pixel_offset + 1], blockPtr.pixelPtr[pixel_offset + 2], blockPtr.pixelPtr[pixel_offset + 3]); { int ix; if (x > 0) Tcl_AppendResult(interp, "-", NULL); for (ix = 0; ix < 4; ++ix) { if (ix > 0) Tcl_AppendResult(interp, " ", NULL); |
︙ | ︙ | |||
2993 2994 2995 2996 2997 2998 2999 | * Information appears on the screen. * *---------------------------------------------------------------------- */ static void DisplayCanvas( | | > > > > | | | 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 | * Information appears on the screen. * *---------------------------------------------------------------------- */ static void DisplayCanvas( void *clientData) /* Information about widget. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; Tk_Window tkwin = canvasPtr->tkwin; Tk_Item *itemPtr; Pixmap pixmap; int screenX1, screenX2, screenY1, screenY2, width, height; #ifdef MAC_OSX_TK TkWindow *winPtr; MacDrawable *macWin; #endif if (canvasPtr->tkwin == NULL) { return; } if (!Tk_IsMapped(tkwin)) { goto done; } #ifdef MAC_OSX_TK /* * If drawing is disabled, all we need to do is * clear the REDRAW_PENDING flag. */ winPtr = (TkWindow *)(canvasPtr->tkwin); macWin = winPtr->privatePtr; if (macWin && (macWin->flags & TK_DO_NOT_DRAW)){ canvasPtr->flags &= ~REDRAW_PENDING; return; } #endif /* |
︙ | ︙ | |||
3122 3123 3124 3125 3126 3127 3128 | (screenX2 + 30 - canvasPtr->drawableXOrigin), (screenY2 + 30 - canvasPtr->drawableYOrigin), Tk_Depth(tkwin)); #else canvasPtr->drawableXOrigin = canvasPtr->xOrigin; canvasPtr->drawableYOrigin = canvasPtr->yOrigin; pixmap = Tk_WindowId(tkwin); | | | 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 | (screenX2 + 30 - canvasPtr->drawableXOrigin), (screenY2 + 30 - canvasPtr->drawableYOrigin), Tk_Depth(tkwin)); #else canvasPtr->drawableXOrigin = canvasPtr->xOrigin; canvasPtr->drawableYOrigin = canvasPtr->yOrigin; pixmap = Tk_WindowId(tkwin); Tk_ClipDrawableToRect(Tk_Display(tkwin), pixmap, screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin, width, height); #endif /* TK_NO_DOUBLE_BUFFERING */ /* * Clear the area to be redrawn. */ |
︙ | ︙ | |||
3181 3182 3183 3184 3185 3186 3187 | canvasPtr->pixmapGC, screenX1 - canvasPtr->drawableXOrigin, screenY1 - canvasPtr->drawableYOrigin, (unsigned int) width, (unsigned int) height, screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin); Tk_FreePixmap(Tk_Display(tkwin), pixmap); #else | | | 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 | canvasPtr->pixmapGC, screenX1 - canvasPtr->drawableXOrigin, screenY1 - canvasPtr->drawableYOrigin, (unsigned int) width, (unsigned int) height, screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin); Tk_FreePixmap(Tk_Display(tkwin), pixmap); #else Tk_ClipDrawableToRect(Tk_Display(tkwin), pixmap, 0, 0, -1, -1); #endif /* TK_NO_DOUBLE_BUFFERING */ } /* * Draw the window borders, if needed. */ |
︙ | ︙ | |||
3208 3209 3210 3211 3212 3213 3214 | GC fgGC, bgGC; bgGC = Tk_GCForColor(canvasPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (canvasPtr->textInfo.gotFocus) { fgGC = Tk_GCForColor(canvasPtr->highlightColorPtr, Tk_WindowId(tkwin)); | | | | 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 | GC fgGC, bgGC; bgGC = Tk_GCForColor(canvasPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (canvasPtr->textInfo.gotFocus) { fgGC = Tk_GCForColor(canvasPtr->highlightColorPtr, Tk_WindowId(tkwin)); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, canvasPtr->highlightWidth, Tk_WindowId(tkwin)); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, canvasPtr->highlightWidth, Tk_WindowId(tkwin)); } } } done: canvasPtr->flags &= ~(REDRAW_PENDING|BBOX_NOT_EMPTY); |
︙ | ︙ | |||
3246 3247 3248 3249 3250 3251 3252 | * it gets exposed, it is redisplayed. * *---------------------------------------------------------------------- */ static void CanvasEventProc( | | | 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 | * it gets exposed, it is redisplayed. * *---------------------------------------------------------------------- */ static void CanvasEventProc( void *clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; if (eventPtr->type == Expose) { int x, y; |
︙ | ︙ | |||
3337 3338 3339 3340 3341 3342 3343 | * The widget is destroyed. * *---------------------------------------------------------------------- */ static void CanvasCmdDeletedProc( | | | 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 | * The widget is destroyed. * *---------------------------------------------------------------------- */ static void CanvasCmdDeletedProc( void *clientData) /* Pointer to widget record for widget. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; Tk_Window tkwin = canvasPtr->tkwin; /* * This function could be invoked either because the window was destroyed * and the command was then deleted (in which case tkwin is NULL) or |
︙ | ︙ | |||
4591 4592 4593 4594 4595 4596 4597 | */ if (itemPtr->tagSpace == itemPtr->numTags) { Tk_Uid *newTagPtr; itemPtr->tagSpace += 5; newTagPtr = (Tk_Uid *)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid)); | | | 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 | */ if (itemPtr->tagSpace == itemPtr->numTags) { Tk_Uid *newTagPtr; itemPtr->tagSpace += 5; newTagPtr = (Tk_Uid *)ckalloc(itemPtr->tagSpace * sizeof(Tk_Uid)); memcpy(newTagPtr, itemPtr->tagPtr, itemPtr->numTags * sizeof(Tk_Uid)); if (itemPtr->tagPtr != itemPtr->staticTagSpace) { ckfree(itemPtr->tagPtr); } itemPtr->tagPtr = newTagPtr; tagPtr = &itemPtr->tagPtr[itemPtr->numTags]; } |
︙ | ︙ | |||
5072 5073 5074 5075 5076 5077 5078 | * any). * *-------------------------------------------------------------- */ static void CanvasBindProc( | | | 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 | * any). * *-------------------------------------------------------------- */ static void CanvasBindProc( void *clientData, /* Pointer to canvas structure. */ XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; unsigned mask; Tcl_Preserve(canvasPtr); |
︙ | ︙ | |||
5273 5274 5275 5276 5277 5278 5279 | */ if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr) && (canvasPtr->currentItemPtr != NULL) && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) { XEvent event; Tk_Item *itemPtr = canvasPtr->currentItemPtr; | | | 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 | */ if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr) && (canvasPtr->currentItemPtr != NULL) && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) { XEvent event; Tk_Item *itemPtr = canvasPtr->currentItemPtr; TkSizeT i; event = canvasPtr->pickEvent; event.type = LeaveNotify; /* * If the event's detail happens to be NotifyInferior the binding * mechanism will discard the event. To be consistent, always use |
︙ | ︙ | |||
5295 5296 5297 5298 5299 5300 5301 | /* * The check below is needed because there could be an event handler * for <LeaveNotify> that deletes the current item. */ if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) { | | | 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 | /* * The check below is needed because there could be an event handler * for <LeaveNotify> that deletes the current item. */ if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) { for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) { if (itemPtr->tagPtr[i] == searchUids->currentUid) /* then */ { memmove((void *)(itemPtr->tagPtr + i), itemPtr->tagPtr + i + 1, (itemPtr->numTags - (i+1)) * sizeof(Tk_Uid)); itemPtr->numTags--; break; |
︙ | ︙ | |||
5431 5432 5433 5434 5435 5436 5437 | TkCanvas *canvasPtr, /* Canvas widget in which event occurred. */ XEvent *eventPtr) /* Real or simulated X event that is to be * processed. */ { #define NUM_STATIC 3 void *staticObjects[NUM_STATIC]; void **objectPtr; | | | 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 | TkCanvas *canvasPtr, /* Canvas widget in which event occurred. */ XEvent *eventPtr) /* Real or simulated X event that is to be * processed. */ { #define NUM_STATIC 3 void *staticObjects[NUM_STATIC]; void **objectPtr; TkSizeT numObjects, i; Tk_Item *itemPtr; TagSearchExpr *expr; int numExprs; SearchUids *searchUids = GetStaticUids(); if (canvasPtr->bindingTable == NULL) { return; |
︙ | ︙ | |||
5483 5484 5485 5486 5487 5488 5489 | numObjects = itemPtr->numTags + numExprs + 2; if (numObjects <= NUM_STATIC) { objectPtr = staticObjects; } else { objectPtr = (void **)ckalloc(numObjects * sizeof(void *)); } objectPtr[0] = (char *)searchUids->allUid; | | | 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 | numObjects = itemPtr->numTags + numExprs + 2; if (numObjects <= NUM_STATIC) { objectPtr = staticObjects; } else { objectPtr = (void **)ckalloc(numObjects * sizeof(void *)); } objectPtr[0] = (char *)searchUids->allUid; for (i = itemPtr->numTags - 1; i != TCL_INDEX_NONE; i--) { objectPtr[i+1] = (char *)itemPtr->tagPtr[i]; } objectPtr[itemPtr->numTags + 1] = itemPtr; /* * Copy uids of matching expressions into object array */ |
︙ | ︙ | |||
5535 5536 5537 5538 5539 5540 5541 | * function reschedules itself. * *---------------------------------------------------------------------- */ static void CanvasBlinkProc( | | | 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 | * function reschedules itself. * *---------------------------------------------------------------------- */ static void CanvasBlinkProc( void *clientData) /* Pointer to record describing entry. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; if (!canvasPtr->textInfo.gotFocus || (canvasPtr->insertOffTime == 0)) { return; } if (canvasPtr->textInfo.cursorOn) { |
︙ | ︙ | |||
5685 5686 5687 5688 5689 5690 5691 | * None. * *-------------------------------------------------------------- */ static TkSizeT CanvasFetchSelection( | | | 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 | * None. * *-------------------------------------------------------------- */ static TkSizeT CanvasFetchSelection( void *clientData, /* Information about canvas widget. */ TkSizeT offset, /* 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, * not including terminating NULL * character. */ { |
︙ | ︙ | |||
5719 5720 5721 5722 5723 5724 5725 | * not containing a selection. * *---------------------------------------------------------------------- */ static void CanvasLostSelection( | | | 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 | * not containing a selection. * *---------------------------------------------------------------------- */ static void CanvasLostSelection( void *clientData) /* Information about entry widget. */ { TkCanvas *canvasPtr = (TkCanvas *)clientData; EventuallyRedrawItem(canvasPtr, canvasPtr->textInfo.selItemPtr); canvasPtr->textInfo.selItemPtr = NULL; } |
︙ | ︙ |
Changes to generic/tkCanvas.h.
1 2 3 4 5 | /* * tkCanvas.h -- * * Declarations shared among all the files that implement canvas widgets. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkCanvas.h -- * * Declarations shared among all the files that implement canvas widgets. * * 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. */ #ifndef _TKCANVAS #define _TKCANVAS |
︙ | ︙ |
Changes to generic/tkClipboard.c.
1 2 3 4 5 6 7 | /* * tkClipboard.c -- * * This file manages the clipboard for the Tk toolkit, maintaining a * collection of data buffers that will be supplied on demand to * requesting applications. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkClipboard.c -- * * 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 © 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 "tkSelect.h" |
︙ | ︙ | |||
450 451 452 453 454 455 456 | "-displayof", "-format", "-type", NULL }; enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE }; int subIndex; TkSizeT length; for (i = 2; i < objc - 1; i++) { | | | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | "-displayof", "-format", "-type", NULL }; enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE }; int subIndex; TkSizeT length; for (i = 2; i < objc - 1; i++) { string = Tcl_GetStringFromObj(objv[i], &length); if (string[0] != '-') { break; } /* * If the argument is "--", it signifies the end of arguments. */ |
︙ | ︙ | |||
705 706 707 708 709 710 711 | ClipboardGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { | > > > > | > > | 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | ClipboardGetProc( ClientData clientData, /* Dynamic string holding partially assembled * selection. */ TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not * used). */ const char *portion) /* New information to be appended. */ { Tcl_Encoding utf8 = Tcl_GetEncoding(NULL, "utf-8"); Tcl_DString ds; (void)Tcl_ExternalToUtfDStringEx(utf8, portion, -1, TCL_ENCODING_NOCOMPLAIN, &ds); Tcl_DStringAppend((Tcl_DString *) clientData, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); Tcl_FreeEncoding(utf8); return TCL_OK; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkCmds.c.
1 2 3 4 5 6 | /* * tkCmds.c -- * * This file contains a collection of Tk-related Tcl commands that didn't * fit in any particular file of the toolkit. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkCmds.c -- * * This file contains a collection of Tk-related Tcl commands that didn't * fit in any particular file of the toolkit. * * 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. */ #include "tkInt.h" |
︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #endif /* * Table of tk subcommand names and implementations. */ static const TkEnsemble tkCmdMap[] = { {"appname", AppnameCmd, NULL }, {"busy", Tk_BusyObjCmd, NULL }, {"caret", CaretCmd, NULL }, {"inactive", InactiveCmd, NULL }, {"scaling", ScalingCmd, NULL }, {"useinputmethods", UseinputmethodsCmd, NULL }, {"windowingsystem", WindowingsystemCmd, NULL }, | > < | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #endif /* * Table of tk subcommand names and implementations. */ static const TkEnsemble tkCmdMap[] = { {"fontchooser", NULL, tkFontchooserEnsemble}, {"appname", AppnameCmd, NULL }, {"busy", Tk_BusyObjCmd, NULL }, {"caret", CaretCmd, NULL }, {"inactive", InactiveCmd, NULL }, {"scaling", ScalingCmd, NULL }, {"useinputmethods", UseinputmethodsCmd, NULL }, {"windowingsystem", WindowingsystemCmd, NULL }, {NULL, NULL, NULL} }; /* *---------------------------------------------------------------------- * * Tk_BellObjCmd -- |
︙ | ︙ | |||
181 182 183 184 185 186 187 | */ if (string[0] == '.') { winPtr = (TkWindow *) Tk_NameToWindow(interp, string, tkwin); if (winPtr == NULL) { return TCL_ERROR; } | | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | */ if (string[0] == '.') { winPtr = (TkWindow *) Tk_NameToWindow(interp, string, tkwin); if (winPtr == NULL) { return TCL_ERROR; } object = winPtr->pathName; } else { winPtr = (TkWindow *)clientData; object = (void *) Tk_GetUid(string); } /* * If there are four arguments, the command is modifying a binding. If * there are three arguments, the command is querying a binding. If there * are only two arguments, the command is querying all the bindings for * the given tag/window. |
︙ | ︙ | |||
263 264 265 266 267 268 269 | void TkBindEventProc( TkWindow *winPtr, /* Pointer to info about window. */ XEvent *eventPtr) /* Information about event. */ { #define MAX_OBJS 20 | | | | | | | | | | | 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | void TkBindEventProc( TkWindow *winPtr, /* Pointer to info about window. */ XEvent *eventPtr) /* Information about event. */ { #define MAX_OBJS 20 void *objects[MAX_OBJS], **objPtr; TkWindow *topLevPtr; TkSizeT i, count; char *p; Tcl_HashEntry *hPtr; if ((winPtr->mainPtr == NULL) || (winPtr->mainPtr->bindingTable == NULL)) { return; } objPtr = objects; if (winPtr->numTags != 0) { /* * Make a copy of the tags for the window, replacing window names with * pointers to the pathName from the appropriate window. */ if (winPtr->numTags > MAX_OBJS) { objPtr = (void **)ckalloc(winPtr->numTags * sizeof(void *)); } for (i = 0; i < winPtr->numTags; i++) { p = (char *)winPtr->tagPtr[i]; if (*p == '.') { hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, p); if (hPtr != NULL) { p = ((TkWindow *) Tcl_GetHashValue(hPtr))->pathName; } else { p = NULL; } } objPtr[i] = p; } count = winPtr->numTags; } else { objPtr[0] = winPtr->pathName; objPtr[1] = (void *)winPtr->classUid; for (topLevPtr = winPtr; (topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_HIERARCHY); topLevPtr = topLevPtr->parentPtr) { /* Empty loop body. */ } if ((winPtr != topLevPtr) && (topLevPtr != NULL)) { count = 4; objPtr[2] = topLevPtr->pathName; } else { count = 3; } objPtr[count-1] = (void *) Tk_GetUid("all"); } Tk_BindEvent(winPtr->mainPtr->bindingTable, eventPtr, (Tk_Window) winPtr, count, objPtr); if (objPtr != objects) { ckfree(objPtr); } } |
︙ | ︙ | |||
345 346 347 348 349 350 351 | 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 = (Tk_Window)clientData; TkWindow *winPtr, *winPtr2; | | | 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | 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 = (Tk_Window)clientData; TkWindow *winPtr, *winPtr2; TkSizeT i, length; const char *p; Tcl_Obj *listPtr, **tags; if ((objc < 2) || (objc > 3)) { Tcl_WrongNumArgs(interp, 1, objv, "window ?taglist?"); return TCL_ERROR; } |
︙ | ︙ | |||
396 397 398 399 400 401 402 | } if (length == 0) { return TCL_OK; } winPtr->numTags = length; winPtr->tagPtr = (void **)ckalloc(length * sizeof(void *)); | | | | | 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | } if (length == 0) { return TCL_OK; } winPtr->numTags = length; winPtr->tagPtr = (void **)ckalloc(length * sizeof(void *)); for (i = 0; i < (TkSizeT)length; i++) { p = Tcl_GetString(tags[i]); if (p[0] == '.') { char *copy; /* * Handle names starting with "." specially: store a malloc'ed * string, rather than a Uid; at event time we'll look up the name * in the window table and use the corresponding window, if there * is one. */ copy = (char *)ckalloc(strlen(p) + 1); strcpy(copy, p); winPtr->tagPtr[i] = copy; } else { winPtr->tagPtr[i] = (void *)Tk_GetUid(p); } } return TCL_OK; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
440 441 442 443 444 445 446 | *---------------------------------------------------------------------- */ void TkFreeBindingTags( TkWindow *winPtr) /* Window whose tags are to be released. */ { | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | *---------------------------------------------------------------------- */ void TkFreeBindingTags( TkWindow *winPtr) /* Window whose tags are to be released. */ { TkSizeT i; const char *p; for (i = 0; i < winPtr->numTags; i++) { p = (const char *)winPtr->tagPtr[i]; if (*p == '.') { /* * Names starting with "." are malloced rather than Uids, so they |
︙ | ︙ | |||
645 646 647 648 649 650 651 | */ int TkInitTkCmd( Tcl_Interp *interp, ClientData clientData) { | > > | > | > | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | */ int TkInitTkCmd( Tcl_Interp *interp, ClientData clientData) { /* If the interp is safe, leave out "fontchooser" */ int isSafe = Tcl_IsSafe(interp); TkMakeEnsemble(interp, "::", "tk", clientData, tkCmdMap + isSafe); #if defined(_WIN32) || defined(MAC_OSX_TK) if (!isSafe) { TkInitFontchooser(interp, clientData); } #endif return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 | return code; } static char * WaitVariableProc( ClientData clientData, /* Pointer to integer to set to 1. */ | | | > > | 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | return code; } static char * WaitVariableProc( ClientData clientData, /* Pointer to integer to set to 1. */ Tcl_Interp *interp, /* Interpreter containing variable. */ const char *name1, /* Name of variable. */ TCL_UNUSED(const char *), /* Second part of variable name. */ TCL_UNUSED(int)) /* Information about what happened. */ { int *donePtr = (int *)clientData; *donePtr = 1; Tcl_UntraceVar(interp, name1, TCL_TRACE_WRITES|TCL_TRACE_UNSETS, WaitVariableProc, clientData); return NULL; } static void WaitVisibilityProc( ClientData clientData, /* Pointer to integer to set to 1. */ XEvent *eventPtr) /* Information about event (not used). */ |
︙ | ︙ | |||
1858 1859 1860 1861 1862 1863 1864 | { const char *string; TkSizeT length; if (objc < 1) { return 0; } | | | 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 | { const char *string; TkSizeT length; if (objc < 1) { return 0; } 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)); Tcl_SetErrorCode(interp, "TK", "NO_VALUE", "DISPLAYOF", NULL); return -1; |
︙ | ︙ |
Changes to generic/tkColor.c.
1 2 3 4 5 6 7 | /* * tkColor.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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkColor.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 © 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 "tkColor.h" |
︙ | ︙ |
Changes to generic/tkColor.h.
1 2 3 4 5 | /* * tkColor.h -- * * Declarations of data types and functions used by the Tk color module. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkColor.h -- * * Declarations of data types and functions used by the Tk color module. * * 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. */ #ifndef _TKCOLOR #define _TKCOLOR |
︙ | ︙ |
Changes to generic/tkConfig.c.
1 2 3 4 5 6 | /* * tkConfig.c -- * * This file contains functions that manage configuration options for * widgets and other things. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkConfig.c -- * * This file contains functions that manage configuration options for * widgets and other things. * * 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. */ /* * Temporary flag for working on new config package. |
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #define __NO_OLD_CONFIG #endif #include "tkInt.h" #include "tkFont.h" /* * The following definition keeps track of all of * the option tables that have been created for a thread. */ typedef struct { int initialized; /* 0 means table below needs initializing. */ | > > > > > > > > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #define __NO_OLD_CONFIG #endif #include "tkInt.h" #include "tkFont.h" /* * The following encoding is used in TYPE_FLAGS: * * if sizeof(type) == sizeof(int) => TYPE_FLAGS(type) = 0 * if sizeof(type) == 1 => TYPE_FLAGS(type) = 64 * if sizeof(type) == 2 => TYPE_FLAGS(type) = 128 */ #define TYPE_FLAGS(type) (((int)(sizeof(type)&(sizeof(int)-1))<<6)) #define TYPE_MASK (((((int)sizeof(int)-1))|3)<<6) /* * The following definition keeps track of all of * the option tables that have been created for a thread. */ typedef struct { int initialized; /* 0 means table below needs initializing. */ |
︙ | ︙ | |||
451 452 453 454 455 456 457 | /* * Second, check for a system-specific default value. */ if ((valuePtr == NULL) && (optionPtr->dbNameUID != NULL)) { | | | 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | /* * Second, check for a system-specific default value. */ if ((valuePtr == NULL) && (optionPtr->dbNameUID != NULL)) { valuePtr = Tk_GetSystemDefault(tkwin, optionPtr->dbNameUID, optionPtr->dbClassUID); if (valuePtr != NULL) { source = SYSTEM_DEFAULT; } } /* |
︙ | ︙ | |||
605 606 607 608 609 610 611 | if (savedOptionPtr != NULL) { savedOptionPtr->optionPtr = optionPtr; savedOptionPtr->valuePtr = oldPtr; oldInternalPtr = (char *) &savedOptionPtr->internalForm; } else { oldInternalPtr = (char *) &internal.internalForm; } | | > > > | > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > > > > > > > > | | | | | | > > > > > > > > > > > | | > | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 | if (savedOptionPtr != NULL) { savedOptionPtr->optionPtr = optionPtr; savedOptionPtr->valuePtr = oldPtr; oldInternalPtr = (char *) &savedOptionPtr->internalForm; } else { oldInternalPtr = (char *) &internal.internalForm; } nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)); switch (optionPtr->specPtr->type) { case TK_OPTION_BOOLEAN: { int newBool; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newBool = -1; } else if (Tcl_GetBooleanFromObj(nullOK ? NULL : interp, valuePtr, &newBool) != TCL_OK) { if (nullOK && interp) { Tcl_AppendResult(interp, "expected boolean value or \"\" but got \"", Tcl_GetString(valuePtr), "\"", NULL); } return TCL_ERROR; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = newBool; } break; } case TK_OPTION_INT: { int newInt; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newInt = INT_MIN; } else if (Tcl_GetIntFromObj(nullOK ? NULL : interp, valuePtr, &newInt) != TCL_OK) { if (nullOK && interp) { Tcl_Obj *msg = Tcl_NewStringObj("expected integer or \"\" but got \"", -1); Tcl_AppendLimitedToObj(msg, Tcl_GetString(valuePtr), -1, 50, ""); Tcl_AppendToObj(msg, "\"", -1); Tcl_SetObjResult(interp, msg); Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL); } return TCL_ERROR; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = newInt; } break; } case TK_OPTION_INDEX: { TkSizeT newIndex; if (TkGetIntForIndex(valuePtr, TCL_INDEX_END, 0, &newIndex) != TCL_OK) { if (interp) { Tcl_AppendResult(interp, "bad index \"", Tcl_GetString(valuePtr), "\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL); } return TCL_ERROR; } if (newIndex == TCL_INDEX_NONE) { newIndex = (TkSizeT)INT_MIN; } else if ((size_t)newIndex > (size_t)TCL_INDEX_END>>1) { newIndex++; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = (int)newIndex; } break; } case TK_OPTION_DOUBLE: { double newDbl; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; #if defined(NAN) newDbl = NAN; #else newDbl = 0.0; #endif } else { if (Tcl_GetDoubleFromObj(nullOK ? NULL : interp, valuePtr, &newDbl) != TCL_OK) { if (nullOK && interp) { Tcl_Obj *msg = Tcl_NewStringObj("expected floating-point number or \"\" but got \"", -1); Tcl_AppendLimitedToObj(msg, Tcl_GetString(valuePtr), -1, 50, ""); Tcl_AppendToObj(msg, "\"", -1); Tcl_SetObjResult(interp, msg); Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", NULL); } return TCL_ERROR; } } if (internalPtr != NULL) { *((double *) oldInternalPtr) = *((double *) internalPtr); *((double *) internalPtr) = newDbl; } break; } case TK_OPTION_STRING: { char *newStr; const char *value; TkSizeT length; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; } if (internalPtr != NULL) { if (valuePtr != NULL) { value = Tcl_GetStringFromObj(valuePtr, &length); newStr = (char *)ckalloc(length + 1); strcpy(newStr, value); } else { newStr = NULL; } *((char **) oldInternalPtr) = *((char **) internalPtr); *((char **) internalPtr) = newStr; } break; } case TK_OPTION_STRING_TABLE: { int newValue; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newValue = -1; } else { if (Tcl_GetIndexFromObjStruct(interp, valuePtr, optionPtr->specPtr->clientData, sizeof(char *), optionPtr->specPtr->optionName+1, (nullOK ? TCL_INDEX_NULL_OK : 0), &newValue) != TCL_OK) { return TCL_ERROR; } } if (internalPtr != NULL) { if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) { *((char *) oldInternalPtr) = *((char *) internalPtr); *((char *) internalPtr) = newValue; } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) { *((short *) oldInternalPtr) = *((short *) internalPtr); *((short *) internalPtr) = newValue; } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE"); } } else { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = newValue; } } break; } case TK_OPTION_COLOR: { XColor *newPtr; if (nullOK && ObjectIsEmpty(valuePtr)) { |
︙ | ︙ | |||
785 786 787 788 789 790 791 | } case TK_OPTION_RELIEF: { int newRelief; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newRelief = TK_RELIEF_NULL; | | | | < | 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 | } case TK_OPTION_RELIEF: { int newRelief; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newRelief = TK_RELIEF_NULL; } else if (Tcl_GetIndexFromObj(interp, valuePtr, tkReliefStrings, "relief", (nullOK ? TCL_INDEX_NULL_OK : 0), &newRelief) != TCL_OK) { return TCL_ERROR; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = newRelief; } break; } |
︙ | ︙ | |||
816 817 818 819 820 821 822 | *((Tk_Cursor *) oldInternalPtr) = *((Tk_Cursor *) internalPtr); *((Tk_Cursor *) internalPtr) = newCursor; } Tk_DefineCursor(tkwin, newCursor); break; } case TK_OPTION_JUSTIFY: { | | > > > | > | | > > > | > | | < | | | < < | | | < | 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 | *((Tk_Cursor *) oldInternalPtr) = *((Tk_Cursor *) internalPtr); *((Tk_Cursor *) internalPtr) = newCursor; } Tk_DefineCursor(tkwin, newCursor); break; } case TK_OPTION_JUSTIFY: { int newJustify; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newJustify = -1; } else if (Tcl_GetIndexFromObj(interp, valuePtr, tkJustifyStrings, "justification", (nullOK ? TCL_INDEX_NULL_OK : 0), &newJustify) != TCL_OK) { return TCL_ERROR; } if (internalPtr != NULL) { *((Tk_Justify *) oldInternalPtr) = *((Tk_Justify *) internalPtr); *((Tk_Justify *) internalPtr) = (Tk_Justify)newJustify; } break; } case TK_OPTION_ANCHOR: { int newAnchor; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newAnchor = -1; } else if (Tcl_GetIndexFromObj(interp, valuePtr, tkAnchorStrings, "anchor", (nullOK ? TCL_INDEX_NULL_OK : 0), &newAnchor) != TCL_OK) { return TCL_ERROR; } if (internalPtr != NULL) { *((Tk_Anchor *) oldInternalPtr) = *((Tk_Anchor *) internalPtr); *((Tk_Anchor *) internalPtr) = (Tk_Anchor)newAnchor; } break; } case TK_OPTION_PIXELS: { int newPixels; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newPixels = INT_MIN; } else if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr, &newPixels) != TCL_OK) { return TCL_ERROR; } if (internalPtr != NULL) { *((int *) oldInternalPtr) = *((int *) internalPtr); *((int *) internalPtr) = newPixels; } break; } case TK_OPTION_WINDOW: { Tk_Window newWin; if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; newWin = NULL; } else if (TkGetWindowFromObj(interp, tkwin, valuePtr, &newWin) != TCL_OK) { return TCL_ERROR; } if (internalPtr != NULL) { *((Tk_Window *) oldInternalPtr) = *((Tk_Window *) internalPtr); *((Tk_Window *) internalPtr) = newWin; } break; } |
︙ | ︙ | |||
1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 | if (specPtr->internalOffset != TCL_INDEX_NONE) { char *ptr = (char *) &savePtr->items[i].internalForm; CLANG_ASSERT(internalPtr); switch (specPtr->type) { case TK_OPTION_BOOLEAN: case TK_OPTION_INT: *((int *) internalPtr) = *((int *) ptr); break; case TK_OPTION_DOUBLE: *((double *) internalPtr) = *((double *) ptr); break; case TK_OPTION_STRING: *((char **) internalPtr) = *((char **) ptr); break; case TK_OPTION_STRING_TABLE: | > > > > > > > > > > | > | 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 | if (specPtr->internalOffset != TCL_INDEX_NONE) { char *ptr = (char *) &savePtr->items[i].internalForm; CLANG_ASSERT(internalPtr); switch (specPtr->type) { case TK_OPTION_BOOLEAN: case TK_OPTION_INT: case TK_OPTION_INDEX: *((int *) internalPtr) = *((int *) ptr); break; case TK_OPTION_DOUBLE: *((double *) internalPtr) = *((double *) ptr); break; case TK_OPTION_STRING: *((char **) internalPtr) = *((char **) ptr); break; case TK_OPTION_STRING_TABLE: if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) { *((char *) internalPtr) = *((char *) ptr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) { *((short *) internalPtr) = *((short *) ptr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE"); } } else { *((int *) internalPtr) = *((int *) ptr); } break; case TK_OPTION_COLOR: *((XColor **) internalPtr) = *((XColor **) ptr); break; case TK_OPTION_FONT: *((Tk_Font *) internalPtr) = *((Tk_Font *) ptr); break; |
︙ | ︙ | |||
1863 1864 1865 1866 1867 1868 1869 | void *recordPtr, /* Pointer to record holding current values of * configuration options. */ Option *optionPtr, /* Pointer to information describing an option * whose internal value is stored in * *recordPtr. */ Tk_Window tkwin) /* Window corresponding to recordPtr. */ { | | | < < > > > > > | > > > > > > > > > > > > > > > > > | > | > > > > > > > > > > > > > | | > > | 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 | void *recordPtr, /* Pointer to record holding current values of * configuration options. */ Option *optionPtr, /* Pointer to information describing an option * whose internal value is stored in * *recordPtr. */ Tk_Window tkwin) /* Window corresponding to recordPtr. */ { Tcl_Obj *objPtr = NULL; void *internalPtr; /* Points to internal value of option in record. */ if (optionPtr->specPtr->internalOffset != TCL_INDEX_NONE) { internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset; switch (optionPtr->specPtr->type) { case TK_OPTION_BOOLEAN: if (*((int *) internalPtr) != -1) { objPtr = Tcl_NewBooleanObj(*((int *)internalPtr)); } break; case TK_OPTION_INT: if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)) || *((int *) internalPtr) != INT_MIN) { objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); } break; case TK_OPTION_INDEX: if (*((int *) internalPtr) == INT_MIN) { objPtr = TkNewIndexObj(TCL_INDEX_NONE); } else if (*((int *) internalPtr) == INT_MAX) { objPtr = Tcl_NewStringObj("end+1", -1); } else if (*((int *) internalPtr) == -1) { objPtr = Tcl_NewStringObj("end", -1); } else if (*((int *) internalPtr) < 0) { char buf[32]; sprintf(buf, "end%d", *((int *) internalPtr)); objPtr = Tcl_NewStringObj(buf, -1); } else { objPtr = Tcl_NewWideIntObj(*((int *) internalPtr)); } break; case TK_OPTION_DOUBLE: if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)) || !isnan(*((double *) internalPtr))) { objPtr = Tcl_NewDoubleObj(*((double *) internalPtr)); } break; case TK_OPTION_STRING: objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1); break; case TK_OPTION_STRING_TABLE: { int value; if (optionPtr->specPtr->flags & TYPE_MASK) { if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) { value = *((signed char *)internalPtr); } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) { value = *((short *)internalPtr); } else { Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE"); } } else { value = *((int *)internalPtr); } if (value >= 0) { objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[ value], -1); } break; } case TK_OPTION_COLOR: { XColor *colorPtr = *((XColor **)internalPtr); if (colorPtr != NULL) { objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1); } break; |
︙ | ︙ | |||
1947 1948 1949 1950 1951 1952 1953 | *((Tk_Justify *)internalPtr)), -1); break; case TK_OPTION_ANCHOR: objPtr = Tcl_NewStringObj(Tk_NameOfAnchor( *((Tk_Anchor *)internalPtr)), -1); break; case TK_OPTION_PIXELS: | > | > | 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 | *((Tk_Justify *)internalPtr)), -1); break; case TK_OPTION_ANCHOR: objPtr = Tcl_NewStringObj(Tk_NameOfAnchor( *((Tk_Anchor *)internalPtr)), -1); break; case TK_OPTION_PIXELS: if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_INDEX_NULL_OK)) || *((int *) internalPtr) != INT_MIN) { objPtr = Tcl_NewWideIntObj(*((int *)internalPtr)); } break; case TK_OPTION_WINDOW: { tkwin = *((Tk_Window *) internalPtr); if (tkwin != NULL) { objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1); } |
︙ | ︙ |
Changes to generic/tkConsole.c.
1 2 3 4 5 6 7 | /* * tkConsole.c -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkConsole.c -- * * 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 © 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. */ #include "tkInt.h" |
︙ | ︙ | |||
513 514 515 516 517 518 519 | /* * Not checking for utf8 == NULL. Did not check for TCL_ERROR * from Tcl_SetChannelOption() in Tk_InitConsoleChannels() either. * Assumption is utf-8 Tcl_Encoding is reliably present. */ | > | < | 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | /* * Not checking for utf8 == NULL. Did not check for TCL_ERROR * from Tcl_SetChannelOption() in Tk_InitConsoleChannels() either. * Assumption is utf-8 Tcl_Encoding is reliably present. */ (void)Tcl_ExternalToUtfDStringEx(utf8, buf, toWrite, TCL_ENCODING_NOCOMPLAIN, &ds); const char *bytes = Tcl_DStringValue(&ds); int numBytes = Tcl_DStringLength(&ds); Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", -1); Tcl_FreeEncoding(utf8); if (data->type == TCL_STDERR) { Tcl_ListObjAppendElement(NULL, cmd, |
︙ | ︙ |
Changes to generic/tkCursor.c.
1 2 3 4 5 6 7 | /* * tkCursor.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkCursor.c -- * * 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 © 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" |
︙ | ︙ |
Changes to generic/tkDList.h.
1 2 3 4 5 6 7 8 9 | /* * tkDList.h -- * * A list is headed by pointers to first and last element. The elements * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkDList.h -- * * A list is headed by pointers to first and last element. The elements * 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 © 2018 Gregor Cramer. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* * Note that this file will not be included in header files, it is the purpose |
︙ | ︙ |
Changes to generic/tkDecls.h.
1 2 3 4 5 | /* * tkDecls.h -- * * Declarations of functions in the platform independent public Tcl API. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkDecls.h -- * * Declarations of functions in the platform independent public Tcl API. * * 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. */ #ifndef _TKDECLS #define _TKDECLS |
︙ | ︙ | |||
889 890 891 892 893 894 895 896 897 898 899 900 901 902 | /* 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); typedef struct { const struct TkPlatStubs *tkPlatStubs; const struct TkIntStubs *tkIntStubs; const struct TkIntPlatStubs *tkIntPlatStubs; const struct TkIntXlibStubs *tkIntXlibStubs; } TkStubHooks; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | /* 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); /* 281 */ EXTERN void Tk_DrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 282 */ EXTERN void Tk_SetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 283 */ EXTERN void Tk_SetWindowMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 284 */ EXTERN void Tk_ClipDrawableToRect(Display *display, Drawable d, int x, int y, int width, int height); /* 285 */ EXTERN Tcl_Obj * Tk_GetSystemDefault(Tk_Window tkwin, const char *dbName, const char *className); /* 286 */ EXTERN int Tk_UseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 287 */ EXTERN void Tk_MakeContainer(Tk_Window tkwin); /* 288 */ EXTERN Tk_Window Tk_GetOtherWindow(Tk_Window tkwin); /* 289 */ EXTERN void Tk_Get3DBorderColors(Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr, XColor *lightColorPtr); /* 290 */ EXTERN Window Tk_MakeWindow(Tk_Window tkwin, Window parent); typedef struct { const struct TkPlatStubs *tkPlatStubs; const struct TkIntStubs *tkIntStubs; const struct TkIntPlatStubs *tkIntPlatStubs; const struct TkIntXlibStubs *tkIntXlibStubs; } TkStubHooks; |
︙ | ︙ | |||
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | 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 */ } TkStubs; extern const TkStubs *tkStubsPtr; #ifdef __cplusplus } #endif | > > > > > > > > > > > | 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 | 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); /* 280 */ void (*tk_DrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 281 */ void (*tk_SetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 282 */ void (*tk_SetWindowMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 283 */ void (*tk_ClipDrawableToRect) (Display *display, Drawable d, int x, int y, int width, int height); /* 284 */ Tcl_Obj * (*tk_GetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 285 */ int (*tk_UseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 286 */ void (*tk_MakeContainer) (Tk_Window tkwin); /* 287 */ Tk_Window (*tk_GetOtherWindow) (Tk_Window tkwin); /* 288 */ void (*tk_Get3DBorderColors) (Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr, XColor *lightColorPtr); /* 289 */ Window (*tk_MakeWindow) (Tk_Window tkwin, Window parent); /* 290 */ } TkStubs; extern const TkStubs *tkStubsPtr; #ifdef __cplusplus } #endif |
︙ | ︙ | |||
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 | (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 */ #endif /* defined(USE_TK_STUBS) */ /* !END!: Do not edit above this line. */ /* Functions that don't belong in the stub table */ #undef Tk_MainEx #undef Tk_Init #undef Tk_SafeInit #undef Tk_CreateConsoleWindow #undef Tk_FreeXId #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); #endif #if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 #undef Tk_PhotoPutBlock_NoComposite #undef Tk_PhotoPutZoomedBlock_NoComposite #undef Tk_PhotoExpand_Panic #undef Tk_PhotoPutBlock_Panic #undef Tk_PhotoPutZoomedBlock_Panic #undef Tk_PhotoSetSize_Panic #undef Tk_CreateOldPhotoImageFormat #endif /* TK_NO_DEPRECATED */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT #endif /* _TKDECLS */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 | (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) /* 280 */ #define Tk_DrawHighlightBorder \ (tkStubsPtr->tk_DrawHighlightBorder) /* 281 */ #define Tk_SetMainMenubar \ (tkStubsPtr->tk_SetMainMenubar) /* 282 */ #define Tk_SetWindowMenubar \ (tkStubsPtr->tk_SetWindowMenubar) /* 283 */ #define Tk_ClipDrawableToRect \ (tkStubsPtr->tk_ClipDrawableToRect) /* 284 */ #define Tk_GetSystemDefault \ (tkStubsPtr->tk_GetSystemDefault) /* 285 */ #define Tk_UseWindow \ (tkStubsPtr->tk_UseWindow) /* 286 */ #define Tk_MakeContainer \ (tkStubsPtr->tk_MakeContainer) /* 287 */ #define Tk_GetOtherWindow \ (tkStubsPtr->tk_GetOtherWindow) /* 288 */ #define Tk_Get3DBorderColors \ (tkStubsPtr->tk_Get3DBorderColors) /* 289 */ #define Tk_MakeWindow \ (tkStubsPtr->tk_MakeWindow) /* 290 */ #endif /* defined(USE_TK_STUBS) */ /* !END!: Do not edit above this line. */ /* Functions that don't belong in the stub table */ #undef Tk_MainEx #undef Tk_Init #undef Tk_SafeInit #undef Tk_CreateConsoleWindow #undef Tk_FreeXId #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 #ifndef MAC_OSX_TK # undef Tk_ClipDrawableToRect #endif #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); #endif #if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8 #undef Tk_PhotoPutBlock_NoComposite #undef Tk_PhotoPutZoomedBlock_NoComposite #undef Tk_PhotoExpand_Panic #undef Tk_PhotoPutBlock_Panic #undef Tk_PhotoPutZoomedBlock_Panic #undef Tk_PhotoSetSize_Panic #undef Tk_CreateOldPhotoImageFormat #endif /* TK_NO_DEPRECATED */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT #undef TkUnusedStubEntry #endif /* _TKDECLS */ |
Changes to generic/tkEntry.c.
1 2 3 4 5 6 7 8 | /* * tkEntry.c -- * * 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. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tkEntry.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkEntry.h" |
︙ | ︙ | |||
73 74 75 76 77 78 79 | DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-disabledbackground", "disabledBackground", "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK, | | | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-disabledbackground", "disabledBackground", "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK, DEF_ENTRY_DISABLED_BG_MONO, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE, offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE, offsetof(Entry, exportSelection), 0, 0, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, |
︙ | ︙ | |||
99 100 101 102 103 104 105 | "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, highlightWidth), 0, 0, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE, offsetof(Entry, insertBorderWidth), 0, | | | | | | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, highlightWidth), 0, 0, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE, offsetof(Entry, insertBorderWidth), 0, DEF_ENTRY_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime), 0, 0, 0}, {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0}, {TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand", DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_SYNONYM, "-invcmd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), 0, 0, 0}, {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder", DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground", "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE, offsetof(Entry, placeholderColorPtr), 0, 0, 0}, {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground", "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK, DEF_ENTRY_READONLY_BG_MONO, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder), 0, DEF_ENTRY_SELECT_MONO, 0}, {TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE, |
︙ | ︙ | |||
212 213 214 215 216 217 218 | TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-disabledbackground", "disabledBackground", "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK, | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-disabledbackground", "disabledBackground", "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK, DEF_ENTRY_DISABLED_BG_MONO, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE, offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-exportselection", "exportSelection", "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE, offsetof(Entry, exportSelection), 0, 0, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, |
︙ | ︙ | |||
245 246 247 248 249 250 251 | {TK_OPTION_DOUBLE, "-increment", "increment", "Increment", DEF_SPINBOX_INCREMENT, TCL_INDEX_NONE, offsetof(Spinbox, increment), 0, 0, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE, offsetof(Entry, insertBorderWidth), 0, | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | {TK_OPTION_DOUBLE, "-increment", "increment", "Increment", DEF_SPINBOX_INCREMENT, TCL_INDEX_NONE, offsetof(Spinbox, increment), 0, 0, 0}, {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE, offsetof(Entry, insertBorderWidth), 0, DEF_ENTRY_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime), 0, 0, 0}, {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0}, |
︙ | ︙ | |||
271 272 273 274 275 276 277 | "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE, offsetof(Entry, placeholderColorPtr), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground", "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK, | | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE, offsetof(Entry, placeholderColorPtr), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0}, {TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground", "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK, DEF_ENTRY_READONLY_BG_MONO, 0}, {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", DEF_SPINBOX_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(Spinbox, repeatDelay), 0, 0, 0}, {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", DEF_SPINBOX_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(Spinbox, repeatInterval), 0, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", |
︙ | ︙ | |||
383 384 385 386 387 388 389 | /* * This is the string array corresponding to the enum in selelement. If you * modify them, you must modify the strings here. */ static const char *const selElementNames[] = { | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | /* * This is the string array corresponding to the enum in selelement. If you * modify them, you must modify the strings here. */ static const char *const selElementNames[] = { "buttondown", "buttonup", "none", NULL, "entry" }; /* * Flags for GetEntryIndex function: */ #define ZERO_OK 1 |
︙ | ︙ | |||
707 708 709 710 711 712 713 | } case COMMAND_GET: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); goto error; } | | | 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | } case COMMAND_GET: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); goto error; } Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, -1)); break; case COMMAND_ICURSOR: if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "pos"); goto error; } |
︙ | ︙ | |||
780 781 782 783 784 785 786 | entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( | | | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 | entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scan option \"%s\": must be dragto or mark", minorCmd)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option", minorCmd, NULL); goto error; } break; } |
︙ | ︙ | |||
1257 1258 1259 1260 1261 1262 1263 | if (oldValues != sbPtr->valueStr) { if (sbPtr->listObj != NULL) { Tcl_DecrRefCount(sbPtr->listObj); } sbPtr->listObj = NULL; if (sbPtr->valueStr != NULL) { Tcl_Obj *newObjPtr; | | | | 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 | if (oldValues != sbPtr->valueStr) { if (sbPtr->listObj != NULL) { Tcl_DecrRefCount(sbPtr->listObj); } sbPtr->listObj = NULL; if (sbPtr->valueStr != NULL) { Tcl_Obj *newObjPtr; TkSizeT nelems; newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, -1); if (Tcl_ListObjLength(interp, newObjPtr, &nelems) != TCL_OK) { valuesChanged = -1; continue; } sbPtr->listObj = newObjPtr; Tcl_IncrRefCount(sbPtr->listObj); |
︙ | ︙ | |||
1923 1924 1925 1926 1927 1928 1929 | } if (xBound > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, pixmap); if (entryPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(entryPtr->highlightColorPtr, pixmap); | | | | 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 | } if (xBound > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, pixmap); if (entryPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(entryPtr->highlightColorPtr, pixmap); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, xBound, pixmap); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, xBound, pixmap); } } } #ifndef TK_NO_DOUBLE_BUFFERING /* * Everything's been redisplayed; now copy the pixmap onto the screen and |
︙ | ︙ | |||
2686 2687 2688 2689 2690 2691 2692 | } else if (idx > entryPtr->numChars) { idx = entryPtr->numChars; } *indexPtr = idx; return TCL_OK; } | | | 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 | } else if (idx > entryPtr->numChars) { idx = entryPtr->numChars; } *indexPtr = idx; return TCL_OK; } string = Tcl_GetStringFromObj(indexObj, &length); switch (string[0]) { case 'a': if (strncmp(string, "anchor", length) != 0) { goto badIndex; } *indexPtr = entryPtr->selectAnchor; |
︙ | ︙ | |||
3263 3264 3265 3266 3267 3268 3269 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && entryPtr->textVarName) { | | | | 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && entryPtr->textVarName) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, EntryTextVarProc, probe); if (probe == (void *)entryPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not |
︙ | ︙ | |||
4055 4056 4057 4058 4059 4060 4061 | entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( | | | 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 | entryPtr->scanMarkX = x; entryPtr->scanMarkIndex = entryPtr->leftIndex; } else if ((minorCmd[0] == 'd') && (strncmp(minorCmd, "dragto", strlen(minorCmd)) == 0)) { EntryScanTo(entryPtr, x); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scan option \"%s\": must be dragto or mark", minorCmd)); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option", minorCmd, NULL); goto error; } break; } |
︙ | ︙ | |||
4422 4423 4424 4425 4426 4427 4428 | if (strcmp(Tcl_GetString(objPtr), entryPtr->string)) { /* * Somehow the string changed from what we expected, so let's * do a search on the list to see if the current value is * there. If not, move to the first element of the list. */ | | | | 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 | if (strcmp(Tcl_GetString(objPtr), entryPtr->string)) { /* * Somehow the string changed from what we expected, so let's * do a search on the list to see if the current value is * there. If not, move to the first element of the list. */ TkSizeT i, listc; TkSizeT elemLen, length = entryPtr->numChars; const char *bytes; Tcl_Obj **listv; Tcl_ListObjGetElements(interp, sbPtr->listObj, &listc, &listv); for (i = 0; i < listc; i++) { bytes = Tcl_GetStringFromObj(listv[i], &elemLen); if ((length == elemLen) && (memcmp(bytes, entryPtr->string, length) == 0)) { sbPtr->eIndex = i; break; } } |
︙ | ︙ |
Changes to generic/tkEntry.h.
1 2 3 4 5 6 7 8 | /* * tkEntry.h -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkEntry.h -- * * 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 © 2002 Apple Inc. */ #ifndef _TKENTRY #define _TKENTRY #ifndef _TKINT #include "tkInt.h" |
︙ | ︙ | |||
292 293 294 295 296 297 298 | /* * This is the element index corresponding to the strings in selElementNames. * If you modify them, you must modify the numbers here. */ enum selelement { | | | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | /* * This is the element index corresponding to the strings in selElementNames. * If you modify them, you must modify the numbers here. */ enum selelement { SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NONE, SEL_NULL, SEL_ENTRY }; /* * Declaration of functions used in the implementation of the native side of * the Entry widget. */ MODULE_SCOPE int TkpDrawEntryBorderAndFocus(Entry *entryPtr, Drawable d, int isSpinbox); MODULE_SCOPE int TkpDrawSpinboxButtons(Spinbox *sbPtr, Drawable d); #endif /* _TKENTRY */ |
Changes to generic/tkError.c.
1 2 3 4 5 6 7 8 | /* * tkError.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkError.c -- * * 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 © 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" |
︙ | ︙ |
Changes to generic/tkEvent.c.
1 2 3 4 5 6 | /* * tkEvent.c -- * * This file provides basic low-level facilities for managing X events in * Tk. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkEvent.c -- * * This file provides basic low-level facilities for managing X events in * Tk. * * 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. */ #include "tkInt.h" |
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | 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) { | | | 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 | 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. |
︙ | ︙ | |||
1838 1839 1840 1841 1842 1843 1844 | * *---------------------------------------------------------------------- */ void TkCreateExitHandler( Tcl_ExitProc *proc, /* Function to invoke. */ | | | 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 | * *---------------------------------------------------------------------- */ void TkCreateExitHandler( Tcl_ExitProc *proc, /* Function to invoke. */ void *clientData) /* Arbitrary value to pass to proc. */ { ExitHandler *exitPtr; exitPtr = (ExitHandler *)ckalloc(sizeof(ExitHandler)); exitPtr->proc = proc; exitPtr->clientData = clientData; Tcl_MutexLock(&exitMutex); |
︙ | ︙ | |||
2003 2004 2005 2006 2007 2008 2009 | /* *---------------------------------------------------------------------- * * TkFinalize -- * * Runs our private exit handlers and removes itself from Tcl. This is | | | 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 | /* *---------------------------------------------------------------------- * * TkFinalize -- * * Runs our private exit handlers and removes itself from Tcl. This is * beneficial should we want to protect from dangling pointers should the * Tk shared library be unloaded prior to Tcl which can happen on windows * should the process be forcefully exiting from an exception handler. * * Results: * None. * * Side effects. |
︙ | ︙ |
Changes to generic/tkFileFilter.c.
1 2 3 4 5 6 | /* * tkFileFilter.c -- * * Process the -filetypes option for the file dialogs on Windows and the * Mac. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkFileFilter.c -- * * Process the -filetypes option for the file dialogs on Windows and the * Mac. * * 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. */ #include "tkInt.h" #include "tkFileFilter.h" |
︙ | ︙ | |||
259 260 261 262 263 264 265 | * Might be cleaner to use 'Tcl_GetOSTypeFromObj' but that is actually * static to the MacOS X/Darwin version of Tcl, and would therefore * require further code refactoring. */ for (i=0; i<ostypeCount; i++) { TkSizeT len; | | | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | * Might be cleaner to use 'Tcl_GetOSTypeFromObj' but that is actually * static to the MacOS X/Darwin version of Tcl, and would therefore * require further code refactoring. */ for (i=0; i<ostypeCount; i++) { TkSizeT len; const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len); /* * If len is < 4, it is definitely an error. If equal or longer, * we need to use the macRoman encoding to determine the correct * length (assuming there may be non-ascii characters, e.g., * embedded nulls or accented characters in the string, the * macRoman length will be different). |
︙ | ︙ | |||
282 283 284 285 286 287 288 | Tcl_DString osTypeDS; /* * Convert utf to macRoman, since MacOS types are defined to * be 4 macRoman characters long */ | | | 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | Tcl_DString osTypeDS; /* * Convert utf to macRoman, since MacOS types are defined to * be 4 macRoman characters long */ (void)Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS); len = Tcl_DStringLength(&osTypeDS); Tcl_DStringFree(&osTypeDS); } if (len != 4) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad Macintosh file type \"%s\"", Tcl_GetString(ostypeList[i]))); |
︙ | ︙ | |||
319 320 321 322 323 324 325 | } clausePtr->next = NULL; if (globCount > 0 && globList != NULL) { for (i=0; i<globCount; i++) { GlobPattern *globPtr = (GlobPattern *)ckalloc(sizeof(GlobPattern)); TkSizeT len; | | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | } clausePtr->next = NULL; if (globCount > 0 && globList != NULL) { for (i=0; i<globCount; i++) { GlobPattern *globPtr = (GlobPattern *)ckalloc(sizeof(GlobPattern)); TkSizeT len; const char *str = Tcl_GetStringFromObj(globList[i], &len); len = (len + 1) * sizeof(char); if (str[0] && str[0] != '*') { /* * Prepend a "*" to patterns that do not have a leading "*" */ |
︙ | ︙ | |||
373 374 375 376 377 378 379 | if (macRoman == NULL) { macRoman = Tcl_GetEncoding(NULL, "macRoman"); } for (i=0; i<ostypeCount; i++) { Tcl_DString osTypeDS; TkSizeT len; MacFileType *mfPtr = (MacFileType *)ckalloc(sizeof(MacFileType)); | | | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | if (macRoman == NULL) { macRoman = Tcl_GetEncoding(NULL, "macRoman"); } for (i=0; i<ostypeCount; i++) { Tcl_DString osTypeDS; TkSizeT len; MacFileType *mfPtr = (MacFileType *)ckalloc(sizeof(MacFileType)); const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len); char *string; /* * Convert utf to macRoman, since MacOS types are defined to be 4 * macRoman characters long */ (void)Tcl_UtfToExternalDStringEx(macRoman, strType, len, TCL_ENCODING_NOCOMPLAIN, &osTypeDS); string = Tcl_DStringValue(&osTypeDS); mfPtr->type = (OSType) string[0] << 24 | (OSType) string[1] << 16 | (OSType) string[2] << 8 | (OSType) string[3]; Tcl_DStringFree(&osTypeDS); /* * Add the Mac type pattern into the list of Mac types |
︙ | ︙ |
Changes to generic/tkFileFilter.h.
1 2 3 4 5 6 | /* * tkFileFilter.h -- * * Declarations for the file filter processing routines needed by the * file selection dialogs. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkFileFilter.h -- * * Declarations for the file filter processing routines needed by the * file selection dialogs. * * 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. */ #ifndef _TK_FILE_FILTER #define _TK_FILE_FILTER |
︙ | ︙ |
Changes to generic/tkFocus.c.
1 2 3 4 5 | /* * tkFocus.c -- * * This file contains functions that manage the input focus for Tk. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkFocus.c -- * * This file contains functions that manage the input focus for Tk. * * 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" |
︙ | ︙ | |||
311 312 313 314 315 316 317 | * Skip FocusIn events that cause confusion * NotifyVirtual and NotifyNonlinearVirtual - Virtual events occur on * windows in between the origin and destination of the focus * change. For FocusIn we may see this when focus goes into an * embedded child. We don't care about this, although we may end * up getting a NotifyPointer later. * NotifyInferior - focus is coming to us from an embedded child. When | | | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | * Skip FocusIn events that cause confusion * NotifyVirtual and NotifyNonlinearVirtual - Virtual events occur on * windows in between the origin and destination of the focus * change. For FocusIn we may see this when focus goes into an * embedded child. We don't care about this, although we may end * up getting a NotifyPointer later. * NotifyInferior - focus is coming to us from an embedded child. When * focus is on an embedded focus, we still think we have the * focus, too, so this message doesn't change our state. * NotifyPointerRoot - should never happen because this is sent to the * root window. * * Interesting FocusIn events are * NotifyAncestor - focus is coming from our parent, probably the root. * NotifyNonlinear - focus is coming from a different branch, probably |
︙ | ︙ | |||
365 366 367 368 369 370 371 | retValue = 1; if (eventPtr->xcrossing.detail == NotifyInferior) { return retValue; } } /* | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | retValue = 1; if (eventPtr->xcrossing.detail == NotifyInferior) { return retValue; } } /* * If winPtr isn't a top-level window then just ignore the event. */ winPtr = TkWmFocusToplevel(winPtr); if (winPtr == NULL) { return retValue; } |
︙ | ︙ | |||
632 633 634 635 636 637 638 | if (topLevelPtr->flags & TK_EMBEDDED && (displayFocusPtr->focusWinPtr == NULL)) { /* * We are assigning focus to an embedded toplevel. The platform * specific function TkpClaimFocus needs to handle the job of * assigning focus to the container, since we have no way to find the | | | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | if (topLevelPtr->flags & TK_EMBEDDED && (displayFocusPtr->focusWinPtr == NULL)) { /* * We are assigning focus to an embedded toplevel. The platform * specific function TkpClaimFocus needs to handle the job of * assigning focus to the container, since we have no way to find the * container. */ TkpClaimFocus(topLevelPtr, force); } else if ((displayFocusPtr->focusWinPtr != NULL) || force) { /* * If we are forcing removal of focus from a container hosting a |
︙ | ︙ | |||
809 810 811 812 813 814 815 816 817 818 819 820 821 822 | TkFocusDeadWindow( TkWindow *winPtr) /* Information about the window that is being * deleted. */ { ToplevelFocusInfo *tlFocusPtr, *prevPtr; DisplayFocusInfo *displayFocusPtr; TkDisplay *dispPtr = winPtr->dispPtr; /* * Certain special windows like those used for send and clipboard have no * mainPtr. */ if (winPtr->mainPtr == NULL) { | > | 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | TkFocusDeadWindow( TkWindow *winPtr) /* Information about the window that is being * deleted. */ { ToplevelFocusInfo *tlFocusPtr, *prevPtr; DisplayFocusInfo *displayFocusPtr; TkDisplay *dispPtr = winPtr->dispPtr; int noMatch = 1; /* * Certain special windows like those used for send and clipboard have no * mainPtr. */ if (winPtr->mainPtr == NULL) { |
︙ | ︙ | |||
852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 | } if (prevPtr == NULL) { winPtr->mainPtr->tlFocusPtr = tlFocusPtr->nextPtr; } else { prevPtr->nextPtr = tlFocusPtr->nextPtr; } ckfree(tlFocusPtr); break; } else if (winPtr == tlFocusPtr->focusWinPtr) { /* * The deleted window had the focus for its top-level: move the * focus to the top-level itself. */ tlFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr; if ((displayFocusPtr->focusWinPtr == winPtr) && !(tlFocusPtr->topLevelPtr->flags & TK_ALREADY_DEAD)) { DEBUG(dispPtr, ("forwarding focus to %s after %s died\n", tlFocusPtr->topLevelPtr->pathName, winPtr->pathName)); GenerateFocusEvents(displayFocusPtr->focusWinPtr, tlFocusPtr->topLevelPtr); displayFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr; dispPtr->focusPtr = tlFocusPtr->topLevelPtr; } break; } } /* * Occasionally, things can become unsynchronized. Move them back into * synch now. [Bug 2496114] */ if (displayFocusPtr->focusWinPtr == winPtr) { DEBUG(dispPtr, ("focus cleared after %s died\n", winPtr->pathName)); displayFocusPtr->focusWinPtr = NULL; } if (displayFocusPtr->focusOnMapPtr == winPtr) { displayFocusPtr->focusOnMapPtr = NULL; } } /* *---------------------------------------------------------------------- * * GenerateFocusEvents -- * | > > > > > > > > > > > | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 | } if (prevPtr == NULL) { winPtr->mainPtr->tlFocusPtr = tlFocusPtr->nextPtr; } else { prevPtr->nextPtr = tlFocusPtr->nextPtr; } ckfree(tlFocusPtr); noMatch = 0; break; } else if (winPtr == tlFocusPtr->focusWinPtr) { /* * The deleted window had the focus for its top-level: move the * focus to the top-level itself. */ tlFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr; if ((displayFocusPtr->focusWinPtr == winPtr) && !(tlFocusPtr->topLevelPtr->flags & TK_ALREADY_DEAD)) { DEBUG(dispPtr, ("forwarding focus to %s after %s died\n", tlFocusPtr->topLevelPtr->pathName, winPtr->pathName)); GenerateFocusEvents(displayFocusPtr->focusWinPtr, tlFocusPtr->topLevelPtr); displayFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr; dispPtr->focusPtr = tlFocusPtr->topLevelPtr; } noMatch = 0; break; } } /* * Occasionally, things can become unsynchronized. Move them back into * synch now. [Bug 2496114] */ if (displayFocusPtr->focusWinPtr == winPtr) { DEBUG(dispPtr, ("focus cleared after %s died\n", winPtr->pathName)); displayFocusPtr->focusWinPtr = NULL; } if (displayFocusPtr->focusOnMapPtr == winPtr) { displayFocusPtr->focusOnMapPtr = NULL; } /* * It may happen that the search above for focus records that refer * to this window did not find any match. In such a case, when the * dead window had the focus, release it. */ if (noMatch && (dispPtr->focusPtr == winPtr)) { dispPtr->focusPtr = NULL; } } /* *---------------------------------------------------------------------- * * GenerateFocusEvents -- * |
︙ | ︙ | |||
1163 1164 1165 1166 1167 1168 1169 | } /* *---------------------------------------------------------------------- * * TkFocusJoin -- * | | | 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 | } /* *---------------------------------------------------------------------- * * TkFocusJoin -- * * Remove the focus record for this window that is no longer managed * * Results: * None. * * Side effects: * A tlFocusPtr record is removed * |
︙ | ︙ |
Changes to generic/tkFont.c.
1 2 3 4 5 6 | /* * tkFont.c -- * * This file maintains a database of fonts for the Tk toolkit. It also * provides several utility functions for measuring and displaying text. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * 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 © 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" |
︙ | ︙ | |||
729 730 731 732 733 734 735 | "font ?-displayof window? text"); return TCL_ERROR; } tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); if (tkfont == NULL) { return TCL_ERROR; } | | | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 | "font ?-displayof window? text"); return TCL_ERROR; } tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); if (tkfont == NULL) { return TCL_ERROR; } 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, i; const TkFontMetrics *fmPtr; static const char *const switches[] = { "-ascent", "-descent", "-fixed", "-linespace", NULL }; skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin); if (skip < 0) { return TCL_ERROR; } if ((objc < 3) || ((objc - skip) > 4)) { |
︙ | ︙ | |||
774 775 776 777 778 779 780 | Tk_FreeFont(tkfont); return TCL_ERROR; } i = 0; /* Needed only to prevent compiler warning. */ switch (index) { case 0: i = fmPtr->ascent; break; case 1: i = fmPtr->descent; break; | | | | 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 | Tk_FreeFont(tkfont); return TCL_ERROR; } i = 0; /* Needed only to prevent compiler warning. */ switch (index) { case 0: i = fmPtr->ascent; break; case 1: i = fmPtr->descent; break; case 2: i = fmPtr->fixed; break; case 3: i = fmPtr->ascent + fmPtr->descent; break; } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i)); } Tk_FreeFont(tkfont); break; } case FONT_NAMES: { |
︙ | ︙ | |||
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | static void RecomputeWidgets( TkWindow *winPtr) /* Window to which command is sent. */ { Tk_ClassWorldChangedProc *proc = Tk_GetClassProc(winPtr->classProcsPtr, worldChangedProc); if (proc != NULL) { proc(winPtr->instanceData); } /* * Notify all the descendants of this window that the world has changed. * * This could be done recursively or iteratively. The recursive version is * easier to implement and understand, and typically, windows with a -font * option will be leaf nodes in the widget heirarchy (buttons, labels, * etc.), so the recursion depth will be shallow. * * However, the additional overhead of the recursive calls may become a * performance problem if typical usage alters such that -font'ed widgets | > | | | | | | > > > > > > > | 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 | static void RecomputeWidgets( TkWindow *winPtr) /* Window to which command is sent. */ { Tk_ClassWorldChangedProc *proc = Tk_GetClassProc(winPtr->classProcsPtr, worldChangedProc); TkWindow *tkwinPtr; if (proc != NULL) { proc(winPtr->instanceData); } /* * Notify all the descendants of this window that the world has changed. * * This could be done recursively or iteratively. The recursive version is * easier to implement and understand, and typically, windows with a -font * option will be leaf nodes in the widget heirarchy (buttons, labels, * etc.), so the recursion depth will be shallow. * * However, the additional overhead of the recursive calls may become a * performance problem if typical usage alters such that -font'ed widgets * appear high in the hierarchy, causing deep recursion. This could happen * with text widgets, or more likely with the labelframe * widget. With these widgets it is possible, even likely, that a * -font'ed widget (text or labelframe) will not be a leaf node, but * will instead have many descendants. If this is ever found to cause a * performance problem, it may be worth investigating an iterative version * of the code below. */ for (tkwinPtr=winPtr->childList ; tkwinPtr!=NULL ; tkwinPtr=tkwinPtr->nextPtr) { RecomputeWidgets(tkwinPtr); } /* * Broadcast font change virtually for mega-widget layout managers. * Do this after the font change has been propagated to core widgets. */ Tk_SendVirtualEvent((Tk_Window)winPtr, "TkWorldChanged", Tcl_NewStringObj("FontChanged",-1)); } /* *--------------------------------------------------------------------------- * * TkCreateNamedFont -- * |
︙ | ︙ | |||
2467 2468 2469 2470 2471 2472 2473 | Drawable drawable, /* Window or pixmap in which to draw. */ GC gc, /* Graphics context to use for drawing text. */ 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 underline) /* Index of the single character to underline, | | | 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 | Drawable drawable, /* Window or pixmap in which to draw. */ GC gc, /* Graphics context to use for drawing text. */ 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 underline) /* Index of the single character to underline, * or INT_MIN for no underline. */ { int xx, yy, width, height; if ((Tk_CharBbox(layout, underline, &xx, &yy, &width, &height) != 0) && (width != 0)) { TextLayout *layoutPtr = (TextLayout *) layout; TkFont *fontPtr = (TkFont *) layoutPtr->tkfont; |
︙ | ︙ | |||
2494 2495 2496 2497 2498 2499 2500 | * text. */ 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). */ double angle, int underline) /* Index of the single character to underline, | | | 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 | * text. */ 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). */ double angle, int underline) /* Index of the single character to underline, * or INT_MIN for no underline. */ { int xx, yy, width, height; if (angle == 0.0) { Tk_UnderlineTextLayout(display, drawable, gc, layout, x,y, underline); return; } |
︙ | ︙ | |||
2722 2723 2724 2725 2726 2727 2728 | */ int Tk_CharBbox( Tk_TextLayout layout, /* Layout information, from a previous call to * Tk_ComputeTextLayout(). */ int index, /* The index of the character whose bbox is | | > > > > | > | 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 | */ int Tk_CharBbox( Tk_TextLayout layout, /* Layout information, from a previous call to * Tk_ComputeTextLayout(). */ int index, /* The index of the character whose bbox is * desired. Negative means count backwards. */ int *xPtr, int *yPtr, /* Filled with the upper-left hand corner, in * pixels, of the bounding box for the * character specified by index, if * non-NULL. */ int *widthPtr, int *heightPtr) /* 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 = layoutPtr->chunks; int i, x = 0, w; Tk_Font tkfont; TkFont *fontPtr; const char *end; if (index < 0) { for (i = 0; i < layoutPtr->numChunks; i++) { index += (chunkPtr + i)->numChars; } if (index < 0) { return 0; } } tkfont = layoutPtr->tkfont; fontPtr = (TkFont *) tkfont; for (i = 0; i < layoutPtr->numChunks; i++) { if (chunkPtr->numDisplayChars < 0) { |
︙ | ︙ | |||
3340 3341 3342 3343 3344 3345 3346 | if (ch > 0xffff) { goto noMapping; } sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { | | | 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 | if (ch > 0xffff) { goto noMapping; } sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { ps = Tcl_GetStringFromObj(psObj, &len); if (ps[len-1] == '(') { /* * In-place edit. Ewww! */ ps[len-1] = '/'; } else { |
︙ | ︙ | |||
3654 3655 3656 3657 3658 3659 3660 | Tcl_Obj *objPtr, /* Parseable font description object. */ TkFontAttributes *faPtr) /* Filled with attributes parsed from font * name. Any attributes that were not * specified in font name are filled with * default values. */ { const char *dash; | | > | 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 | Tcl_Obj *objPtr, /* Parseable font description object. */ TkFontAttributes *faPtr) /* Filled with attributes parsed from font * name. Any attributes that were not * specified in font name are filled with * default values. */ { const char *dash; int result, n; TkSizeT objc, i; Tcl_Obj **objv; const char *string; TkInitFontAttributes(faPtr); string = Tcl_GetString(objPtr); if (*string == '-') { |
︙ | ︙ |
Changes to generic/tkFont.h.
1 2 3 4 5 6 7 | /* * tkFont.h -- * * Declarations for interfaces between the generic and platform-specific * parts of the font package. This information is not visible outside of * the font package. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkFont.h -- * * 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 © 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. */ #ifndef _TKFONT #define _TKFONT |
︙ | ︙ |
Changes to generic/tkFrame.c.
1 2 3 4 5 6 7 | /* * tkFrame.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkFrame.c -- * * 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 © 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 "default.h" |
︙ | ︙ | |||
326 327 328 329 330 331 332 | * Forward declarations for functions defined later in this file: */ static void ComputeFrameGeometry(Frame *framePtr); static int ConfigureFrame(Tcl_Interp *interp, Frame *framePtr, int objc, Tcl_Obj *const objv[]); static int CreateFrame(ClientData clientData, Tcl_Interp *interp, | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | * Forward declarations for functions defined later in this file: */ static void ComputeFrameGeometry(Frame *framePtr); static int ConfigureFrame(Tcl_Interp *interp, Frame *framePtr, int objc, Tcl_Obj *const objv[]); static int CreateFrame(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], enum FrameType type, const char *appName); static void DestroyFrame(void *memPtr); static void DestroyFramePartly(Frame *framePtr); static void DisplayFrame(ClientData clientData); static void DrawFrameBackground(Tk_Window tkwin, Pixmap pixmap, int highlightWidth, int borderWidth, Tk_Image bgimg, int bgtile); |
︙ | ︙ | |||
485 486 487 488 489 490 491 | int toplevel, /* Non-zero means create a toplevel window, * zero means create a frame. */ Tcl_Obj *nameObj) /* Should only be non-NULL if there is no main * window associated with the interpreter. * Gives the base name to use for the new * application. */ { | | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 | int toplevel, /* Non-zero means create a toplevel window, * zero means create a frame. */ Tcl_Obj *nameObj) /* Should only be non-NULL if there is no main * window associated with the interpreter. * Gives the base name to use for the new * application. */ { TkSizeT objc; Tcl_Obj **objv; if (TCL_OK != Tcl_ListObjGetElements(interp, listObj, &objc, &objv)) { return TCL_ERROR; } return CreateFrame(clientData, interp, objc, objv, toplevel ? TYPE_TOPLEVEL : TYPE_FRAME, |
︙ | ︙ | |||
543 544 545 546 547 548 549 | * be processed specially, before the window is configured using the usual * Tk mechanisms. */ className = colormapName = screenName = visualName = useOption = NULL; colormap = None; for (i = 2; i < objc; i += 2) { | | | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 | * be processed specially, before the window is configured using the usual * Tk mechanisms. */ className = colormapName = screenName = visualName = useOption = NULL; colormap = None; for (i = 2; i < objc; i += 2) { arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } if ((arg[1] == 'c') && (length >= 3) && (strncmp(arg, "-class", length) == 0)) { className = Tcl_GetString(objv[i+1]); } else if ((arg[1] == 'c') && (length >= 3) |
︙ | ︙ | |||
575 576 577 578 579 580 581 | * before calling ConfigureFrame below, and they must also be processed in * a particular order, for the following reasons: * 1. Must set the window's class before calling ConfigureFrame, so that * unspecified options are looked up in the option database using the * correct class. * 2. Must set visual information before calling ConfigureFrame so that * colors are allocated in a proper colormap. | | | | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | * before calling ConfigureFrame below, and they must also be processed in * a particular order, for the following reasons: * 1. Must set the window's class before calling ConfigureFrame, so that * unspecified options are looked up in the option database using the * correct class. * 2. Must set visual information before calling ConfigureFrame so that * colors are allocated in a proper colormap. * 3. Must call Tk_UseWindow before setting non-default visual * information, since Tk_UseWindow changes the defaults. */ if (screenName == NULL) { screenName = (type == TYPE_TOPLEVEL) ? "" : NULL; } /* |
︙ | ︙ | |||
630 631 632 633 634 635 636 | } } Tk_SetClass(newWin, className); if (useOption == NULL) { useOption = Tk_GetOption(newWin, "use", "Use"); } if ((useOption != NULL) && (*useOption != 0) | | | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | } } Tk_SetClass(newWin, className); if (useOption == NULL) { useOption = Tk_GetOption(newWin, "use", "Use"); } if ((useOption != NULL) && (*useOption != 0) && (Tk_UseWindow(interp, newWin, useOption) != TCL_OK)) { goto error; } if (visualName == NULL) { visualName = Tk_GetOption(newWin, "visual", "Visual"); } if (colormapName == NULL) { colormapName = Tk_GetOption(newWin, "colormap", "Colormap"); |
︙ | ︙ | |||
723 724 725 726 727 728 729 | if (framePtr->useThis != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "windows cannot have both the -use and the -container" " option set", -1)); Tcl_SetErrorCode(interp, "TK", "FRAME", "CONTAINMENT", NULL); goto error; } | | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | if (framePtr->useThis != NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "windows cannot have both the -use and the -container" " option set", -1)); Tcl_SetErrorCode(interp, "TK", "FRAME", "CONTAINMENT", NULL); goto error; } Tk_MakeContainer(framePtr->tkwin); } if (type == TYPE_TOPLEVEL) { Tcl_DoWhenIdle(MapFrame, framePtr); } Tcl_SetObjResult(interp, Tk_NewWindowObj(newWin)); return TCL_OK; |
︙ | ︙ | |||
816 817 818 819 820 821 822 | } else { /* * Don't allow the options -class, -colormap, -container, -screen, * -use, or -visual to be changed. */ for (i = 2; i < objc; i++) { | | | | | 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | } else { /* * Don't allow the options -class, -colormap, -container, -screen, * -use, or -visual to be changed. */ for (i = 2; i < objc; i++) { const char *arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { continue; } c = arg[1]; if (((c == 'c') && (length >= 2) && (strncmp(arg, "-class", length) == 0)) || ((c == 'c') && (length >= 3) && (strncmp(arg, "-colormap", length) == 0)) || ((c == 'c') && (length >= 3) && (strncmp(arg, "-container", length) == 0)) || ((c == 's') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-screen", length) == 0)) || ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL) && (strncmp(arg, "-use", length) == 0)) || ((c == 'v') && (strncmp(arg, "-visual", length) == 0))) { #ifdef _WIN32 if (c == 'u') { const char *string = Tcl_GetString(objv[i+1]); if (Tk_UseWindow(interp, framePtr->tkwin, string) != TCL_OK) { result = TCL_ERROR; goto done; } continue; } #endif |
︙ | ︙ | |||
1031 1032 1033 1034 1035 1036 1037 | */ if ((((oldMenuName == NULL) && (framePtr->menuName != NULL)) || ((oldMenuName != NULL) && (framePtr->menuName == NULL)) || ((oldMenuName != NULL) && (framePtr->menuName != NULL) && strcmp(oldMenuName, framePtr->menuName) != 0)) && framePtr->type == TYPE_TOPLEVEL) { | | | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 | */ if ((((oldMenuName == NULL) && (framePtr->menuName != NULL)) || ((oldMenuName != NULL) && (framePtr->menuName == NULL)) || ((oldMenuName != NULL) && (framePtr->menuName != NULL) && strcmp(oldMenuName, framePtr->menuName) != 0)) && framePtr->type == TYPE_TOPLEVEL) { Tk_SetWindowMenubar(interp, framePtr->tkwin, oldMenuName, framePtr->menuName); } if (oldMenuName != NULL) { ckfree(oldMenuName); } |
︙ | ︙ | |||
1498 1499 1500 1501 1502 1503 1504 | GC fgGC, bgGC; bgGC = Tk_GCForColor(framePtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (framePtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(framePtr->highlightColorPtr, Tk_WindowId(tkwin)); | | | | 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 | GC fgGC, bgGC; bgGC = Tk_GCForColor(framePtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (framePtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(framePtr->highlightColorPtr, Tk_WindowId(tkwin)); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth, Tk_WindowId(tkwin)); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth, Tk_WindowId(tkwin)); } } /* * If -background is set to "", no interior is drawn. */ |
︙ | ︙ | |||
1743 1744 1745 1746 1747 1748 1749 | if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { goto redraw; } else if (eventPtr->type == ConfigureNotify) { ComputeFrameGeometry(framePtr); goto redraw; } else if (eventPtr->type == DestroyNotify) { if (framePtr->menuName != NULL) { | | | 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { goto redraw; } else if (eventPtr->type == ConfigureNotify) { ComputeFrameGeometry(framePtr); goto redraw; } else if (eventPtr->type == DestroyNotify) { if (framePtr->menuName != NULL) { Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin, framePtr->menuName, NULL); ckfree(framePtr->menuName); framePtr->menuName = NULL; } if (framePtr->tkwin != NULL) { /* * If this window is a container, then this event could be coming |
︙ | ︙ | |||
1792 1793 1794 1795 1796 1797 1798 | if (eventPtr->xfocus.detail != NotifyInferior) { framePtr->flags &= ~GOT_FOCUS; if (framePtr->highlightWidth > 0) { goto redraw; } } } else if (eventPtr->type == ActivateNotify) { | | | 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 | if (eventPtr->xfocus.detail != NotifyInferior) { framePtr->flags &= ~GOT_FOCUS; if (framePtr->highlightWidth > 0) { goto redraw; } } } else if (eventPtr->type == ActivateNotify) { Tk_SetMainMenubar(framePtr->interp, framePtr->tkwin, framePtr->menuName); } return; redraw: if ((framePtr->tkwin != NULL) && !(framePtr->flags & REDRAW_PENDING)) { Tcl_DoWhenIdle(DisplayFrame, framePtr); |
︙ | ︙ | |||
1830 1831 1832 1833 1834 1835 1836 | FrameCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { Frame *framePtr = (Frame *)clientData; Tk_Window tkwin = framePtr->tkwin; if (framePtr->menuName != NULL) { | | | 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 | FrameCmdDeletedProc( ClientData clientData) /* Pointer to widget record for widget. */ { Frame *framePtr = (Frame *)clientData; Tk_Window tkwin = framePtr->tkwin; if (framePtr->menuName != NULL) { Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin, framePtr->menuName, NULL); ckfree(framePtr->menuName); framePtr->menuName = NULL; } /* * This function could be invoked either because the window was destroyed |
︙ | ︙ | |||
2064 2065 2066 2067 2068 2069 2070 | Frame *framePtr = (Frame *)((TkWindow *) tkwin)->instanceData; Tk_OptionTable optionTable; if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) { framePtr->type = TYPE_TOPLEVEL; Tcl_DoWhenIdle(MapFrame, framePtr); if (framePtr->menuName != NULL) { | | | 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 | Frame *framePtr = (Frame *)((TkWindow *) tkwin)->instanceData; Tk_OptionTable optionTable; if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) { framePtr->type = TYPE_TOPLEVEL; Tcl_DoWhenIdle(MapFrame, framePtr); if (framePtr->menuName != NULL) { Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin, NULL, framePtr->menuName); } } else if (!Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_TOPLEVEL) { framePtr->type = TYPE_FRAME; } else { /* * Not a frame or toplevel, skip it. |
︙ | ︙ |
Changes to generic/tkGC.c.
1 2 3 4 5 6 | /* * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * 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 © 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. */ #include "tkInt.h" |
︙ | ︙ |
Changes to generic/tkGeometry.c.
1 2 3 4 5 6 | /* * tkGeometry.c -- * * This file contains generic Tk code for geometry management (stuff * that's used by all geometry managers). * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkGeometry.c -- * * This file contains generic Tk code for geometry management (stuff * that's used by all geometry managers). * * 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" |
︙ | ︙ | |||
557 558 559 560 561 562 563 | * container, then this procedure has no effect. * *---------------------------------------------------------------------- */ void Tk_UnmaintainGeometry( | | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | * container, then this procedure has no effect. * *---------------------------------------------------------------------- */ void Tk_UnmaintainGeometry( Tk_Window window, /* Window for geometry management. */ Tk_Window container) /* Container for window; must be a descendant of * window's parent. */ { Tcl_HashEntry *hPtr; MaintainContainer *containerPtr; MaintainContent *contentPtr, *prevPtr; Tk_Window ancestor; |
︙ | ︙ |
Changes to generic/tkGet.c.
1 2 3 4 5 6 7 8 | /* * tkGet.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkGet.c -- * * 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 © 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. */ #include "tkInt.h" |
︙ | ︙ | |||
31 32 33 34 35 36 37 | static void FreeUidThreadExitProc(ClientData clientData); /* * The following tables defines the string values for reliefs, which are * used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj. */ | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | static void FreeUidThreadExitProc(ClientData clientData); /* * The following tables defines the string values for reliefs, which are * used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj. */ const char *const tkAnchorStrings[] = { "n", "ne", "e", "se", "s", "sw", "w", "nw", "center", NULL }; const char *const tkJustifyStrings[] = { "left", "right", "center", NULL }; /* *---------------------------------------------------------------------- * * Tk_GetAnchorFromObj -- |
︙ | ︙ | |||
67 68 69 70 71 72 73 | * from. */ Tk_Anchor *anchorPtr) /* Where to place the Tk_Anchor that * corresponds to the string value of * objPtr. */ { int index, code; | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | * from. */ Tk_Anchor *anchorPtr) /* Where to place the Tk_Anchor that * corresponds to the string value of * objPtr. */ { int index, code; code = Tcl_GetIndexFromObj(interp, objPtr, tkAnchorStrings, "anchor", 0, &index); if (code == TCL_OK) { *anchorPtr = (Tk_Anchor) index; } return code; } |
︙ | ︙ | |||
186 187 188 189 190 191 192 193 194 195 196 197 198 199 | case TK_ANCHOR_E: return "e"; case TK_ANCHOR_SE: return "se"; case TK_ANCHOR_S: return "s"; case TK_ANCHOR_SW: return "sw"; case TK_ANCHOR_W: return "w"; case TK_ANCHOR_NW: return "nw"; case TK_ANCHOR_CENTER: return "center"; } return "unknown anchor position"; } /* *-------------------------------------------------------------- * | > | 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | case TK_ANCHOR_E: return "e"; case TK_ANCHOR_SE: return "se"; case TK_ANCHOR_S: return "s"; case TK_ANCHOR_SW: return "sw"; case TK_ANCHOR_W: return "w"; case TK_ANCHOR_NW: return "nw"; case TK_ANCHOR_CENTER: return "center"; case TK_ANCHOR_NULL: return ""; } return "unknown anchor position"; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
381 382 383 384 385 386 387 | * from. */ Tk_Justify *justifyPtr) /* Where to place the Tk_Justify that * corresponds to the string value of * objPtr. */ { int index, code; | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | * from. */ Tk_Justify *justifyPtr) /* Where to place the Tk_Justify that * corresponds to the string value of * objPtr. */ { int index, code; code = Tcl_GetIndexFromObj(interp, objPtr, tkJustifyStrings, "justification", 0, &index); if (code == TCL_OK) { *justifyPtr = (Tk_Justify) index; } return code; } |
︙ | ︙ | |||
467 468 469 470 471 472 473 474 475 476 477 478 479 480 | Tk_Justify justify) /* Justification style for which identifying * string is desired. */ { switch (justify) { case TK_JUSTIFY_LEFT: return "left"; case TK_JUSTIFY_RIGHT: return "right"; case TK_JUSTIFY_CENTER: return "center"; } return "unknown justification style"; } /* *---------------------------------------------------------------------- * | > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | Tk_Justify justify) /* Justification style for which identifying * string is desired. */ { switch (justify) { case TK_JUSTIFY_LEFT: return "left"; case TK_JUSTIFY_RIGHT: return "right"; case TK_JUSTIFY_CENTER: return "center"; case TK_JUSTIFY_NULL: return ""; } return "unknown justification style"; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
690 691 692 693 694 695 696 697 698 699 700 701 702 703 | * units. */ const char *string, /* String describing a number of pixels. */ double *doublePtr) /* Place to store converted result. */ { char *end; double d; d = strtod((char *) string, &end); if (end == string) { goto error; } while ((*end != '\0') && isspace(UCHAR(*end))) { end++; } | > > > > > | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 | * units. */ const char *string, /* String describing a number of pixels. */ 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))) { end++; } |
︙ | ︙ |
Changes to generic/tkGrab.c.
1 2 3 4 5 | /* * tkGrab.c -- * * This file provides functions that implement grabs for Tk. * | | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * tkGrab.c -- * * This file provides functions that implement grabs for Tk. * * 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. */ #include "tkInt.h" #ifdef _WIN32 #include "tkWinInt.h" #elif !defined(MAC_OSX_TK) #include "tkUnixInt.h" #else #include "tkMacOSXInt.h" #endif /* * The grab state machine has four states: ungrabbed, button pressed, grabbed, * and button pressed while grabbed. In addition, there are three pieces of * grab state information: the current grab window, the current restrict * window, and whether the mouse is captured. |
︙ | ︙ | |||
211 212 213 214 215 216 217 | return TCL_ERROR; } /* * First check for a window name or "-global" as the first argument. */ | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | return TCL_ERROR; } /* * First check for a window name or "-global" as the first argument. */ arg = Tcl_GetStringFromObj(objv[1], &len); if (arg[0] == '.') { /* [grab window] */ if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "?-global? window"); return TCL_ERROR; } tkwin = Tk_NameToWindow(interp, arg, (Tk_Window)clientData); |
︙ | ︙ |
Changes to generic/tkGrid.c.
1 2 3 4 5 | /* * tkGrid.c -- * * Grid based geometry manager. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkGrid.c -- * * Grid based geometry manager. * * 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. */ #include "tkInt.h" |
︙ | ︙ | |||
979 980 981 982 983 984 985 | { 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 */ | | | > | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | { 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 */ TkSizeT lObjc; /* Number of items in index list */ Tcl_Obj **lObjv; /* array of indices */ int ok; /* temporary TCL result code */ int i, first, last; TkSizeT j; const char *string; static const char *const optionStrings[] = { "-minsize", "-pad", "-uniform", "-weight", NULL }; enum options { ROWCOL_MINSIZE, ROWCOL_PAD, ROWCOL_UNIFORM, ROWCOL_WEIGHT }; |
︙ | ︙ | |||
2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 | static void DestroyGrid( void *memPtr) /* Info about window that is now dead. */ { Gridder *gridPtr = (Gridder *)memPtr; if (gridPtr->containerDataPtr != NULL) { if (gridPtr->containerDataPtr->rowPtr != NULL) { ckfree(gridPtr->containerDataPtr -> rowPtr); } if (gridPtr->containerDataPtr->columnPtr != NULL) { ckfree(gridPtr->containerDataPtr -> columnPtr); } | > > > | 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 | static void DestroyGrid( void *memPtr) /* Info about window that is now dead. */ { Gridder *gridPtr = (Gridder *)memPtr; if (gridPtr->flags & REQUESTED_RELAYOUT) { Tcl_CancelIdleCall(ArrangeGrid, gridPtr); } if (gridPtr->containerDataPtr != NULL) { if (gridPtr->containerDataPtr->rowPtr != NULL) { ckfree(gridPtr->containerDataPtr -> rowPtr); } if (gridPtr->containerDataPtr->columnPtr != NULL) { ckfree(gridPtr->containerDataPtr -> columnPtr); } |
︙ | ︙ | |||
2982 2983 2984 2985 2986 2987 2988 | */ firstChar = 0; for (numWindows=0, i=0; i < objc; i++) { TkSizeT length; char prevChar = firstChar; | | | 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 | */ firstChar = 0; for (numWindows=0, i=0; i < objc; i++) { TkSizeT length; char prevChar = firstChar; string = Tcl_GetStringFromObj(objv[i], &length); firstChar = string[0]; if (firstChar == '.') { /* * Check that windows are valid, and locate the first content's * parent window (default for -in). */ |
︙ | ︙ |
Added generic/tkIcu.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | /* * tkIcu.c -- * * tkIcu.c implements various Tk commands which can find * grapheme cluster and workchar bounderies in Unicode strings. * * Copyright © 2021 Jan Nijtmans * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #include "tkInt.h" #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif #ifdef HAVE_STDINT_H #include <stdint.h> #endif /* * Runtime linking of libicu. */ typedef enum UBreakIteratorTypex { UBRK_CHARACTERX = 0, UBRK_WORDX = 1 } UBreakIteratorTypex; typedef enum UErrorCodex { U_ZERO_ERRORZ = 0 /**< No error, no warning. */ } UErrorCodex; typedef void *(*fn_icu_open)(UBreakIteratorTypex, const char *, const uint16_t *, int32_t, UErrorCodex *); typedef void (*fn_icu_close)(void *); typedef int32_t (*fn_icu_preceding)(void *, int32_t); typedef int32_t (*fn_icu_following)(void *, int32_t); typedef int32_t (*fn_icu_previous)(void *); typedef int32_t (*fn_icu_next)(void *); typedef void (*fn_icu_setText)(void *, const void *, int32_t, UErrorCodex *); static struct { size_t nopen; Tcl_LoadHandle lib; fn_icu_open open; fn_icu_close close; fn_icu_preceding preceding; fn_icu_following following; fn_icu_previous previous; fn_icu_next next; fn_icu_setText setText; } icu_fns = { 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; #define FLAG_WORD 1 #define FLAG_FOLLOWING 4 #define FLAG_SPACE 8 #define icu_open icu_fns.open #define icu_close icu_fns.close #define icu_preceding icu_fns.preceding #define icu_following icu_fns.following #define icu_previous icu_fns.previous #define icu_next icu_fns.next #define icu_setText icu_fns.setText TCL_DECLARE_MUTEX(icu_mutex); static int startEndOfCmd( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tcl_DString ds; TkSizeT len; const char *str; UErrorCodex errorCode = U_ZERO_ERRORZ; void *it; TkSizeT idx; int flags = PTR2INT(clientData); const uint16_t *ustr; const char *locale = NULL; if ((unsigned)(objc - 3) > 1) { Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?"); return TCL_ERROR; } if (objc > 3) { locale = Tcl_GetString(objv[3]); if (!*locale) { locale = NULL; } } Tcl_DStringInit(&ds); str = Tcl_GetStringFromObj(objv[1], &len); Tcl_UtfToChar16DString(str, len, &ds); len = Tcl_DStringLength(&ds)/2; if (TkGetIntForIndex(objv[2], len-1, 0, &idx) != TCL_OK) { Tcl_DStringFree(&ds); Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "ICU", "INDEX", NULL); return TCL_ERROR; } it = icu_open((UBreakIteratorTypex)(flags&3), locale, NULL, -1, &errorCode); if (it != NULL) { errorCode = U_ZERO_ERRORZ; ustr = (const uint16_t *)Tcl_DStringValue(&ds); icu_setText(it, ustr, len, &errorCode); } if (it == NULL || errorCode != U_ZERO_ERRORZ) { Tcl_DStringFree(&ds); Tcl_SetObjResult(interp, Tcl_ObjPrintf("cannot open ICU iterator, errorcode: %d", (int)errorCode)); Tcl_SetErrorCode(interp, "TK", "ICU", "CANNOTOPEN", NULL); return TCL_ERROR; } if (flags & FLAG_FOLLOWING) { if ((idx == TCL_INDEX_NONE) && (flags & FLAG_WORD)) { idx = 0; } idx = icu_following(it, idx); if ((flags & FLAG_WORD) && idx >= len) { idx = -1; } } else if (idx > 0) { if (!(flags & FLAG_WORD)) { idx += 1 + (((ustr[idx]&0xFFC0) == 0xD800) && ((ustr[idx+1]&0xFFC0) == 0xDC00)); } idx = icu_preceding(it, idx); if (idx == 0 && (flags & FLAG_WORD)) { flags &= ~FLAG_WORD; /* If 0 is reached here, don't do a further search */ } } if ((flags & FLAG_WORD) && (idx != TCL_INDEX_NONE)) { if (!(flags & FLAG_SPACE) == ((idx >= len) || Tcl_UniCharIsSpace(ustr[idx]))) { if (flags & FLAG_FOLLOWING) { idx = icu_next(it); if (idx >= len) { idx = TCL_INDEX_NONE; } } else { idx = icu_previous(it); } } else if (idx == 0 && !(flags & FLAG_FOLLOWING)) { idx = TCL_INDEX_NONE; } } icu_close(it); Tcl_DStringFree(&ds); if (idx != TCL_INDEX_NONE) { Tcl_SetObjResult(interp, TkNewIndexObj(idx)); } return TCL_OK; } /* *---------------------------------------------------------------------- * * SysNotifyDeleteCmd -- * * Delete notification and clean up. * * Results: * Window destroyed. * * Side effects: * None. * *---------------------------------------------------------------------- */ static void icuCleanup( TCL_UNUSED(void *)) { Tcl_MutexLock(&icu_mutex); if (icu_fns.nopen-- <= 1) { if (icu_fns.lib != NULL) { Tcl_FSUnloadFile(NULL, icu_fns.lib); } memset(&icu_fns, 0, sizeof(icu_fns)); } Tcl_MutexUnlock(&icu_mutex); } void Icu_Init( Tcl_Interp *interp) { Tcl_MutexLock(&icu_mutex); char symbol[24]; char icuversion[4] = "_75"; /* Highest ICU version + 1 */ if (icu_fns.nopen == 0) { int i = 0; Tcl_Obj *nameobj; static const char *iculibs[] = { #if defined(_WIN32) "icuuc??.dll", /* When running under Windows, user-provided */ NULL, "cygicuuc??.dll", /* When running under Cygwin */ #elif defined(__CYGWIN__) "cygicuuc??.dll", #elif defined(MAC_OSX_TCL) "libicuuc.??.dylib", #else "libicuuc.so.??", #endif NULL }; /* Going back down to ICU version 50 */ while ((icu_fns.lib == NULL) && (icuversion[1] >= '5')) { if (icuversion[2]-- < '0') { icuversion[1]--; icuversion[2] = '9'; } #if defined(_WIN32) && !defined(STATIC_BUILD) if (tclStubsPtr->tcl_CreateFileHandler) { /* Running on Cygwin, so try to load the cygwin icu dll */ i = 2; } else #endif i = 0; while (iculibs[i] != NULL) { Tcl_ResetResult(interp); nameobj = Tcl_NewStringObj(iculibs[i], -1); char *nameStr = Tcl_GetString(nameobj); char *p = strchr(nameStr, '?'); if (p != NULL) { memcpy(p, icuversion+1, 2); } Tcl_IncrRefCount(nameobj); if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib) == TCL_OK) { if (p == NULL) { icuversion[0] = '\0'; } Tcl_DecrRefCount(nameobj); break; } Tcl_DecrRefCount(nameobj); ++i; } } #if defined(_WIN32) if (icu_fns.lib == NULL) { Tcl_ResetResult(interp); nameobj = Tcl_NewStringObj("icu.dll", -1); Tcl_IncrRefCount(nameobj); if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib) == TCL_OK) { icuversion[0] = '\0'; } Tcl_DecrRefCount(nameobj); } if (icu_fns.lib == NULL) { Tcl_ResetResult(interp); nameobj = Tcl_NewStringObj("icuuc.dll", -1); Tcl_IncrRefCount(nameobj); if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib) == TCL_OK) { icuversion[0] = '\0'; } Tcl_DecrRefCount(nameobj); } #endif if (icu_fns.lib != NULL) { #define ICU_SYM(name) \ strcpy(symbol, "ubrk_" #name ); \ strcat(symbol, icuversion); \ icu_fns.name = (fn_icu_ ## name) \ Tcl_FindSymbol(NULL, icu_fns.lib, symbol) ICU_SYM(open); ICU_SYM(close); ICU_SYM(preceding); ICU_SYM(following); ICU_SYM(previous); ICU_SYM(next); ICU_SYM(setText); #undef ICU_SYM } } Tcl_MutexUnlock(&icu_mutex); if (icu_fns.lib != NULL) { Tcl_CreateObjCommand(interp, "::tk::startOfCluster", startEndOfCmd, INT2PTR(0), icuCleanup); Tcl_CreateObjCommand(interp, "::tk::startOfNextWord", startEndOfCmd, INT2PTR(FLAG_WORD|FLAG_FOLLOWING), icuCleanup); Tcl_CreateObjCommand(interp, "::tk::startOfPreviousWord", startEndOfCmd, INT2PTR(FLAG_WORD), icuCleanup); Tcl_CreateObjCommand(interp, "::tk::endOfCluster", startEndOfCmd, INT2PTR(FLAG_FOLLOWING), icuCleanup); Tcl_CreateObjCommand(interp, "::tk::endOfWord", startEndOfCmd, INT2PTR(FLAG_WORD|FLAG_FOLLOWING|FLAG_SPACE), icuCleanup); icu_fns.nopen += 5; } } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * coding: utf-8 * End: */ |
Changes to generic/tkImage.c.
1 2 3 4 5 6 | /* * tkImage.c -- * * This module implements the image protocol, which allows lots of * different kinds of images to be used in lots of different widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * 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 © 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" |
︙ | ︙ |
Changes to generic/tkImgBmap.c.
1 2 3 4 5 | /* * tkImgBmap.c -- * * This procedure implements images of type "bitmap" for Tk. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkImgBmap.c -- * * This procedure implements images of type "bitmap" for Tk. * * 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" |
︙ | ︙ | |||
71 72 73 74 75 76 77 | /* * The type record for bitmap images: */ static int GetByte(Tcl_Channel chan); static int ImgBmapCreate(Tcl_Interp *interp, | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* * The type record for bitmap images: */ static int GetByte(Tcl_Channel chan); static int ImgBmapCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], 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, int drawableX, int drawableY); |
︙ | ︙ | |||
142 143 144 145 146 147 148 | } ParseInfo; /* * Prototypes for procedures used only locally in this file: */ static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, | | | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | } ParseInfo; /* * Prototypes for procedures used only locally in this file: */ static int ImgBmapCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static void ImgBmapCmdDeletedProc(ClientData clientData); static void ImgBmapConfigureInstance(BitmapInstance *instancePtr); static int ImgBmapConfigureModel(BitmapModel *modelPtr, int objc, Tcl_Obj *const objv[], int flags); static int NextBitmapWord(ParseInfo *parseInfoPtr); /* *---------------------------------------------------------------------- * * ImgBmapCreate -- * |
︙ | ︙ | |||
170 171 172 173 174 175 176 | */ static int ImgBmapCreate( Tcl_Interp *interp, /* Interpreter for application containing * image. */ const char *name, /* Name to use for image. */ | | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | */ static int ImgBmapCreate( Tcl_Interp *interp, /* Interpreter for application containing * image. */ 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). */ const Tk_ImageType *typePtr,/* 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. */ { |
︙ | ︙ | |||
196 197 198 199 200 201 202 | modelPtr->fgUid = NULL; modelPtr->bgUid = NULL; modelPtr->fileString = NULL; modelPtr->dataString = NULL; modelPtr->maskFileString = NULL; modelPtr->maskDataString = NULL; modelPtr->instancePtr = NULL; | | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | modelPtr->fgUid = NULL; modelPtr->bgUid = NULL; modelPtr->fileString = NULL; modelPtr->dataString = NULL; modelPtr->maskFileString = NULL; modelPtr->maskDataString = NULL; modelPtr->instancePtr = NULL; if (ImgBmapConfigureModel(modelPtr, objc, objv, 0) != TCL_OK) { ImgBmapDelete(modelPtr); return TCL_ERROR; } *clientDataPtr = modelPtr; return TCL_OK; } |
︙ | ︙ | |||
496 497 498 499 500 501 502 | if ((interp != NULL) && Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get bitmap data from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL); return NULL; } | | | > > | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | if ((interp != NULL) && Tcl_IsSafe(interp)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "can't get bitmap data from a file in a safe interpreter", -1)); Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL); return NULL; } expandedFileName = Tcl_TranslateFileName(NULL, fileName, &buffer); if (expandedFileName == NULL) { Tcl_SetErrno(ENOENT); goto cannotRead; } pi.chan = Tcl_OpenFileChannel(interp, expandedFileName, "r", 0); Tcl_DStringFree(&buffer); if (pi.chan == NULL) { cannotRead: if (interp != NULL) { Tcl_ResetResult(interp); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't read bitmap file \"%s\": %s", fileName, Tcl_PosixError(interp))); } return NULL; |
︙ | ︙ |
Changes to generic/tkImgGIF.c.
1 2 3 4 5 6 7 8 9 10 | /* * tkImgGIF.c -- * * A photo image file handler for GIF files. Reads 87a and 89a GIF files. * At present, there only is a file write function. GIF images may be * 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. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * tkImgGIF.c -- * * A photo image file handler for GIF files. Reads 87a and 89a GIF files. * At present, there only is a file write function. GIF images may be * 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 © Reed Wade ([email protected]), 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 * copyrighted as follows: * |
︙ | ︙ | |||
114 115 116 117 118 119 120 | typedef size_t (WriteBytesFunc) (ClientData clientData, const char *bytes, size_t byteCount); /* * The format record for the GIF file format: */ | | | | > | | > | > | > > | | > | > | > > | | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | typedef size_t (WriteBytesFunc) (ClientData clientData, const char *bytes, size_t byteCount); /* * The format record for the GIF file format: */ static int FileMatchGIF(Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataInObj, int *widthPtr, int *heightPtr, Tcl_Obj *metadataOutObj); static int FileReadGIF(Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY, Tcl_Obj *metadataOutObj); static int StringMatchGIF(Tcl_Interp *interp, Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataInObj, int *widthPtr, int *heightPtr, Tcl_Obj *metadataOutObj); static int StringReadGIF(Tcl_Interp *interp, Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY, Tcl_Obj *metadataOutObj); static int FileWriteGIF(Tcl_Interp *interp, const char *filename, Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr); static int StringWriteGIF(Tcl_Interp *interp, Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr); static int CommonWriteGIF(Tcl_Interp *interp, ClientData clientData, WriteBytesFunc *writeProc, Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr); Tk_PhotoImageFormatVersion3 tkImgFmtGIF = { "gif", /* name */ FileMatchGIF, /* fileMatchProc */ StringMatchGIF, /* stringMatchProc */ FileReadGIF, /* fileReadProc */ StringReadGIF, /* stringReadProc */ FileWriteGIF, /* fileWriteProc */ StringWriteGIF, /* stringWriteProc */ |
︙ | ︙ | |||
161 162 163 164 165 166 167 168 169 | #define MAX_LWZ_BITS 12 #define LM_to_uint(a,b) (((b)<<8)|(a)) /* * Prototypes for local functions defined in this file: */ static int DoExtension(GIFImageConfig *gifConfPtr, Tcl_Channel chan, int label, unsigned char *buffer, | > > | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | #define MAX_LWZ_BITS 12 #define LM_to_uint(a,b) (((b)<<8)|(a)) /* * Prototypes for local functions defined in this file: */ static int ReadOneByte(Tcl_Interp *interp, GIFImageConfig *gifConfPtr, Tcl_Channel chan); static int DoExtension(GIFImageConfig *gifConfPtr, Tcl_Channel chan, int label, unsigned char *buffer, int *transparent, Tcl_Obj *metadataOutObj); static int GetCode(Tcl_Channel chan, int code_size, int flag, GIFImageConfig *gifConfPtr); static int GetDataBlock(GIFImageConfig *gifConfPtr, Tcl_Channel chan, unsigned char *buf); static int ReadColorMap(GIFImageConfig *gifConfPtr, Tcl_Channel chan, int number, unsigned char buffer[MAXCOLORMAPSIZE][4]); |
︙ | ︙ | |||
341 342 343 344 345 346 347 348 | * The access position in f may change. * *---------------------------------------------------------------------- */ static int FileMatchGIF( Tcl_Channel chan, /* The image file, open for reading. */ | > | | > | < < < | 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | * The access position in f may change. * *---------------------------------------------------------------------- */ static int FileMatchGIF( 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 *), /* 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 */ { GIFImageConfig gifConf; memset(&gifConf, 0, sizeof(GIFImageConfig)); return ReadGIFHeader(&gifConf, chan, widthPtr, heightPtr); } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
383 384 385 386 387 388 389 390 391 392 393 394 | static int FileReadGIF( 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 object, 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. */ | > | > > | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | static int FileReadGIF( 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 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. */ int width, int height, /* Dimensions of block of photo image to be * written to. */ int srcX, int srcY, /* Coordinates of top-left pixel to be used in * image being read. */ Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */ { int fileWidth, fileHeight, imageWidth, imageHeight; unsigned int nBytes; int index = 0, argc = 0, i, result = TCL_ERROR; Tcl_Obj **objv; unsigned char buf[100]; unsigned char *trashBuffer = NULL; int bitPixel; int gifLabel; unsigned char colorMap[MAXCOLORMAPSIZE][4]; int transparent = -1; static const char *const optionStrings[] = { "-index", NULL }; GIFImageConfig gifConf, *gifConfPtr = &gifConf; |
︙ | ︙ | |||
499 500 501 502 503 504 505 506 507 508 509 510 | */ if (Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height) != TCL_OK) { return TCL_ERROR; } /* * Search for the frame from the GIF to display. */ while (1) { | > > > > > > < < < < | < < < < | | < < < < < | | > | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | */ if (Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height) != TCL_OK) { return TCL_ERROR; } /* * ------------------------------------------------------------------------- * From here on, go to error to not leave memory leaks * ------------------------------------------------------------------------- */ /* * Search for the frame from the GIF to display. */ while (1) { if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) { goto error; } switch (gifLabel) { case GIF_TERMINATOR: Tcl_SetObjResult(interp, Tcl_NewStringObj( "no image data for this index", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "NO_DATA", NULL); goto error; case GIF_EXTENSION: /* * This is a GIF extension. */ if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) { goto error; } if (DoExtension(gifConfPtr, chan, gifLabel, gifConfPtr->workingBuffer, &transparent, metadataOutObj) < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading extension in GIF image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT", NULL); goto error; } continue; |
︙ | ︙ | |||
623 624 625 626 627 628 629 630 631 632 633 634 635 636 | * common case. */ if (ReadImage(gifConfPtr, interp, trashBuffer, chan, imageWidth, imageHeight, colorMap, 0, 0, 0, -1) != TCL_OK) { goto error; } continue; } break; } /* * Found the frame we want to read. Next, check for a local color map for | > > > > > > > | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 | * common case. */ if (ReadImage(gifConfPtr, interp, trashBuffer, chan, imageWidth, imageHeight, colorMap, 0, 0, 0, -1) != TCL_OK) { goto error; } /* * This extension starts a new scope, so Graphic control Extension * data should be cleared */ transparent = -1; continue; } break; } /* * Found the frame we want to read. Next, check for a local color map for |
︙ | ︙ | |||
714 715 716 717 718 719 720 721 722 723 724 | ckfree(block.pixelPtr); } /* * We've successfully read the GIF frame (or there was nothing to read, * which suits as well). We're done. */ Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, -1)); result = TCL_OK; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > < > < < | | 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 | ckfree(block.pixelPtr); } /* * We've successfully read the GIF frame (or there was nothing to read, * which suits as well). We're done. */ while (1) { if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) { goto error; } switch (gifLabel) { case GIF_TERMINATOR: break; case GIF_EXTENSION: /* * This is a GIF extension. */ if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) { goto error; } if (DoExtension(gifConfPtr, chan, gifLabel, gifConfPtr->workingBuffer, &transparent, metadataOutObj) < 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "error reading extension in GIF image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT", NULL); goto error; } continue; case GIF_START: /* * There should not be a second image block - bail out without error */ break; default: /* * Not a valid start character; ignore it. */ continue; } break; } Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, -1)); result = TCL_OK; error: /* * If a trash buffer has been allocated, free it now. */ if (trashBuffer != NULL) { ckfree(trashBuffer); } return result; } /* *---------------------------------------------------------------------- * * Read one Byte -- * * Read one byte (label byte) from the image stream. * * Results: * The return value is 1 if the first characters in the data are like GIF * data, and 0 otherwise. * * Side effects: * The access position in the source is incremented. * *---------------------------------------------------------------------- */ static int ReadOneByte( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ GIFImageConfig *gifConfPtr, Tcl_Channel chan /* The image file, open for reading. */ ) { unsigned char buf[2]; if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) { /* * Premature end of image. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "premature end of image data", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END", NULL); return -1; } return buf[0]; } /* *---------------------------------------------------------------------- * * StringMatchGIF -- * * This function is invoked by the photo image type to see if an object * contains image data in GIF format. * * Results: * The return value is 1 if the first characters in the data are like GIF * data, and 0 otherwise. * * Side effects: * The size of the image is placed in widthPtr and heightPtr. * *---------------------------------------------------------------------- */ static int StringMatchGIF( TCL_UNUSED(Tcl_Interp *), /* not used */ Tcl_Obj *dataObj, /* the object containing the image data */ 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 */ { unsigned char *data, header[10]; TkSizeT got, length; MFile handle; data = Tcl_GetByteArrayFromObj(dataObj, &length); /* * Header is a minimum of 10 bytes. */ if (length < 10) { return 0; |
︙ | ︙ | |||
821 822 823 824 825 826 827 828 829 830 | */ static int StringReadGIF( Tcl_Interp *interp, /* interpreter for reporting errors in */ Tcl_Obj *dataObj, /* object containing the image */ Tcl_Obj *format, /* format object, or NULL */ Tk_PhotoHandle imageHandle, /* the image to write this data into */ int destX, int destY, /* The rectangular region of the */ int width, int height, /* image to copy */ | > | > | | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 | */ static int StringReadGIF( Tcl_Interp *interp, /* interpreter for reporting errors in */ Tcl_Obj *dataObj, /* object containing the image */ Tcl_Obj *format, /* format object, or NULL */ Tcl_Obj *metadataInObj, /* metadata input, may be NULL */ Tk_PhotoHandle imageHandle, /* the image to write this data into */ int destX, int destY, /* The rectangular region of the */ int width, int height, /* image to copy */ int srcX, int srcY, Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */ { MFile handle, *hdlPtr = &handle; TkSizeT length; const char *xferFormat; unsigned char *data = Tcl_GetByteArrayFromObj(dataObj, &length); mInit(data, hdlPtr, length); /* * Check whether the data is Base64 encoded by doing a character-by- * charcter comparison with the binary-format headers; BASE64-encoded * never matches (matching the other way is harder because of potential |
︙ | ︙ | |||
853 854 855 856 857 858 859 | /* * Fall through to the file reader now that we have a correctly-configured * pseudo-channel to pull the data from. */ return FileReadGIF(interp, (Tcl_Channel) hdlPtr, xferFormat, format, | | > | 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 | /* * Fall through to the file reader now that we have a correctly-configured * pseudo-channel to pull the data from. */ return FileReadGIF(interp, (Tcl_Channel) hdlPtr, xferFormat, format, metadataInObj, imageHandle, destX, destY, width, height, srcX, srcY, metadataOutObj); } /* *---------------------------------------------------------------------- * * ReadGIFHeader -- * |
︙ | ︙ | |||
932 933 934 935 936 937 938 939 940 941 942 943 | buffer[i][CM_BLUE] = rgb[2]; buffer[i][CM_ALPHA] = 255; } } return 1; } static int DoExtension( GIFImageConfig *gifConfPtr, Tcl_Channel chan, int label, | > > > > > > > > > > > > > > > > > > > > > | | > > > > > > > > | | > | < < < < < < < | > > > > > | > > > > > | | > | > > > > > > > | | > > > > > > > > > > > > > > > > > > > | | 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | buffer[i][CM_BLUE] = rgb[2]; buffer[i][CM_ALPHA] = 255; } } return 1; } /* *---------------------------------------------------------------------- * * DoExtension -- * * Process a GIF extension block * * Results: * -1 to trigger an extension read error * >= 0 ok * * Side effects: * The transparent color is set if present in current extensions * The data of the following extensions are saved to the metadata dict: * - Application extension * - Comment extension in key "comment" * Plain text extensions are currently ignored. * *---------------------------------------------------------------------- */ static int DoExtension( GIFImageConfig *gifConfPtr, Tcl_Channel chan, int label, unsigned char *buf, /* defined as 280 byte working buffer */ int *transparent, Tcl_Obj *metadataOutObj) { int count; /* Prepare extension name * Maximum string size: "comment" + Code(3) + trailing zero */ char extensionStreamName[8]; extensionStreamName[0] = '\0'; switch (label) { case 0x01: /* Plain Text Extension */ /* * This extension starts a new scope, so Graphic control Extension * data should be cleared */ *transparent = -1; /* this extension is ignored, skip below */ break; case 0xf9: /* Graphic Control Extension */ count = GetDataBlock(gifConfPtr, chan, buf); if (count < 0) { return -1; } if ((buf[0] & 0x1) != 0) { *transparent = buf[3]; } break; case 0xfe: /* Comment Extension */ strcpy(extensionStreamName,"comment"); /* copy the extension data below */ break; } /* Add extension to dict */ if (NULL != metadataOutObj && extensionStreamName[0] != '\0' ) { Tcl_Obj *ValueObj = NULL; int length = 0; for (;;) { count = GetDataBlock(gifConfPtr, chan, buf); switch (count) { case -1: /* error */ return -1; case 0: /* end of data */ if (length > 0) { if ( TCL_OK != Tcl_DictObjPut(NULL, metadataOutObj, Tcl_NewByteArrayObj( (unsigned char *)extensionStreamName, strlen(extensionStreamName)), ValueObj)) { return -1; } } /* return success */ return 0; default: /* block received */ if (length == 0) { /* first block */ ValueObj = Tcl_NewByteArrayObj(buf, count); length = count; } else { /* consecutive block */ unsigned char *bytePtr; bytePtr = Tcl_SetByteArrayLength(ValueObj, length+count); memcpy(bytePtr+length,buf,count); length += count; } break; } } /* for */ } /* skip eventual remaining data block bytes */ do { count = GetDataBlock(gifConfPtr, chan, buf); } while (count > 0); return count; /* this may be -1 for error or 0 */ } static int GetDataBlock( GIFImageConfig *gifConfPtr, Tcl_Channel chan, unsigned char *buf) |
︙ | ︙ | |||
1030 1031 1032 1033 1034 1035 1036 | ReadImage( GIFImageConfig *gifConfPtr, Tcl_Interp *interp, unsigned char *imagePtr, Tcl_Channel chan, int len, int rows, unsigned char cmap[MAXCOLORMAPSIZE][4], | | > < < | 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 | ReadImage( GIFImageConfig *gifConfPtr, Tcl_Interp *interp, unsigned char *imagePtr, Tcl_Channel chan, int len, int rows, unsigned char cmap[MAXCOLORMAPSIZE][4], TCL_UNUSED(int), TCL_UNUSED(int), int interlace, int transparent) { unsigned char initialCodeSize; int xpos = 0, ypos = 0, pass = 0, i, count; unsigned char *pixelPtr; static const int interlaceStep[] = { 8, 8, 4, 2 }; static const int interlaceStart[] = { 0, 4, 2, 1 }; unsigned short prefix[(1 << MAX_LWZ_BITS)]; unsigned char append[(1 << MAX_LWZ_BITS)]; unsigned char stack[(1 << MAX_LWZ_BITS)*2]; unsigned char *top; int codeSize, clearCode, inCode, endCode, oldCode, maxCode; int code, firstCode, v; /* * Initialize the decoder */ if (((size_t)Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) + 1) < 2) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( |
︙ | ︙ | |||
1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 | static int FileWriteGIF( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ const char *filename, Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan = NULL; int result; chan = Tcl_OpenFileChannel(interp, (char *) filename, "w", 0644); if (!chan) { return TCL_ERROR; } if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } | > | > > | | 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 | static int FileWriteGIF( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ const char *filename, Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan = NULL; int result; chan = Tcl_OpenFileChannel(interp, (char *) filename, "w", 0644); if (!chan) { return TCL_ERROR; } if (Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } result = CommonWriteGIF(interp, chan, WriteToChannel, format, metadataInObj, blockPtr); if (Tcl_Close(interp, chan) == TCL_ERROR) { return TCL_ERROR; } return result; } static int StringWriteGIF( Tcl_Interp *interp, /* Interpreter to use for reporting errors and * returning the GIF data. */ Tcl_Obj *format, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr) { int result; Tcl_Obj *objPtr = Tcl_NewObj(); Tcl_IncrRefCount(objPtr); result = CommonWriteGIF(interp, objPtr, WriteToByteArray, format, metadataInObj, blockPtr); if (result == TCL_OK) { Tcl_SetObjResult(interp, objPtr); } Tcl_DecrRefCount(objPtr); return result; } |
︙ | ︙ | |||
1707 1708 1709 1710 1711 1712 1713 | } static int CommonWriteGIF( Tcl_Interp *interp, ClientData handle, WriteBytesFunc *writeProc, | > | < | 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 | } static int CommonWriteGIF( Tcl_Interp *interp, ClientData handle, WriteBytesFunc *writeProc, TCL_UNUSED(Tcl_Obj *), Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr) { GifWriterState state; int resolution; long width, height, x; unsigned char c; unsigned int top, left; top = 0; left = 0; memset(&state, 0, sizeof(state)); state.pixelSize = blockPtr->pixelSize; |
︙ | ︙ | |||
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 | state.ssize = state.rsize = blockPtr->width; state.csize = blockPtr->height; Compress(resolution+1, handle, writeProc, ReadValue, &state); c = 0; writeProc(handle, (char *) &c, 1); c = GIF_TERMINATOR; writeProc(handle, (char *) &c, 1); return TCL_OK; } static int | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 | state.ssize = state.rsize = blockPtr->width; state.csize = blockPtr->height; Compress(resolution+1, handle, writeProc, ReadValue, &state); c = 0; writeProc(handle, (char *) &c, 1); /* * Check for metadata keys to add to file */ if (NULL != metadataInObj) { Tcl_Obj *itemData; /* * Check and code comment block */ if (TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj, Tcl_NewStringObj("comment",-1), &itemData)) { return TCL_ERROR; } if (itemData != NULL) { int length; unsigned char *comment; comment = Tcl_GetByteArrayFromObj(itemData, &length); if (length > 0) { /* write comment header */ writeProc(handle, (char *) "\x21\xfe", 2); /* write comment blocks */ for (;length > 0;) { int blockLength; unsigned char blockLengthChar; if (length > 255) { length -=255; blockLength = 255; } else { blockLength = length; length = 0; } blockLengthChar = (unsigned char) blockLength; writeProc(handle, (char *) &blockLengthChar, 1); writeProc(handle, (char *) comment, blockLength); comment += blockLength; } /* Block terminator */ c = 0; writeProc(handle, (char *) &c, 1); } } } c = GIF_TERMINATOR; writeProc(handle, (char *) &c, 1); return TCL_OK; } static int |
︙ | ︙ |
Changes to generic/tkImgListFormat.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | * list element being itself a list of pixels (or columns). For details, * see the manpage photo.n * * This image format cannot read/write files, it is meant for string * data only. * * | | | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * list element being itself a list of pixels (or columns). For details, * see the manpage photo.n * * This image format cannot read/write files, it is meant for string * data only. * * * 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: * Paul Mackerras ([email protected]), * Department of Computer Science, |
︙ | ︙ | |||
40 41 42 43 44 45 46 | /* * Color name length limit: do not attempt to parse as color strings that are * longer than this limit */ | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | /* * Color name length limit: do not attempt to parse as color strings that are * longer than this limit */ #define TK_PHOTO_MAX_COLOR_LENGTH 99 /* * Symbols for the different formats of a color string. */ enum ColorFormatType { COLORFORMAT_TKCOLOR, |
︙ | ︙ | |||
192 193 194 195 196 197 198 | int *indexPtr, /* Index giving the first element to * parse. The value is updated to the * index where parsing ended */ struct FormatOptions *optPtr) /* Parsed option values are written to * this struct */ { | | < | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | int *indexPtr, /* Index giving the first element to * parse. The value is updated to the * index where parsing ended */ struct FormatOptions *optPtr) /* Parsed option values are written to * this struct */ { int index, optIndex, first, typeIndex; const char *option; first = 1; /* * Fill in default values */ |
︙ | ︙ | |||
254 255 256 257 258 259 260 | Tcl_SetObjResult(interp, Tcl_ObjPrintf("the \"%s\" option " "requires a value", Tcl_GetString(objv[index - 1]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "", | | | | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | Tcl_SetObjResult(interp, Tcl_ObjPrintf("the \"%s\" option " "requires a value", Tcl_GetString(objv[index - 1]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "", TCL_EXACT, &typeIndex) != TCL_OK || (typeIndex != COLORFORMAT_LIST && typeIndex != COLORFORMAT_RGB2 && typeIndex != COLORFORMAT_RGBA2) ) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad color format " "\"%s\": must be rgb, rgba, or list", Tcl_GetString(objv[index]))); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_COLOR_FORMAT", NULL); return TCL_ERROR; } optPtr->colorFormat = (enum ColorFormatType)typeIndex; break; default: Tcl_Panic("ParseFormatOptions: unexpected switch fallthrough"); } /* * Add option to bitfield in optPtr |
︙ | ︙ | |||
409 410 411 412 413 414 415 | * Data in base64 encoding (or even binary data), might actually pass * these tests. To avoid parsing it as list of lists format, check one * pixel for validity. */ if (Tcl_ListObjIndex(interp, rowListPtr[0], 0, &pixelData) != TCL_OK) { return 0; } | > | | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | * Data in base64 encoding (or even binary data), might actually pass * these tests. To avoid parsing it as list of lists format, check one * pixel for validity. */ if (Tcl_ListObjIndex(interp, rowListPtr[0], 0, &pixelData) != TCL_OK) { return 0; } (void)Tcl_GetString(pixelData); if (pixelData->length > TK_PHOTO_MAX_COLOR_LENGTH) { return 0; } if (ParseColor(interp, pixelData, Tk_Display(Tk_MainWindow(interp)), Tk_Colormap(Tk_MainWindow(interp)), &dummy, &dummy, &dummy, &dummy) != TCL_OK) { return 0; } |
︙ | ︙ | |||
771 772 773 774 775 776 777 | Colormap colormap, /* colormap of current display */ unsigned char *redPtr, /* the result is written to these pointers */ unsigned char *greenPtr, unsigned char *bluePtr, unsigned char *alphaPtr) { const char *specString; | | | | | | | | | 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | Colormap colormap, /* colormap of current display */ unsigned char *redPtr, /* the result is written to these pointers */ unsigned char *greenPtr, unsigned char *bluePtr, unsigned char *alphaPtr) { const char *specString; TkSizeT length; /* * Find out which color format we have */ specString = Tcl_GetStringFromObj(specObj, &length); if (length == 0) { /* Empty string */ *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0; return TCL_OK; } if (length > TK_PHOTO_MAX_COLOR_LENGTH) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid color")); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "INVALID_COLOR", NULL); return TCL_ERROR; } if (specString[0] == '#') { return ParseColorAsHex(interp, specString, length, display, colormap, redPtr, greenPtr, bluePtr, alphaPtr); } if (ParseColorAsList(interp, specString, length, redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK) { return TCL_OK; } /* * Parsing the color as standard Tk color always is the last option tried * because TkParseColor() is very slow with values it cannot parse. */ Tcl_ResetResult(interp); return ParseColorAsStandard(interp, specString, length, display, colormap, redPtr, greenPtr, bluePtr, alphaPtr); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
1001 1002 1003 1004 1005 1006 1007 | unsigned char *redPtr, /* the result is written to these pointers */ unsigned char *greenPtr, unsigned char *bluePtr, unsigned char *alphaPtr) { XColor parsedColor; const char *suffixString, *colorString; | | | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 | unsigned char *redPtr, /* the result is written to these pointers */ unsigned char *greenPtr, unsigned char *bluePtr, unsigned char *alphaPtr) { XColor parsedColor; const char *suffixString, *colorString; char colorBuffer[TK_PHOTO_MAX_COLOR_LENGTH + 1]; char *tmpString; double fracAlpha; unsigned int suffixAlpha; int i; /* * Split color data string in color and suffix parts |
︙ | ︙ |
Changes to generic/tkImgPNG.c.
1 2 3 4 5 | /* * tkImgPNG.c -- * * A Tk photo image file handler for PNG files. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * tkImgPNG.c -- * * A Tk photo image file handler for PNG files. * * 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. */ #include "tkInt.h" #define PNG_UINT32(a,b,c,d) \ (((unsigned long)(a) << 24) | ((unsigned long)(b) << 16) | ((unsigned long)(c) << 8) | (unsigned long)(d)) #define PNG_BLOCK_SZ 1024 /* Process up to 1k at a time. */ #define PNG_MIN(a, b) (((a) < (b)) ? (a) : (b)) /* * Every PNG image starts with the following 8-byte signature. */ |
︙ | ︙ | |||
41 42 43 44 45 46 47 | /* * Chunk types, not all of which have support implemented. Note that there are * others in the official extension set which we will never support (as they * are officially deprecated). */ | | | | | | | | | | | | | | | | | | | | | | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | /* * Chunk types, not all of which have support implemented. Note that there are * others in the official extension set which we will never support (as they * are officially deprecated). */ #define CHUNK_IDAT PNG_UINT32('I','D','A','T') /* Pixel data. */ #define CHUNK_IEND PNG_UINT32('I','E','N','D') /* End of Image. */ #define CHUNK_IHDR PNG_UINT32('I','H','D','R') /* Header. */ #define CHUNK_PLTE PNG_UINT32('P','L','T','E') /* Palette. */ #define CHUNK_bKGD PNG_UINT32('b','K','G','D') /* Background Color */ #define CHUNK_cHRM PNG_UINT32('c','H','R','M') /* Chroma values. */ #define CHUNK_gAMA PNG_UINT32('g','A','M','A') /* Gamma. */ #define CHUNK_hIST PNG_UINT32('h','I','S','T') /* Histogram. */ #define CHUNK_iCCP PNG_UINT32('i','C','C','P') /* Color profile. */ #define CHUNK_iTXt PNG_UINT32('i','T','X','t') /* Internationalized * text (comments, * etc.) */ #define CHUNK_oFFs PNG_UINT32('o','F','F','s') /* Image offset. */ #define CHUNK_pCAL PNG_UINT32('p','C','A','L') /* Pixel calibration * data. */ #define CHUNK_pHYs PNG_UINT32('p','H','Y','s') /* Physical pixel * dimensions. */ #define CHUNK_sBIT PNG_UINT32('s','B','I','T') /* Significant bits */ #define CHUNK_sCAL PNG_UINT32('s','C','A','L') /* Physical scale. */ #define CHUNK_sPLT PNG_UINT32('s','P','L','T') /* Suggested * palette. */ #define CHUNK_sRGB PNG_UINT32('s','R','G','B') /* Standard RGB space * declaration. */ #define CHUNK_tEXt PNG_UINT32('t','E','X','t') /* Plain Latin-1 * text. */ #define CHUNK_tIME PNG_UINT32('t','I','M','E') /* Time stamp. */ #define CHUNK_tRNS PNG_UINT32('t','R','N','S') /* Transparency. */ #define CHUNK_zTXt PNG_UINT32('z','T','X','t') /* Compressed Latin-1 * text. */ /* * Color flags. */ #define PNG_COLOR_INDEXED 1 |
︙ | ︙ | |||
171 172 173 174 175 176 177 178 179 180 181 182 183 184 | Tcl_ZlibStream stream; /* Inflating or deflating stream; this one is * not bound to a Tcl command. */ Tcl_Obj *lastLineObj; /* Last line of pixels, for unfiltering. */ Tcl_Obj *thisLineObj; /* Current line of pixels to process. */ int lineSize; /* Number of bytes in a PNG line. */ int phaseSize; /* Number of bytes/line in current phase. */ } PNGImage; /* * Maximum size of various chunks. */ #define PNG_PLTE_MAXSZ 768 /* 3 bytes/RGB entry, 256 entries max */ | > > > > > > > > > | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | Tcl_ZlibStream stream; /* Inflating or deflating stream; this one is * not bound to a Tcl command. */ Tcl_Obj *lastLineObj; /* Last line of pixels, for unfiltering. */ Tcl_Obj *thisLineObj; /* Current line of pixels to process. */ int lineSize; /* Number of bytes in a PNG line. */ int phaseSize; /* Number of bytes/line in current phase. */ /* * Physical size: pHYS chunks. */ double DPI; double aspect; } PNGImage; /* * Maximum size of various chunks. */ #define PNG_PLTE_MAXSZ 768 /* 3 bytes/RGB entry, 256 entries max */ |
︙ | ︙ | |||
194 195 196 197 198 199 200 | unsigned long calculated); static void CleanupPNGImage(PNGImage *pngPtr); static int DecodeLine(Tcl_Interp *interp, PNGImage *pngPtr); static int DecodePNG(Tcl_Interp *interp, PNGImage *pngPtr, Tcl_Obj *fmtObj, Tk_PhotoHandle imageHandle, int destX, int destY); static int EncodePNG(Tcl_Interp *interp, | | > | | | > | | > > | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | unsigned long calculated); static void CleanupPNGImage(PNGImage *pngPtr); static int DecodeLine(Tcl_Interp *interp, PNGImage *pngPtr); static int DecodePNG(Tcl_Interp *interp, PNGImage *pngPtr, Tcl_Obj *fmtObj, Tk_PhotoHandle imageHandle, int destX, int destY); static int EncodePNG(Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr, PNGImage *pngPtr, Tcl_Obj *metadataInObj); static int FileMatchPNG(Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj, int *widthPtr, int *heightPtr, Tcl_Obj *metadataOut); static int FileReadPNG(Tcl_Interp *interp, Tcl_Channel chan, const char *fileName, Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY, Tcl_Obj *metadataOutPtr); static int FileWritePNG(Tcl_Interp *interp, const char *filename, Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr); static int InitPNGImage(Tcl_Interp *interp, PNGImage *pngPtr, Tcl_Channel chan, Tcl_Obj *objPtr, int dir); static inline unsigned char Paeth(int a, int b, int c); static int ParseFormat(Tcl_Interp *interp, Tcl_Obj *fmtObj, PNGImage *pngPtr); static int ReadBase64(Tcl_Interp *interp, PNGImage *pngPtr, unsigned char *destPtr, size_t destSz, |
︙ | ︙ | |||
232 233 234 235 236 237 238 | unsigned long *resultPtr, unsigned long *crcPtr); static int ReadPLTE(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); static int ReadTRNS(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); static int SkipChunk(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); | | > | | > | | > > | | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | unsigned long *resultPtr, unsigned long *crcPtr); static int ReadPLTE(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); static int ReadTRNS(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); static int SkipChunk(Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc); static int StringMatchPNG(Tcl_Interp *interp, Tcl_Obj *pObjData, Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj, int *widthPtr, int *heightPtr, Tcl_Obj *metadataOutObj); static int StringReadPNG(Tcl_Interp *interp, Tcl_Obj *pObjData, Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY, Tcl_Obj *metadataOutObj); static int StringWritePNG(Tcl_Interp *interp, Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr); static int UnfilterLine(Tcl_Interp *interp, PNGImage *pngPtr); static inline int WriteByte(Tcl_Interp *interp, PNGImage *pngPtr, unsigned char c, unsigned long *crcPtr); static inline int WriteChunk(Tcl_Interp *interp, PNGImage *pngPtr, unsigned long chunkType, const unsigned char *dataPtr, size_t dataSize); static int WriteData(Tcl_Interp *interp, PNGImage *pngPtr, const unsigned char *srcPtr, size_t srcSz, unsigned long *crcPtr); static int WriteExtraChunks(Tcl_Interp *interp, PNGImage *pngPtr, Tcl_Obj *metadataInObj); static int WriteIHDR(Tcl_Interp *interp, PNGImage *pngPtr, Tk_PhotoImageBlock *blockPtr); static int WriteIDAT(Tcl_Interp *interp, PNGImage *pngPtr, Tk_PhotoImageBlock *blockPtr); static inline int WriteInt32(Tcl_Interp *interp, PNGImage *pngPtr, unsigned long l, unsigned long *crcPtr); /* * The format record for the PNG file format: */ Tk_PhotoImageFormatVersion3 tkImgFmtPNG = { "png", /* name */ FileMatchPNG, /* fileMatchProc */ StringMatchPNG, /* stringMatchProc */ FileReadPNG, /* fileReadProc */ StringReadPNG, /* stringReadProc */ FileWritePNG, /* fileWriteProc */ StringWritePNG, /* stringWriteProc */ |
︙ | ︙ | |||
315 316 317 318 319 320 321 | * reading with ReadData(). */ if (objPtr) { Tcl_IncrRefCount(objPtr); pngPtr->objDataPtr = objPtr; pngPtr->strDataBuf = | | | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | * reading with ReadData(). */ if (objPtr) { Tcl_IncrRefCount(objPtr); pngPtr->objDataPtr = objPtr; pngPtr->strDataBuf = Tcl_GetByteArrayFromObj(objPtr, &pngPtr->strDataLen); } /* * Initialize the palette transparency table to fully opaque. */ memset(pngPtr->palette, 255, sizeof(pngPtr->palette)); |
︙ | ︙ | |||
341 342 343 344 345 346 347 348 349 350 351 352 353 354 | } if (objPtr) { Tcl_DecrRefCount(objPtr); } return TCL_ERROR; } return TCL_OK; } /* *---------------------------------------------------------------------- * * CleanupPNGImage -- | > > > > > > > | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | } if (objPtr) { Tcl_DecrRefCount(objPtr); } return TCL_ERROR; } /* * Initialize physical size pHYS values */ pngPtr->DPI = -1; pngPtr->aspect = -1; return TCL_OK; } /* *---------------------------------------------------------------------- * * CleanupPNGImage -- |
︙ | ︙ | |||
690 691 692 693 694 695 696 | { unsigned char p[4]; if (ReadData(interp, pngPtr, p, 4, crcPtr) == TCL_ERROR) { return TCL_ERROR; } | | | 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 | { unsigned char p[4]; if (ReadData(interp, pngPtr, p, 4, crcPtr) == TCL_ERROR) { return TCL_ERROR; } *resultPtr = PNG_UINT32(p[0], p[1], p[2], p[3]); return TCL_OK; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
882 883 884 885 886 887 888 | * maximum size for Tcl_Read, Tcl_GetByteArrayFromObj, etc. */ if (ReadData(interp, pngPtr, pc, 4, NULL) == TCL_ERROR) { return TCL_ERROR; } | | | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | * maximum size for Tcl_Read, Tcl_GetByteArrayFromObj, etc. */ if (ReadData(interp, pngPtr, pc, 4, NULL) == TCL_ERROR) { return TCL_ERROR; } temp = PNG_UINT32(pc[0], pc[1], pc[2], pc[3]); if (temp > INT_MAX) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "chunk size is out of supported range on this architecture", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "OUTSIZE", NULL); return TCL_ERROR; |
︙ | ︙ | |||
907 908 909 910 911 912 913 | return TCL_ERROR; } /* * Convert it to a host-order integer for simple comparison. */ | | | 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 | return TCL_ERROR; } /* * Convert it to a host-order integer for simple comparison. */ chunkType = PNG_UINT32(pc[0], pc[1], pc[2], pc[3]); /* * Check to see if this is a known/supported chunk type. Note that the * PNG specs require non-critical (i.e., ancillary) chunk types that * are not recognized to be ignored, rather than be treated as an * error. It does, however, recommend that an unknown critical chunk * type be treated as a failure. |
︙ | ︙ | |||
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 | /* * These chunk types are required and/or supported. */ case CHUNK_IDAT: case CHUNK_IEND: case CHUNK_IHDR: case CHUNK_PLTE: case CHUNK_tRNS: break; /* * These chunk types are part of the standard, but are not used by * this implementation (at least not yet). Note that these are all * ancillary chunks (lowercase first letter). */ case CHUNK_bKGD: case CHUNK_cHRM: case CHUNK_gAMA: case CHUNK_hIST: case CHUNK_iCCP: case CHUNK_iTXt: case CHUNK_oFFs: case CHUNK_pCAL: | > < | 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | /* * These chunk types are required and/or supported. */ case CHUNK_IDAT: case CHUNK_IEND: case CHUNK_IHDR: case CHUNK_pHYs: case CHUNK_PLTE: case CHUNK_tRNS: break; /* * These chunk types are part of the standard, but are not used by * this implementation (at least not yet). Note that these are all * ancillary chunks (lowercase first letter). */ case CHUNK_bKGD: case CHUNK_cHRM: case CHUNK_gAMA: case CHUNK_hIST: case CHUNK_iCCP: case CHUNK_iTXt: case CHUNK_oFFs: case CHUNK_pCAL: case CHUNK_sBIT: case CHUNK_sCAL: case CHUNK_sPLT: case CHUNK_sRGB: case CHUNK_tEXt: case CHUNK_tIME: case CHUNK_zTXt: |
︙ | ︙ | |||
972 973 974 975 976 977 978 | default: /* * Unknown chunk type. If it's critical, we can't continue. */ if (!(chunkType & PNG_CF_ANCILLARY)) { | | | 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 | default: /* * Unknown chunk type. If it's critical, we can't continue. */ if (!(chunkType & PNG_CF_ANCILLARY)) { if (chunkType & PNG_UINT32(128,128,128,128)) { /* * No nice ASCII conversion; shouldn't happen either, but * we'll be doubly careful. */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "encountered an unsupported critical chunk type", |
︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 | mismatch = memcmp(sigBuf, pngSignature, PNG_SIG_SZ); /* * If reading from string, reset position and try base64 decode. */ if (mismatch && pngPtr->strDataBuf) { | | | 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 | mismatch = memcmp(sigBuf, pngSignature, PNG_SIG_SZ); /* * If reading from string, reset position and try base64 decode. */ if (mismatch && pngPtr->strDataBuf) { 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; } |
︙ | ︙ | |||
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 | return TCL_OK; } /* *---------------------------------------------------------------------- * * Paeth -- * * Utility function for applying the Paeth filter to a pixel. The Paeth * filter is a linear function of the pixel to be filtered and the pixels * to the left, above, and above-left of the pixel to be unfiltered. * * Results: | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 | return TCL_OK; } /* *---------------------------------------------------------------------- * * ReadPHYS -- * * This function reads the PHYS (physical size) chunk data from * the PNG file and populates the fields in the PNGImage * structure. * * Results: * TCL_OK, or TCL_ERROR if an I/O error occurs or the PHYS chunk is * invalid. * * Side effects: * The access position in f advances. * *---------------------------------------------------------------------- */ static int ReadPHYS( Tcl_Interp *interp, PNGImage *pngPtr, int chunkSz, unsigned long crc) { unsigned long PPUx, PPUy; char unitSpecifier; /* * Check chunk size equal 9 bytes */ if (chunkSz != 9) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid physical chunk size", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PHYS", NULL); return TCL_ERROR; } /* * Read the chunk data * 4 bytes: Pixels per unit, x axis * 4 bytes: Pixels per unit, y axis * 1 byte: unit specifier */ if (ReadInt32(interp, pngPtr, &PPUx, &crc) == TCL_ERROR) { return TCL_ERROR; } if (ReadInt32(interp, pngPtr, &PPUy, &crc) == TCL_ERROR) { return TCL_ERROR; } if (ReadData(interp, pngPtr, (unsigned char *)&unitSpecifier, 1, &crc) == TCL_ERROR) { return TCL_ERROR; } if (CheckCRC(interp, pngPtr, crc) == TCL_ERROR) { return TCL_ERROR; } if ( PPUx > 2147483647 || PPUy > 2147483647 || unitSpecifier > 1 ) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid physical size value", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PHYS", NULL); return TCL_ERROR; } if (PPUx > 0) { pngPtr->aspect = ((double) PPUy) / ((double) PPUx); } if (1 == unitSpecifier) { pngPtr->DPI = ((double) PPUx) * 0.0254; } return TCL_OK; } /* *---------------------------------------------------------------------- * * Paeth -- * * Utility function for applying the Paeth filter to a pixel. The Paeth * filter is a linear function of the pixel to be filtered and the pixels * to the left, above, and above-left of the pixel to be unfiltered. * * Results: |
︙ | ︙ | |||
1704 1705 1706 1707 1708 1709 1710 | static int UnfilterLine( Tcl_Interp *interp, PNGImage *pngPtr) { unsigned char *thisLine = | | | | 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 | static int UnfilterLine( Tcl_Interp *interp, PNGImage *pngPtr) { unsigned char *thisLine = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL); unsigned char *lastLine = 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 #define PNG_FILTER_PAETH 4 |
︙ | ︙ | |||
1836 1837 1838 1839 1840 1841 1842 | int haveBits = 0; /* Number of bits remaining in current byte */ unsigned char pixBits = 0; /* Extracted bits for current channel */ 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]; | | | 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 | int haveBits = 0; /* Number of bits remaining in current byte */ unsigned char pixBits = 0; /* Extracted bits for current channel */ 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, (int *)NULL); p++; if (UnfilterLine(interp, pngPtr) == TCL_ERROR) { return TCL_ERROR; } if (pngPtr->currentLine >= pngPtr->block.height) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( |
︙ | ︙ | |||
2142 2143 2144 2145 2146 2147 2148 | /* * Inflate, processing each output buffer's worth as a line of pixels, * until we cannot fill the buffer any more. */ getNextLine: | | | | 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 | /* * Inflate, processing each output buffer's worth as a line of pixels, * until we cannot fill the buffer any more. */ getNextLine: Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len1); if (Tcl_ZlibStreamGet(pngPtr->stream, pngPtr->thisLineObj, pngPtr->phaseSize - len1) == TCL_ERROR) { return TCL_ERROR; } 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", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", |
︙ | ︙ | |||
2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 | * PLTE is mandatory for color type 3 and forbidden for 2 and 6 */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } if (CHUNK_PLTE == chunkType) { /* * Finish parsing the PLTE chunk. */ if (ReadPLTE(interp, pngPtr, chunkSz, crc) == TCL_ERROR) { | > > > > > > > > > > > > > > > > > > > > > > > | 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 | * PLTE is mandatory for color type 3 and forbidden for 2 and 6 */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } /* * Physical header may be present here so try to parse it */ if (CHUNK_pHYs == chunkType) { /* * Finish parsing the PHYS chunk. */ if (ReadPHYS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) { return TCL_ERROR; } /* * Begin the next chunk. */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } } if (CHUNK_PLTE == chunkType) { /* * Finish parsing the PLTE chunk. */ if (ReadPLTE(interp, pngPtr, chunkSz, crc) == TCL_ERROR) { |
︙ | ︙ | |||
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 | /* * Finish parsing the tRNS chunk. */ if (ReadTRNS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) { return TCL_ERROR; } /* * Begin the next chunk. */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { | > > > > > > > > > > > > > > > > > > > > > > > | 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 | /* * Finish parsing the tRNS chunk. */ if (ReadTRNS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) { return TCL_ERROR; } /* * Begin the next chunk. */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { return TCL_ERROR; } } /* * Physical header may be present here so try to parse it */ if (CHUNK_pHYs == chunkType) { /* * Finish parsing the PHYS chunk. */ if (ReadPHYS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) { return TCL_ERROR; } /* * Begin the next chunk. */ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType, &crc) == TCL_ERROR) { |
︙ | ︙ | |||
2663 2664 2665 2666 2667 2668 2669 | * The access position in f may change. * *---------------------------------------------------------------------- */ static int FileMatchPNG( | > | | > | | < > > | < < | 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 | * The access position in f may change. * *---------------------------------------------------------------------- */ 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 *), /* 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 */ { PNGImage png; int match = 0; InitPNGImage(NULL, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE); if (ReadIHDR(interp, &png) == TCL_OK) { *widthPtr = png.block.width; *heightPtr = png.block.height; match = 1; |
︙ | ︙ | |||
2709 2710 2711 2712 2713 2714 2715 | * image given by imageHandle. * *---------------------------------------------------------------------- */ static int FileReadPNG( | | | | | > | | < > > | | > | | > < < < < < > > > > > > > > > > > > | 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 | * image given by imageHandle. * *---------------------------------------------------------------------- */ static int FileReadPNG( 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_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 * written to. */ TCL_UNUSED(int), TCL_UNUSED(int), /* Coordinates of top-left pixel to be used in * image being read. */ TCL_UNUSED(int), Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */ { PNGImage png; int result = TCL_ERROR; result = InitPNGImage(interp, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE); if (TCL_OK == result) { result = DecodePNG(interp, &png, fmtObj, imageHandle, destX, destY); } if (TCL_OK == result && metadataOutObj != NULL && png.DPI != -1) { result = Tcl_DictObjPut(NULL, metadataOutObj, Tcl_NewStringObj("DPI",-1), Tcl_NewDoubleObj(png.DPI)); } if (TCL_OK == result && metadataOutObj != NULL && png.aspect != -1) { result = Tcl_DictObjPut(NULL, metadataOutObj, Tcl_NewStringObj("aspect",-1), Tcl_NewDoubleObj(png.aspect)); } CleanupPNGImage(&png); return result; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2759 2760 2761 2762 2763 2764 2765 | * The size of the image is placed in widthPre and heightPtr. * *---------------------------------------------------------------------- */ static int StringMatchPNG( | > | > | | | | < | | 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 | * The size of the image is placed in widthPre and heightPtr. * *---------------------------------------------------------------------- */ 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 *), /* 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 */ { PNGImage png; int match = 0; InitPNGImage(NULL, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE); png.strDataBuf = Tcl_GetByteArrayFromObj(pObjData, &png.strDataLen); if (ReadIHDR(interp, &png) == TCL_OK) { *widthPtr = png.block.width; *heightPtr = png.block.height; match = 1; } |
︙ | ︙ | |||
2803 2804 2805 2806 2807 2808 2809 | * New data is added to the image given by imageHandle. * *---------------------------------------------------------------------- */ static int StringReadPNG( | | | | > | | | | < | | > < < < < > > > > > > > > > > > > | 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 | * New data is added to the image given by imageHandle. * *---------------------------------------------------------------------- */ static int StringReadPNG( Tcl_Interp *interp, /* interpreter for reporting errors in */ 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), TCL_UNUSED(int), TCL_UNUSED(int), Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */ { PNGImage png; int result = TCL_ERROR; result = InitPNGImage(interp, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE); if (TCL_OK == result) { result = DecodePNG(interp, &png, fmtObj, imageHandle, destX, destY); } if (TCL_OK == result && metadataOutObj != NULL && png.DPI != -1) { result = Tcl_DictObjPut(NULL, metadataOutObj, Tcl_NewStringObj("DPI",-1), Tcl_NewDoubleObj(png.DPI)); } if (TCL_OK == result && metadataOutObj != NULL && png.aspect != -1) { result = Tcl_DictObjPut(NULL, metadataOutObj, Tcl_NewStringObj("aspect",-1), Tcl_NewDoubleObj(png.aspect)); } CleanupPNGImage(&png); return result; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2873 2874 2875 2876 2877 2878 2879 | * objects immediately or store them in a multi-object rep? */ if (pngPtr->objDataPtr) { TkSizeT objSz; unsigned char *destPtr; | | | 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 | * objects immediately or store them in a multi-object rep? */ if (pngPtr->objDataPtr) { TkSizeT objSz; unsigned char *destPtr; 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); return TCL_ERROR; } |
︙ | ︙ | |||
2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 | { return WriteData(interp, pngPtr, &c, 1, crcPtr); } /* *---------------------------------------------------------------------- * * WriteInt32 -- * * This function writes a 32-bit integer value out to the PNG image as * four bytes in network byte order. * * Results: * TCL_OK, or TCL_ERROR if the write fails. | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 | { return WriteData(interp, pngPtr, &c, 1, crcPtr); } /* *---------------------------------------------------------------------- * * LongToInt32 -- * * This function transforms to a 32-bit integer value as * four bytes in network byte order. * * Results: * None * * Side effects: * Buffer will be modified. * *---------------------------------------------------------------------- */ static inline void LongToInt32( unsigned long l, unsigned char *pc) { pc[0] = (unsigned char) ((l & 0xff000000) >> 24); pc[1] = (unsigned char) ((l & 0x00ff0000) >> 16); pc[2] = (unsigned char) ((l & 0x0000ff00) >> 8); pc[3] = (unsigned char) ((l & 0x000000ff) >> 0); } /* *---------------------------------------------------------------------- * * WriteInt32 -- * * This function writes a 32-bit integer value out to the PNG image as * four bytes in network byte order. * * Results: * TCL_OK, or TCL_ERROR if the write fails. |
︙ | ︙ | |||
2936 2937 2938 2939 2940 2941 2942 | WriteInt32( Tcl_Interp *interp, PNGImage *pngPtr, unsigned long l, unsigned long *crcPtr) { unsigned char pc[4]; | | < < < < < | 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 | WriteInt32( Tcl_Interp *interp, PNGImage *pngPtr, unsigned long l, unsigned long *crcPtr) { unsigned char pc[4]; LongToInt32(l,pc); return WriteData(interp, pngPtr, pc, 4, crcPtr); } /* *---------------------------------------------------------------------- * * WriteChunk -- |
︙ | ︙ | |||
3234 3235 3236 3237 3238 3239 3240 | /* * Now get the compressed data and write it as one big IDAT chunk. */ outputObj = Tcl_NewObj(); (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1); | | | 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 | /* * Now get the compressed data and write it as one big IDAT chunk. */ outputObj = Tcl_NewObj(); (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1); outputBytes = Tcl_GetByteArrayFromObj(outputObj, &outputSize); result = WriteChunk(interp, pngPtr, CHUNK_IDAT, outputBytes, outputSize); Tcl_DecrRefCount(outputObj); return result; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
3260 3261 3262 3263 3264 3265 3266 | * *---------------------------------------------------------------------- */ static int WriteExtraChunks( Tcl_Interp *interp, | | > | 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 | * *---------------------------------------------------------------------- */ static int WriteExtraChunks( Tcl_Interp *interp, PNGImage *pngPtr, Tcl_Obj *metadataInObj) { static const unsigned char sBIT_contents[] = { 8, 8, 8, 8 }; int sBIT_length = 4; Tcl_DString buf; |
︙ | ︙ | |||
3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 | (unsigned char *) Tcl_DStringValue(&buf), Tcl_DStringLength(&buf)) != TCL_OK) { Tcl_DStringFree(&buf); return TCL_ERROR; } Tcl_DStringFree(&buf); return TCL_OK; } /* *---------------------------------------------------------------------- * * EncodePNG -- | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 | (unsigned char *) Tcl_DStringValue(&buf), Tcl_DStringLength(&buf)) != TCL_OK) { Tcl_DStringFree(&buf); return TCL_ERROR; } Tcl_DStringFree(&buf); /* * Add a pHYs chunk if there is metadata for DPI and/or aspect * aspect = PPUy / PPUx * DPI = PPUx * 0.0254 * 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 */ if (metadataInObj != NULL) { Tcl_Obj *aspectObj, *DPIObj; double aspectValue=-1, DPIValue=-1; unsigned long PPUx = 65536, PPUy = 65536; char unitSpecifier; if (TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj, Tcl_NewStringObj("aspect",-1), &aspectObj) || TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj, Tcl_NewStringObj("DPI",-1), &DPIObj) ) { return TCL_ERROR; } if (DPIObj != NULL) { if (TCL_ERROR == Tcl_GetDoubleFromObj(interp, DPIObj, &DPIValue)) { return TCL_ERROR; } PPUx = (unsigned long)floor(DPIValue / 0.0254+0.5); if (aspectObj == NULL) { PPUy = PPUx; } unitSpecifier = 1; } if (aspectObj != NULL) { if (TCL_ERROR == Tcl_GetDoubleFromObj(interp, aspectObj, &aspectValue)) { return TCL_ERROR; } /* * aspect = PPUy / PPUx */ if (DPIObj == NULL) { unitSpecifier = 0; PPUx = 65536; PPUy = (unsigned long)floor(65536.0 * aspectValue+0.5); } else { PPUy = (unsigned long)floor(DPIValue * aspectValue / 0.0254+0.5); } } if (DPIObj != NULL || aspectObj != NULL) { unsigned char buffer[9]; if ( PPUx > 2147483647 || PPUy > 2147483647 ) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "DPI or aspect out of range", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "PHYS", NULL); return TCL_ERROR; } LongToInt32(PPUx, buffer); LongToInt32(PPUy, buffer+4); buffer[8] = unitSpecifier; if (WriteChunk(interp, pngPtr, CHUNK_pHYs, buffer, 9) != TCL_OK) { return TCL_ERROR; } } } return TCL_OK; } /* *---------------------------------------------------------------------- * * EncodePNG -- |
︙ | ︙ | |||
3337 3338 3339 3340 3341 3342 3343 | *---------------------------------------------------------------------- */ static int EncodePNG( Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr, | | > | 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 | *---------------------------------------------------------------------- */ static int EncodePNG( Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr, PNGImage *pngPtr, Tcl_Obj *metadataInObj) { int greenOffset, blueOffset, alphaOffset; /* * Determine appropriate color type based on color usage (e.g., only red * and maybe alpha channel = grayscale). * |
︙ | ︙ | |||
3420 3421 3422 3423 3424 3425 3426 | } /* * Write out the extra chunks containing metadata that is of interest to * other programs more than us. */ | | | 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 | } /* * Write out the extra chunks containing metadata that is of interest to * other programs more than us. */ if (WriteExtraChunks(interp, pngPtr, metadataInObj) == TCL_ERROR) { return TCL_ERROR; } /* * Write out the image pixels in the IDAT (data) chunk. */ |
︙ | ︙ | |||
3461 3462 3463 3464 3465 3466 3467 | *---------------------------------------------------------------------- */ static int FileWritePNG( Tcl_Interp *interp, const char *filename, | > | < | 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 | *---------------------------------------------------------------------- */ static int FileWritePNG( Tcl_Interp *interp, const char *filename, TCL_UNUSED(Tcl_Obj *), Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr) { Tcl_Channel chan; PNGImage png; int result = TCL_ERROR; /* * Open a Tcl file channel where the image data will be stored. Tk ought * to take care of this, and just provide a channel, but it doesn't. */ chan = Tcl_OpenFileChannel(interp, filename, "w", 0644); |
︙ | ︙ | |||
3503 3504 3505 3506 3507 3508 3509 | goto cleanup; } /* * Write the raw PNG data out to the file. */ | | | 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 | goto cleanup; } /* * Write the raw PNG data out to the file. */ result = EncodePNG(interp, blockPtr, &png, metadataInObj); cleanup: Tcl_Close(interp, chan); CleanupPNGImage(&png); return result; } |
︙ | ︙ | |||
3532 3533 3534 3535 3536 3537 3538 | * *---------------------------------------------------------------------- */ static int StringWritePNG( Tcl_Interp *interp, | > | < | | 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 | * *---------------------------------------------------------------------- */ static int StringWritePNG( Tcl_Interp *interp, TCL_UNUSED(Tcl_Obj *), Tcl_Obj *metadataInObj, Tk_PhotoImageBlock *blockPtr) { Tcl_Obj *resultObj = Tcl_NewObj(); PNGImage png; int result = TCL_ERROR; /* * Initalize PNGImage instance for encoding. */ if (InitPNGImage(interp, &png, NULL, resultObj, TCL_ZLIB_STREAM_DEFLATE) == TCL_ERROR) { goto cleanup; } /* * Write the raw PNG data into the prepared Tcl_Obj buffer. Set the result * back to the interpreter if successful. */ result = EncodePNG(interp, blockPtr, &png, metadataInObj); if (TCL_OK == result) { Tcl_SetObjResult(interp, png.objDataPtr); } cleanup: CleanupPNGImage(&png); |
︙ | ︙ |
Changes to generic/tkImgPPM.c.
1 2 3 4 5 | /* * tkImgPPM.c -- * * A photo image file handler for PPM (Portable PixMap) files. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkImgPPM.c -- * * A photo image file handler for PPM (Portable PixMap) files. * * 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 ([email protected]), * Department of Computer Science, * Australian National University. |
︙ | ︙ | |||
197 198 199 200 201 202 203 | if (Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height) != TCL_OK) { return TCL_ERROR; } if (srcY > 0) { | | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | if (Tk_PhotoExpand(interp, imageHandle, destX + width, destY + height) != TCL_OK) { return TCL_ERROR; } if (srcY > 0) { Tcl_Seek(chan, (long long)srcY * block.pitch, SEEK_CUR); } nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch; if (nLines > height) { nLines = height; } if (nLines <= 0) { |
︙ | ︙ | |||
237 238 239 240 241 242 243 | for (p = pixelPtr; count > 0; count--, p++) { *p = (((int) *p) * 255)/maxIntensity; } } else if (maxIntensity > 0x00ff) { unsigned char *p; unsigned int value; | | | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | for (p = pixelPtr; count > 0; count--, p++) { *p = (((int) *p) * 255)/maxIntensity; } } else if (maxIntensity > 0x00ff) { unsigned char *p; unsigned int value; for (p = pixelPtr; count > 0; count -= 2, p += 2) { value = ((unsigned int) p[0]) * 256 + ((unsigned int) p[1]); value = value * 255 / maxIntensity; p[0] = p[1] = (unsigned char) value; } } block.height = nLines; if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, |
︙ | ︙ | |||
600 601 602 603 604 605 606 | if (maxIntensity < 0x00ff) { for (p=pixelPtr,count=nBytes ; count>0 ; count--,p++,dataBuffer++) { *p = (((int) *dataBuffer) * 255)/maxIntensity; } } else { unsigned int value; | | | | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | if (maxIntensity < 0x00ff) { for (p=pixelPtr,count=nBytes ; count>0 ; count--,p++,dataBuffer++) { *p = (((int) *dataBuffer) * 255)/maxIntensity; } } else { unsigned int value; for (p = pixelPtr,count=nBytes; count > 1; count-=2, p += 2, dataBuffer += 2) { value = ((unsigned int)dataBuffer[0]) * 256 + ((unsigned int)dataBuffer[1]); value = value * 255 / maxIntensity; p[0] = p[1] = (unsigned char) value; } } dataSize -= nBytes; block.height = nLines; if (Tk_PhotoPutBlock(interp, imageHandle, &block, destX, destY, |
︙ | ︙ | |||
763 764 765 766 767 768 769 | { #define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE], c; int i, numFields, type = 0; TkSizeT dataSize; unsigned char *dataBuffer; | | | 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | { #define BUFFER_SIZE 1000 char buffer[BUFFER_SIZE], c; int i, numFields, type = 0; TkSizeT dataSize; unsigned char *dataBuffer; dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize); /* * Read 4 space-separated fields from the string, ignoring comments (any * line that starts with "#"). */ if (dataSize-- < 1) { |
︙ | ︙ |
Changes to generic/tkImgPhInstance.c.
1 2 3 4 5 6 7 | /* * tkImgPhInstance.c -- * * 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. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * tkImgPhInstance.c -- * * 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 © 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 ([email protected]), * Department of Computer Science, * Australian National University. |
︙ | ︙ | |||
34 35 36 37 38 39 40 | #endif #endif /* * Forward declarations */ | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #endif #endif /* * Forward declarations */ #ifndef TK_CAN_RENDER_RGBA 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(unsigned mask); static void GetColorTable(PhotoInstance *instancePtr); |
︙ | ︙ | |||
412 413 414 415 416 417 418 | * 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. * *---------------------------------------------------------------------- */ | | | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | * 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. * *---------------------------------------------------------------------- */ #ifndef TK_CAN_RENDER_RGBA #ifndef _WIN32 #define GetRValue(rgb) (UCHAR(((rgb) & red_mask) >> red_shift)) #define GetGValue(rgb) (UCHAR(((rgb) & green_mask) >> green_shift)) #define GetBValue(rgb) (UCHAR(((rgb) & blue_mask) >> blue_shift)) #define RGB(r, g, b) ((unsigned)( \ (UCHAR(r) << red_shift) | \ (UCHAR(g) << green_shift) | \ |
︙ | ︙ | |||
578 579 580 581 582 583 584 | } XPutPixel(bgImg, x, y, RGB(r, g, b)); } } } #undef ALPHA_BLEND } | | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | } XPutPixel(bgImg, x, y, RGB(r, g, b)); } } } #undef ALPHA_BLEND } #endif /* TK_CAN_RENDER_RGBA */ /* *---------------------------------------------------------------------- * * TkImgPhotoDisplay -- * * This function is invoked to draw a photo image. |
︙ | ︙ | |||
610 611 612 613 614 615 616 | * draw. */ int width, int height, /* Dimensions of region within image to * draw. */ int drawableX,int drawableY)/* Coordinates within drawable that correspond * to imageX and imageY. */ { PhotoInstance *instancePtr = (PhotoInstance *)clientData; | | | > | | > | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 | * draw. */ int width, int height, /* Dimensions of region within image to * draw. */ int drawableX,int drawableY)/* Coordinates within drawable that correspond * to imageX and imageY. */ { PhotoInstance *instancePtr = (PhotoInstance *)clientData; #ifndef TK_CAN_RENDER_RGBA XVisualInfo visInfo = instancePtr->visualInfo; #endif /* * If there's no pixmap, it means that an error occurred while creating * the image instance so it can't be displayed. */ if (instancePtr->pixels == None) { return; } #ifdef TK_CAN_RENDER_RGBA /* * We can use TkpPutRGBAImage to render RGBA Ximages directly so there is * no need to call XGetImage or to do the Porter-Duff compositing by hand. */ 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)); TkpPutRGBAImage(display, drawable, instancePtr->gc, photo, imageX, imageY, drawableX, drawableY, (unsigned int) width, (unsigned int) height); photo->data = NULL; XDestroyImage(photo); #else if ((instancePtr->modelPtr->flags & COMPLEX_ALPHA) && visInfo.depth >= 15 && (visInfo.c_class == DirectColor || visInfo.c_class == TrueColor)) { Tk_ErrorHandler handler; XImage *bgImg = NULL; |
︙ | ︙ |
Changes to generic/tkImgPhoto.c.
1 2 3 4 5 6 7 | /* * tkImgPhoto.c -- * * 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. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * tkImgPhoto.c -- * * 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 © 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 ([email protected]), * Department of Computer Science, * Australian National University. |
︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | int toX2, toY2; /* Second coordinate pair for -to option. */ int zoomX, zoomY; /* Values specified for -zoom option. */ int subsampleX, subsampleY; /* Values specified for -subsample option. */ Tcl_Obj *format; /* Value specified for -format option. */ XColor *background; /* Value specified for -background option. */ int compositingRule; /* Value specified for -compositingrule * option. */ }; /* * Bit definitions for use with ParseSubcommandOptions: each bit is set in the * allowedOptions parameter on a call to ParseSubcommandOptions if that option * is allowed for the current photo image subcommand. On return, the bit is * set in the options field of the SubcommandOptions structure if that option * was specified. * * OPT_ALPHA: Set if -alpha option allowed/specified. * OPT_BACKGROUND: Set if -format option allowed/specified. * OPT_COMPOSITE: Set if -compositingrule option allowed/spec'd. * OPT_FORMAT: Set if -format option allowed/specified. * OPT_FROM: Set if -from option allowed/specified. * OPT_GRAYSCALE: Set if -grayscale option allowed/specified. * OPT_SHRINK: Set if -shrink option allowed/specified. * OPT_SUBSAMPLE: Set if -subsample option allowed/spec'd. * OPT_TO: Set if -to option allowed/specified. * OPT_WITHALPHA: Set if -withalpha option allowed/specified. * OPT_ZOOM: Set if -zoom option allowed/specified. */ #define OPT_ALPHA 1 #define OPT_BACKGROUND 2 #define OPT_COMPOSITE 4 #define OPT_FORMAT 8 #define OPT_FROM 0x10 #define OPT_GRAYSCALE 0x20 | > > > | | | | | > | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | int toX2, toY2; /* Second coordinate pair for -to option. */ int zoomX, zoomY; /* Values specified for -zoom option. */ int subsampleX, subsampleY; /* Values specified for -subsample option. */ Tcl_Obj *format; /* Value specified for -format option. */ XColor *background; /* Value specified for -background option. */ int compositingRule; /* Value specified for -compositingrule * option. */ Tcl_Obj *metadata; /* Value specified for -metadata option. */ }; /* * Bit definitions for use with ParseSubcommandOptions: each bit is set in the * allowedOptions parameter on a call to ParseSubcommandOptions if that option * is allowed for the current photo image subcommand. On return, the bit is * set in the options field of the SubcommandOptions structure if that option * was specified. * * OPT_ALPHA: Set if -alpha option allowed/specified. * OPT_BACKGROUND: Set if -format option allowed/specified. * OPT_COMPOSITE: Set if -compositingrule option allowed/spec'd. * OPT_FORMAT: Set if -format option allowed/specified. * OPT_FROM: Set if -from option allowed/specified. * OPT_GRAYSCALE: Set if -grayscale option allowed/specified. * OPT_METADATA: Set if -metadata option allowed/specified. * OPT_SHRINK: Set if -shrink option allowed/specified. * OPT_SUBSAMPLE: Set if -subsample option allowed/spec'd. * OPT_TO: Set if -to option allowed/specified. * OPT_WITHALPHA: Set if -withalpha option allowed/specified. * OPT_ZOOM: Set if -zoom option allowed/specified. */ #define OPT_ALPHA 1 #define OPT_BACKGROUND 2 #define OPT_COMPOSITE 4 #define OPT_FORMAT 8 #define OPT_FROM 0x10 #define OPT_GRAYSCALE 0x20 #define OPT_METADATA 0x40 #define OPT_SHRINK 0x80 #define OPT_SUBSAMPLE 0x100 #define OPT_TO 0x200 #define OPT_WITHALPHA 0x400 #define OPT_ZOOM 0x800 /* * List of option names. The order here must match the order of declarations * of the OPT_* constants above. */ static const char *const optionNames[] = { "-alpha", "-background", "-compositingrule", "-format", "-from", "-grayscale", "-metadata", "-shrink", "-subsample", "-to", "-withalpha", "-zoom", NULL }; |
︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /* Pointer to the first in the list of known * photo image formats.*/ #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 Tk_PhotoImageFormat *oldFormatList; /* Pointer to the first in the list of known * photo image formats.*/ #endif int initialized; /* Set to 1 if we've initialized the * structure. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; /* * Default configuration | > > > | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | /* Pointer to the first in the list of known * photo image formats.*/ #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 Tk_PhotoImageFormat *oldFormatList; /* Pointer to the first in the list of known * photo image formats.*/ #endif Tk_PhotoImageFormatVersion3 *formatListVersion3; /* Pointer to the first in the list of known * photo image formats in Version3 format.*/ int initialized; /* Set to 1 if we've initialized the * structure. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; /* * Default configuration |
︙ | ︙ | |||
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | static int ImgPhotoSetSize(PhotoModel *modelPtr, int width, int height); 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, Tk_PhotoImageFormat **imageFormatPtr, int *widthPtr, int *heightPtr, int *oldformat); static int MatchStringFormat(Tcl_Interp *interp, Tcl_Obj *data, Tcl_Obj *formatString, Tk_PhotoImageFormat **imageFormatPtr, int *widthPtr, int *heightPtr, int *oldformat); static const char * GetExtension(const char *path); /* *---------------------------------------------------------------------- * * PhotoFormatThreadExitProc -- | > > > > > > | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | static int ImgPhotoSetSize(PhotoModel *modelPtr, int width, int height); 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, Tcl_Obj *metadataOutObj, Tk_PhotoImageFormat **imageFormatPtr, Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr, int *widthPtr, int *heightPtr, int *oldformat); static int MatchStringFormat(Tcl_Interp *interp, Tcl_Obj *data, Tcl_Obj *formatString, Tcl_Obj *metadataInObj, Tcl_Obj *metadataOutObj, Tk_PhotoImageFormat **imageFormatPtr, Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr, int *widthPtr, int *heightPtr, int *oldformat); static const char * GetExtension(const char *path); /* *---------------------------------------------------------------------- * * PhotoFormatThreadExitProc -- |
︙ | ︙ | |||
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | */ static void PhotoFormatThreadExitProc( TCL_UNUSED(void *)) /* not used */ { Tk_PhotoImageFormat *freePtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 while (tsdPtr->oldFormatList != NULL) { freePtr = tsdPtr->oldFormatList; tsdPtr->oldFormatList = tsdPtr->oldFormatList->nextPtr; ckfree(freePtr); } #endif while (tsdPtr->formatList != NULL) { freePtr = tsdPtr->formatList; tsdPtr->formatList = tsdPtr->formatList->nextPtr; ckfree((char *)freePtr->name); ckfree(freePtr); } } /* *---------------------------------------------------------------------- * | > > > > > > > | > | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | */ static void PhotoFormatThreadExitProc( TCL_UNUSED(void *)) /* not used */ { Tk_PhotoImageFormat *freePtr; Tk_PhotoImageFormatVersion3 *freePtrVersion3; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 while (tsdPtr->oldFormatList != NULL) { freePtr = tsdPtr->oldFormatList; tsdPtr->oldFormatList = tsdPtr->oldFormatList->nextPtr; ckfree(freePtr); } #endif while (tsdPtr->formatList != NULL) { freePtr = tsdPtr->formatList; tsdPtr->formatList = tsdPtr->formatList->nextPtr; ckfree((char *)freePtr->name); ckfree(freePtr); } while (tsdPtr->formatListVersion3 != NULL) { freePtrVersion3 = tsdPtr->formatListVersion3; tsdPtr->formatListVersion3 = tsdPtr->formatListVersion3->nextPtr; ckfree((char *)freePtrVersion3->name); ckfree(freePtrVersion3); } } /* *---------------------------------------------------------------------- * * Tk_CreateOldPhotoImageFormat, Tk_CreatePhotoImageFormat, * Tk_CreatePhotoImageFormatVersion3 -- * * This function is invoked by an image file handler to register a new * photo image format and the functions that handle the new format. The * function is typically invoked during Tcl_AppInit. * * Results: * None. |
︙ | ︙ | |||
312 313 314 315 316 317 318 319 320 321 322 323 324 325 | char *name = (char *)ckalloc(strlen(formatPtr->name) + 1); strcpy(name, formatPtr->name); copyPtr->name = name; copyPtr->nextPtr = tsdPtr->formatList; tsdPtr->formatList = copyPtr; } } /* *---------------------------------------------------------------------- * * ImgPhotoCreate -- * * This function is called by the Tk image code to create a new photo | > > > > > > > > > > > > > > > > > > > > > > > > > > | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | char *name = (char *)ckalloc(strlen(formatPtr->name) + 1); strcpy(name, formatPtr->name); copyPtr->name = name; copyPtr->nextPtr = tsdPtr->formatList; tsdPtr->formatList = copyPtr; } } void Tk_CreatePhotoImageFormatVersion3( const Tk_PhotoImageFormatVersion3 *formatPtr) /* Structure describing the format. All of the * fields except "nextPtr" must be filled in * by caller. */ { Tk_PhotoImageFormatVersion3 *copyPtr; char *name; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (!tsdPtr->initialized) { tsdPtr->initialized = 1; Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL); } copyPtr = (Tk_PhotoImageFormatVersion3 *) ckalloc(sizeof(Tk_PhotoImageFormatVersion3)); *copyPtr = *formatPtr; /* for compatibility with aMSN: make a copy of formatPtr->name */ name = (char *)ckalloc(strlen(formatPtr->name) + 1); strcpy(name, formatPtr->name); copyPtr->name = name; copyPtr->nextPtr = tsdPtr->formatListVersion3; tsdPtr->formatListVersion3 = copyPtr; } /* *---------------------------------------------------------------------- * * ImgPhotoCreate -- * * This function is called by the Tk image code to create a new photo |
︙ | ︙ | |||
415 416 417 418 419 420 421 422 423 424 425 426 427 428 | PhotoModel *modelPtr = (PhotoModel *)clientData; int result, index, x, y, width, height; struct SubcommandOptions options; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_PhotoImageFormat *imageFormat; TkSizeT length; int imageWidth, imageHeight, matched, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); | > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | PhotoModel *modelPtr = (PhotoModel *)clientData; int result, index, x, y, width, height; struct SubcommandOptions options; unsigned char *pixelPtr; Tk_PhotoImageBlock block; Tk_PhotoImageFormat *imageFormat; Tk_PhotoImageFormatVersion3 *imageFormatVersion3; TkSizeT length; int imageWidth, imageHeight, matched, oldformat = 0; Tcl_Channel chan; Tk_PhotoHandle srcHandle; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
︙ | ︙ | |||
453 454 455 456 457 458 459 | case PHOTO_CGET: { const char *arg; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } | | > > > > | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 | case PHOTO_CGET: { const char *arg; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "option"); return TCL_ERROR; } arg = Tcl_GetStringFromObj(objv[2], &length); if (strncmp(arg,"-data", length) == 0) { if (modelPtr->dataString) { Tcl_SetObjResult(interp, modelPtr->dataString); } } else if (strncmp(arg,"-format", length) == 0) { if (modelPtr->format) { Tcl_SetObjResult(interp, modelPtr->format); } } else if (strncmp(arg, "-metadata", length) == 0) { if (modelPtr->metadata) { Tcl_SetObjResult(interp, modelPtr->metadata); } } else { Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs, (char *) modelPtr, Tcl_GetString(objv[2]), 0); } return TCL_OK; } |
︙ | ︙ | |||
495 496 497 498 499 500 501 502 503 504 505 506 507 508 | } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-format {} {} {}", 16); if (modelPtr->format) { Tcl_ListObjAppendElement(NULL, subobj, modelPtr->format); } 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) { | > > > > > > > | | 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 | } Tcl_ListObjAppendElement(interp, obj, subobj); subobj = Tcl_NewStringObj("-format {} {} {}", 16); 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 (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 = Tcl_GetStringFromObj(objv[2], &length); if (length > 1 && !strncmp(arg, "-data", length)) { Tcl_AppendResult(interp, "-data {} {} {}", NULL); if (modelPtr->dataString) { /* * TODO: Modifying result is bad! */ |
︙ | ︙ | |||
527 528 529 530 531 532 533 534 535 536 537 538 539 540 | if (modelPtr->format) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->format); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), configSpecs, (char *) modelPtr, arg, 0); | > > > > > > > > > > > > > > | 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | if (modelPtr->format) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->format); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else if (length > 1 && !strncmp(arg, "-metadata", length)) { Tcl_AppendResult(interp, "-metadata {} {} {}", NULL); if (modelPtr->metadata) { /* * TODO: Modifying result is bad! */ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), modelPtr->metadata); } else { Tcl_AppendResult(interp, " {}", NULL); } return TCL_OK; } else { return Tk_ConfigureInfo(interp, Tk_MainWindow(interp), configSpecs, (char *) modelPtr, arg, 0); |
︙ | ︙ | |||
580 581 582 583 584 585 586 | Tcl_GetString(options.name), NULL); return TCL_ERROR; } Tk_PhotoGetImage(srcHandle, &block); if ((options.fromX2 > block.width) || (options.fromY2 > block.height) || (options.fromX2 > block.width) || (options.fromY2 > block.height)) { | < < < | 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | Tcl_GetString(options.name), NULL); return TCL_ERROR; } Tk_PhotoGetImage(srcHandle, &block); if ((options.fromX2 > block.width) || (options.fromY2 > block.height) || (options.fromX2 > block.width) || (options.fromY2 > block.height)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); return TCL_ERROR; } |
︙ | ︙ | |||
635 636 637 638 639 640 641 | options.toY2 = options.toY + height * options.zoomY; } /* * Copy the image data over using Tk_PhotoPutZoomedBlock. */ | > | | | | | | | | | > > > < < < > | | < < > > > | > > > > > > > > > > > > > > > > > | 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | options.toY2 = options.toY + height * options.zoomY; } /* * Copy the image data over using Tk_PhotoPutZoomedBlock. */ if (block.pixelPtr) { 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) modelPtr, &block, options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, options.zoomX, options.zoomY, options.subsampleX, options.subsampleY, options.compositingRule); } else { result = TCL_OK; } /* * Set the destination image size if the -shrink option was specified. * This has to be done _after_ copying the data. Otherwise, if source * and destination are the same image, block.pixelPtr would point to * an invalid memory block (bug [5239fd749b]). */ if (options.options & OPT_SHRINK) { if (ImgPhotoSetSize(modelPtr, options.toX2, options.toY2) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_NewStringObj( TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1)); Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL); return TCL_ERROR; } } if (block.pixelPtr || (options.options & OPT_SHRINK)) { Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, modelPtr->width, modelPtr->height); } return result; case PHOTO_DATA: { char *data = NULL; Tcl_Obj *freeObj = NULL; Tcl_Obj *metadataIn; /* * photo data command - first parse and check any options given. */ Tk_ImageStringWriteProc *stringWriteProc = NULL; Tk_ImageStringWriteProcVersion3 *stringWriteProcVersion3 = NULL; index = 1; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; options.metadata = NULL; options.fromX = 0; options.fromY = 0; if (ParseSubcommandOptions(&options, interp, OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND | OPT_METADATA, &index, objc, objv) != TCL_OK) { return TCL_ERROR; } if ((options.name == NULL) || (index < objc)) { Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?"); if (options.background) { Tk_FreeColor(options.background); } return TCL_ERROR; } 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); if (options.background) { Tk_FreeColor(options.background); } return TCL_ERROR; } /* * Fill in default values for unspecified parameters. */ if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { options.fromX2 = modelPtr->width; options.fromY2 = modelPtr->height; } if (!(options.options & OPT_FORMAT)) { options.format = Tcl_NewStringObj("default", -1); freeObj = options.format; } /* * Use argument metadata if specified, otherwise the master metadata */ if (NULL != options.metadata) { metadataIn = options.metadata; } else { metadataIn = modelPtr->metadata; } /* * Search for an appropriate image string format handler. */ matched = 0; for (imageFormat = tsdPtr->formatList; imageFormat != NULL; |
︙ | ︙ | |||
753 754 755 756 757 758 759 760 | break; } } } } #endif if (stringWriteProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( | > > > > > > > > > > > > > > > > > | | | | > > > | | 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 | break; } } } } #endif if (stringWriteProc == NULL) { oldformat = 0; for (imageFormatVersion3 = tsdPtr->formatListVersion3; imageFormatVersion3 != NULL; imageFormatVersion3 = imageFormatVersion3->nextPtr) { if ((strncasecmp(Tcl_GetString(options.format), imageFormatVersion3->name, strlen(imageFormatVersion3->name)) == 0)) { matched = 1; if (imageFormatVersion3->stringWriteProc != NULL) { stringWriteProcVersion3 = imageFormatVersion3->stringWriteProc; break; } } } } if (stringWriteProc == NULL && stringWriteProcVersion3 == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image string format \"%s\" is %s", Tcl_GetString(options.format), (matched ? "not supported" : "unknown"))); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", Tcl_GetString(options.format), NULL); goto dataErrorExit; } /* * Call the handler's string write function to write out the image. */ data = ImgGetPhoto(modelPtr, &block, &options); if (stringWriteProc == NULL) { result = (stringWriteProcVersion3)(interp, options.format, metadataIn, &block); } else if (oldformat) { Tcl_DString buffer; typedef int (*OldStringWriteProc)(Tcl_Interp *interp, Tcl_DString *dataPtr, const char *formatString, Tk_PhotoImageBlock *blockPtr); Tcl_DStringInit(&buffer); result = ((OldStringWriteProc)(void *)stringWriteProc)(interp, &buffer, |
︙ | ︙ | |||
796 797 798 799 800 801 802 | } if (options.background) { Tk_FreeColor(options.background); } if (data) { ckfree(data); } | | | | | | | | | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | } if (options.background) { Tk_FreeColor(options.background); } if (data) { ckfree(data); } if (freeObj != NULL) { Tcl_DecrRefCount(freeObj); } return result; dataErrorExit: if (options.background) { Tk_FreeColor(options.background); } if (data) { ckfree(data); } if (freeObj != NULL) { Tcl_DecrRefCount(freeObj); } return TCL_ERROR; } case PHOTO_GET: { /* * photo get command - first parse and check parameters. */ |
︙ | ︙ | |||
875 876 877 878 879 880 881 | * photo put command - first parse the options. */ index = 2; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; | > | > | > | > | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 | * photo put command - first parse the options. */ index = 2; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; options.metadata = NULL; if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT|OPT_METADATA, &index, objc, objv) != TCL_OK) { return TCL_ERROR; } if ((options.name == NULL) || (index < objc)) { Tcl_WrongNumArgs(interp, 2, objv, "data ?-option value ...?"); return TCL_ERROR; } /* * See if there's a format that can read the data */ if (MatchStringFormat(interp, objv[2], options.format, options.metadata, NULL, &imageFormat, &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { return TCL_ERROR; } if (!(options.options & OPT_TO) || (options.toX2 < 0)) { options.toX2 = options.toX + imageWidth; options.toY2 = options.toY + imageHeight; } |
︙ | ︙ | |||
912 913 914 915 916 917 918 | if (oldformat) { if (format) { format = (Tcl_Obj *) Tcl_GetString(format); } data = (Tcl_Obj *) Tcl_GetString(data); } | > | | | | | | > > > > > > > > > > > > | 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 | if (oldformat) { if (format) { format = (Tcl_Obj *) Tcl_GetString(format); } data = (Tcl_Obj *) Tcl_GetString(data); } if (imageFormat != NULL) { if (imageFormat->stringReadProc(interp, data, format, (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) modelPtr, options.toX, options.toY, options.toX2 - options.toX, options.toY2 - options.toY, 0, 0, NULL) != TCL_OK) { return TCL_ERROR; } } /* * 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. */ modelPtr->flags |= IMAGE_CHANGED; |
︙ | ︙ | |||
939 940 941 942 943 944 945 946 | * photo read command - first parse the options specified. */ index = 2; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; if (ParseSubcommandOptions(&options, interp, | > | | 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 | * photo read command - first parse the options specified. */ index = 2; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; options.metadata = NULL; if (ParseSubcommandOptions(&options, interp, OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK | OPT_METADATA, &index, objc, objv) != TCL_OK) { return TCL_ERROR; } if ((options.name == NULL) || (index < objc)) { Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?"); return TCL_ERROR; } |
︙ | ︙ | |||
981 982 983 984 985 986 987 | if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } if (MatchFileFormat(interp, chan, | | > | < > | > < | > < | > > | | | | > > > > > > > > | 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 | if (Tcl_SetChannelOption(interp, chan, "-encoding", "binary") != TCL_OK) { Tcl_Close(NULL, chan); return TCL_ERROR; } if (MatchFileFormat(interp, chan, Tcl_GetString(options.name), options.format, options.metadata, NULL, &imageFormat, &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { result = TCL_ERROR; goto readCleanup; } /* * Check the values given for the -from option. */ if ((options.fromX > imageWidth) || (options.fromY > imageHeight) || (options.fromX2 > imageWidth) || (options.fromY2 > imageHeight)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "coordinates for -from option extend outside source image", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", NULL); result = TCL_ERROR; goto readCleanup; } if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) { width = imageWidth - options.fromX; height = imageHeight - options.fromY; } else { width = options.fromX2 - options.fromX; height = options.fromY2 - options.fromY; } /* * If the -shrink option was specified, set the size of the image. */ if (options.options & OPT_SHRINK) { 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); result = TCL_ERROR; goto readCleanup; } } /* * Call the handler's file read function to read the data into the * image. */ format = options.format; if (oldformat && format) { format = (Tcl_Obj *) Tcl_GetString(format); } if (imageFormat != NULL) { result = imageFormat->fileReadProc(interp, chan, Tcl_GetString(options.name), 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) modelPtr, options.toX, options.toY, width, height, options.fromX, options.fromY, NULL); } readCleanup: if (chan != NULL) { Tcl_Close(NULL, chan); } return result; } case PHOTO_REDITHER: |
︙ | ︙ | |||
1267 1268 1269 1270 1271 1272 1273 | } Tcl_Panic("unexpected fallthrough"); } case PHOTO_WRITE: { char *data; const char *fmtString; | | | 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | } Tcl_Panic("unexpected fallthrough"); } case PHOTO_WRITE: { char *data; const char *fmtString; Tcl_Obj *format, *metadataIn; int usedExt; /* * Prevent file system access in safe interpreters. */ if (Tcl_IsSafe(interp)) { |
︙ | ︙ | |||
1289 1290 1291 1292 1293 1294 1295 1296 | * photo write command - first parse and check any options given. */ index = 2; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; if (ParseSubcommandOptions(&options, interp, | > | > > > > > > > | 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 | * photo write command - first parse and check any options given. */ index = 2; memset(&options, 0, sizeof(options)); options.name = NULL; options.format = NULL; options.metadata = NULL; if (ParseSubcommandOptions(&options, interp, OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND | OPT_METADATA, &index, objc, objv) != TCL_OK) { return TCL_ERROR; } if ((options.name == NULL) || (index < objc)) { Tcl_WrongNumArgs(interp, 2, objv, "fileName ?-option value ...?"); if (options.background) { Tk_FreeColor(options.background); } return TCL_ERROR; } 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); if (options.background) { Tk_FreeColor(options.background); } return TCL_ERROR; } /* * Fill in default values for unspecified parameters. Note that a * missing -format flag results in us having a guess from the file * extension. [Bug 2983824] |
︙ | ︙ | |||
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 | fmtString = GetExtension(Tcl_GetString(options.name)); usedExt = (fmtString != NULL); } else { fmtString = Tcl_GetString(options.format); usedExt = 0; } /* * Search for an appropriate image file format handler, and give an * error if none is found. */ matched = 0; redoFormatLookup: for (imageFormat = tsdPtr->formatList; imageFormat != NULL; imageFormat = imageFormat->nextPtr) { if ((fmtString == NULL) || (strncasecmp(fmtString, imageFormat->name, strlen(imageFormat->name)) == 0)) { matched = 1; if (imageFormat->fileWriteProc != NULL) { | > > > > > > > > > > > > | 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 | fmtString = GetExtension(Tcl_GetString(options.name)); usedExt = (fmtString != NULL); } else { fmtString = Tcl_GetString(options.format); usedExt = 0; } /* * Use argument metadata if specified, otherwise the master metadata */ if (NULL != options.metadata) { metadataIn = options.metadata; } else { metadataIn = modelPtr->metadata; } /* * Search for an appropriate image file format handler, and give an * error if none is found. */ matched = 0; redoFormatLookup: imageFormatVersion3 = NULL; for (imageFormat = tsdPtr->formatList; imageFormat != NULL; imageFormat = imageFormat->nextPtr) { if ((fmtString == NULL) || (strncasecmp(fmtString, imageFormat->name, strlen(imageFormat->name)) == 0)) { matched = 1; if (imageFormat->fileWriteProc != NULL) { |
︙ | ︙ | |||
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 | if (imageFormat->fileWriteProc != NULL) { break; } } } } #endif if (usedExt && !matched) { /* * If we didn't find one and we're using file extensions as the * basis for the guessing, go back and look again without * prejudice. Supports old broken code. */ usedExt = 0; fmtString = NULL; goto redoFormatLookup; } | > > > > > > > > > > > > > > > | > > > > | | > > > > > | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 | if (imageFormat->fileWriteProc != NULL) { break; } } } } #endif if (imageFormat == NULL) { oldformat = 0; for (imageFormatVersion3 = tsdPtr->formatListVersion3; imageFormatVersion3 != NULL; imageFormatVersion3 = imageFormatVersion3->nextPtr) { if ((fmtString == NULL) || (strncasecmp(fmtString, imageFormatVersion3->name, strlen(imageFormatVersion3->name)) == 0)) { matched = 1; if (imageFormatVersion3->fileWriteProc != NULL) { break; } } } } if (usedExt && !matched) { /* * If we didn't find one and we're using file extensions as the * basis for the guessing, go back and look again without * prejudice. Supports old broken code. */ usedExt = 0; fmtString = NULL; goto redoFormatLookup; } if (imageFormat == NULL && imageFormatVersion3 == NULL) { if (fmtString == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "no available image file format has file writing" " capability", -1)); } else if (!matched) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image file format \"%s\" is unknown", fmtString)); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image file format \"%s\" has no file writing capability", fmtString)); } Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", fmtString, NULL); if (options.background) { Tk_FreeColor(options.background); } return TCL_ERROR; } /* * Call the handler's file write function to write out the image. */ data = ImgGetPhoto(modelPtr, &block, &options); format = options.format; if (oldformat && format) { format = (Tcl_Obj *) Tcl_GetString(options.format); } if (imageFormat != NULL) { result = imageFormat->fileWriteProc(interp, Tcl_GetString(options.name), format, &block); } else { result = imageFormatVersion3->fileWriteProc(interp, Tcl_GetString(options.name), format, metadataIn, &block); } if (options.background) { Tk_FreeColor(options.background); } if (data) { ckfree(data); } return result; |
︙ | ︙ | |||
1451 1452 1453 1454 1455 1456 1457 | /* *---------------------------------------------------------------------- * * ParseSubcommandOptions -- * * This function is invoked to process one of the options which may be * specified for the photo image subcommands, namely, -from, -to, -zoom, | | | | 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 | /* *---------------------------------------------------------------------- * * ParseSubcommandOptions -- * * This function is invoked to process one of the options which may be * specified for the photo image subcommands, namely, -from, -to, -zoom, * -subsample, -format, -shrink, -compositingrule, -alpha, -boolean, * -withalpha and -metadata. * Parsing starts at the index in *optIndexPtr and stops at the end of * objv[] or at the first value that does not belong to an option. * * Results: * A standard Tcl result. * * Side effects: |
︙ | ︙ | |||
1499 1500 1501 1502 1503 1504 1505 | for (index = *optIndexPtr; index < objc; *optIndexPtr = ++index) { /* * We can have one value specified without an option; it goes into * optPtr->name. */ | | | 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 | for (index = *optIndexPtr; index < objc; *optIndexPtr = ++index) { /* * We can have one value specified without an option; it goes into * optPtr->name. */ expandedOption = option = Tcl_GetStringFromObj(objv[index], &length); if (option[0] != '-') { if (optPtr->name == NULL) { optPtr->name = objv[index]; continue; } break; } |
︙ | ︙ | |||
1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 | */ if (index + 1 >= objc) { goto oneValueRequired; } *optIndexPtr = ++index; optPtr->format = objv[index]; } else if (bit == OPT_COMPOSITE) { /* * The -compositingrule option takes a single value from a * well-known set. */ if (index + 1 >= objc) { | > > > > > > > > > > > | 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 | */ if (index + 1 >= objc) { goto oneValueRequired; } *optIndexPtr = ++index; optPtr->format = objv[index]; } else if (bit == OPT_METADATA) { /* * The -metadata option takes a single dict value. Note that * parsing this is outside the scope of this function. */ if (index + 1 >= objc) { goto oneValueRequired; } *optIndexPtr = ++index; optPtr->metadata = objv[index]; } else if (bit == OPT_COMPOSITE) { /* * The -compositingrule option takes a single value from a * well-known set. */ if (index + 1 >= objc) { |
︙ | ︙ | |||
1766 1767 1768 1769 1770 1771 1772 | 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. */ { PhotoInstance *instancePtr; const char *oldFileString, *oldPaletteString; | | > > | | 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 | 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. */ { PhotoInstance *instancePtr; const char *oldFileString, *oldPaletteString; Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL, *metadataInObj = NULL, *metadataOutObj = NULL; Tcl_Obj *tempdata, *tempformat; TkSizeT length; int i, j, result, imageWidth, imageHeight, oldformat; double oldGamma; Tcl_Channel chan; Tk_PhotoImageFormat *imageFormat; 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] = 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]; j--; } else { |
︙ | ︙ | |||
1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 | } else { ckfree(args); Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-format\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } } } } /* * Save the current values for fileString and dataString, so we can tell | > > > > > > > > > > > > > | 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 | } else { ckfree(args); Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-format\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } } else if ((args[j][1] == 'm') && !strncmp(args[j], "-metadata", length)) { if (++i < objc) { metadataInObj = objv[i]; j--; } else { ckfree(args); Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-metadata\" missing", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "MISSING_VALUE", NULL); return TCL_ERROR; } } } } /* * Save the current values for fileString and dataString, so we can tell |
︙ | ︙ | |||
1844 1845 1846 1847 1848 1849 1850 | j, args, (char *) modelPtr, flags) != TCL_OK) { ckfree(args); goto errorExit; } ckfree(args); /* | | | | 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 | 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 ((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) Tcl_GetByteArrayFromObj(data, &bytesize); if (bytesize) { Tcl_IncrRefCount(data); } else { data = NULL; } if (modelPtr->dataString) { Tcl_DecrRefCount(modelPtr->dataString); |
︙ | ︙ | |||
1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 | format = NULL; } if (modelPtr->format) { Tcl_DecrRefCount(modelPtr->format); } modelPtr->format = format; } /* * Set the image to the user-requested size, if any, and make sure storage * is correctly allocated for this image. */ if (ImgPhotoSetSize(modelPtr, modelPtr->width, modelPtr->height) != TCL_OK) { | > > > > > > > > > > > > > > > > > > > > > > > > > > | 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 | format = NULL; } if (modelPtr->format) { Tcl_DecrRefCount(modelPtr->format); } modelPtr->format = format; } if (metadataInObj) { /* * Make -metadata a dict. * Take also empty metadatas as this may be a sign to replace * existing metadata. */ int dictSize; if (TCL_OK != Tcl_DictObjSize(interp,metadataInObj, &dictSize)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "value for \"-metadata\" not a dict", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "UNRECOGNIZED_DATA", NULL); return TCL_ERROR; } if (dictSize > 0) { Tcl_IncrRefCount(metadataInObj); } else { metadataInObj = NULL; } if (modelPtr->metadata) { Tcl_DecrRefCount(modelPtr->metadata); } 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(modelPtr, modelPtr->width, modelPtr->height) != TCL_OK) { |
︙ | ︙ | |||
1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 | } chan = Tcl_OpenFileChannel(interp, modelPtr->fileString, "r", 0); if (chan == NULL) { goto errorExit; } /* * -translation binary also sets -encoding binary */ if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) || (MatchFileFormat(interp, chan, modelPtr->fileString, | > > > > > > > > | | > | | > | > > > > > > > > > > > > > > > > | > | | | | | > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 | } chan = Tcl_OpenFileChannel(interp, modelPtr->fileString, "r", 0); if (chan == NULL) { goto errorExit; } /* * Flag that we want the metadata result dict */ metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); /* * -translation binary also sets -encoding binary */ if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary") != TCL_OK) || (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(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 = modelPtr->format; if (oldformat && tempformat) { tempformat = (Tcl_Obj *) Tcl_GetString(tempformat); } if (imageFormat != NULL) { result = imageFormat->fileReadProc(interp, chan, modelPtr->fileString, tempformat, (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0); } else { result = imageFormatVersion3->fileReadProc(interp, chan, modelPtr->fileString, tempformat, modelPtr->metadata, (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0, metadataOutObj); } Tcl_Close(NULL, chan); if (result != TCL_OK) { goto errorExit; } Tcl_ResetResult(interp); modelPtr->flags |= IMAGE_CHANGED; } 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, modelPtr->dataString, modelPtr->format, modelPtr->metadata, metadataOutObj, &imageFormat, &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat) != TCL_OK) { goto errorExit; } 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 = 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) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0) != TCL_OK) { goto errorExit; } } else { if (imageFormatVersion3->stringReadProc(interp, tempdata, tempformat, modelPtr->metadata, (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight, 0, 0, metadataOutObj) != TCL_OK) { goto errorExit; } } Tcl_ResetResult(interp); modelPtr->flags |= IMAGE_CHANGED; } /* * Merge driver returned metadata and master metadata */ if (metadataOutObj != NULL) { int dictSize; if (TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "driver metadata not a dict", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "UNRECOGNIZED_DATA", NULL); goto errorExit; } if (dictSize > 0) { /* * We have driver return metadata */ if (modelPtr->metadata == NULL) { modelPtr->metadata = metadataOutObj; metadataOutObj = NULL; } else { Tcl_DictSearch search; Tcl_Obj *key, *value; int done; 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, modelPtr->metadata, key, value); } } } } /* * Enforce a reasonable value for gamma. */ if (modelPtr->gamma <= 0) { modelPtr->gamma = 1.0; |
︙ | ︙ | |||
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 | if (oldData != NULL) { Tcl_DecrRefCount(oldData); } if (oldFormat != NULL) { Tcl_DecrRefCount(oldFormat); } ToggleComplexAlphaIfNeeded(modelPtr); return TCL_OK; errorExit: if (oldData != NULL) { Tcl_DecrRefCount(oldData); } if (oldFormat != NULL) { Tcl_DecrRefCount(oldFormat); } return TCL_ERROR; } /* *---------------------------------------------------------------------- * * ToggleComplexAlphaIfNeeded -- | > > > > > > | 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 | if (oldData != NULL) { Tcl_DecrRefCount(oldData); } if (oldFormat != NULL) { Tcl_DecrRefCount(oldFormat); } if (metadataOutObj != NULL) { Tcl_DecrRefCount(metadataOutObj); } ToggleComplexAlphaIfNeeded(modelPtr); return TCL_OK; errorExit: if (oldData != NULL) { Tcl_DecrRefCount(oldData); } if (oldFormat != NULL) { Tcl_DecrRefCount(oldFormat); } if (metadataOutObj != NULL) { Tcl_DecrRefCount(metadataOutObj); } return TCL_ERROR; } /* *---------------------------------------------------------------------- * * ToggleComplexAlphaIfNeeded -- |
︙ | ︙ | |||
2072 2073 2074 2075 2076 2077 2078 | static int ToggleComplexAlphaIfNeeded( 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; | | > | 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 | static int ToggleComplexAlphaIfNeeded( 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; /* * Set the COMPLEX_ALPHA flag if we have an image with partially * transparent bits. */ mPtr->flags &= ~COMPLEX_ALPHA; if (c == NULL) { return 0; } end = c + len; c += 3; /* Start at first alpha byte. */ for (; c < end; c += 4) { if (*c && *c != 255) { mPtr->flags |= COMPLEX_ALPHA; break; } } |
︙ | ︙ | |||
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 | } if (modelPtr->dataString != NULL) { Tcl_DecrRefCount(modelPtr->dataString); } if (modelPtr->format != NULL) { Tcl_DecrRefCount(modelPtr->format); } Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0); ckfree(modelPtr); } /* *---------------------------------------------------------------------- * | > > > | 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 | } 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); } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
2377 2378 2379 2380 2381 2382 2383 | * This function is called to find a photo image file format handler * which can parse the image data in the given file. If a user-specified * format string is provided, only handlers whose names match a prefix of * the format string are tried. * * Results: * A standard TCL return value. If the return value is TCL_OK, a pointer | | | | > > | > > > > > > | 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 | * This function is called to find a photo image file format handler * which can parse the image data in the given file. If a user-specified * format string is provided, only handlers whose names match a prefix of * the format string are tried. * * Results: * A standard TCL return value. If the return value is TCL_OK, a pointer * to the image format record is returned in *imageFormatPtr or * *imageFormatVersion3Ptr, and the width and height of the image are * returned in *widthPtr and *heightPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int MatchFileFormat( 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 *formatObj, /* User-specified format string, or NULL. */ Tcl_Obj *metadataInObj, /* User-specified metadata, may be NULL */ Tcl_Obj *metadataOutObj, /* metadata to return, may be NULL */ Tk_PhotoImageFormat **imageFormatPtr, /* A pointer to the photo image format record * is returned here. For formatVersion3, this is * set to NULL */ Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr, /* A pointer to the photo image formatVersion3 * record is returned here. For non * formatVersion3, this is set to NULL*/ int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here. */ int *oldformat) /* Returns 1 if the old image API is used. */ { int matched = 0; int useoldformat = 0; Tk_PhotoImageFormat *formatPtr; Tk_PhotoImageFormatVersion3 *formatVersion3Ptr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); const char *formatString = NULL; if (formatObj) { formatString = Tcl_GetString(formatObj); } |
︙ | ︙ | |||
2486 2487 2488 2489 2490 2491 2492 | break; } } } } #endif | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | < < < < < < | | | > > | > > > > > > | 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 | break; } } } } #endif /* * For old and not version 3 format, exit now with success */ if (formatPtr != NULL) { *imageFormatPtr = formatPtr; *imageFormatVersion3Ptr = NULL; *oldformat = useoldformat; (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); return TCL_OK; } /* * Scan through the table of file format version 3 handlers to find one * which can handle the image. */ for (formatVersion3Ptr = tsdPtr->formatListVersion3; formatVersion3Ptr != NULL; formatVersion3Ptr = formatVersion3Ptr->nextPtr) { if (formatObj != NULL) { if (strncasecmp(formatString, formatVersion3Ptr->name, strlen(formatVersion3Ptr->name)) != 0) { continue; } matched = 1; if (formatVersion3Ptr->fileMatchProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-file option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NOT_FILE_FORMAT", NULL); return TCL_ERROR; } } if (formatVersion3Ptr->fileMatchProc != NULL) { (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); if (formatVersion3Ptr->fileMatchProc(interp, chan, fileName, formatObj, metadataInObj, widthPtr, heightPtr, metadataOutObj)) { if (*widthPtr < 1) { *widthPtr = 1; } if (*heightPtr < 1) { *heightPtr = 1; } *imageFormatVersion3Ptr = formatVersion3Ptr; *imageFormatPtr = NULL; *oldformat = 0; (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET); return TCL_OK; } /* * 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_IsShared(metadataOutObj) || TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize) || dictSize > 0) { Tcl_DecrRefCount(metadataOutObj); metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); } } } } /* * No matching format found */ if ((formatObj != NULL) && !matched) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "image file format \"%s\" is not supported", formatString)); Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT", formatString, NULL); } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "couldn't recognize data in image file \"%s\"", fileName)); Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE", "UNRECOGNIZED_DATA", NULL); } return TCL_ERROR; } /* *---------------------------------------------------------------------- * * MatchStringFormat -- * * This function is called to find a photo image file format handler * which can parse the image data in the given string. If a * user-specified format string is provided, only handlers whose names * match a prefix of the format string are tried. * * Results: * A standard TCL return value. If the return value is TCL_OK, a pointer * to the image format record is returned in *imageFormatPtr or * *imageFormatVersion3Ptr, and the width and height of the image are * returned in *widthPtr and *heightPtr. * * Side effects: * None. * *---------------------------------------------------------------------- */ static int MatchStringFormat( Tcl_Interp *interp, /* Interpreter to use for reporting errors. */ Tcl_Obj *data, /* Object containing the image data. */ Tcl_Obj *formatObj, /* User-specified format string, or NULL. */ Tcl_Obj *metadataInObj, /* User-specified metadata, may be NULL */ Tcl_Obj *metadataOutObj, /* metadata output dict, may be NULL */ Tk_PhotoImageFormat **imageFormatPtr, /* A pointer to the photo image format record * is returned here. For formatVersion3, this is * set to NULL*/ Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr, /* A pointer to the photo image formatVersion3 * record is returned here. For non * formatVersion3, this is set to NULL*/ int *widthPtr, int *heightPtr, /* The dimensions of the image are returned * here. */ int *oldformat) /* Returns 1 if the old image API is used. */ { int matched = 0, useoldformat = 0; Tk_PhotoImageFormat *formatPtr, *defaultFormatPtr = NULL; Tk_PhotoImageFormatVersion3 *formatVersion3Ptr = NULL; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); const char *formatString = NULL; if (formatObj) { formatString = Tcl_GetString(formatObj); } |
︙ | ︙ | |||
2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 | break; } } } #endif if (formatPtr == NULL) { /* * Try the default format as last resort (only if no -format option * was passed). */ if ( formatObj == NULL && defaultFormatPtr == NULL) { Tcl_Panic("default image format handler not registered"); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 | break; } } } #endif if (formatPtr == NULL) { useoldformat = 0; for (formatVersion3Ptr = tsdPtr->formatListVersion3; formatVersion3Ptr != NULL; formatVersion3Ptr = formatVersion3Ptr->nextPtr) { if (formatObj != NULL) { if (strncasecmp(formatString, formatVersion3Ptr->name, strlen(formatVersion3Ptr->name) ) != 0) { continue; } matched = 1; if (formatVersion3Ptr->stringMatchProc == NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "-data option isn't supported for %s images", formatString)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "NOT_DATA_FORMAT", NULL); return TCL_ERROR; } } if ((formatVersion3Ptr->stringMatchProc != NULL) && (formatVersion3Ptr->stringReadProc != NULL) && formatVersion3Ptr->stringMatchProc(interp, data, formatObj, metadataInObj, widthPtr, heightPtr, metadataOutObj)) { break; } /* * 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_IsShared(metadataOutObj) || TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize) || dictSize > 0) { Tcl_DecrRefCount(metadataOutObj); metadataOutObj = Tcl_NewDictObj(); Tcl_IncrRefCount(metadataOutObj); } } } } if (formatPtr == NULL && formatVersion3Ptr == NULL) { /* * Try the default format as last resort (only if no -format option * was passed). */ if ( formatObj == NULL && defaultFormatPtr == NULL) { Tcl_Panic("default image format handler not registered"); |
︙ | ︙ | |||
2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 | "UNRECOGNIZED_DATA", NULL); } return TCL_ERROR; } } *imageFormatPtr = formatPtr; *oldformat = useoldformat; /* * Some stringMatchProc might have left error messages and error codes in * interp. Clear them before return. */ Tcl_ResetResult(interp); | > | 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 | "UNRECOGNIZED_DATA", NULL); } return TCL_ERROR; } } *imageFormatPtr = formatPtr; *imageFormatVersion3Ptr = formatVersion3Ptr; *oldformat = useoldformat; /* * Some stringMatchProc might have left error messages and error codes in * interp. Clear them before return. */ Tcl_ResetResult(interp); |
︙ | ︙ | |||
2803 2804 2805 2806 2807 2808 2809 | * * To find out, just comparing the pointers is not enough - they might have * 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; | | | | | 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 | * * To find out, just comparing the pointers is not enough - they might have * 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 (modelPtr->pix32 && (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 modelPtr->pix32[] when * |
︙ | ︙ | |||
3043 3044 3045 3046 3047 3048 3049 | /* * Add this new block to the region which specifies which data is valid. */ if (alphaOffset) { /* * This block is grossly inefficient. For each row in the image, it | | | 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 | /* * Add this new block to the region which specifies which data is valid. */ if (alphaOffset) { /* * This block is grossly inefficient. For each row in the image, it * finds each contiguous string of nontransparent pixels, then marks * those areas as valid in the validRegion mask. This makes drawing * very efficient, because of the way we use X: we just say, here's * your mask, and here's your data. We need not worry about the * current background color, etc. But this costs us a lot on the image * setup. Still, image setup only happens once, whereas the drawing * happens many times, so this might be the best way to go. * |
︙ | ︙ | |||
3249 3250 3251 3252 3253 3254 3255 | * * To find out, just comparing the pointers is not enough - they might have * 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; | | | | | 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 | * * To find out, just comparing the pointers is not enough - they might have * 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 (modelPtr->pix32 && (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 modelPtr->pix32[] when * |
︙ | ︙ | |||
3634 3635 3636 3637 3638 3639 3640 | modelPtr->validRegion = TkCreateRegion(); /* * Clear out the 32-bit pixel storage array. Clear out the dithering error * arrays for each instance. */ | > | | > | 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 | modelPtr->validRegion = TkCreateRegion(); /* * Clear out the 32-bit pixel storage array. Clear out the dithering error * arrays for each instance. */ if (modelPtr->pix32) { 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. |
︙ | ︙ | |||
4078 4079 4080 4081 4082 4083 4084 | } /* *---------------------------------------------------------------------- * * Tk_PhotoPutBlock_NoComposite, Tk_PhotoPutZoomedBlock_NoComposite -- * | | | 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 | } /* *---------------------------------------------------------------------- * * Tk_PhotoPutBlock_NoComposite, Tk_PhotoPutZoomedBlock_NoComposite -- * * 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. * *---------------------------------------------------------------------- */ |
︙ | ︙ | |||
4119 4120 4121 4122 4123 4124 4125 | /* *---------------------------------------------------------------------- * * Tk_PhotoExpand_Panic, Tk_PhotoPutBlock_Panic, * Tk_PhotoPutZoomedBlock_Panic, Tk_PhotoSetSize_Panic * | | | 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 | /* *---------------------------------------------------------------------- * * Tk_PhotoExpand_Panic, Tk_PhotoPutBlock_Panic, * Tk_PhotoPutZoomedBlock_Panic, Tk_PhotoSetSize_Panic * * 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. * *---------------------------------------------------------------------- */ |
︙ | ︙ |
Changes to generic/tkImgPhoto.h.
1 2 3 4 5 | /* * tkImgPhoto.h -- * * Declarations for images of type "photo" for Tk. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkImgPhoto.h -- * * Declarations for images of type "photo" for Tk. * * 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 ([email protected]), * Department of Computer Science, * Australian National University. |
︙ | ︙ | |||
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | Tk_Uid palette; /* User-specified default palette for * instances of this image. */ double gamma; /* Display gamma value to correct for. */ char *fileString; /* Name of file to read into image. */ Tcl_Obj *dataString; /* Object to use as contents of image. */ Tcl_Obj *format; /* User-specified format of data in image file * or string value. */ unsigned char *pix32; /* Local storage for 32-bit image. */ 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 model. */ | > > | 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | Tk_Uid palette; /* User-specified default palette for * instances of this image. */ double gamma; /* Display gamma value to correct for. */ char *fileString; /* Name of file to read into image. */ Tcl_Obj *dataString; /* Object to use as contents of image. */ Tcl_Obj *format; /* User-specified format of data in image file * or string value. */ Tcl_Obj *metadata; /* User-specified metadata dict or read from * image file */ unsigned char *pix32; /* Local storage for 32-bit image. */ 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 model. */ |
︙ | ︙ |
Changes to generic/tkImgSVGnano.c.
1 2 3 4 5 | /* * tkImgSVGnano.c * * A photo file handler for SVG files. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkImgSVGnano.c * * A photo file handler for SVG files. * * Copyright © 2013-14 Mikko Mononen [email protected] * Copyright © 2018 Christian Gollwitzer [email protected] * Copyright © 2018 Christian Werner https://www.androwish.org/ * Copyright © 2018 Rene Zaumseil [email protected] * * 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 * |
︙ | ︙ | |||
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | */ ClientData dataOrChan; Tcl_DString formatString; NSVGimage *nsvgImage; RastOpts ropts; } NSVGcache; 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, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY); | > > | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | */ ClientData dataOrChan; 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, Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height, int srcX, int srcY); |
︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | NULL, /* stringWriteProc */ NULL }; /* *---------------------------------------------------------------------- * * FileMatchSVG -- * * This function is invoked by the photo image type to see if a file * contains image data in SVG format. * * Results: * The return value is >0 if the file can be successfully parsed, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | NULL, /* stringWriteProc */ NULL }; /* *---------------------------------------------------------------------- * * 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. * * Results: * The return value is >0 if the file can be successfully parsed, |
︙ | ︙ | |||
128 129 130 131 132 133 134 | Tcl_Obj *dataObj = Tcl_NewObj(); const char *data; RastOpts ropts; NSVGimage *nsvgImage; (void)fileName; CleanCache(interp); | | > > > > > > > > > > > > | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | Tcl_Obj *dataObj = Tcl_NewObj(); const char *data; RastOpts ropts; NSVGimage *nsvgImage; (void)fileName; CleanCache(interp); 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 '<svg' and a '>' in the first 4k */ if ((memchr(data, '>', length) == NULL) || (MemMem(data, length, "<svg", 4) == NULL)) { Tcl_DecrRefCount(dataObj); return 0; } if (!Tcl_Eof(chan) && (Tcl_ReadChars(chan, dataObj, -1, 1) == TCL_IO_FAILURE)) { /* in case of an error reading the file */ Tcl_DecrRefCount(dataObj); return 0; } data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); if (nsvgImage != NULL) { GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) { nsvgDelete(nsvgImage); return 0; |
︙ | ︙ | |||
196 197 198 199 200 201 202 | if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) { /* in case of an error reading the file */ Tcl_DecrRefCount(dataObj); Tcl_SetObjResult(interp, Tcl_NewStringObj("read error", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "READ_ERROR", NULL); return TCL_ERROR; } | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) { /* in case of an error reading the file */ Tcl_DecrRefCount(dataObj); Tcl_SetObjResult(interp, Tcl_NewStringObj("read error", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "READ_ERROR", NULL); return TCL_ERROR; } data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); Tcl_DecrRefCount(dataObj); if (nsvgImage == NULL) { return TCL_ERROR; } } |
︙ | ︙ | |||
233 234 235 236 237 238 239 | static int StringMatchSVG( Tcl_Obj *dataObj, Tcl_Obj *formatObj, int *widthPtr, int *heightPtr, Tcl_Interp *interp) { | | | > > > > > > | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | static int StringMatchSVG( Tcl_Obj *dataObj, Tcl_Obj *formatObj, int *widthPtr, int *heightPtr, Tcl_Interp *interp) { TkSizeT length, testLength; const char *data; RastOpts ropts; NSVGimage *nsvgImage; CleanCache(interp); data = Tcl_GetStringFromObj(dataObj, &length); /* should have a '<svg' and a '>' in the first 4k */ testLength = (length > 4096) ? 4096 : length; if ((memchr(data, '>', testLength) == NULL) || (MemMem(data, testLength, "<svg", 4) == NULL)) { return 0; } nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); if (nsvgImage != NULL) { GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr); if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) { nsvgDelete(nsvgImage); return 0; } |
︙ | ︙ | |||
289 290 291 292 293 294 295 | { TkSizeT length; const char *data; RastOpts ropts; NSVGimage *nsvgImage = GetCachedSVG(interp, dataObj, formatObj, &ropts); if (nsvgImage == NULL) { | | | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | { TkSizeT length; const char *data; RastOpts ropts; NSVGimage *nsvgImage = GetCachedSVG(interp, dataObj, formatObj, &ropts); if (nsvgImage == NULL) { data = Tcl_GetStringFromObj(dataObj, &length); nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts); } if (nsvgImage == NULL) { return TCL_ERROR; } return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY, |
︙ | ︙ | |||
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 | RastOpts *ropts) { int w, h, c; NSVGrasterizer *rast; unsigned char *imgData; Tk_PhotoImageBlock svgblock; double scale; (void)srcX; (void)srcY; scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h); rast = nsvgCreateRasterizer(); if (rast == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR", NULL); goto cleanAST; } | > > > > > > > > > > | | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | RastOpts *ropts) { int w, h, c; NSVGrasterizer *rast; unsigned char *imgData; Tk_PhotoImageBlock svgblock; double scale; Tcl_WideUInt wh; (void)srcX; (void)srcY; scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h); rast = nsvgCreateRasterizer(); if (rast == NULL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1)); Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR", NULL); goto cleanAST; } /* Tk Ticket [822330269b] Check potential int overflow in following ckalloc */ wh = (Tcl_WideUInt)w * (Tcl_WideUInt)h; if ( w < 0 || h < 0 || wh > 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; } nsvgRasterize(rast, nsvgImage, 0, 0, (float) scale, imgData, w, h, w * 4); |
︙ | ︙ | |||
690 691 692 693 694 695 696 | TkSizeT length; const char *data; NSVGcache *cachePtr = GetCachePtr(interp); if (cachePtr != NULL) { cachePtr->dataOrChan = dataOrChan; if (formatObj != NULL) { | | | 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | TkSizeT length; const char *data; NSVGcache *cachePtr = GetCachePtr(interp); if (cachePtr != NULL) { cachePtr->dataOrChan = dataOrChan; if (formatObj != NULL) { data = Tcl_GetStringFromObj(formatObj, &length); Tcl_DStringAppend(&cachePtr->formatString, data, length); } cachePtr->nsvgImage = nsvgImage; cachePtr->ropts = *ropts; return 1; } return 0; |
︙ | ︙ | |||
731 732 733 734 735 736 737 | const char *data; NSVGcache *cachePtr = GetCachePtr(interp); NSVGimage *nsvgImage = NULL; if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) && (cachePtr->dataOrChan == dataOrChan)) { if (formatObj != NULL) { | | | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 | const char *data; NSVGcache *cachePtr = GetCachePtr(interp); NSVGimage *nsvgImage = NULL; if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) && (cachePtr->dataOrChan == dataOrChan)) { if (formatObj != NULL) { data = Tcl_GetStringFromObj(formatObj, &length); if (strcmp(data, Tcl_DStringValue(&cachePtr->formatString)) == 0) { nsvgImage = cachePtr->nsvgImage; *ropts = cachePtr->ropts; cachePtr->nsvgImage = NULL; } } else if (Tcl_DStringLength(&cachePtr->formatString) == 0) { nsvgImage = cachePtr->nsvgImage; |
︙ | ︙ |
Changes to generic/tkImgUtil.c.
1 2 3 4 5 | /* * tkImgUtil.c -- * * This file contains image related utility functions. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkImgUtil.c -- * * This file contains image related utility functions. * * 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. */ #include "tkInt.h" #include "xbytes.h" |
︙ | ︙ |
Changes to generic/tkInt.decls.
1 2 3 4 5 6 | # tkInt.decls -- # # 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. # | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # tkInt.decls -- # # 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 © 1998-1999 Scriptics Corporation. # Copyright © 2007 Daniel A. Steffen <[email protected]> # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. library tk ############################################################################## |
︙ | ︙ | |||
222 223 224 225 226 227 228 | } declare 58 { void TkpDisplayWarning(const char *msg, const char *title) } declare 59 { void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name) } | | | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | } declare 58 { void TkpDisplayWarning(const char *msg, const char *title) } declare 59 { void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name) } declare 60 {deprecated {renamed to Tk_GetOtherWindow}} { TkWindow *TkpGetOtherWindow(TkWindow *winPtr) } declare 61 { TkWindow *TkpGetWrapperWindow(TkWindow *winPtr) } declare 62 { int TkpInit(Tcl_Interp *interp) } declare 63 { void TkpInitializeMenuBindings(Tcl_Interp *interp, Tk_BindingTable bindingTable) } declare 64 {deprecated {renamed to Tk_MakeContainer}} { void TkpMakeContainer(Tk_Window tkwin) } declare 65 { void TkpMakeMenuWindow(Tk_Window tkwin, int transient) } declare 66 {deprecated {renamed to Tk_MakeWindow}} { Window TkpMakeWindow(TkWindow *winPtr, Window parent) } declare 67 { void TkpMenuNotifyToplevelCreate(Tcl_Interp *interp, const char *menuName) } declare 68 { TkDisplay *TkpOpenDisplay(const char *display_name) |
︙ | ︙ | |||
265 266 267 268 269 270 271 | } declare 72 { int TkPositionInTree(TkWindow *winPtr, TkWindow *treePtr) } declare 73 { void TkpRedirectKeyEvent(TkWindow *winPtr, XEvent *eventPtr) } | | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | } declare 72 { int TkPositionInTree(TkWindow *winPtr, TkWindow *treePtr) } declare 73 { void TkpRedirectKeyEvent(TkWindow *winPtr, XEvent *eventPtr) } declare 74 {deprecated {renamed to Tk_SetMainMenubar}} { void TkpSetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName) } declare 75 {deprecated {renamed to Tk_UseWindow}} { int TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string) } # # Slot 76 unused (WAS: TkpWindowWasRecentlyDeleted) # declare 77 { void TkQueueEventForAllChildren(TkWindow *winPtr, XEvent *eventPtr) |
︙ | ︙ | |||
304 305 306 307 308 309 310 | } # Exported publically as Tk_SetClassProcs in 8.4a2 #declare 84 { # void TkSetClassProcs(Tk_Window tkwin, # TkClassProcs *procs, ClientData instanceData) #} | | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | } # Exported publically as Tk_SetClassProcs in 8.4a2 #declare 84 { # void TkSetClassProcs(Tk_Window tkwin, # TkClassProcs *procs, ClientData instanceData) #} declare 85 {deprecated {renamed to Tk_SetWindowMenubar}} { void TkSetWindowMenuBar(Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName) } declare 86 { KeySym TkStringToKeysym(const char *name) } declare 87 { |
︙ | ︙ | |||
390 391 392 393 394 395 396 | } declare 109 { const char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr) } declare 110 { void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont) } | | | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | } declare 109 { const char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr) } declare 110 { void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont) } declare 111 {deprecated {renamed to Tk_GetSystemDefault}} { Tcl_Obj *TkpGetSystemDefault(Tk_Window tkwin, const char *dbName, const char *className) } declare 112 { void TkpMenuThreadInit(void) } declare 113 { |
︙ | ︙ | |||
430 431 432 433 434 435 436 | declare 122 aqua { void TkpDefineNativeBitmaps(void) } declare 124 aqua { Pixmap TkpGetNativeAppBitmap(Display *display, const char *name, int *width, int *height) } | | | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | declare 122 aqua { void TkpDefineNativeBitmaps(void) } declare 124 aqua { Pixmap TkpGetNativeAppBitmap(Display *display, const char *name, int *width, int *height) } declare 135 {deprecated {renamed to Tk_DrawHighlightBorder}} { void TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable) } declare 136 { void TkSetFocusWin(TkWindow *winPtr, int force) } declare 137 { |
︙ | ︙ | |||
632 633 634 635 636 637 638 | declare 184 { void TkDrawAngledChars(Display *display,Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle) } # Support for aqua's inability to draw outside [NSView drawRect:] | | | | 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | declare 184 { void TkDrawAngledChars(Display *display,Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle) } # Support for aqua's inability to draw outside [NSView drawRect:] declare 185 { void TkpRedrawWidget(Tk_Window tkwin) } declare 186 { 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) |
︙ | ︙ |
Changes to generic/tkInt.h.
1 2 3 4 5 6 7 8 | /* * tkInt.h -- * * 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. | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * tkInt.h -- * * 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 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKINT #define _TKINT #ifndef _TKPORT #include "tkPort.h" #endif #define TK_OPTION_ENUM_VAR ((int)(sizeof(Tk_OptionType)&(sizeof(int)-1))<<6) /* * Ensure WORDS_BIGENDIAN is defined correctly: * Needs to happen here in addition to configure to work with fat compiles on * Darwin (where configure runs only once for multiple architectures). */ |
︙ | ︙ | |||
90 91 92 93 94 95 96 | #if defined(__GNUC__) && (__GNUC__ > 2) # define TKFLEXARRAY 0 #else # define TKFLEXARRAY 1 #endif | > > > > > > > > | | > | < | < | | | < | < | > > | > | > > > > | > | | > > > > > > > > > > > > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | #if defined(__GNUC__) && (__GNUC__ > 2) # define TKFLEXARRAY 0 #else # define TKFLEXARRAY 1 #endif #if TCL_MAJOR_VERSION < 9 # undef Tcl_ExternalToUtfDStringEx # undef Tcl_UtfToExternalDStringEx /* just assume 'flags' is TCL_ENCODING_NOCOMPLAIN, and return value not used. */ # define Tcl_ExternalToUtfDStringEx(encoding, data, length, flags, ds) \ (Tcl_ExternalToUtfDString(encoding, data, length, ds), TCL_INDEX_NONE) # define Tcl_UtfToExternalDStringEx(encoding, data, length, flags, ds) \ (Tcl_UtfToExternalDString(encoding, data, length, ds), TCL_INDEX_NONE) # if !defined(Tcl_GetParent) && (TCL_MINOR_VERSION < 7) # define Tcl_GetParent Tcl_GetMaster # endif #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". */ #if !defined(INT2PTR) # define INT2PTR(p) ((void *)(ptrdiff_t)(p)) #endif #if !defined(PTR2INT) # define PTR2INT(p) ((ptrdiff_t)(p)) #endif #if !defined(UINT2PTR) # define UINT2PTR(p) ((void *)(size_t)(p)) #endif #if !defined(PTR2UINT) # define PTR2UINT(p) ((size_t)(p)) #endif /* * Fallback in case Tk is linked against a Tcl version not having TIP #585 * (TCL_INDEX_TEMP_TABLE) or TIP #613 (TCL_INDEX_NULL_OK) */ #ifndef TCL_INDEX_NULL_OK # define TCL_INDEX_NULL_OK 32 #endif #if !defined(TCL_INDEX_TEMP_TABLE) # define TCL_INDEX_TEMP_TABLE 64 #endif #ifndef TCL_Z_MODIFIER # if defined(_WIN64) # define TCL_Z_MODIFIER "I" # elif defined(__GNUC__) && !defined(_WIN32) # 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 #if TCL_MAJOR_VERSION > 8 # define TKSIZET_MODIFIER TCL_Z_MODIFIER #else # define TKSIZET_MODIFIER "" #endif /* * Opaque type declarations: */ typedef struct TkColormap TkColormap; typedef struct TkFontAttributes TkFontAttributes; |
︙ | ︙ | |||
370 371 372 373 374 375 376 | Tcl_HashTable maintainHashTable; /* Hash table that maps from a container's * Tk_Window token to a list of windows managed * by that container. */ int geomInit; | > > > > > > | | | 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | Tcl_HashTable maintainHashTable; /* Hash table that maps from a container's * Tk_Window token to a list of windows managed * by that container. */ int geomInit; /* * Information used by tkGrid.c, tkPack.c, tkPlace.c, tkPointer.c, * and ttkMacOSXTheme.c: */ #define TkGetContainer(tkwin) (Tk_TopWinHierarchy((TkWindow *)tkwin) ? NULL : \ (((TkWindow *)tkwin)->maintainerPtr != NULL ? \ ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr)) /* * Information used by tkGet.c only: */ Tcl_HashTable uidTable; /* Stores all Tk_Uid used in a thread. */ int uidInit; /* 0 means uidTable needs initializing. */ |
︙ | ︙ | |||
691 692 693 694 695 696 697 698 699 700 701 702 703 704 | int strictMotif; /* This is linked to the tk_strictMotif global * variable. */ int alwaysShowSelection; /* This is linked to the * ::tk::AlwaysShowSelection variable. */ struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by * this process. */ Tcl_HashTable busyTable; /* Information used by [tk busy] command. */ } TkMainInfo; /* * Tk keeps the following data structure for each of it's builtin bitmaps. * This structure is only used by tkBitmap.c and other platform specific * bitmap files. */ | > > > > > > > > > > > | 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | int strictMotif; /* This is linked to the tk_strictMotif global * variable. */ int alwaysShowSelection; /* This is linked to the * ::tk::AlwaysShowSelection variable. */ struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by * this process. */ Tcl_HashTable busyTable; /* Information used by [tk busy] command. */ Tcl_ObjCmdProc *tclUpdateObjProc; /* Saved Tcl [update] command, used to restore * Tcl's version of [update] after Tk is shut * down */ #if TCL_MAJOR_VERSION > 8 Tcl_ObjCmdProc2 *tclUpdateObjProc2; /* Saved Tcl [update] command, used to restore * Tcl's version of [update] after Tk is shut * down, in case it's a Tcl_ObjCmdProc2 */ #endif } TkMainInfo; /* * Tk keeps the following data structure for each of it's builtin bitmaps. * This structure is only used by tkBitmap.c and other platform specific * bitmap files. */ |
︙ | ︙ | |||
803 804 805 806 807 808 809 | * Information used for event bindings (see "bind" and "bindtags" commands * in tkCmds.c): */ ClientData *tagPtr; /* Points to array of tags used for bindings * on this window. Each tag is a Tk_Uid. * Malloc'ed. NULL means no tags. */ | | | | 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | * Information used for event bindings (see "bind" and "bindtags" commands * in tkCmds.c): */ ClientData *tagPtr; /* Points to array of tags used for bindings * on this window. Each tag is a Tk_Uid. * Malloc'ed. NULL means no tags. */ TkSizeT numTags; /* Number of tags at *tagPtr. */ /* * Information used by tkOption.c to manage options for the window. */ TkSizeT optionLevel; /* TCL_INDEX_NONE means no option information is currently * cached for this window. Otherwise this * gives the level in the option stack at * which info is cached. */ /* * Information used by tkSelect.c to manage the selection. */ |
︙ | ︙ | |||
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | * 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; /* * Real definition of some events. Note that these events come from outside * but have internally generated pieces added to them. */ typedef struct { XKeyEvent keyEvent; /* The real event from X11. */ #ifdef _WIN32 char trans_chars[XMaxTransChars]; /* translated characters */ unsigned char nbytes; | > > > > > > > > > > > > > | | 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 | * 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; /* * String tables: */ MODULE_SCOPE const char *const tkStateStrings[]; MODULE_SCOPE const char *const tkCompoundStrings[]; MODULE_SCOPE const char *const tkAnchorStrings[]; MODULE_SCOPE const char *const tkReliefStrings[]; MODULE_SCOPE const char *const tkJustifyStrings[]; /* * Real definition of some events. Note that these events come from outside * but have internally generated pieces added to them. */ typedef struct { XKeyEvent keyEvent; /* The real event from X11. */ #ifdef _WIN32 # ifndef XMaxTransChars # define XMaxTransChars 7 # endif char trans_chars[XMaxTransChars]; /* translated characters */ unsigned char nbytes; #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(). */ TkSizeT charValueLen; /* Length of string in charValuePtr when that * is non-NULL. */ |
︙ | ︙ | |||
926 927 928 929 930 931 932 933 934 935 936 937 938 939 | #ifndef TCL_IO_FAILURE # define TCL_IO_FAILURE (-1) #endif /* See TIP #537 */ #ifndef TCL_INDEX_NONE # define TCL_INDEX_NONE (-1) #endif /* * The following structure is used with TkMakeEnsemble to create ensemble * commands and optionally to create sub-ensembles. */ typedef struct TkEnsemble { | > > > | 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 | #ifndef TCL_IO_FAILURE # define TCL_IO_FAILURE (-1) #endif /* See TIP #537 */ #ifndef TCL_INDEX_NONE # define TCL_INDEX_NONE (-1) #endif #ifndef TCL_INDEX_END # define TCL_INDEX_END ((TkSizeT)-2) #endif /* * The following structure is used with TkMakeEnsemble to create ensemble * commands and optionally to create sub-ensembles. */ typedef struct TkEnsemble { |
︙ | ︙ | |||
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 | * bits. */ #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 | > > > > > > > > > | 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 | * bits. */ #define META_MASK (AnyModifier<<1) #define ALT_MASK (AnyModifier<<2) #define EXTENDED_MASK (AnyModifier<<3) /* * The following special modifiers are passed to Tk_UpdatePointer to specify * respectively that the cursor should not be changed, and to say to update * the current position but not to generate button events. */ #define NOCURSOR_MASK (AnyModifier<<4) #define NOBUTTONEVENTS_MASK (AnyModifier<<5) /* * 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 |
︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 | /* * Miscellaneous variables shared among Tk modules but not exported to the * outside world: */ MODULE_SCOPE const Tk_SmoothMethod tkBezierSmoothMethod; MODULE_SCOPE Tk_ImageType tkBitmapImageType; | | | | 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 | /* * Miscellaneous variables shared among Tk modules but not exported to the * outside world: */ MODULE_SCOPE const Tk_SmoothMethod tkBezierSmoothMethod; MODULE_SCOPE Tk_ImageType tkBitmapImageType; MODULE_SCOPE Tk_PhotoImageFormatVersion3 tkImgFmtGIF; MODULE_SCOPE void (*tkHandleEventProc) (XEvent* eventPtr); MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtDefault; MODULE_SCOPE Tk_PhotoImageFormatVersion3 tkImgFmtPNG; MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPPM; MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtSVGnano; MODULE_SCOPE TkMainInfo *tkMainWindowList; MODULE_SCOPE Tk_ImageType tkPhotoImageType; MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable; MODULE_SCOPE const char *const tkWebColors[20]; |
︙ | ︙ | |||
1088 1089 1090 1091 1092 1093 1094 | #define PI M_PI #else #define PI 3.14159265358979323846 #endif #endif /* | | | 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 | #define PI M_PI #else #define PI 3.14159265358979323846 #endif #endif /* * Support for Clang Static Analyzer <https://clang-analyzer.llvm.org/> */ #if defined(PURIFY) && defined(__clang__) #if __has_feature(attribute_analyzer_noreturn) && \ !defined(Tcl_Panic) && defined(Tcl_Panic_TCL_DECLARED) void Tcl_Panic(const char *, ...) __attribute__((analyzer_noreturn)); #endif |
︙ | ︙ | |||
1249 1250 1251 1252 1253 1254 1255 | Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SelectionObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SendObjCmd(ClientData clientData, Tcl_Interp *interp,int objc, Tcl_Obj *const objv[]); | < < < | 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 | Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SelectionObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SendObjCmd(ClientData clientData, Tcl_Interp *interp,int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_SpinboxObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_TextObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE int Tk_TkwaitObjCmd(ClientData clientData, |
︙ | ︙ | |||
1281 1282 1283 1284 1285 1286 1287 | 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, | | | | 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 | 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 objv[]); MODULE_SCOPE int TkCanvasGetCoordObj(Tcl_Interp *interp, Tk_Canvas canvas, Tcl_Obj *obj, double *doublePtr); MODULE_SCOPE int TkGetDoublePixels(Tcl_Interp *interp, Tk_Window tkwin, const char *string, double *doublePtr); MODULE_SCOPE int TkPostscriptImage(Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, XImage *ximage, int x, int y, int width, int height); #if TCL_MAJOR_VERSION > 8 MODULE_SCOPE int TkCanvasTagsParseProc(ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, size_t offset); MODULE_SCOPE const char *TkCanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin, char *widgRec, size_t offset, Tcl_FreeProc **freeProcPtr); #else #define TkCanvasTagsParseProc Tk_CanvasTagsParseProc #define TkCanvasTagsPrintProc Tk_CanvasTagsPrintProc #endif MODULE_SCOPE void TkMapTopFrame(Tk_Window tkwin); MODULE_SCOPE XEvent * TkpGetBindingXEvent(Tcl_Interp *interp); MODULE_SCOPE void TkCreateExitHandler(Tcl_ExitProc *proc, void *clientData); MODULE_SCOPE void TkDeleteExitHandler(Tcl_ExitProc *proc, ClientData clientData); MODULE_SCOPE Tcl_ExitProc TkFinalize; MODULE_SCOPE Tcl_ExitProc TkFinalizeThread; MODULE_SCOPE void TkpBuildRegionFromAlphaData(Region region, unsigned x, unsigned y, unsigned width, unsigned height, unsigned char *dataPtr, |
︙ | ︙ | |||
1367 1368 1369 1370 1371 1372 1373 | 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*); | > | > > > > > > | 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 | 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*); #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) # define TkNewIndexObj(value) Tcl_NewWideIntObj((Tcl_WideInt)(value + 1) - 1) # define TK_OPTION_UNDERLINE_DEF(type, field) "-1", TCL_INDEX_NONE, offsetof(type, field), 0, NULL #else # define TkNewIndexObj(value) (((TkSizeT)(value) == TCL_INDEX_NONE) ? Tcl_NewObj() : Tcl_NewWideIntObj(value)) # define TK_OPTION_UNDERLINE_DEF(type, field) NULL, TCL_INDEX_NONE, offsetof(type, field), TK_OPTION_NULL_OK, NULL #endif #ifdef _WIN32 #define TkParseColor XParseColor #else MODULE_SCOPE Status TkParseColor (Display * display, Colormap map, const char* spec, XColor * colorPtr); |
︙ | ︙ | |||
1406 1407 1408 1409 1410 1411 1412 | MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion); #endif #if !defined(__cplusplus) && !defined(c_plusplus) # define c_class class #endif | > | < < | | < < < < < < < > > | 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 | MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion); #endif #if !defined(__cplusplus) && !defined(c_plusplus) # define c_class class #endif /* Tcl 8.6 has a different definition of Tcl_UniChar than other Tcl versions for TCL_UTF_MAX > 3 */ #if TCL_UTF_MAX > (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6)) # define TkUtfToUniChar(src, ch) (size_t)(((int (*)(const char *, int *))Tcl_UtfToUniChar)(src, ch)) # define TkUniCharToUtf(ch, src) (size_t)(((int (*)(int, char *))Tcl_UniCharToUtf)(ch, src)) #else MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *); MODULE_SCOPE size_t TkUniCharToUtf(int, char *); #endif #if defined(_WIN32) && !defined(STATIC_BUILD) && TCL_MAJOR_VERSION < 9 # define tcl_CreateFileHandler reserved9 #endif MODULE_SCOPE void Icu_Init(Tcl_Interp* interp); /* * Unsupported commands. */ MODULE_SCOPE int TkUnsupported1ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, |
︙ | ︙ |
Changes to generic/tkIntDecls.h.
1 2 3 4 5 6 7 8 | /* * tkIntDecls.h -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkIntDecls.h -- * * 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 Scriptics Corporation. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKINTDECLS #define _TKINTDECLS |
︙ | ︙ | |||
200 201 202 203 204 205 206 | /* 57 */ EXTERN void TkpClaimFocus(TkWindow *topLevelPtr, int force); /* 58 */ EXTERN void TkpDisplayWarning(const char *msg, const char *title); /* 59 */ EXTERN void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name); /* 60 */ | > | > | > | > | > | | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | /* 57 */ EXTERN void TkpClaimFocus(TkWindow *topLevelPtr, int force); /* 58 */ EXTERN void TkpDisplayWarning(const char *msg, const char *title); /* 59 */ EXTERN void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name); /* 60 */ TK_DEPRECATED("renamed to Tk_GetOtherWindow") TkWindow * TkpGetOtherWindow(TkWindow *winPtr); /* 61 */ EXTERN TkWindow * TkpGetWrapperWindow(TkWindow *winPtr); /* 62 */ EXTERN int TkpInit(Tcl_Interp *interp); /* 63 */ EXTERN void TkpInitializeMenuBindings(Tcl_Interp *interp, Tk_BindingTable bindingTable); /* 64 */ TK_DEPRECATED("renamed to Tk_MakeContainer") void TkpMakeContainer(Tk_Window tkwin); /* 65 */ EXTERN void TkpMakeMenuWindow(Tk_Window tkwin, int transient); /* 66 */ TK_DEPRECATED("renamed to Tk_MakeWindow") Window TkpMakeWindow(TkWindow *winPtr, Window parent); /* 67 */ EXTERN void TkpMenuNotifyToplevelCreate(Tcl_Interp *interp, const char *menuName); /* 68 */ EXTERN TkDisplay * TkpOpenDisplay(const char *display_name); /* 69 */ EXTERN int TkPointerEvent(XEvent *eventPtr, TkWindow *winPtr); /* 70 */ EXTERN int TkPolygonToArea(double *polyPtr, int numPoints, double *rectPtr); /* 71 */ EXTERN double TkPolygonToPoint(double *polyPtr, int numPoints, double *pointPtr); /* 72 */ EXTERN int TkPositionInTree(TkWindow *winPtr, TkWindow *treePtr); /* 73 */ EXTERN void TkpRedirectKeyEvent(TkWindow *winPtr, XEvent *eventPtr); /* 74 */ TK_DEPRECATED("renamed to Tk_SetMainMenubar") void TkpSetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 75 */ TK_DEPRECATED("renamed to Tk_UseWindow") int TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* Slot 76 is reserved */ /* 77 */ EXTERN void TkQueueEventForAllChildren(TkWindow *winPtr, XEvent *eventPtr); /* 78 */ EXTERN int TkReadBitmapFile(Display *display, Drawable d, |
︙ | ︙ | |||
263 264 265 266 267 268 269 | EXTERN void TkSelEventProc(Tk_Window tkwin, XEvent *eventPtr); /* 82 */ EXTERN void TkSelInit(Tk_Window tkwin); /* 83 */ EXTERN void TkSelPropProc(XEvent *eventPtr); /* Slot 84 is reserved */ /* 85 */ | > | | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | EXTERN void TkSelEventProc(Tk_Window tkwin, XEvent *eventPtr); /* 82 */ EXTERN void TkSelInit(Tk_Window tkwin); /* 83 */ EXTERN void TkSelPropProc(XEvent *eventPtr); /* Slot 84 is reserved */ /* 85 */ TK_DEPRECATED("renamed to Tk_SetWindowMenubar") void TkSetWindowMenuBar(Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 86 */ EXTERN KeySym TkStringToKeysym(const char *name); /* 87 */ EXTERN int TkThickPolyLineToArea(double *coordPtr, int numPoints, double width, int capStyle, |
︙ | ︙ | |||
327 328 329 330 331 332 333 | Tk_Window *windowPtr); /* 109 */ EXTERN const char * TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 110 */ EXTERN void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont); /* 111 */ | > | | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | Tk_Window *windowPtr); /* 109 */ EXTERN const char * TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 110 */ EXTERN void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont); /* 111 */ TK_DEPRECATED("renamed to Tk_GetSystemDefault") Tcl_Obj * TkpGetSystemDefault(Tk_Window tkwin, const char *dbName, const char *className); /* 112 */ EXTERN void TkpMenuThreadInit(void); /* 113 */ EXTERN int XClipBox(Region rgn, XRectangle *rect_return); /* 114 */ EXTERN Region XCreateRegion(void); |
︙ | ︙ | |||
375 376 377 378 379 380 381 | /* Slot 129 is reserved */ /* Slot 130 is reserved */ /* Slot 131 is reserved */ /* Slot 132 is reserved */ /* Slot 133 is reserved */ /* Slot 134 is reserved */ /* 135 */ | > | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | /* Slot 129 is reserved */ /* Slot 130 is reserved */ /* Slot 131 is reserved */ /* Slot 132 is reserved */ /* Slot 133 is reserved */ /* Slot 134 is reserved */ /* 135 */ TK_DEPRECATED("renamed to Tk_DrawHighlightBorder") void TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 136 */ EXTERN void TkSetFocusWin(TkWindow *winPtr, int force); /* 137 */ EXTERN void TkpSetKeycodeAndState(Tk_Window tkwin, KeySym keySym, XEvent *eventPtr); |
︙ | ︙ | |||
554 555 556 557 558 559 560 | int x, int y, int width, int height, double angle); /* 184 */ EXTERN void TkDrawAngledChars(Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); | < < < < | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 | int x, int y, int width, int height, double angle); /* 184 */ EXTERN void TkDrawAngledChars(Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); /* 185 */ EXTERN void TkpRedrawWidget(Tk_Window tkwin); /* 186 */ EXTERN int TkpWillDrawWidget(Tk_Window tkwin); /* 187 */ EXTERN int TkDebugPhotoStringMatchDef(Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); typedef struct TkIntStubs { int magic; |
︙ | ︙ | |||
631 632 633 634 635 636 637 | int (*tkOvalToArea) (double *ovalPtr, double *rectPtr); /* 53 */ double (*tkOvalToPoint) (double ovalPtr[], double width, int filled, double pointPtr[]); /* 54 */ int (*tkpChangeFocus) (TkWindow *winPtr, int force); /* 55 */ void (*tkpCloseDisplay) (TkDisplay *dispPtr); /* 56 */ void (*tkpClaimFocus) (TkWindow *topLevelPtr, int force); /* 57 */ void (*tkpDisplayWarning) (const char *msg, const char *title); /* 58 */ void (*tkpGetAppName) (Tcl_Interp *interp, Tcl_DString *name); /* 59 */ | | | | | | | | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 | int (*tkOvalToArea) (double *ovalPtr, double *rectPtr); /* 53 */ double (*tkOvalToPoint) (double ovalPtr[], double width, int filled, double pointPtr[]); /* 54 */ int (*tkpChangeFocus) (TkWindow *winPtr, int force); /* 55 */ void (*tkpCloseDisplay) (TkDisplay *dispPtr); /* 56 */ void (*tkpClaimFocus) (TkWindow *topLevelPtr, int force); /* 57 */ void (*tkpDisplayWarning) (const char *msg, const char *title); /* 58 */ void (*tkpGetAppName) (Tcl_Interp *interp, Tcl_DString *name); /* 59 */ TCL_DEPRECATED_API("renamed to Tk_GetOtherWindow") TkWindow * (*tkpGetOtherWindow) (TkWindow *winPtr); /* 60 */ TkWindow * (*tkpGetWrapperWindow) (TkWindow *winPtr); /* 61 */ int (*tkpInit) (Tcl_Interp *interp); /* 62 */ void (*tkpInitializeMenuBindings) (Tcl_Interp *interp, Tk_BindingTable bindingTable); /* 63 */ TCL_DEPRECATED_API("renamed to Tk_MakeContainer") void (*tkpMakeContainer) (Tk_Window tkwin); /* 64 */ void (*tkpMakeMenuWindow) (Tk_Window tkwin, int transient); /* 65 */ TCL_DEPRECATED_API("renamed to Tk_MakeWindow") Window (*tkpMakeWindow) (TkWindow *winPtr, Window parent); /* 66 */ void (*tkpMenuNotifyToplevelCreate) (Tcl_Interp *interp, const char *menuName); /* 67 */ TkDisplay * (*tkpOpenDisplay) (const char *display_name); /* 68 */ int (*tkPointerEvent) (XEvent *eventPtr, TkWindow *winPtr); /* 69 */ int (*tkPolygonToArea) (double *polyPtr, int numPoints, double *rectPtr); /* 70 */ double (*tkPolygonToPoint) (double *polyPtr, int numPoints, double *pointPtr); /* 71 */ int (*tkPositionInTree) (TkWindow *winPtr, TkWindow *treePtr); /* 72 */ void (*tkpRedirectKeyEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 73 */ TCL_DEPRECATED_API("renamed to Tk_SetMainMenubar") void (*tkpSetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 74 */ TCL_DEPRECATED_API("renamed to Tk_UseWindow") int (*tkpUseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 75 */ void (*reserved76)(void); void (*tkQueueEventForAllChildren) (TkWindow *winPtr, XEvent *eventPtr); /* 77 */ int (*tkReadBitmapFile) (Display *display, Drawable d, const char *filename, unsigned int *width_return, unsigned int *height_return, Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return); /* 78 */ int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, Region damageRgn); /* 79 */ void (*tkSelDeadWindow) (TkWindow *winPtr); /* 80 */ void (*tkSelEventProc) (Tk_Window tkwin, XEvent *eventPtr); /* 81 */ void (*tkSelInit) (Tk_Window tkwin); /* 82 */ void (*tkSelPropProc) (XEvent *eventPtr); /* 83 */ void (*reserved84)(void); TCL_DEPRECATED_API("renamed to Tk_SetWindowMenubar") void (*tkSetWindowMenuBar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 85 */ KeySym (*tkStringToKeysym) (const char *name); /* 86 */ int (*tkThickPolyLineToArea) (double *coordPtr, int numPoints, double width, int capStyle, int joinStyle, double *rectPtr); /* 87 */ void (*tkWmAddToColormapWindows) (TkWindow *winPtr); /* 88 */ void (*tkWmDeadWindow) (TkWindow *winPtr); /* 89 */ TkWindow * (*tkWmFocusToplevel) (TkWindow *winPtr); /* 90 */ void (*tkWmMapWindow) (TkWindow *winPtr); /* 91 */ void (*tkWmNewWindow) (TkWindow *winPtr); /* 92 */ |
︙ | ︙ | |||
682 683 684 685 686 687 688 | int (*tkFindStateNumObj) (Tcl_Interp *interp, Tcl_Obj *optionPtr, const TkStateMap *mapPtr, Tcl_Obj *keyPtr); /* 104 */ Tcl_HashTable * (*tkGetBitmapPredefTable) (void); /* 105 */ TkDisplay * (*tkGetDisplayList) (void); /* 106 */ TkMainInfo * (*tkGetMainInfoList) (void); /* 107 */ int (*tkGetWindowFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Tk_Window *windowPtr); /* 108 */ const char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */ void (*tkpGetSubFonts) (Tcl_Interp *interp, Tk_Font tkfont); /* 110 */ | | | 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | int (*tkFindStateNumObj) (Tcl_Interp *interp, Tcl_Obj *optionPtr, const TkStateMap *mapPtr, Tcl_Obj *keyPtr); /* 104 */ Tcl_HashTable * (*tkGetBitmapPredefTable) (void); /* 105 */ TkDisplay * (*tkGetDisplayList) (void); /* 106 */ TkMainInfo * (*tkGetMainInfoList) (void); /* 107 */ int (*tkGetWindowFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Tk_Window *windowPtr); /* 108 */ const char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */ void (*tkpGetSubFonts) (Tcl_Interp *interp, Tk_Font tkfont); /* 110 */ TCL_DEPRECATED_API("renamed to Tk_GetSystemDefault") Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */ void (*tkpMenuThreadInit) (void); /* 112 */ int (*xClipBox) (Region rgn, XRectangle *rect_return); /* 113 */ Region (*xCreateRegion) (void); /* 114 */ int (*xDestroyRegion) (Region rgn); /* 115 */ int (*xIntersectRegion) (Region sra, Region srcb, Region dr_return); /* 116 */ int (*xRectInRegion) (Region rgn, int x, int y, unsigned int width, unsigned int height); /* 117 */ int (*xSetRegion) (Display *display, GC gc, Region rgn); /* 118 */ |
︙ | ︙ | |||
733 734 735 736 737 738 739 | void (*reserved128)(void); void (*reserved129)(void); void (*reserved130)(void); void (*reserved131)(void); void (*reserved132)(void); void (*reserved133)(void); void (*reserved134)(void); | | | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | void (*reserved128)(void); void (*reserved129)(void); void (*reserved130)(void); void (*reserved131)(void); void (*reserved132)(void); void (*reserved133)(void); void (*reserved134)(void); TCL_DEPRECATED_API("renamed to Tk_DrawHighlightBorder") void (*tkpDrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 135 */ void (*tkSetFocusWin) (TkWindow *winPtr, int force); /* 136 */ void (*tkpSetKeycodeAndState) (Tk_Window tkwin, KeySym keySym, XEvent *eventPtr); /* 137 */ KeySym (*tkpGetKeySym) (TkDisplay *dispPtr, XEvent *eventPtr); /* 138 */ void (*tkpInitKeymapInfo) (TkDisplay *dispPtr); /* 139 */ Region (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */ TkWindow ** (*tkWmStackorderToplevel) (TkWindow *parentPtr); /* 141 */ void (*tkFocusFree) (TkMainInfo *mainPtr); /* 142 */ |
︙ | ︙ | |||
783 784 785 786 787 788 789 | const char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 178 */ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 179 */ 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 */ | < < < < < < < < < < < < < < < < | 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 | const char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 178 */ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 179 */ 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 */ void (*tkpRedrawWidget) (Tk_Window tkwin); /* 185 */ int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 186 */ int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 187 */ } TkIntStubs; extern const TkIntStubs *tkIntStubsPtr; #ifdef __cplusplus } |
︙ | ︙ | |||
1174 1175 1176 1177 1178 1179 1180 | (tkIntStubsPtr->tkDrawAngledTextLayout) /* 181 */ #define TkUnderlineAngledTextLayout \ (tkIntStubsPtr->tkUnderlineAngledTextLayout) /* 182 */ #define TkIntersectAngledTextLayout \ (tkIntStubsPtr->tkIntersectAngledTextLayout) /* 183 */ #define TkDrawAngledChars \ (tkIntStubsPtr->tkDrawAngledChars) /* 184 */ | < < < < > > > > > > > > > > > > > > > > > > > | | 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 | (tkIntStubsPtr->tkDrawAngledTextLayout) /* 181 */ #define TkUnderlineAngledTextLayout \ (tkIntStubsPtr->tkUnderlineAngledTextLayout) /* 182 */ #define TkIntersectAngledTextLayout \ (tkIntStubsPtr->tkIntersectAngledTextLayout) /* 183 */ #define TkDrawAngledChars \ (tkIntStubsPtr->tkDrawAngledChars) /* 184 */ #define TkpRedrawWidget \ (tkIntStubsPtr->tkpRedrawWidget) /* 185 */ #define TkpWillDrawWidget \ (tkIntStubsPtr->tkpWillDrawWidget) /* 186 */ #define TkDebugPhotoStringMatchDef \ (tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 187 */ #endif /* defined(USE_TK_STUBS) */ /* !END!: Do not edit above this line. */ #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT #undef TkpCmapStressed_ #undef TkpSync_ #undef TkUnixContainerId_ #undef TkUnixDoOneXEvent_ #undef TkUnixSetMenubar_ #undef TkWmCleanup_ #undef TkSendCleanup_ #undef TkpTestsendCmd_ #undef TkSetWindowMenuBar #undef TkpDrawHighlightBorder #undef TkpUseWindow #undef TkpSetMainMenubar #undef TkpGetOtherWindow #undef TkpGetSystemDefault #undef TkpMakeContainer #undef TkpMakeWindow #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION == 8) # define TkSetWindowMenuBar Tk_SetWindowMenubar # define TkpDrawHighlightBorder Tk_DrawHighlightBorder # define TkpUseWindow Tk_UseWindow # define TkpSetMainMenubar Tk_SetMainMenubar # define TkpGetOtherWindow ((TkWindow *(*)(TkWindow *))(void *)Tk_GetOtherWindow) # define TkpGetSystemDefault Tk_GetSystemDefault # define TkpMakeContainer Tk_MakeContainer # define TkpMakeWindow ((Window (*)(TkWindow *, Window))(void *)Tk_MakeWindow) #endif #if !defined(MAC_OSX_TK) && !defined(USE_TK_STUBS) # undef TkpWillDrawWidget # undef TkpRedrawWidget # define TkpWillDrawWidget(w) 0 # define TkpRedrawWidget(w) #endif #endif /* _TKINTDECLS */ |
Changes to generic/tkIntPlatDecls.h.
1 2 3 4 5 6 7 8 | /* * tkIntPlatDecls.h -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkIntPlatDecls.h -- * * 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 Scriptics Corporation. * All rights reserved. */ #ifndef _TKINTPLATDECLS #define _TKINTPLATDECLS #ifdef BUILD_tk |
︙ | ︙ |
Changes to generic/tkIntXlibDecls.h.
1 2 3 4 5 6 7 8 | /* * tkIntXlibDecls.h -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkIntXlibDecls.h -- * * 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 Scriptics Corporation. * All rights reserved. */ #ifndef _TKINTXLIBDECLS #define _TKINTXLIBDECLS /* |
︙ | ︙ |
Changes to generic/tkListbox.c.
1 2 3 4 5 6 7 | /* * tkListbox.c -- * * This module implements listbox widgets for the Tk toolkit. A listbox * displays a collection of strings, one per line, and provides scrolling * and selection. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkListbox.c -- * * 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 © 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 "default.h" |
︙ | ︙ | |||
216 217 218 219 220 221 222 | * below. */ enum state { STATE_DISABLED, STATE_NORMAL }; | < < < < | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | * below. */ enum state { STATE_DISABLED, STATE_NORMAL }; enum activeStyle { ACTIVE_STYLE_DOTBOX, ACTIVE_STYLE_NONE, ACTIVE_STYLE_UNDERLINE }; static const char *const activeStyleStrings[] = { "dotbox", "none", "underline", NULL }; |
︙ | ︙ | |||
293 294 295 296 297 298 299 | {TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode", DEF_LISTBOX_SELECT_MODE, TCL_INDEX_NONE, offsetof(Listbox, selectMode), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_LISTBOX_SET_GRID, TCL_INDEX_NONE, offsetof(Listbox, setGrid), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_LISTBOX_STATE, TCL_INDEX_NONE, offsetof(Listbox, state), | | | 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | {TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode", DEF_LISTBOX_SELECT_MODE, TCL_INDEX_NONE, offsetof(Listbox, selectMode), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid", DEF_LISTBOX_SET_GRID, TCL_INDEX_NONE, offsetof(Listbox, setGrid), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_LISTBOX_STATE, TCL_INDEX_NONE, offsetof(Listbox, state), 0, &tkStateStrings[1], 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_LISTBOX_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Listbox, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INT, "-width", "width", "Width", DEF_LISTBOX_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, width), 0, 0, 0}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, xScrollCmd), |
︙ | ︙ | |||
319 320 321 322 323 324 325 | * The itemAttrOptionSpecs table defines the valid configuration options for * listbox items. */ static const Tk_OptionSpec itemAttrOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border), | | | | | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | * The itemAttrOptionSpecs table defines the valid configuration options for * listbox items. */ static const Tk_OptionSpec itemAttrOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border), TK_OPTION_NULL_OK, DEF_LISTBOX_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground", NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder), TK_OPTION_NULL_OK, DEF_LISTBOX_SELECT_MONO, 0}, {TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background", NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor), TK_OPTION_NULL_OK, DEF_LISTBOX_SELECT_FG_MONO, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0} }; /* * The following tables define the listbox widget commands (and sub-commands) * and map the indexes into the string tables into enumerated types used to |
︙ | ︙ | |||
366 367 368 369 370 371 372 | "anchor", "clear", "includes", "set", NULL }; enum selcommand { SELECTION_ANCHOR, SELECTION_CLEAR, SELECTION_INCLUDES, SELECTION_SET }; static const char *const scanCommandNames[] = { | | | | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | "anchor", "clear", "includes", "set", NULL }; enum selcommand { SELECTION_ANCHOR, SELECTION_CLEAR, SELECTION_INCLUDES, SELECTION_SET }; static const char *const scanCommandNames[] = { "dragto", "mark", NULL }; enum scancommand { SCAN_DRAGTO, SCAN_MARK }; static const char *const indexNames[] = { "active", "anchor", NULL }; enum indices { INDEX_ACTIVE, INDEX_ANCHOR |
︙ | ︙ | |||
1112 1113 1114 1115 1116 1117 1118 | */ result = Tcl_ListObjIndex(interp, listPtr->listObj, index, &el); if (result != TCL_OK) { return result; } | | | 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | */ result = Tcl_ListObjIndex(interp, listPtr->listObj, index, &el); if (result != TCL_OK) { return result; } 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; } else if (listPtr->justify == TK_JUSTIFY_RIGHT) { x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth) |
︙ | ︙ | |||
2075 2076 2077 2078 2079 2080 2081 | } /* * Draw the actual text of this item. */ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); | | | 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 | } /* * Draw the actual text of this item. */ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); stringRep = Tcl_GetStringFromObj(curElement, &stringLen); textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen); Tk_GetFontMetrics(listPtr->tkfont, &fm); y += fm.ascent + listPtr->selBorderWidth; if (listPtr->justify == TK_JUSTIFY_LEFT) { x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset; |
︙ | ︙ | |||
2188 2189 2190 2191 2192 2193 2194 | listPtr->borderWidth, listPtr->relief); if (listPtr->highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(listPtr->highlightBgColorPtr, pixmap); if (listPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(listPtr->highlightColorPtr, pixmap); | | | | 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 | listPtr->borderWidth, listPtr->relief); if (listPtr->highlightWidth > 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(listPtr->highlightBgColorPtr, pixmap); if (listPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(listPtr->highlightColorPtr, pixmap); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, listPtr->highlightWidth, pixmap); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, listPtr->highlightWidth, pixmap); } } #ifndef TK_NO_DOUBLE_BUFFERING XCopyArea(listPtr->display, pixmap, Tk_WindowId(tkwin), listPtr->textGC, 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin), 0, 0); |
︙ | ︙ | |||
2259 2260 2261 2262 2263 2264 2265 | */ result = Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); if (result != TCL_OK) { continue; } | | | 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 | */ result = Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); if (result != TCL_OK) { continue; } text = Tcl_GetStringFromObj(element, &textLength); Tk_GetFontMetrics(listPtr->tkfont, &fm); pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength); if (pixelWidth > listPtr->maxWidth) { listPtr->maxWidth = pixelWidth; } } } |
︙ | ︙ | |||
2337 2338 2339 2340 2341 2342 2343 | oldMaxWidth = listPtr->maxWidth; for (i = 0; i < objc; i++) { /* * Check if any of the new elements are wider than the current widest; * if so, update our notion of "widest." */ | | | 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 | oldMaxWidth = listPtr->maxWidth; for (i = 0; i < objc; i++) { /* * Check if any of the new elements are wider than the current widest; * if so, update our notion of "widest." */ stringRep = Tcl_GetStringFromObj(objv[i], &length); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length); if (pixelWidth > listPtr->maxWidth) { listPtr->maxWidth = pixelWidth; } } /* |
︙ | ︙ | |||
2496 2497 2498 2499 2500 2501 2502 | * Check width of the element. We only have to check if widthChanged * has not already been set to 1, because we only need one maxWidth * element to disappear for us to have to recompute the width. */ if (widthChanged == 0) { Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); | | | 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 | * Check width of the element. We only have to check if widthChanged * has not already been set to 1, because we only need one maxWidth * element to disappear for us to have to recompute the width. */ if (widthChanged == 0) { Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element); stringRep = Tcl_GetStringFromObj(element, &length); pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length); if (pixelWidth == listPtr->maxWidth) { widthChanged = 1; } } } |
︙ | ︙ | |||
2800 2801 2802 2803 2804 2805 2806 | /* * Everything failed, nothing matched. Throw up an error message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad listbox index \"%s\": must be active, anchor, end, @x,y," | | | 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 | /* * Everything failed, nothing matched. Throw up an error message. */ badIndex: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad listbox index \"%s\": must be active, anchor, end, @x,y," " or an index", Tcl_GetString(indexObj))); Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", NULL); return TCL_ERROR; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
3144 3145 3146 3147 3148 3149 3150 | entry = Tcl_FindHashEntry(listPtr->selection, KEY(i)); if (entry != NULL) { if (needNewline) { Tcl_DStringAppend(&selection, "\n", 1); } Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); | | | 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 | entry = Tcl_FindHashEntry(listPtr->selection, KEY(i)); if (entry != NULL) { if (needNewline) { Tcl_DStringAppend(&selection, "\n", 1); } Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement); stringRep = Tcl_GetStringFromObj(curElement, &stringLen); Tcl_DStringAppend(&selection, stringRep, stringLen); needNewline = 1; } } length = Tcl_DStringLength(&selection); if (length == 0) { |
︙ | ︙ | |||
3451 3452 3453 3454 3455 3456 3457 | /* * Bwah hahahaha! Puny mortal, you can't unset a -listvar'd variable! */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) { | | | | 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 | /* * Bwah hahahaha! Puny mortal, you can't unset a -listvar'd variable! */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, listPtr->listVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ListboxListVarProc, probe); if (probe == (void *)listPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * listVarName, which means it is not unset and not |
︙ | ︙ |
Changes to generic/tkMacWinMenu.c.
1 2 3 4 5 6 | /* * tkMacWinMenu.c -- * * This module implements the common elements of the Mac and Windows * specific features of menus. This file is not used for UNIX. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * 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 © 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. */ #include "tkInt.h" #include "tkMenu.h" |
︙ | ︙ |
Changes to generic/tkMain.c.
︙ | ︙ | |||
21 22 23 24 25 26 27 | /* * The default prompt used when the user has not overridden it. */ static const char DEFAULT_PRIMARY_PROMPT[] = "% "; /* | | | | | < | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * The default prompt used when the user has not overridden it. */ static const char DEFAULT_PRIMARY_PROMPT[] = "% "; /* * This file can be compiled on Windows in UNICODE mode, as well as on all * other platforms using the native encoding. This is done by using the normal * Windows functions like _tcscmp, but on platforms which don't have <tchar.h> * we have to translate that to strcmp here. */ #ifdef _WIN32 #ifdef __cplusplus extern "C" { #endif /* Little hack to eliminate the need for "tclInt.h" here: Just copy a small portion of TclIntPlatStubs, just |
︙ | ︙ | |||
64 65 66 67 68 69 70 | static inline Tcl_Obj * NewNativeObj( TCHAR *string) { Tcl_Obj *obj; Tcl_DString ds; | | | | | | | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | static inline Tcl_Obj * NewNativeObj( TCHAR *string) { Tcl_Obj *obj; Tcl_DString ds; #if defined(_WIN32) && defined(UNICODE) Tcl_DStringInit(&ds); Tcl_WCharToUtfDString(string, wcslen(string), &ds); #else (void)Tcl_ExternalToUtfDStringEx(NULL, (char *)string, -1, TCL_ENCODING_NOCOMPLAIN, &ds); #endif obj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); Tcl_DStringFree(&ds); return obj; } /* * Declarations for various library functions and variables (don't want to * include tclInt.h or tclPort.h here, because people might copy this file out * of the Tk source directory to make their own modified versions). Note: do * not declare "exit" here even though a declaration is really needed, because * it will conflict with a declaration elsewhere on some systems. */ #if defined(_WIN32) #define isatty WinIsTty static int WinIsTty(int fd) { HANDLE handle; /* * For now, under Windows, we assume we are not running as a console mode * app, so we need to use the GUI console. In order to enable this, we * always claim to be running on a tty. This probably isn't the right way * to do it. */ #if !defined(STATIC_BUILD) if (tclStubsPtr->tcl_CreateFileHandler && tclIntPlatStubsPtr->tclpIsAtty) { /* We are running on Cygwin */ return tclIntPlatStubsPtr->tclpIsAtty(fd); } #endif handle = GetStdHandle(STD_INPUT_HANDLE + fd); /* * If it's a bad or closed handle, then it's been connected to a wish * console window. A character file handle is a tty by definition. */ return (handle == INVALID_HANDLE_VALUE) || (handle == 0) || (GetFileType(handle) == FILE_TYPE_UNKNOWN) || (GetFileType(handle) == FILE_TYPE_CHAR); } #else extern int isatty(int fd); #endif typedef struct { Tcl_Channel input; /* The standard input channel from which lines * are read. */ int tty; /* Non-zero means standard input is a * terminal-like device. Zero means it's a * file. */ Tcl_DString command; /* Used to assemble lines of terminal input * into Tcl commands. */ |
︙ | ︙ | |||
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | TCHAR **argv, /* Array of argument strings. */ Tcl_AppInitProc *appInitProc, /* Application-specific initialization * function to call after most initialization * but before starting to execute commands. */ Tcl_Interp *interp) { Tcl_Obj *path, *argvPtr, *appName; const char *encodingName; int code, nullStdin = 0; Tcl_Channel chan; InteractiveState is; /* * Ensure that we are getting a compatible version of Tcl. */ if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { abort(); } else { Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp))); } } #if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD) | > > > > > > | | | | | > > | > | | | > | | | > | | | > < < | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | TCHAR **argv, /* Array of argument strings. */ Tcl_AppInitProc *appInitProc, /* Application-specific initialization * function to call after most initialization * but before starting to execute commands. */ Tcl_Interp *interp) { int i=0; /* argv[i] index */ Tcl_Obj *path, *argvPtr, *appName; const char *encodingName; int code, nullStdin = 0; Tcl_Channel chan; InteractiveState is; if (0 < argc) { --argc; /* "consume" argv[0] */ ++i; } /* * Ensure that we are getting a compatible version of Tcl. */ if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) { if (Tcl_InitStubs(interp, "8.1", 0) == NULL) { abort(); } else { Tcl_Panic("%s", Tcl_GetString(Tcl_GetObjResult(interp))); } } #if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD) 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)) { loadCygwinTk: if (TkCygwinMainEx(argc, argv, appInitProc, interp)) { /* Should never reach here. */ return; } } else { int j; for (j = 1; j < argc; ++j) { if (!strcmp(argv[j], "-display")) { goto loadCygwinTk; } } } } #endif Tcl_InitMemory(interp); is.interp = interp; is.gotPartial = 0; Tcl_Preserve(interp); #if defined(_WIN32) #if !defined(STATIC_BUILD) /* If compiled for Win32 but running on Cygwin, don't use console */ if (!tclStubsPtr->tcl_CreateFileHandler) #endif Tk_InitConsoleChannels(interp); #endif #ifdef MAC_OSX_TK if (Tcl_GetStartupScript(NULL) == NULL) { TkMacOSXDefaultStartupScript(); } #endif /* * If the application has not already set a startup script, parse the * first few command line arguments to determine the script path and * encoding. */ if (NULL == Tcl_GetStartupScript(NULL)) { #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 size_t length; #endif /* * Check whether first 3 args (argv[1] - argv[3]) look like * -encoding ENCODING FILENAME * or like * FILENAME * or like * -file FILENAME (ancient history support only, removed with Tcl 9.0) */ /* mind argc is being adjusted as we proceed */ if ((argc >= 3) && (0 == _tcscmp(TEXT("-encoding"), argv[1])) && ('-' != argv[3][0])) { Tcl_Obj *value = NewNativeObj(argv[2]); Tcl_SetStartupScript(NewNativeObj(argv[3]), Tcl_GetString(value)); Tcl_DecrRefCount(value); argc -= 3; i += 3; } else if ((argc >= 1) && ('-' != argv[1][0])) { Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL); argc--; i++; #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 } else if ((argc >= 2) && (length = _tcslen(argv[1])) && (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length)) && ('-' != argv[2][0])) { Tcl_SetStartupScript(NewNativeObj(argv[2]), NULL); argc -= 2; i += 2; #endif } } path = Tcl_GetStartupScript(&encodingName); if (path == NULL) { appName = NewNativeObj(argv[0]); } else { appName = path; } Tcl_SetVar2Ex(interp, "argv0", NULL, appName, TCL_GLOBAL_ONLY); Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY); argvPtr = Tcl_NewListObj(0, NULL); while (argc--) { Tcl_ListObjAppendElement(NULL, argvPtr, NewNativeObj(argv[i++])); } Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY); /* * Set the "tcl_interactive" variable. */ |
︙ | ︙ | |||
399 400 401 402 403 404 405 | * *---------------------------------------------------------------------- */ static void StdinProc( ClientData clientData, /* The state of interactive cmd line */ | | | | | > > > > > > < < > | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | * *---------------------------------------------------------------------- */ static void StdinProc( ClientData clientData, /* The state of interactive cmd line */ TCL_UNUSED(int) /*mask*/) { char *cmd; int code; int length; InteractiveState *isPtr = (InteractiveState *)clientData; Tcl_Channel chan = isPtr->input; Tcl_Interp *interp = isPtr->interp; length = Tcl_Gets(chan, &isPtr->line); if ((length < 0) && !isPtr->gotPartial) { if (isPtr->tty) { /* * Would be better to find a way to exit the mainLoop? Or perhaps * evaluate [exit]? Leaving as is for now due to compatibility * concerns. */ Tcl_Exit(0); } Tcl_DeleteChannelHandler(chan, StdinProc, isPtr); return; } Tcl_DStringAppend(&isPtr->command, Tcl_DStringValue(&isPtr->line), -1); cmd = Tcl_DStringAppend(&isPtr->command, "\n", -1); Tcl_DStringFree(&isPtr->line); if (!Tcl_CommandComplete(cmd)) { |
︙ | ︙ | |||
437 438 439 440 441 442 443 | * otherwise if the command re-enters the event loop we might process * commands from stdin before the current command is finished. Among other * things, this will trash the text of the command being evaluated. */ Tcl_CreateChannelHandler(chan, 0, StdinProc, isPtr); code = Tcl_RecordAndEval(interp, cmd, TCL_EVAL_GLOBAL); | < | | | < | | > | | | | > > > | > > > > > > > | 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | * otherwise if the command re-enters the event loop we might process * commands from stdin before the current command is finished. Among other * things, this will trash the text of the command being evaluated. */ Tcl_CreateChannelHandler(chan, 0, StdinProc, isPtr); code = Tcl_RecordAndEval(interp, cmd, TCL_EVAL_GLOBAL); isPtr->input = chan = Tcl_GetStdChannel(TCL_STDIN); if (chan != NULL) { Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc, isPtr); } Tcl_DStringFree(&isPtr->command); if (code != TCL_OK) { chan = Tcl_GetStdChannel(TCL_STDERR); if (chan != NULL) { Tcl_WriteObj(chan, Tcl_GetObjResult(interp)); Tcl_WriteChars(chan, "\n", 1); } } else if (isPtr->tty) { Tcl_Obj *resultPtr = Tcl_GetObjResult(interp); chan = Tcl_GetStdChannel(TCL_STDOUT); Tcl_IncrRefCount(resultPtr); (void)Tcl_GetStringFromObj(resultPtr, &length); if ((length > 0) && (chan != NULL)) { Tcl_WriteObj(chan, resultPtr); Tcl_WriteChars(chan, "\n", 1); } Tcl_DecrRefCount(resultPtr); } /* * If a tty stdin is still around, output a prompt. */ prompt: |
︙ | ︙ | |||
506 507 508 509 510 511 512 | } } } else { code = Tcl_EvalObjEx(interp, promptCmdPtr, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (script that generates prompt)"); | < | | | | < | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | } } } else { code = Tcl_EvalObjEx(interp, promptCmdPtr, TCL_EVAL_GLOBAL); if (code != TCL_OK) { Tcl_AddErrorInfo(interp, "\n (script that generates prompt)"); chan = Tcl_GetStdChannel(TCL_STDERR); if (chan != NULL) { Tcl_WriteObj(chan, Tcl_GetObjResult(interp)); Tcl_WriteChars(chan, "\n", 1); } goto defaultPrompt; } } chan = Tcl_GetStdChannel(TCL_STDOUT); if (chan != NULL) { |
︙ | ︙ |
Changes to generic/tkMenu.c.
1 2 3 4 5 6 7 8 | /* * tkMenu.c -- * * 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 * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkMenu.c -- * * 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 © 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. */ /* * Notes on implementation of menus: |
︙ | ︙ | |||
97 98 99 100 101 102 103 | TCL_DECLARE_MUTEX(menuMutex) /* * Configuration specs for individual menu entries. If this changes, be sure * to update code in TkpMenuInit that changes the font string entry. */ | < < < < < < < < < < < | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | TCL_DECLARE_MUTEX(menuMutex) /* * Configuration specs for individual menu entries. If this changes, be sure * to update code in TkpMenuInit that changes the font string entry. */ static const char *const menuEntryTypeStrings[] = { "cascade", "checkbutton", "command", "radiobutton", "separator", NULL }; static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = { {TK_OPTION_BORDER, "-activebackground", NULL, NULL, DEF_MENU_ENTRY_ACTIVE_BG, offsetof(TkMenuEntry, activeBorderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-activeforeground", NULL, NULL, DEF_MENU_ENTRY_ACTIVE_FG, offsetof(TkMenuEntry, activeFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, |
︙ | ︙ | |||
136 137 138 139 140 141 142 | DEF_MENU_ENTRY_COLUMN_BREAK, TCL_INDEX_NONE, offsetof(TkMenuEntry, columnBreak), 0, NULL, 0}, {TK_OPTION_STRING, "-command", NULL, NULL, DEF_MENU_ENTRY_COMMAND, offsetof(TkMenuEntry, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_MENU_ENTRY_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuEntry, compound), 0, | | | | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | DEF_MENU_ENTRY_COLUMN_BREAK, TCL_INDEX_NONE, offsetof(TkMenuEntry, columnBreak), 0, NULL, 0}, {TK_OPTION_STRING, "-command", NULL, NULL, DEF_MENU_ENTRY_COMMAND, offsetof(TkMenuEntry, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_MENU_ENTRY_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuEntry, compound), 0, tkCompoundStrings, 0}, {TK_OPTION_FONT, "-font", NULL, NULL, DEF_MENU_ENTRY_FONT, offsetof(TkMenuEntry, fontPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-foreground", NULL, NULL, DEF_MENU_ENTRY_FG, offsetof(TkMenuEntry, fgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_BOOLEAN, "-hidemargin", NULL, NULL, DEF_MENU_ENTRY_HIDE_MARGIN, TCL_INDEX_NONE, offsetof(TkMenuEntry, hideMargin), 0, NULL, 0}, {TK_OPTION_STRING, "-image", NULL, NULL, DEF_MENU_ENTRY_IMAGE, offsetof(TkMenuEntry, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING, "-label", NULL, NULL, DEF_MENU_ENTRY_LABEL, offsetof(TkMenuEntry, labelPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_STRING_TABLE, "-state", NULL, NULL, DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0, tkStateStrings, 0}, {TK_OPTION_INDEX, "-underline", NULL, NULL, TK_OPTION_UNDERLINE_DEF(TkMenuEntry, underline), 0}, {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0} }; static const Tk_OptionSpec tkSeparatorEntryConfigSpecs[] = { {TK_OPTION_BORDER, "-background", NULL, NULL, DEF_MENU_ENTRY_BG, offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, |
︙ | ︙ | |||
224 225 226 227 228 229 230 | }; static const Tk_OptionSpec tkTearoffEntryConfigSpecs[] = { {TK_OPTION_BORDER, "-background", NULL, NULL, DEF_MENU_ENTRY_BG, offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-state", NULL, NULL, | | | | | | | | | | | | 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | }; static const Tk_OptionSpec tkTearoffEntryConfigSpecs[] = { {TK_OPTION_BORDER, "-background", NULL, NULL, DEF_MENU_ENTRY_BG, offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-state", NULL, NULL, DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0, tkStateStrings, 0}, {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0} }; static const Tk_OptionSpec *specsArray[] = { tkCascadeEntryConfigSpecs, tkCheckButtonEntryConfigSpecs, tkBasicMenuEntryConfigSpecs, tkRadioButtonEntryConfigSpecs, tkSeparatorEntryConfigSpecs, tkTearoffEntryConfigSpecs }; /* * Menu type strings for use with Tcl_GetIndexFromObj. */ static const char *const menuTypeStrings[] = { "menubar", "normal", "tearoff", NULL }; static const Tk_OptionSpec tkMenuConfigSpecs[] = { {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground", DEF_MENU_ACTIVE_BG_COLOR, offsetof(TkMenu, activeBorderPtr), TCL_INDEX_NONE, 0, DEF_MENU_ACTIVE_BG_MONO, 0}, {TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth", "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH, offsetof(TkMenu, activeBorderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_MENU_ACTIVE_FG_COLOR, offsetof(TkMenu, activeFgPtr), TCL_INDEX_NONE, 0, DEF_MENU_ACTIVE_FG_MONO, 0}, {TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief", DEF_MENU_ACTIVE_RELIEF, offsetof(TkMenu, activeReliefPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_MENU_BG_COLOR, offsetof(TkMenu, borderPtr), TCL_INDEX_NONE, 0, DEF_MENU_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MENU_BORDER_WIDTH, offsetof(TkMenu, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENU_CURSOR, offsetof(TkMenu, cursorPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_MENU_DISABLED_FG_COLOR, offsetof(TkMenu, disabledFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, DEF_MENU_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_MENU_FONT, offsetof(TkMenu, fontPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_MENU_FG, offsetof(TkMenu, fgPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_STRING, "-postcommand", "postCommand", "Command", DEF_MENU_POST_COMMAND, offsetof(TkMenu, postCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENU_RELIEF, offsetof(TkMenu, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_COLOR, "-selectcolor", "selectColor", "Background", DEF_MENU_SELECT_COLOR, offsetof(TkMenu, indicatorFgPtr), TCL_INDEX_NONE, 0, DEF_MENU_SELECT_MONO, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_MENU_TAKE_FOCUS, offsetof(TkMenu, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_BOOLEAN, "-tearoff", "tearOff", "TearOff", DEF_MENU_TEAROFF, TCL_INDEX_NONE, offsetof(TkMenu, tearoff), 0, NULL, 0}, {TK_OPTION_STRING, "-tearoffcommand", "tearOffCommand", "TearOffCommand", DEF_MENU_TEAROFF_CMD, offsetof(TkMenu, tearoffCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING, "-title", "title", "Title", DEF_MENU_TITLE, offsetof(TkMenu, titlePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-type", "type", "Type", DEF_MENU_TYPE, offsetof(TkMenu, menuTypePtr), TCL_INDEX_NONE, 0, menuTypeStrings, 0}, {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0} }; /* * Command line options. Put here because MenuCmd has to look at them along * with MenuWidgetObjCmd. */ |
︙ | ︙ | |||
576 577 578 579 580 581 582 | if (menuRefPtr->topLevelListPtr != NULL) { TkMenuTopLevelList *topLevelListPtr = menuRefPtr->topLevelListPtr; TkMenuTopLevelList *nextPtr; Tk_Window listtkwin; while (topLevelListPtr != NULL) { /* | | | | 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | if (menuRefPtr->topLevelListPtr != NULL) { TkMenuTopLevelList *topLevelListPtr = menuRefPtr->topLevelListPtr; TkMenuTopLevelList *nextPtr; Tk_Window listtkwin; while (topLevelListPtr != NULL) { /* * Need to get the next pointer first. Tk_SetWindowMenubar changes * the list, so that the next pointer is different after calling * it. */ nextPtr = topLevelListPtr->nextPtr; listtkwin = topLevelListPtr->tkwin; Tk_SetWindowMenubar(menuPtr->interp, listtkwin, Tk_PathName(menuPtr->tkwin), Tk_PathName(menuPtr->tkwin)); topLevelListPtr = nextPtr; } } Tcl_SetObjResult(interp, Tk_NewWindowObj(menuPtr->tkwin)); return TCL_OK; |
︙ | ︙ | |||
839 840 841 842 843 844 845 846 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { | > | > | 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) if (index == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_NewObj()); } else #endif Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } case MENU_INSERT: if (objc < 4) { Tcl_WrongNumArgs(interp, 2, objv, "index type ?-option value ...?"); |
︙ | ︙ | |||
1706 1707 1708 1709 1710 1711 1712 | * Tk_ConfigureWidget, such as special processing for defaults, sizing * strings, graphics contexts, etc. */ if (mePtr->labelPtr == NULL) { mePtr->labelLength = 0; } else { | | | | 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 | * Tk_ConfigureWidget, such as special processing for defaults, sizing * strings, graphics contexts, etc. */ if (mePtr->labelPtr == NULL) { mePtr->labelLength = 0; } else { (void)Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength); } if (mePtr->accelPtr == NULL) { mePtr->accelLength = 0; } else { (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 * cascades have to be updated. */ |
︙ | ︙ | |||
2124 2125 2126 2127 2128 2129 2130 | { int i; const char *string; if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) { /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */ if (*indexPtr != TCL_INDEX_NONE || Tcl_GetString(objPtr)[0] != '-') { | | > > > > > > | 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 | { int i; const char *string; if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) { /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */ if (*indexPtr != TCL_INDEX_NONE || Tcl_GetString(objPtr)[0] != '-') { if (*indexPtr + 1 >= menuPtr->numEntries + 1) { *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1); } return TCL_OK; } } string = Tcl_GetString(objPtr); if ((string[0] == 'a') && (strcmp(string, "active") == 0)) { *indexPtr = menuPtr->active; goto success; } if ((string[0] == 'l') && (strcmp(string, "last") == 0)) { *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1); goto success; } if (string[0] == 0) { *indexPtr = TCL_INDEX_NONE; goto success; } #if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9 if ((string[0] == 'n') && (strcmp(string, "none") == 0)) { *indexPtr = TCL_INDEX_NONE; goto success; } #endif if (string[0] == '@') { if (GetIndexFromCoords(NULL, menuPtr, string, indexPtr) == TCL_OK) { goto success; } } |
︙ | ︙ | |||
2272 2273 2274 2275 2276 2277 2278 | mePtr = (TkMenuEntry *)ckalloc(sizeof(TkMenuEntry)); menuPtr->entries[index] = mePtr; mePtr->type = type; mePtr->optionTable = tsdPtr->entryOptionTables[type]; mePtr->menuPtr = menuPtr; mePtr->labelPtr = NULL; mePtr->labelLength = 0; | | | 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 | mePtr = (TkMenuEntry *)ckalloc(sizeof(TkMenuEntry)); menuPtr->entries[index] = mePtr; mePtr->type = type; mePtr->optionTable = tsdPtr->entryOptionTables[type]; mePtr->menuPtr = menuPtr; mePtr->labelPtr = NULL; mePtr->labelLength = 0; mePtr->underline = INT_MIN; mePtr->bitmapPtr = NULL; mePtr->imagePtr = NULL; mePtr->image = NULL; mePtr->selectImagePtr = NULL; mePtr->selectImage = NULL; mePtr->accelPtr = NULL; mePtr->accelLength = 0; |
︙ | ︙ | |||
2510 2511 2512 2513 2514 2515 2516 | name = Tcl_GetString(mePtr->namePtr); /* * If the variable is being unset, then re-establish the trace. */ if (flags & TCL_TRACE_UNSETS) { | | | | 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 | name = Tcl_GetString(mePtr->namePtr); /* * If the variable is being unset, then re-establish the trace. */ if (flags & TCL_TRACE_UNSETS) { void *probe = NULL; mePtr->entryFlags &= ~ENTRY_SELECTED; do { probe = Tcl_VarTraceInfo(interp, name, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuVarProc, probe); if (probe == (void *)mePtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * namePtr, which means it is not unset and not |
︙ | ︙ | |||
2689 2690 2691 2692 2693 2694 2695 | CloneMenu( TkMenu *menuPtr, /* The menu we are going to clone. */ Tcl_Obj *newMenuNamePtr, /* The name to give the new menu. */ Tcl_Obj *newMenuTypePtr) /* What kind of menu is this, a normal menu a * menubar, or a tearoff? */ { int returnResult; | | > | 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 | CloneMenu( TkMenu *menuPtr, /* The menu we are going to clone. */ Tcl_Obj *newMenuNamePtr, /* The name to give the new menu. */ Tcl_Obj *newMenuTypePtr) /* What kind of menu is this, a normal menu a * menubar, or a tearoff? */ { int returnResult; int menuType; TkSizeT i; TkMenuReferences *menuRefPtr; Tcl_Obj *menuDupCommandArray[4]; if (newMenuTypePtr == NULL) { menuType = MAIN_MENU; } else { if (Tcl_GetIndexFromObjStruct(menuPtr->interp, newMenuTypePtr, |
︙ | ︙ | |||
2729 2730 2731 2732 2733 2734 2735 | if ((returnResult == TCL_OK) && ((menuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, newMenuNamePtr)) != NULL) && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) { TkMenu *newMenuPtr = menuRefPtr->menuPtr; Tcl_Obj *newObjv[3]; | | | 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 | if ((returnResult == TCL_OK) && ((menuRefPtr = TkFindMenuReferencesObj(menuPtr->interp, newMenuNamePtr)) != NULL) && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) { TkMenu *newMenuPtr = menuRefPtr->menuPtr; Tcl_Obj *newObjv[3]; TkSizeT numElements; /* * Now put this newly created menu into the parent menu's instance * chain. */ if (menuPtr->nextInstancePtr == NULL) { |
︙ | ︙ | |||
2800 2801 2802 2803 2804 2805 2806 | Tcl_DecrRefCount(newObjv[1]); Tcl_ResetResult(menuPtr->interp); /* * Clone all of the cascade menus that this menu points to. */ | | | 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 | Tcl_DecrRefCount(newObjv[1]); Tcl_ResetResult(menuPtr->interp); /* * Clone all of the cascade menus that this menu points to. */ for (i = 0; i < menuPtr->numEntries; i++) { TkMenuReferences *cascadeRefPtr; TkMenu *oldCascadePtr; if ((menuPtr->entries[i]->type == CASCADE_ENTRY) && (menuPtr->entries[i]->namePtr != NULL)) { cascadeRefPtr = TkFindMenuReferencesObj(menuPtr->interp, |
︙ | ︙ | |||
3127 3128 3129 3130 3131 3132 3133 | Tcl_DecrRefCount(childPtr); return resultPtr; } /* *---------------------------------------------------------------------- * | | | | 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 | Tcl_DecrRefCount(childPtr); return resultPtr; } /* *---------------------------------------------------------------------- * * Tk_SetWindowMenubar -- * * Associates a menu with a window. Called by ConfigureFrame in in * response to a "-menu .foo" configuration option for a top level. * * Results: * None. * * Side effects: * The old menu clones for the menubar are thrown away, and a handler is * set up to allocate the new ones. * *---------------------------------------------------------------------- */ void Tk_SetWindowMenubar( Tcl_Interp *interp, /* The interpreter the toplevel lives in. */ Tk_Window tkwin, /* The toplevel window. */ const char *oldMenuName, /* The name of the menubar previously set in * this toplevel. NULL means no menu was set * previously. */ const char *menuName) /* The name of the new menubar that the * toplevel needs to be set to. NULL means |
︙ | ︙ | |||
3285 3286 3287 3288 3289 3290 3291 | topLevelListPtr = (TkMenuTopLevelList *)ckalloc(sizeof(TkMenuTopLevelList)); topLevelListPtr->tkwin = tkwin; topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr; menuRefPtr->topLevelListPtr = topLevelListPtr; } else { TkpSetWindowMenuBar(tkwin, NULL); } | | | 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 | topLevelListPtr = (TkMenuTopLevelList *)ckalloc(sizeof(TkMenuTopLevelList)); topLevelListPtr->tkwin = tkwin; topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr; menuRefPtr->topLevelListPtr = topLevelListPtr; } else { TkpSetWindowMenuBar(tkwin, NULL); } Tk_SetMainMenubar(interp, tkwin, menuName); } /* *---------------------------------------------------------------------- * * DestroyMenuHashTable -- * |
︙ | ︙ |
Changes to generic/tkMenu.h.
1 2 3 4 5 6 | /* * tkMenu.h -- * * Declarations shared among all of the files that implement menu * widgets. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkMenu.h -- * * Declarations shared among all of the files that implement menu * widgets. * * 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. */ #ifndef _TKMENU #define _TKMENU |
︙ | ︙ | |||
240 241 242 243 244 245 246 | #define TEAROFF_ENTRY 5 /* * Menu states */ #define ENTRY_ACTIVE 0 | | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | #define TEAROFF_ENTRY 5 /* * Menu states */ #define ENTRY_ACTIVE 0 #define ENTRY_DISABLED 1 #define ENTRY_NORMAL 2 /* * A data structure of the following type is kept for each menu widget: */ typedef struct TkMenu { Tk_Window tkwin; /* Window that embodies the pane. NULL means |
︙ | ︙ | |||
457 458 459 460 461 462 463 | * a menu bar, a MENUBAR instance is created. All instances have the same * 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 | > | | < | 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | * a menu bar, a MENUBAR instance is created. All instances have the same * 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 MENUBAR 0 #define MAIN_MENU 1 #define TEAROFF_MENU 2 /* * Various geometry definitions: */ #define CASCADE_ARROW_HEIGHT 10 #define CASCADE_ARROW_WIDTH 8 |
︙ | ︙ | |||
511 512 513 514 515 516 517 | int imgHeight); MODULE_SCOPE Tcl_Obj * TkNewMenuName(Tcl_Interp *interp, Tcl_Obj *parentNamePtr, TkMenu *menuPtr); MODULE_SCOPE int TkPostCommand(TkMenu *menuPtr); MODULE_SCOPE int TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr, TkMenuEntry *mePtr); MODULE_SCOPE int TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, | | | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | int imgHeight); MODULE_SCOPE Tcl_Obj * TkNewMenuName(Tcl_Interp *interp, Tcl_Obj *parentNamePtr, TkMenu *menuPtr); MODULE_SCOPE int TkPostCommand(TkMenu *menuPtr); MODULE_SCOPE int TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr, TkMenuEntry *mePtr); MODULE_SCOPE int TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, int x, int y); MODULE_SCOPE int TkPreprocessMenu(TkMenu *menuPtr); MODULE_SCOPE void TkRecomputeMenu(TkMenu *menuPtr); /* * These routines are the platform-dependent routines called by the common * code. */ |
︙ | ︙ | |||
536 537 538 539 540 541 542 | int drawingParameters); MODULE_SCOPE void TkpMenuInit(void); MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr); MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr); MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr, int x, int y, int index); MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, | | | 536 537 538 539 540 541 542 543 544 545 546 | int drawingParameters); MODULE_SCOPE void TkpMenuInit(void); MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr); MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr); MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr, int x, int y, int index); MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, int x, int y, int index); MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); #endif /* _TKMENU */ |
Changes to generic/tkMenuDraw.c.
1 2 3 4 5 6 | /* * tkMenuDraw.c -- * * This module implements the platform-independent drawing and geometry * calculations of menu widgets. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkMenuDraw.c -- * * This module implements the platform-independent drawing and geometry * calculations of menu widgets. * * 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. */ #include "tkInt.h" #include "tkMenu.h" |
︙ | ︙ | |||
771 772 773 774 775 776 777 | if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { TkEventuallyRedrawMenu(menuPtr, NULL); } else if (eventPtr->type == ConfigureNotify) { TkEventuallyRecomputeMenu(menuPtr); TkEventuallyRedrawMenu(menuPtr, NULL); } else if (eventPtr->type == ActivateNotify) { if (menuPtr->menuType == TEAROFF_MENU) { | | | 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) { TkEventuallyRedrawMenu(menuPtr, NULL); } else if (eventPtr->type == ConfigureNotify) { TkEventuallyRecomputeMenu(menuPtr); TkEventuallyRedrawMenu(menuPtr, NULL); } else if (eventPtr->type == ActivateNotify) { if (menuPtr->menuType == TEAROFF_MENU) { Tk_SetMainMenubar(menuPtr->interp, menuPtr->tkwin, NULL); } } else if (eventPtr->type == DestroyNotify) { if (menuPtr->tkwin != NULL) { if (!(menuPtr->menuFlags & MENU_DELETION_PENDING)) { TkDestroyMenu(menuPtr); } menuPtr->tkwin = NULL; |
︙ | ︙ |
Changes to generic/tkMenubutton.c.
1 2 3 4 5 6 | /* * tkMenubutton.c -- * * This module implements button-like widgets that are used to invoke * pull-down menus. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMenubutton.c -- * * This module implements button-like widgets that are used to invoke * pull-down menus. * * 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" |
︙ | ︙ | |||
31 32 33 34 35 36 37 | * is used together with the "enum direction" declaration in tkMenubutton.h. */ static const char *const directionStrings[] = { "above", "below", "flush", "left", "right", NULL }; | < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | * is used together with the "enum direction" declaration in tkMenubutton.h. */ static const char *const directionStrings[] = { "above", "below", "flush", "left", "right", NULL }; /* * Information used for parsing configuration specs: */ static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground", DEF_MENUBUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, activeBorder), 0, DEF_MENUBUTTON_ACTIVE_BG_MONO, 0}, {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background", DEF_MENUBUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, activeFg), 0, DEF_MENUBUTTON_ACTIVE_FG_MONO, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MENUBUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkMenuButton, anchor), 0, 0, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_MENUBUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, normalBorder), 0, DEF_MENUBUTTON_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_MENUBUTTON_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, borderWidth), 0, 0, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction", DEF_MENUBUTTON_DIRECTION, TCL_INDEX_NONE, offsetof(TkMenuButton, direction), TK_OPTION_ENUM_VAR, directionStrings, 0}, {TK_OPTION_COLOR, "-disabledforeground", "disabledForeground", "DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, disabledFg), TK_OPTION_NULL_OK, DEF_MENUBUTTON_DISABLED_FG_MONO, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_MENUBUTTON_FONT, TCL_INDEX_NONE, offsetof(TkMenuButton, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_MENUBUTTON_FG, TCL_INDEX_NONE, offsetof(TkMenuButton, normalFg), 0, 0, 0}, {TK_OPTION_STRING, "-height", "height", "Height", DEF_MENUBUTTON_HEIGHT, TCL_INDEX_NONE, offsetof(TkMenuButton, heightString), 0, 0, 0}, |
︙ | ︙ | |||
127 128 129 130 131 132 133 | {TK_OPTION_PIXELS, "-pady", "padY", "Pad", DEF_MENUBUTTON_PADY, TCL_INDEX_NONE, offsetof(TkMenuButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", | | | | | | < | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | {TK_OPTION_PIXELS, "-pady", "padY", "Pad", DEF_MENUBUTTON_PADY, TCL_INDEX_NONE, offsetof(TkMenuButton, padY), 0, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuButton, compound), 0, tkCompoundStrings, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_MENUBUTTON_STATE, TCL_INDEX_NONE, offsetof(TkMenuButton, state), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_MENUBUTTON_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-text", "text", "Text", DEF_MENUBUTTON_TEXT, TCL_INDEX_NONE, offsetof(TkMenuButton, text), 0, 0, 0}, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(TkMenuButton, underline), 0}, {TK_OPTION_STRING, "-width", "width", "Width", DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString), 0, 0, 0}, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength), 0, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} |
︙ | ︙ | |||
257 258 259 260 261 262 263 | mbPtr->interp = interp; mbPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, mbPtr, MenuButtonCmdDeletedProc); mbPtr->optionTable = optionTable; mbPtr->menuName = NULL; mbPtr->text = NULL; | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | mbPtr->interp = interp; mbPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(mbPtr->tkwin), MenuButtonWidgetObjCmd, mbPtr, MenuButtonCmdDeletedProc); mbPtr->optionTable = optionTable; mbPtr->menuName = NULL; mbPtr->text = NULL; mbPtr->underline = INT_MIN; mbPtr->textVarName = NULL; mbPtr->bitmap = None; mbPtr->imageString = NULL; mbPtr->image = NULL; mbPtr->state = STATE_NORMAL; mbPtr->normalBorder = NULL; mbPtr->activeBorder = NULL; |
︙ | ︙ | |||
885 886 887 888 889 890 891 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && mbPtr->textVarName) { | | | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && mbPtr->textVarName) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MenuButtonTextVarProc, probe); if (probe == (void *)mbPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not |
︙ | ︙ |
Changes to generic/tkMenubutton.h.
1 2 3 4 5 6 | /* * tkMenubutton.h -- * * Declarations of types and functions used to implement the menubutton * widget. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkMenubutton.h -- * * Declarations of types and functions used to implement the menubutton * widget. * * 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. */ #ifndef _TKMENUBUTTON #define _TKMENUBUTTON |
︙ | ︙ | |||
60 61 62 63 64 65 66 | /* * Information about what's displayed in the menu button: */ char *text; /* Text to display in button (malloc'ed) or * NULL. */ | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | /* * Information about what's displayed in the menu button: */ char *text; /* Text to display in button (malloc'ed) or * NULL. */ int underline; /* Index of character to underline. INT_MIN means no underline */ char *textVarName; /* Name of variable (malloc'ed) or NULL. If * non-NULL, button displays the contents of * this variable. */ Pixmap bitmap; /* Bitmap to display or None. If not None then * text and textVar and underline are * ignored. */ char *imageString; /* Name of image to display (malloc'ed), or |
︙ | ︙ |
Changes to generic/tkMessage.c.
1 2 3 4 5 6 7 | /* * tkMessage.c -- * * 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. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkMessage.c -- * * 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 © 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. */ #include "tkInt.h" #include "default.h" |
︙ | ︙ | |||
708 709 710 711 712 713 714 | } if (msgPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (msgPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin)); | | | | 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 | } if (msgPtr->highlightWidth != 0) { GC fgGC, bgGC; bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin)); if (msgPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin)); Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, msgPtr->highlightWidth, Tk_WindowId(tkwin)); } else { Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, msgPtr->highlightWidth, Tk_WindowId(tkwin)); } } } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
844 845 846 847 848 849 850 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) { | | | | 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, probe); if (probe == (void *)msgPtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * textVarName, which means it is not unset and not |
︙ | ︙ |
Changes to generic/tkObj.c.
1 2 3 4 5 | /* * tkObj.c -- * * This file contains functions that implement the common Tk object types * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkObj.c -- * * This file contains functions that implement the common Tk object types * * 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. */ #include "tkInt.h" |
︙ | ︙ | |||
46 47 48 49 50 51 52 | * "dataKey" below is used to locate the ThreadSpecificData for the current * thread. */ typedef struct { const Tcl_ObjType *doubleTypePtr; const Tcl_ObjType *intTypePtr; | < | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | * "dataKey" below is used to locate the ThreadSpecificData for the current * thread. */ typedef struct { const Tcl_ObjType *doubleTypePtr; const Tcl_ObjType *intTypePtr; } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; /* * The following structure is the internal representation for mm objects. */ |
︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | static ThreadSpecificData *GetTypeCache(void); static void UpdateStringOfMM(Tcl_Obj *objPtr); 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 #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 { 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; | > > > | > > > | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | static ThreadSpecificData *GetTypeCache(void); static void UpdateStringOfMM(Tcl_Obj *objPtr); 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 { 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 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(interp, obj, max, ptr) TclGetIntForIndex(interp, obj, max, ptr) #endif #ifdef __cplusplus } #endif #endif /* * The following structure defines the implementation of the "pixel" Tcl * object, used for measuring distances. The pixel object remembers its * initial display-independent settings. |
︙ | ︙ | |||
180 181 182 183 184 185 186 | ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->doubleTypePtr == NULL) { /* Smart initialization of doubleTypePtr/intTypePtr without * hash-table lookup or creating complete Tcl_Obj's */ Tcl_Obj obj; | < < < < < | | < > | < > | > > > | | < < < < < < | | | | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (tsdPtr->doubleTypePtr == NULL) { /* Smart initialization of doubleTypePtr/intTypePtr without * hash-table lookup or creating complete Tcl_Obj's */ Tcl_Obj obj; obj.bytes = (char *)"0.0"; obj.length = 3; obj.typePtr = NULL; Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue); tsdPtr->doubleTypePtr = obj.typePtr; obj.bytes = (char *)"0"; obj.length = 1; obj.typePtr = NULL; Tcl_GetLongFromObj(NULL, &obj, &obj.internalRep.longValue); tsdPtr->intTypePtr = obj.typePtr; } return tsdPtr; } /* *---------------------------------------------------------------------- * * TkGetIntForIndex -- * * Almost the same as Tcl_GetIntForIndex, but it return an int. Accepts * "" (empty string) as well. * * Results: * The return value is a standard Tcl object result. * * Side effects: * None * *---------------------------------------------------------------------- */ int TkGetIntForIndex( Tcl_Obj *indexObj, TkSizeT end, int lastOK, TkSizeT *indexPtr) { if (indexObj == NULL) { *indexPtr = TCL_INDEX_NONE; return TCL_OK; } if (Tcl_GetIntForIndex(NULL, indexObj, end + lastOK, indexPtr) != TCL_OK) { const char *value = Tcl_GetString(indexObj); if (!*value) { *indexPtr = TCL_INDEX_NONE; return TCL_OK; } return TCL_ERROR; } #if TCL_MAJOR_VERSION < 9 if (*indexPtr < -1) { *indexPtr = TCL_INDEX_NONE; } else if (end >= -1) #endif if ((*indexPtr + 1) > (end + 1)) { *indexPtr = end + 1; } return TCL_OK; } |
︙ | ︙ | |||
1054 1055 1056 1057 1058 1059 1060 | } /* *---------------------------------------------------------------------- * * Tk_NewWindowObj -- * | | | | 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | } /* *---------------------------------------------------------------------- * * Tk_NewWindowObj -- * * This function allocates a new Tcl_Obj that refers to a particular * Tk window. * * Results: * A standard Tcl object reference, with refcount 0. * * Side effects: * None. * |
︙ | ︙ | |||
1115 1116 1117 1118 1119 1120 1121 | Tk_Window tkwin, /* A window. Needed by Tk_GetPixels() */ Tcl_Obj *specObj, /* The argument to "-padx", "-pady", "-ipadx", * or "-ipady". The thing to be parsed. */ int *halfPtr, /* Write the left/top part of padding here */ int *allPtr) /* Write the total padding here */ { int firstInt, secondInt; /* The two components of the padding */ | | | 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | Tk_Window tkwin, /* A window. Needed by Tk_GetPixels() */ Tcl_Obj *specObj, /* The argument to "-padx", "-pady", "-ipadx", * or "-ipady". The thing to be parsed. */ int *halfPtr, /* Write the left/top part of padding here */ int *allPtr) /* Write the total padding here */ { int firstInt, secondInt; /* The two components of the padding */ TkSizeT objc; /* The length of the list (should be 1 or 2) */ Tcl_Obj **objv; /* The objects in the list */ /* * Check for a common case where a single object would otherwise be * shimmered between a list and a pixel spec. */ |
︙ | ︙ |
Changes to generic/tkOldConfig.c.
1 2 3 4 5 6 7 | /* * tkOldConfig.c -- * * This file contains the Tk_ConfigureWidget function. THIS FILE IS HERE * FOR BACKWARD COMPATIBILITY; THE NEW CONFIGURATION PACKAGE SHOULD BE * USED FOR NEW PROJECTS. * | | | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * tkOldConfig.c -- * * 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 © 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" /* * Values for "flags" field of Tk_ConfigSpec structures. Be sure to coordinate * these values with those defined in tk.h (TK_CONFIG_COLOR_ONLY, etc.) There * must not be overlap! */ #ifndef TK_CONFIG_OPTION_SPECIFIED # define TK_CONFIG_OPTION_SPECIFIED (1 << 4) #endif /* * Forward declarations for functions defined later in this file: */ |
︙ | ︙ | |||
348 349 350 351 352 353 354 | * Values must be properly initialized. */ { void *ptr; Tk_Uid uid; int nullValue; nullValue = 0; | | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | * Values must be properly initialized. */ { void *ptr; Tk_Uid uid; int nullValue; nullValue = 0; if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_INDEX_NULL_OK))) { nullValue = 1; } do { ptr = (char *)widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_BOOLEAN: |
︙ | ︙ |
Changes to generic/tkOldTest.c.
1 2 3 4 5 6 7 8 | /* * tkOldTest.c -- * * 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. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * tkOldTest.c -- * * 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 © 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. */ #define USE_OLD_IMAGE |
︙ | ︙ |
Changes to generic/tkOption.c.
1 2 3 4 5 6 7 | /* * tkOption.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkOption.c -- * * 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 © 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" |
︙ | ︙ | |||
747 748 749 750 751 752 753 | * If this window is in the option stacks, then clear the stacks. * * XXX: OptionThreadExitProc will be invoked before DeleteWindowsExitProc * XXX: if it is thread-specific (which it should be), invalidating the * XXX: tsd. Tk shutdown needs to be verified to handle this correctly. */ | | | | 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | * If this window is in the option stacks, then clear the stacks. * * XXX: OptionThreadExitProc will be invoked before DeleteWindowsExitProc * XXX: if it is thread-specific (which it should be), invalidating the * XXX: tsd. Tk shutdown needs to be verified to handle this correctly. */ if (tsdPtr->initialized && (winPtr->optionLevel != TCL_INDEX_NONE)) { int i; for (i = 1; i <= tsdPtr->curLevel; i++) { tsdPtr->levels[i].winPtr->optionLevel = TCL_INDEX_NONE; } tsdPtr->curLevel = -1; tsdPtr->cachedWindow = NULL; } /* * If this window was a main window, then delete its option database. |
︙ | ︙ | |||
795 796 797 798 799 800 801 | TkWindow *winPtr) /* Window whose class changed. */ { int i, j, *basePtr; ElArray *arrayPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); | | | | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | TkWindow *winPtr) /* Window whose class changed. */ { int i, j, *basePtr; ElArray *arrayPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->optionLevel == TCL_INDEX_NONE) { return; } /* * Find the lowest stack level that refers to this window, then flush all * of the levels above the matching one. */ for (i = 1; i <= tsdPtr->curLevel; i++) { if (tsdPtr->levels[i].winPtr == winPtr) { for (j = i; j <= tsdPtr->curLevel; j++) { tsdPtr->levels[j].winPtr->optionLevel = TCL_INDEX_NONE; } tsdPtr->curLevel = i-1; basePtr = tsdPtr->levels[i].bases; for (j = 0; j < NUM_STACKS; j++) { arrayPtr = tsdPtr->stacks[j]; arrayPtr->numUsed = basePtr[j]; arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed]; |
︙ | ︙ | |||
1265 1266 1267 1268 1269 1270 1271 | /* * Step 2: pop extra unneeded information off the stacks and mark those * windows as no longer having cached information. */ if (tsdPtr->curLevel >= level) { while (tsdPtr->curLevel >= level) { | | | 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 | /* * Step 2: pop extra unneeded information off the stacks and mark those * windows as no longer having cached information. */ if (tsdPtr->curLevel >= level) { while (tsdPtr->curLevel >= level) { tsdPtr->levels[tsdPtr->curLevel].winPtr->optionLevel = TCL_INDEX_NONE; tsdPtr->curLevel--; } levelPtr = &tsdPtr->levels[level]; for (i = 0; i < NUM_STACKS; i++) { arrayPtr = tsdPtr->stacks[i]; arrayPtr->numUsed = levelPtr->bases[i]; arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed]; |
︙ | ︙ |
Changes to generic/tkPack.c.
1 2 3 4 5 6 | /* * tkPack.c -- * * This file contains code to implement the "packer" geometry manager for * Tk. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* * tkPack.c -- * * This file contains code to implement the "packer" geometry manager for * Tk. * * 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" typedef enum {BOTTOM, LEFT, RIGHT, TOP} Side; static const char *const sideNames[] = { "bottom", "left", "right", "top", NULL }; /* * For each window that the packer cares about (either because the window is * managed by the packer or because the window has content that are managed by * the packer), there is a structure of the following type: */ |
︙ | ︙ | |||
220 221 222 223 224 225 226 | } } if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } | | | | | | 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | } } if (objc < 3) { Tcl_WrongNumArgs(interp, 1, objv, "option arg ?arg ...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObj(NULL, objv[1], optionStrings, "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_GetIndexFromObj(interp, objv[1], optionStringsNoDep, "option", 0, &index); return TCL_ERROR; } argv2 = Tcl_GetString(objv[2]); switch ((enum options) index) { #ifndef TK_NO_DEPRECATED case PACK_AFTER: { |
︙ | ︙ | |||
822 823 824 825 826 827 828 | x = frameX + borderLeft; y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; case TK_ANCHOR_NW: x = frameX + borderLeft; y = frameY + borderTop; break; | | < < | 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | x = frameX + borderLeft; y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; case TK_ANCHOR_NW: x = frameX + borderLeft; y = frameY + borderTop; break; default: x = frameX + (borderLeft + frameWidth - width - borderRight)/2; y = frameY + (borderTop + frameHeight - height - borderBtm)/2; break; } width -= contentPtr->doubleBw; height -= contentPtr->doubleBw; /* * The final step is to set the position, size, and mapped/unmapped * state of the content. If the content is a child of the container, then do |
︙ | ︙ | |||
1109 1110 1111 1112 1113 1114 1115 | Tcl_Obj *const objv[]) /* Array of lists, each containing 2 elements: * window name and side against which to * pack. */ { Packer *packPtr; Tk_Window tkwin, ancestor, parent; Tcl_Obj **options; | > | | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 | Tcl_Obj *const objv[]) /* Array of lists, each containing 2 elements: * window name and side against which to * pack. */ { Packer *packPtr; Tk_Window tkwin, ancestor, parent; Tcl_Obj **options; int c; TkSizeT index, optionCount; /* * Iterate over all of the window specifiers, each consisting of two * arguments. The first argument contains the window name and the * additional arguments contain options such as "top" or "padx 20". */ |
︙ | ︙ | |||
1177 1178 1179 1180 1181 1182 1183 | packPtr->padLeft = packPtr->padTop = 0; packPtr->iPadX = packPtr->iPadY = 0; packPtr->flags &= ~(FILLX|FILLY|EXPAND); packPtr->flags |= OLD_STYLE; for (index = 0 ; index < optionCount; index++) { Tcl_Obj *curOptPtr = options[index]; TkSizeT length; | | | 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 | packPtr->padLeft = packPtr->padTop = 0; packPtr->iPadX = packPtr->iPadY = 0; 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 = Tcl_GetStringFromObj(curOptPtr, &length); c = curOpt[0]; if ((c == 't') && (strncmp(curOpt, "top", length)) == 0) { packPtr->side = TOP; } else if ((c == 'b') |
︙ | ︙ | |||
1204 1205 1206 1207 1208 1209 1210 | && (strcmp(curOpt, "fill")) == 0) { packPtr->flags |= FILLX|FILLY; } else if ((length == 5) && (strcmp(curOpt, "fillx")) == 0) { packPtr->flags |= FILLX; } else if ((length == 5) && (strcmp(curOpt, "filly")) == 0) { packPtr->flags |= FILLY; } else if ((c == 'p') && (strcmp(curOpt, "padx")) == 0) { | | | | | 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 | && (strcmp(curOpt, "fill")) == 0) { packPtr->flags |= FILLX|FILLY; } else if ((length == 5) && (strcmp(curOpt, "fillx")) == 0) { packPtr->flags |= FILLX; } else if ((length == 5) && (strcmp(curOpt, "filly")) == 0) { packPtr->flags |= FILLY; } else if ((c == 'p') && (strcmp(curOpt, "padx")) == 0) { if (optionCount <= (index+1)) { missingPad: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: \"%s\" option must be" " followed by screen distance", curOpt)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } if (TkParsePadAmount(interp, tkwin, options[index+1], &packPtr->padLeft, &packPtr->padX) != TCL_OK) { return TCL_ERROR; } packPtr->padX /= 2; packPtr->padLeft /= 2; packPtr->iPadX = 0; index++; } else if ((c == 'p') && (strcmp(curOpt, "pady")) == 0) { if (optionCount <= (index+1)) { goto missingPad; } if (TkParsePadAmount(interp, tkwin, options[index+1], &packPtr->padTop, &packPtr->padY) != TCL_OK) { return TCL_ERROR; } packPtr->padY /= 2; packPtr->padTop /= 2; packPtr->iPadY = 0; index++; } else if ((c == 'f') && (length > 1) && (strncmp(curOpt, "frame", length) == 0)) { if (optionCount <= (index+1)) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "wrong # args: \"frame\"" " option must be followed by anchor point", -1)); Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } |
︙ | ︙ | |||
1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 | static void DestroyPacker( void *memPtr) /* Info about packed window that is now * dead. */ { Packer *packPtr = (Packer *)memPtr; ckfree(packPtr); } /* *---------------------------------------------------------------------- * * PackStructureProc -- | > > > | 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 | static void DestroyPacker( void *memPtr) /* Info about packed window that is now * dead. */ { Packer *packPtr = (Packer *)memPtr; if (packPtr->flags & REQUESTED_REPACK) { Tcl_CancelIdleCall(ArrangePacking, packPtr); } ckfree(packPtr); } /* *---------------------------------------------------------------------- * * PackStructureProc -- |
︙ | ︙ | |||
1606 1607 1608 1609 1610 1611 1612 | if ((i+2) > objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "extra option \"%s\" (option with no value?)", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } | | | | 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 | if ((i+2) > objc) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "extra option \"%s\" (option with no value?)", Tcl_GetString(objv[i]))); Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", NULL); return TCL_ERROR; } if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } switch ((enum options) index) { case CONF_AFTER: if (j == 0) { if (TkGetWindowFromObj(interp, tkwin, objv[i+1], &other) |
︙ | ︙ | |||
1738 1739 1740 1741 1742 1743 1744 | case CONF_PADY: if (TkParsePadAmount(interp, content, objv[i+1], &contentPtr->padTop, &contentPtr->padY) != TCL_OK) { return TCL_ERROR; } break; case CONF_SIDE: | | | | 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 | case CONF_PADY: if (TkParsePadAmount(interp, content, objv[i+1], &contentPtr->padTop, &contentPtr->padY) != TCL_OK) { return TCL_ERROR; } break; case CONF_SIDE: if (Tcl_GetIndexFromObj(interp, objv[i+1], sideNames, "side", TCL_EXACT, &side) != TCL_OK) { return TCL_ERROR; } contentPtr->side = (Side) side; break; } } |
︙ | ︙ |
Changes to generic/tkPanedWindow.c.
1 2 3 4 5 6 7 8 | /* * tkPanedWindow.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkPanedWindow.c -- * * 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 © 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. */ #include "tkInt.h" #include "default.h" |
︙ | ︙ | |||
179 180 181 182 183 184 185 | #define PROXY_REDRAW_PENDING 0x0010 #define RESIZE_PENDING 0x0020 /* * Forward declarations for functions defined later in this file: */ | | | | | | | | | | | | | | | | | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | #define PROXY_REDRAW_PENDING 0x0010 #define RESIZE_PENDING 0x0020 /* * Forward declarations for functions defined later in this file: */ int Tk_PanedWindowObjCmd(void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); static void PanedWindowCmdDeletedProc(void *clientData); static int ConfigurePanedWindow(Tcl_Interp *interp, PanedWindow *pwPtr, int objc, Tcl_Obj *const objv[]); static void DestroyPanedWindow(PanedWindow *pwPtr); static void DisplayPanedWindow(void *clientData); static void PanedWindowEventProc(void *clientData, XEvent *eventPtr); static void ProxyWindowEventProc(void *clientData, XEvent *eventPtr); static void DisplayProxyWindow(void *clientData); static void PanedWindowWorldChanged(void *instanceData); static int PanedWindowWidgetObjCmd(void *clientData, Tcl_Interp *, int objc, Tcl_Obj * const objv[]); static void PanedWindowLostPaneProc(void *clientData, Tk_Window tkwin); static void PanedWindowReqProc(void *clientData, Tk_Window tkwin); static void ArrangePanes(void *clientData); static void Unlink(Pane *panePtr); static Pane * GetPane(PanedWindow *pwPtr, Tk_Window tkwin); static void GetFirstLastVisiblePane(PanedWindow *pwPtr, int *firstPtr, int *lastPtr); static void PaneStructureProc(void *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 ConfigurePanes(PanedWindow *pwPtr, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[]); static void DestroyOptionTables(void *clientData, Tcl_Interp *interp); static int SetSticky(void *clientData, Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *recordPtr, TkSizeT internalOffset, char *oldInternalPtr, int flags); static Tcl_Obj * GetSticky(void *clientData, Tk_Window tkwin, char *recordPtr, TkSizeT internalOffset); static void RestoreSticky(void *clientData, Tk_Window tkwin, char *internalPtr, char *oldInternalPtr); static void AdjustForSticky(int sticky, int cavityWidth, int cavityHeight, int *xPtr, int *yPtr, 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); |
︙ | ︙ | |||
271 272 273 274 275 276 277 | RestoreSticky, /* restoreProc */ NULL, /* freeProc */ 0 }; static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | RestoreSticky, /* restoreProc */ NULL, /* freeProc */ 0 }; static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", DEF_PANEDWINDOW_BG_COLOR, TCL_INDEX_NONE, offsetof(PanedWindow, background), 0, DEF_PANEDWINDOW_BG_MONO, 0}, {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0}, {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, "-background", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth), 0, 0, GEOMETRY}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad", DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize", DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr), offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-height", "height", "Height", DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightPtr), offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY}, {TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize", DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE, offsetof(PanedWindow, resizeOpaque), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", DEF_PANEDWINDOW_ORIENT, TCL_INDEX_NONE, offsetof(PanedWindow, orient), TK_OPTION_ENUM_VAR, orientStrings, GEOMETRY}, {TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground", 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK, (void *)DEF_PANEDWINDOW_BG_MONO, 0}, {TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth", DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr), offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY}, {TK_OPTION_RELIEF, "-proxyrelief", "proxyRelief", "Relief", 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0}, {TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor", DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad", DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad), 0, 0, GEOMETRY}, {TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief", DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief), 0, 0, 0}, {TK_OPTION_PIXELS, "-sashwidth", "sashWidth", "Width", DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr), offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY}, {TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle", DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle), 0, 0, GEOMETRY}, {TK_OPTION_PIXELS, "-width", "width", "Width", 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 paneOptionSpecs[] = { {TK_OPTION_WINDOW, "-after", NULL, NULL, 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(Pane, before), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-height", NULL, NULL, 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(Pane, hide), 0,0,GEOMETRY}, {TK_OPTION_PIXELS, "-minsize", NULL, NULL, 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(Pane, padx), 0, 0, 0}, {TK_OPTION_PIXELS, "-pady", NULL, NULL, 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(Pane, sticky), 0, &stickyOption, 0}, {TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch", DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch), TK_OPTION_ENUM_VAR, stretchStrings, 0}, {TK_OPTION_PIXELS, "-width", NULL, NULL, 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} }; /* *-------------------------------------------------------------- * * Tk_PanedWindowObjCmd -- |
︙ | ︙ | |||
379 380 381 382 383 384 385 | * A new widget is created and configured. * *-------------------------------------------------------------- */ int Tk_PanedWindowObjCmd( | | | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | * A new widget is created and configured. * *-------------------------------------------------------------- */ int Tk_PanedWindowObjCmd( TCL_UNUSED(void *), /* 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; |
︙ | ︙ | |||
406 407 408 409 410 411 412 | pwOpts = (OptionTables *) Tcl_GetAssocData(interp, "PanedWindowOptionTables", NULL); if (pwOpts == NULL) { /* * The first time this function is invoked, the option tables will be * NULL. We then create the option tables from the templates and store | | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | pwOpts = (OptionTables *) Tcl_GetAssocData(interp, "PanedWindowOptionTables", NULL); if (pwOpts == NULL) { /* * The first time this function is invoked, the option tables will be * NULL. We then create the option tables from the templates and store * a pointer to the tables as the command's clientData so we'll have * easy access to it in the future. */ pwOpts = (OptionTables *)ckalloc(sizeof(OptionTables)); /* * Set up an exit handler to free the optionTables struct. |
︙ | ︙ | |||
526 527 528 529 530 531 532 | * See the user documentation. * *-------------------------------------------------------------- */ static int PanedWindowWidgetObjCmd( | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | * See the user documentation. * *-------------------------------------------------------------- */ static int PanedWindowWidgetObjCmd( void *clientData, /* Information about square widget. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj * const objv[]) /* Argument objects. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; int result = TCL_OK; static const char *const optionStrings[] = { |
︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 1018 | i = sizeof(Pane *) * (pwPtr->numPanes + numNewPanes); newPanes = (Pane **)ckalloc(i); memset(newPanes, 0, i); if (index == -1) { /* * If none of the existing panes have to be moved, just copy the old * and append the new. */ | > > > | | > | | | 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 | i = sizeof(Pane *) * (pwPtr->numPanes + numNewPanes); newPanes = (Pane **)ckalloc(i); memset(newPanes, 0, i); if (index == -1) { /* * If none of the existing panes have to be moved, just copy the old * and append the new. * Be careful about the case pwPtr->numPanes == 0 since in this case * pwPtr->panes is NULL, and the memcpy would have undefined behavior. */ if (pwPtr->numPanes) { memcpy(newPanes, pwPtr->panes, sizeof(Pane *) * pwPtr->numPanes); } memcpy(&newPanes[pwPtr->numPanes], inserts, sizeof(Pane *) * numNewPanes); } else { /* * 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 panes * array as we go; when we get to the insert location for the new * panes, copy the inserts array over, then finish off the old panes * array. */ for (i = 0, j = 0; i < index; i++) { if (pwPtr->panes[i] != NULL) { newPanes[j] = pwPtr->panes[i]; j++; } } memcpy(&newPanes[j], inserts, sizeof(Pane *)*insertIndex); j += firstOptionArg - 2; for (i = index; i < pwPtr->numPanes; i++) { if (pwPtr->panes[i] != NULL) { newPanes[j] = pwPtr->panes[i]; j++; } |
︙ | ︙ | |||
1286 1287 1288 1289 1290 1291 1292 | * Paned window will be relayed out and redisplayed. * *---------------------------------------------------------------------- */ static void PanedWindowWorldChanged( | | | 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 | * Paned window will be relayed out and redisplayed. * *---------------------------------------------------------------------- */ static void PanedWindowWorldChanged( void *instanceData) /* Information about the paned window. */ { XGCValues gcValues; GC newGC; PanedWindow *pwPtr = (PanedWindow *)instanceData; /* * Allocated a graphics context for drawing the paned window widget |
︙ | ︙ | |||
1344 1345 1346 1347 1348 1349 1350 | * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ static void PanedWindowEventProc( | | | 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 | * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ static void PanedWindowEventProc( void *clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; int i; if (eventPtr->type == Expose) { if (pwPtr->tkwin != NULL && !(pwPtr->flags & REDRAW_PENDING)) { |
︙ | ︙ | |||
1398 1399 1400 1401 1402 1403 1404 | * The widget is destroyed. * *---------------------------------------------------------------------- */ static void PanedWindowCmdDeletedProc( | | | 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 | * The widget is destroyed. * *---------------------------------------------------------------------- */ static void PanedWindowCmdDeletedProc( void *clientData) /* Pointer to widget record for widget. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; /* * This function could be invoked either because the window was destroyed * and the command was then deleted or because the command was deleted, * and then this function destroys the widget. The WIDGET_DELETED flag |
︙ | ︙ | |||
1435 1436 1437 1438 1439 1440 1441 | * Information appears on the screen. * *-------------------------------------------------------------- */ static void DisplayPanedWindow( | | | 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 | * Information appears on the screen. * *-------------------------------------------------------------- */ static void DisplayPanedWindow( void *clientData) /* Information about window. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; Pane *panePtr; Pixmap pixmap; Tk_Window tkwin = pwPtr->tkwin; int i, sashWidth, sashHeight; const int horizontal = (pwPtr->orient == ORIENT_HORIZONTAL); |
︙ | ︙ | |||
1620 1621 1622 1623 1624 1625 1626 | * the next idle point. * *-------------------------------------------------------------- */ static void PanedWindowReqProc( | | | 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 | * the next idle point. * *-------------------------------------------------------------- */ static void PanedWindowReqProc( void *clientData, /* Paned window's information about window * that got new preferred geometry. */ TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the * window. */ { Pane *panePtr = (Pane *)clientData; PanedWindow *pwPtr = (PanedWindow *) panePtr->containerPtr; |
︙ | ︙ | |||
1666 1667 1668 1669 1670 1671 1672 | * recomputed for the panedwindow. * *-------------------------------------------------------------- */ static void PanedWindowLostPaneProc( | | | 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 | * recomputed for the panedwindow. * *-------------------------------------------------------------- */ static void PanedWindowLostPaneProc( void *clientData, /* Grid structure for the pane that was * stolen away. */ 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)) { |
︙ | ︙ | |||
1706 1707 1708 1709 1710 1711 1712 | * The panes of containerPtr may get resized or moved. * *-------------------------------------------------------------- */ static void ArrangePanes( | | | 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 | * The panes of containerPtr may get resized or moved. * *-------------------------------------------------------------- */ static void ArrangePanes( void *clientData) /* Structure describing parent whose panes * are to be re-layed out. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; Pane *panePtr; int i, newPaneWidth, newPaneHeight, paneX, paneY; int paneWidth, paneHeight, paneSize, paneMinSize; int doubleBw; |
︙ | ︙ | |||
2152 2153 2154 2155 2156 2157 2158 | * window which managed it. * *-------------------------------------------------------------- */ static void PaneStructureProc( | | | 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 | * window which managed it. * *-------------------------------------------------------------- */ static void PaneStructureProc( void *clientData, /* Pointer to record describing window item. */ XEvent *eventPtr) /* Describes what just happened. */ { Pane *panePtr = (Pane *)clientData; PanedWindow *pwPtr = panePtr->containerPtr; if (eventPtr->type == DestroyNotify) { Unlink(panePtr); |
︙ | ︙ | |||
2364 2365 2366 2367 2368 2369 2370 | * Frees memory. * *---------------------------------------------------------------------- */ static void DestroyOptionTables( | | | 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 | * Frees memory. * *---------------------------------------------------------------------- */ static void DestroyOptionTables( void *clientData, /* Pointer to the OptionTables struct */ TCL_UNUSED(Tcl_Interp *)) /* Pointer to the calling interp */ { ckfree(clientData); } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
2747 2748 2749 2750 2751 2752 2753 | * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ static void ProxyWindowEventProc( | | | 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 | * it gets exposed, it is redisplayed. * *-------------------------------------------------------------- */ static void ProxyWindowEventProc( void *clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; if (eventPtr->type == Expose) { if (pwPtr->proxywin != NULL &&!(pwPtr->flags & PROXY_REDRAW_PENDING)) { Tcl_DoWhenIdle(DisplayProxyWindow, pwPtr); |
︙ | ︙ | |||
2780 2781 2782 2783 2784 2785 2786 | * Information appears on the screen. * *-------------------------------------------------------------- */ static void DisplayProxyWindow( | | | 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 | * Information appears on the screen. * *-------------------------------------------------------------- */ static void DisplayProxyWindow( void *clientData) /* Information about window. */ { PanedWindow *pwPtr = (PanedWindow *)clientData; Pixmap pixmap; Tk_Window tkwin = pwPtr->proxywin; pwPtr->flags &= ~PROXY_REDRAW_PENDING; if ((tkwin == NULL) || !Tk_IsMapped(tkwin)) { return; |
︙ | ︙ |
Changes to generic/tkPkgConfig.c.
1 2 3 4 5 6 | /* * tkPkgConfig.c -- * * This file contains the configuration information to embed into the tcl * binary library. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkPkgConfig.c -- * * This file contains the configuration information to embed into the tcl * binary library. * * Copyright © 2002 Andreas Kupries <[email protected]> * Copyright © 2017 Stuart Cassoff <[email protected]> * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. */ /* Note, the definitions in this module are influenced by the following C * preprocessor macros: |
︙ | ︙ | |||
91 92 93 94 95 96 97 98 99 100 101 102 | #elif defined(HAVE_XFT) # define CFG_FONTSYSTEM "xft" #else # define CFG_FONTSYSTEM "x11" #endif static const Tcl_Config cfg[] = { {"debug", CFG_DEBUG}, {"threaded", CFG_THREADED}, {"profiled", CFG_PROFILED}, {"64bit", CFG_64}, {"optimized", CFG_OPTIMIZED}, | > | < < | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #elif defined(HAVE_XFT) # define CFG_FONTSYSTEM "xft" #else # define CFG_FONTSYSTEM "x11" #endif static const Tcl_Config cfg[] = { #if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 {"debug", CFG_DEBUG}, {"threaded", CFG_THREADED}, {"profiled", CFG_PROFILED}, {"64bit", CFG_64}, {"optimized", CFG_OPTIMIZED}, {"mem_debug", CFG_MEMDEBUG}, #endif {"fontsystem", CFG_FONTSYSTEM}, /* Runtime paths to various stuff */ #ifdef CFG_RUNTIME_LIBDIR {"libdir,runtime", CFG_RUNTIME_LIBDIR}, #endif |
︙ | ︙ | |||
122 123 124 125 126 127 128 129 130 131 132 133 134 135 | #endif #ifdef CFG_RUNTIME_DOCDIR {"docdir,runtime", CFG_RUNTIME_DOCDIR}, #endif #ifdef CFG_RUNTIME_DEMODIR {"demodir,runtime", CFG_RUNTIME_DEMODIR}, #endif /* Installation paths to various stuff */ #ifdef CFG_INSTALL_LIBDIR {"libdir,install", CFG_INSTALL_LIBDIR}, #endif #ifdef CFG_INSTALL_BINDIR | > > > | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | #endif #ifdef CFG_RUNTIME_DOCDIR {"docdir,runtime", CFG_RUNTIME_DOCDIR}, #endif #ifdef CFG_RUNTIME_DEMODIR {"demodir,runtime", CFG_RUNTIME_DEMODIR}, #endif #if !defined(STATIC_BUILD) {"dllfile,runtime", CFG_RUNTIME_DLLFILE}, #endif /* Installation paths to various stuff */ #ifdef CFG_INSTALL_LIBDIR {"libdir,install", CFG_INSTALL_LIBDIR}, #endif #ifdef CFG_INSTALL_BINDIR |
︙ | ︙ |
Changes to generic/tkPlace.c.
1 2 3 4 5 6 | /* * tkPlace.c -- * * This file contains code to implement a simple geometry manager for Tk * based on absolute placement or "rubber-sheet" placement. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | /* * tkPlace.c -- * * This file contains code to implement a simple geometry manager for Tk * based on absolute placement or "rubber-sheet" placement. * * 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. */ #include "tkInt.h" /* * Border modes for relative placement: * * BM_INSIDE: relative distances computed using area inside all * borders of container window. * BM_OUTSIDE: relative distances computed using outside area that * 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", "ignore", "outside", NULL }; typedef enum {BM_INSIDE, BM_IGNORE, BM_OUTSIDE} BorderMode; /* * For each window whose geometry is managed by the placer there is a * structure of the following type: */ typedef struct Content { |
︙ | ︙ | |||
66 67 68 69 70 71 72 | double relWidth, relHeight; /* Dimensions for tkwin relative to size of * 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 container window. */ | < < | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | double relWidth, relHeight; /* Dimensions for tkwin relative to size of * 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 container window. */ } 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(Content, anchor), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE, offsetof(Content, borderMode), TK_OPTION_ENUM_VAR, 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(Content, relHeightPtr), offsetof(Content, relHeight), TK_OPTION_NULL_OK, 0, 0}, |
︙ | ︙ | |||
104 105 106 107 108 109 110 | {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} }; | < < < < < < < < < < < < < < | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | {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} }; /* * For each container window that has a content managed by the placer there is a * structure of the following form: */ typedef struct Container { Tk_Window tkwin; /* Tk's token for container window. */ |
︙ | ︙ | |||
275 276 277 278 279 280 281 | dispPtr = ((TkWindow *) tkwin)->dispPtr; if (!dispPtr->placeInit) { Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS); Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS); dispPtr->placeInit = 1; } | | | | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | dispPtr = ((TkWindow *) tkwin)->dispPtr; if (!dispPtr->placeInit) { Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS); Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS); dispPtr->placeInit = 1; } if (Tcl_GetIndexFromObj(NULL, objv[1], optionStrings, "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, |
︙ | ︙ | |||
406 407 408 409 410 411 412 413 414 415 416 417 418 419 | 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; } | > > > > | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | 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->width = INT_MIN; contentPtr->height = INT_MIN; contentPtr->relWidth = NAN; contentPtr->relHeight = NAN; contentPtr->optionTable = table; Tcl_SetHashValue(hPtr, contentPtr); Tk_CreateEventHandler(tkwin, StructureNotifyMask, ContentStructureProc, contentPtr); return contentPtr; } |
︙ | ︙ | |||
433 434 435 436 437 438 439 440 441 442 443 444 445 446 | *---------------------------------------------------------------------- */ static void FreeContent( Content *contentPtr) { Tk_FreeConfigOptions((char *) contentPtr, contentPtr->optionTable, contentPtr->tkwin); ckfree(contentPtr); } /* *---------------------------------------------------------------------- | > > > | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | *---------------------------------------------------------------------- */ static void FreeContent( Content *contentPtr) { if (contentPtr->containerPtr && (contentPtr->containerPtr->flags & PARENT_RECONFIG_PENDING)) { Tcl_CancelIdleCall(RecomputePlacement, contentPtr->containerPtr); } Tk_FreeConfigOptions((char *) contentPtr, contentPtr->optionTable, contentPtr->tkwin); ckfree(contentPtr); } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
642 643 644 645 646 647 648 | contentPtr = CreateContent(tkwin, table); if (Tk_SetOptions(interp, contentPtr, table, objc, objv, contentPtr->tkwin, &savedOptions, &mask) != TCL_OK) { goto error; } | < < < < < < < < < < < < < < < < < < < < < | 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | contentPtr = CreateContent(tkwin, table); if (Tk_SetOptions(interp, contentPtr, table, objc, objv, contentPtr->tkwin, &savedOptions, &mask) != TCL_OK) { goto error; } if (!(mask & IN_MASK) && (contentPtr->containerPtr != NULL)) { /* * If no -in option was passed and the content is already placed then * just recompute the placement. */ containerPtr = contentPtr->containerPtr; |
︙ | ︙ | |||
820 821 822 823 824 825 826 | Tcl_ListObjAppendElement(NULL, infoObj, Tk_NewWindowObj(contentPtr->containerPtr->tkwin)); Tcl_AppendToObj(infoObj, " ", -1); } Tcl_AppendPrintfToObj(infoObj, "-x %d -relx %.4g -y %d -rely %.4g", contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY); | | | | | | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 | Tcl_ListObjAppendElement(NULL, infoObj, Tk_NewWindowObj(contentPtr->containerPtr->tkwin)); Tcl_AppendToObj(infoObj, " ", -1); } Tcl_AppendPrintfToObj(infoObj, "-x %d -relx %.4g -y %d -rely %.4g", contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY); if (contentPtr->widthPtr) { Tcl_AppendPrintfToObj(infoObj, " -width %d", contentPtr->width); } else { Tcl_AppendToObj(infoObj, " -width {}", -1); } if (contentPtr->relWidthPtr) { Tcl_AppendPrintfToObj(infoObj, " -relwidth %.4g", contentPtr->relWidth); } else { Tcl_AppendToObj(infoObj, " -relwidth {}", -1); } if (contentPtr->heightPtr) { Tcl_AppendPrintfToObj(infoObj, " -height %d", contentPtr->height); } else { Tcl_AppendToObj(infoObj, " -height {}", -1); } if (contentPtr->relHeightPtr) { Tcl_AppendPrintfToObj(infoObj, " -relheight %.4g", contentPtr->relHeight); } else { Tcl_AppendToObj(infoObj, " -relheight {}", -1); } Tcl_AppendPrintfToObj(infoObj, " -anchor %s -bordermode %s", |
︙ | ︙ | |||
932 933 934 935 936 937 938 | * 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)); | | | | | | | | 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 | * 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->widthPtr) || contentPtr->relWidthPtr) { width = 0; if (contentPtr->widthPtr) { width += contentPtr->width; } if (contentPtr->relWidthPtr) { /* * 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 + (contentPtr->relWidth*containerWidth); tmp = (int) (x2 + ((x2 > 0) ? 0.5 : -0.5)); width += tmp - x; } } else { width = Tk_ReqWidth(contentPtr->tkwin) + 2*Tk_Changes(contentPtr->tkwin)->border_width; } if (contentPtr->heightPtr || contentPtr->relHeightPtr) { height = 0; if (contentPtr->heightPtr) { height += contentPtr->height; } if (contentPtr->relHeightPtr) { /* * See note above for rounding errors in width computation. */ y2 = y1 + (contentPtr->relHeight*containerHeight); tmp = (int) (y2 + ((y2 > 0) ? 0.5 : -0.5)); height += tmp - y; |
︙ | ︙ | |||
1006 1007 1008 1009 1010 1011 1012 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; | | | 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 | y -= height; break; case TK_ANCHOR_W: y -= height/2; break; case TK_ANCHOR_NW: break; default: x -= width/2; y -= height/2; break; } /* * Step 4: adjust width and height again to reflect inside dimensions |
︙ | ︙ | |||
1210 1211 1212 1213 1214 1215 1216 | PlaceRequestProc( ClientData clientData, /* Pointer to our record for content. */ TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */ { Content *contentPtr = (Content *)clientData; Container *containerPtr; | | | | 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 | PlaceRequestProc( 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->widthPtr || contentPtr->relWidthPtr) && (contentPtr->heightPtr || contentPtr->relHeightPtr)) { /* * Send a ConfigureNotify to indicate that the size change * request was rejected. */ TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin)); return; |
︙ | ︙ |
Changes to generic/tkPlatDecls.h.
1 2 3 4 5 | /* * tkPlatDecls.h -- * * Declarations of functions in the platform-specific public Tcl API. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkPlatDecls.h -- * * Declarations of functions in the platform-specific public Tcl API. * * 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. */ #ifndef _TKPLATDECLS #define _TKPLATDECLS |
︙ | ︙ |
Changes to generic/tkPointer.c.
1 2 3 4 5 6 7 8 | /* * tkPointer.c -- * * 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. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkPointer.c -- * * 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 © 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. */ #include "tkInt.h" |
︙ | ︙ | |||
216 217 218 219 220 221 222 | Tk_Window tkwin, /* Window to which pointer event is reported. * May be NULL. */ int x, int y, /* Pointer location in root coords. */ int state) /* Modifier state mask. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); | | > > > > > > > > > > > > > > > > > > > > | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | Tk_Window tkwin, /* Window to which pointer event is reported. * May be NULL. */ int x, int y, /* Pointer location in root coords. */ int state) /* Modifier state mask. */ { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); TkWindow *winPtr = (TkWindow *) tkwin; TkWindow *targetWinPtr; XPoint pos; XEvent event; int no_cursor = (state & NOCURSOR_MASK); int no_button_events = (state & NOBUTTONEVENTS_MASK); unsigned changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; int type, b; unsigned mask; if (state & ALL_BUTTONS) { tsdPtr->lastState &= ~NOCURSOR_MASK; } state &= ~NOCURSOR_MASK & ~NOBUTTONEVENTS_MASK; if (no_cursor) { tsdPtr->lastState &= ~ALL_BUTTONS; tsdPtr->lastState |= (state & ALL_BUTTONS) | NOCURSOR_MASK; return; } else if (tsdPtr->lastState & NOCURSOR_MASK) { tsdPtr->lastState &= ~(NOCURSOR_MASK | ALL_BUTTONS); tsdPtr->lastState |= state & ALL_BUTTONS; return; } changes = (state ^ tsdPtr->lastState) & ALL_BUTTONS; pos.x = x; pos.y = y; /* * Use the current keyboard state, but the old mouse button state since we * haven't generated the button events yet. */ tsdPtr->lastState = (state & ~ALL_BUTTONS) | (tsdPtr->lastState & ALL_BUTTONS); if (no_button_events) { return; } /* * Generate Enter/Leave events. If the pointer has crossed window * boundaries, update the current mouse position so we don't generate * redundant motion events. */ |
︙ | ︙ | |||
498 499 500 501 502 503 504 | TkPointerDeadWindow( TkWindow *winPtr) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr == tsdPtr->lastWinPtr) { | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 | TkPointerDeadWindow( TkWindow *winPtr) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr == tsdPtr->lastWinPtr) { tsdPtr->lastWinPtr = TkGetContainer(winPtr); } if (winPtr == tsdPtr->grabWinPtr) { tsdPtr->grabWinPtr = NULL; } if (winPtr == tsdPtr->restrictWinPtr) { tsdPtr->restrictWinPtr = NULL; } |
︙ | ︙ |
Changes to generic/tkRectOval.c.
1 2 3 4 5 | /* * tkRectOval.c -- * * This file implements rectangle and oval items for canvas widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkRectOval.c -- * * This file implements rectangle and oval items for canvas widgets. * * 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ |
Changes to generic/tkScale.c.
1 2 3 4 5 6 7 8 9 10 11 | /* * tkScale.c -- * * This module implements a scale widgets for the Tk toolkit. A scale * displays a slider that can be adjusted to change a value; it also * displays numeric labels and a textual label, if desired. * * 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. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * tkScale.c -- * * This module implements a scale widgets for the Tk toolkit. A scale * displays a slider that can be adjusted to change a value; it also * displays numeric labels and a textual label, if desired. * * 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 © 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. */ #include "tkInt.h" #include "tkScale.h" |
︙ | ︙ | |||
30 31 32 33 34 35 36 | * used together with the "enum orient" declaration in tkScale.h. */ static const char *const orientStrings[] = { "horizontal", "vertical", NULL }; | < < < < < < < < < | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | * used together with the "enum orient" declaration in tkScale.h. */ static const char *const orientStrings[] = { "horizontal", "vertical", NULL }; static const Tk_OptionSpec optionSpecs[] = { {TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground", DEF_SCALE_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, activeBorder), 0, DEF_SCALE_ACTIVE_BG_MONO, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", DEF_SCALE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, bgBorder), 0, DEF_SCALE_BG_MONO, 0}, |
︙ | ︙ | |||
71 72 73 74 75 76 77 | 0, 0, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_SCALE_FONT, TCL_INDEX_NONE, offsetof(TkScale, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_SCALE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, textColorPtr), 0, | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 0, 0, 0}, {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", DEF_SCALE_FONT, TCL_INDEX_NONE, offsetof(TkScale, tkfont), 0, 0, 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", DEF_SCALE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, textColorPtr), 0, DEF_SCALE_FG_MONO, 0}, {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, TCL_INDEX_NONE, offsetof(TkScale, fromValue), 0, 0, 0}, {TK_OPTION_BORDER, "-highlightbackground", "highlightBackground", "HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, highlightBorder), 0, DEF_SCALE_HIGHLIGHT_BG_MONO, 0}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", DEF_SCALE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkScale, highlightColorPtr), 0, 0, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, highlightWidth), 0, 0, 0}, {TK_OPTION_STRING, "-label", "label", "Label", DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-length", "length", "Length", DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient), TK_OPTION_ENUM_VAR, orientStrings, 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", DEF_SCALE_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, relief), 0, 0, 0}, {TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay", DEF_SCALE_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkScale, repeatDelay), 0, 0, 0}, {TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval", DEF_SCALE_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, repeatInterval), |
︙ | ︙ | |||
114 115 116 117 118 119 120 | DEF_SCALE_SLIDER_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, sliderLength), 0, 0, 0}, {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief", DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_SCALE_STATE, TCL_INDEX_NONE, offsetof(TkScale, state), | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | DEF_SCALE_SLIDER_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, sliderLength), 0, 0, 0}, {TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief", DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_SCALE_STATE, TCL_INDEX_NONE, offsetof(TkScale, state), TK_OPTION_ENUM_VAR, tkStateStrings, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_SCALE_TAKE_FOCUS, offsetof(TkScale, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval", DEF_SCALE_TICK_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, tickInterval), 0, 0, 0}, {TK_OPTION_DOUBLE, "-to", "to", "To", |
︙ | ︙ | |||
1355 1356 1357 1358 1359 1360 1361 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && scalePtr->varNamePtr) { | | | | 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 | /* * If the variable is unset, then immediately recreate it unless the whole * interpreter is going away. */ if (flags & TCL_TRACE_UNSETS) { if (!Tcl_InterpDeleted(interp) && scalePtr->varNamePtr) { void *probe = NULL; do { probe = Tcl_VarTraceInfo(interp, Tcl_GetString(scalePtr->varNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ScaleVarProc, probe); if (probe == (void *)scalePtr) { break; } } while (probe); if (probe) { /* * We were able to fetch the unset trace for our * varNamePtr, which means it is not unset and not |
︙ | ︙ |
Changes to generic/tkScale.h.
1 2 3 4 5 6 | /* * tkScale.h -- * * Declarations of types and functions used to implement the scale * widget. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkScale.h -- * * Declarations of types and functions used to implement the scale * widget. * * 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. */ #ifndef _TKSCALE #define _TKSCALE |
︙ | ︙ |
Changes to generic/tkScrollbar.c.
1 2 3 4 5 6 7 | /* * tkScrollbar.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkScrollbar.c -- * * 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 © 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 "tkScrollbar.h" |
︙ | ︙ | |||
267 268 269 270 271 272 273 | Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); goto done; } if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "activate element"); goto error; } | | | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1)); goto done; } if (objc != 3) { Tcl_WrongNumArgs(interp, 1, objv, "activate element"); goto error; } 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", len) == 0)) { scrollPtr->activeField = SLIDER; |
︙ | ︙ |
Changes to generic/tkScrollbar.h.
1 2 3 4 5 6 | /* * tkScrollbar.h -- * * Declarations of types and functions used to implement the scrollbar * widget. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkScrollbar.h -- * * Declarations of types and functions used to implement the scrollbar * widget. * * 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. */ #ifndef _TKSCROLLBAR #define _TKSCROLLBAR |
︙ | ︙ |
Changes to generic/tkSelect.c.
1 2 3 4 5 6 | /* * tkSelect.c -- * * This file manages the selection for the Tk toolkit, translating * between the standard X ICCCM conventions and Tcl commands. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkSelect.c -- * * This file manages the selection for the Tk toolkit, translating * between the standard X ICCCM conventions and Tcl commands. * * 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. */ #include "tkInt.h" #include "tkSelect.h" |
︙ | ︙ | |||
896 897 898 899 900 901 902 | if (count > 3) { format = Tk_InternAtom(tkwin, Tcl_GetString(objs[3])); } else if (formatName != NULL) { format = Tk_InternAtom(tkwin, formatName); } else { format = XA_STRING; } | | | 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 | if (count > 3) { format = Tk_InternAtom(tkwin, Tcl_GetString(objs[3])); } else if (formatName != NULL) { format = Tk_InternAtom(tkwin, formatName); } else { format = XA_STRING; } string = Tcl_GetStringFromObj(objs[1], &cmdLength); if (cmdLength == 0) { Tk_DeleteSelHandler(tkwin, selection, target); } else { cmdInfoPtr = (CommandInfo *)ckalloc(offsetof(CommandInfo, command) + 1 + cmdLength); cmdInfoPtr->interp = interp; cmdInfoPtr->charOffset = 0; |
︙ | ︙ | |||
1187 1188 1189 1190 1191 1192 1193 | dispPtr->clipboardAtom = Tk_InternAtom(tkwin, "CLIPBOARD"); dispPtr->atomPairAtom = Tk_InternAtom(tkwin, "ATOM_PAIR"); /* * Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us to * support older X servers that didn't have UTF8_STRING yet. This is * necessary on Unix systems. For more information, see: | | | 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 | dispPtr->clipboardAtom = Tk_InternAtom(tkwin, "CLIPBOARD"); dispPtr->atomPairAtom = Tk_InternAtom(tkwin, "ATOM_PAIR"); /* * Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us to * support older X servers that didn't have UTF8_STRING yet. This is * necessary on Unix systems. For more information, see: * https://www.cl.cam.ac.uk/~mgk25/unicode.html#x11 */ #if !defined(_WIN32) dispPtr->utf8Atom = Tk_InternAtom(tkwin, "UTF8_STRING"); #else dispPtr->utf8Atom = (Atom) 0; #endif |
︙ | ︙ | |||
1395 1396 1397 1398 1399 1400 1401 | */ if (cmdInfoPtr->interp != NULL) { if (length <= (int)maxBytes) { cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1); cmdInfoPtr->buffer[0] = '\0'; } else { | | | | 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 | */ if (cmdInfoPtr->interp != NULL) { if (length <= (int)maxBytes) { cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1); cmdInfoPtr->buffer[0] = '\0'; } else { Tcl_UniChar ch = 0; p = string; string += count; numChars = 0; while (p < string) { p += Tcl_UtfToUniChar(p, &ch); numChars++; } cmdInfoPtr->charOffset += numChars; length = p - string; if (length > 0) { strncpy(cmdInfoPtr->buffer, string, length); } |
︙ | ︙ |
Changes to generic/tkSelect.h.
1 2 3 4 5 6 | /* * tkSelect.h -- * * Declarations of types shared among the files that implement selection * support. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkSelect.h -- * * Declarations of types shared among the files that implement selection * support. * * 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. */ #ifndef _TKSELECT #define _TKSELECT |
︙ | ︙ |
Changes to generic/tkSquare.c.
1 2 3 4 5 6 7 8 9 | /* * tkSquare.c -- * * This module implements "square" widgets that are object based. A * "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". * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkSquare.c -- * * This module implements "square" widgets that are object based. A * "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 © 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. */ #if 0 #define __NO_OLD_CONFIG |
︙ | ︙ |
Changes to generic/tkStubInit.c.
1 2 3 4 5 | /* * tkStubInit.c -- * * This file contains the initializers for the Tk stub vectors. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkStubInit.c -- * * This file contains the initializers for the Tk stub vectors. * * 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. */ #include "tkInt.h" |
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include "tkWinInt.h" #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" MODULE_SCOPE const TkStubs tkStubs; | > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | #include "tkWinInt.h" #endif #if defined(MAC_OSX_TK) /* we could have used _TKMACINT */ #include "tkMacOSXInt.h" #include "tkMacOSXPrivate.h" #else # define Tk_ClipDrawableToRect 0 #endif /* TODO: These ought to come in some other way */ #include "tkPlatDecls.h" #include "tkIntXlibDecls.h" MODULE_SCOPE const TkStubs tkStubs; |
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | return 2; } #else # 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; } | > > > > > > > > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | return 2; } #else # define Tk_TranslateWinEvent 0 # define Tk_PointerEvent 0 # define TkWinGetPlatformId 0 #endif #if defined(TK_NO_DEPRECATED) || (TCL_MAJOR_VERSION > 8) # define TkSetWindowMenuBar 0 # define TkpDrawHighlightBorder 0 # define TkpUseWindow 0 # define TkpSetMainMenubar 0 # define TkpGetOtherWindow 0 # define TkpGetSystemDefault 0 # define TkpMakeContainer 0 # define TkpMakeWindow 0 #endif static int doNothing(void) { /* dummy implementation, no need to do anything */ return 0; } |
︙ | ︙ | |||
103 104 105 106 107 108 109 | #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 | | | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | #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) # undef TkpWillDrawWidget # undef TkpRedrawWidget # define TkpWillDrawWidget ((int (*)(Tk_Window))(void *)doNothing) # define TkpRedrawWidget ((void (*)(Tk_Window))(void *)doNothing) #endif #ifdef _WIN32 |
︙ | ︙ | |||
497 498 499 500 501 502 503 | TkOrientPrintProc, /* 178 */ TkSmoothParseProc, /* 179 */ TkSmoothPrintProc, /* 180 */ TkDrawAngledTextLayout, /* 181 */ TkUnderlineAngledTextLayout, /* 182 */ TkIntersectAngledTextLayout, /* 183 */ TkDrawAngledChars, /* 184 */ | < < < < < < < < < < < < < < < < | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | TkOrientPrintProc, /* 178 */ TkSmoothParseProc, /* 179 */ TkSmoothPrintProc, /* 180 */ TkDrawAngledTextLayout, /* 181 */ TkUnderlineAngledTextLayout, /* 182 */ TkIntersectAngledTextLayout, /* 183 */ TkDrawAngledChars, /* 184 */ TkpRedrawWidget, /* 185 */ TkpWillDrawWidget, /* 186 */ TkDebugPhotoStringMatchDef, /* 187 */ }; static const TkIntPlatStubs tkIntPlatStubs = { TCL_STUB_MAGIC, 0, #if defined(_WIN32) || defined(__CYGWIN__) /* WIN */ |
︙ | ︙ | |||
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 | Tk_CreateOldPhotoImageFormat, /* 273 */ Tk_AlwaysShowSelection, /* 274 */ Tk_GetButtonMask, /* 275 */ Tk_GetDoublePixelsFromObj, /* 276 */ Tk_NewWindowObj, /* 277 */ Tk_SendVirtualEvent, /* 278 */ Tk_FontGetDescription, /* 279 */ }; /* !END!: Do not edit above this line. */ #ifdef __CYGWIN__ void *Tk_GetHINSTANCE(void) | > > > > > > > > > > > | 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 | Tk_CreateOldPhotoImageFormat, /* 273 */ Tk_AlwaysShowSelection, /* 274 */ Tk_GetButtonMask, /* 275 */ Tk_GetDoublePixelsFromObj, /* 276 */ Tk_NewWindowObj, /* 277 */ Tk_SendVirtualEvent, /* 278 */ Tk_FontGetDescription, /* 279 */ Tk_CreatePhotoImageFormatVersion3, /* 280 */ Tk_DrawHighlightBorder, /* 281 */ Tk_SetMainMenubar, /* 282 */ Tk_SetWindowMenubar, /* 283 */ Tk_ClipDrawableToRect, /* 284 */ Tk_GetSystemDefault, /* 285 */ Tk_UseWindow, /* 286 */ Tk_MakeContainer, /* 287 */ Tk_GetOtherWindow, /* 288 */ Tk_Get3DBorderColors, /* 289 */ Tk_MakeWindow, /* 290 */ }; /* !END!: Do not edit above this line. */ #ifdef __CYGWIN__ void *Tk_GetHINSTANCE(void) |
︙ | ︙ |
Changes to generic/tkStubLib.c.
1 2 3 4 5 6 | /* * tkStubLib.c -- * * Stub object that will be statically linked into extensions that want * to access Tk. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkStubLib.c -- * * Stub object that will be statically linked into extensions that want * to access Tk. * * 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. */ #include "tkInt.h" |
︙ | ︙ | |||
71 72 73 74 75 76 77 | #undef Tk_InitStubs MODULE_SCOPE const char * Tk_InitStubs( Tcl_Interp *interp, const char *version, int exact) { | | < > > > > | > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | #undef Tk_InitStubs MODULE_SCOPE const char * Tk_InitStubs( Tcl_Interp *interp, const char *version, int exact) { const char *packageName = "tk"; const char *errMsg = NULL; void *clientData = NULL; const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, 0, &clientData); if (actualVersion == 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; while (*p) { |
︙ | ︙ | |||
109 110 111 112 113 114 115 | actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, 1, NULL); if (actualVersion == NULL) { return NULL; } } } | | | | | | | | | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp, packageName, version, 1, NULL); if (actualVersion == NULL) { return NULL; } } } if (clientData == NULL) { errMsg = "missing stub table pointer"; } else { 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; } return actualVersion; |
︙ | ︙ |
Changes to generic/tkStyle.c.
1 2 3 4 5 | /* * tkStyle.c -- * * This file implements the widget styles and themes support. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkStyle.c -- * * This file implements the widget styles and themes support. * * 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. */ #include "tkInt.h" |
︙ | ︙ |
Changes to generic/tkTest.c.
1 2 3 4 5 6 7 8 | /* * tkTest.c -- * * 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. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * tkTest.c -- * * 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 © 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. */ #undef STATIC_BUILD #ifndef USE_TCL_STUBS |
︙ | ︙ | |||
83 84 85 86 87 88 89 | } TImageInstance; /* * The type record for test images: */ static int ImageCreate(Tcl_Interp *interp, | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | } TImageInstance; /* * The type record for test images: */ static int ImageCreate(Tcl_Interp *interp, const char *name, int objc, Tcl_Obj *const objv[], 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, int height, int drawableX, |
︙ | ︙ | |||
243 244 245 246 247 248 249 | return TCL_ERROR; } /* * Create additional commands for testing Tk. */ | | | | | | | | | | | | | | | | | | | 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | return TCL_ERROR; } /* * Create additional commands for testing Tk. */ 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, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testborder", TestborderObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testcolor", TestcolorObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testcursor", TestcursorObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testdeleteapps", TestdeleteappsObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testembed", TkpTestembedCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testobjconfig", TestobjconfigObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testfont", TestfontObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testmakeexist", TestmakeexistObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testprop", TestpropObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testprintf", TestprintfObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testphotostringmatch", TestPhotoStringMatchCmd, Tk_MainWindow(interp), NULL); #if defined(_WIN32) Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd, Tk_MainWindow(interp), NULL); #elif !defined(__CYGWIN__) && !defined(MAC_OSX_TK) Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd, Tk_MainWindow(interp), NULL); Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd, Tk_MainWindow(interp), NULL); #endif /* _WIN32 */ /* * Create test image type. */ if (!initialized) { |
︙ | ︙ | |||
363 364 365 366 367 368 369 | * None. * *---------------------------------------------------------------------- */ static int TestborderObjCmd( | | | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | * None. * *---------------------------------------------------------------------- */ static int TestborderObjCmd( TCL_UNUSED(void *), /* Main window for application. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { if (objc < 2) { Tcl_WrongNumArgs(interp, 1, objv, "border"); return TCL_ERROR; |
︙ | ︙ | |||
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | typedef struct { TrivialCommandHeader header; Tcl_Obj *booleanPtr; Tcl_Obj *integerPtr; Tcl_Obj *doublePtr; Tcl_Obj *stringPtr; Tcl_Obj *stringTablePtr; Tcl_Obj *colorPtr; Tcl_Obj *fontPtr; Tcl_Obj *bitmapPtr; Tcl_Obj *borderPtr; Tcl_Obj *reliefPtr; Tcl_Obj *cursorPtr; Tcl_Obj *activeCursorPtr; Tcl_Obj *justifyPtr; Tcl_Obj *anchorPtr; Tcl_Obj *pixelPtr; Tcl_Obj *mmPtr; Tcl_Obj *customPtr; } TypesRecord; TypesRecord *recordPtr; static const char *const stringTable[] = { "one", "two", "three", "four", NULL }; static const Tk_OptionSpec typesSpecs[] = { | > > > > | | > > > > | | | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | typedef struct { TrivialCommandHeader header; Tcl_Obj *booleanPtr; Tcl_Obj *integerPtr; Tcl_Obj *doublePtr; Tcl_Obj *stringPtr; Tcl_Obj *stringTablePtr; Tcl_Obj *stringTablePtr2; Tcl_Obj *colorPtr; Tcl_Obj *fontPtr; Tcl_Obj *bitmapPtr; Tcl_Obj *borderPtr; Tcl_Obj *reliefPtr; Tcl_Obj *cursorPtr; Tcl_Obj *activeCursorPtr; Tcl_Obj *justifyPtr; Tcl_Obj *anchorPtr; Tcl_Obj *pixelPtr; Tcl_Obj *mmPtr; Tcl_Obj *customPtr; } TypesRecord; TypesRecord *recordPtr; static const char *const stringTable[] = { "one", "two", "three", "four", NULL }; static const char *const stringTable2[] = { "one", "two", NULL }; static const Tk_OptionSpec typesSpecs[] = { {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", NULL, offsetof(TypesRecord, booleanPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x1}, {TK_OPTION_INT, "-integer", "integer", "Integer", "7", offsetof(TypesRecord, integerPtr), TCL_INDEX_NONE, 0, 0, 0x2}, {TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159", offsetof(TypesRecord, doublePtr), TCL_INDEX_NONE, 0, 0, 0x4}, {TK_OPTION_STRING, "-string", "string", "String", "foo", offsetof(TypesRecord, stringPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x8}, {TK_OPTION_STRING_TABLE, "-stringtable", "StringTable", "stringTable", "one", offsetof(TypesRecord, stringTablePtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, stringTable, 0x10}, {TK_OPTION_STRING_TABLE, "-stringtable2", "StringTable2", "stringTable2", "two", offsetof(TypesRecord, stringTablePtr2), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, stringTable2, 0x10}, {TK_OPTION_COLOR, "-color", "color", "Color", "red", offsetof(TypesRecord, colorPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, "black", 0x20}, {TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12", offsetof(TypesRecord, fontPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x40}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50", offsetof(TypesRecord, bitmapPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x80}, {TK_OPTION_BORDER, "-border", "border", "Border", "blue", offsetof(TypesRecord, borderPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, "white", 0x100}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL, offsetof(TypesRecord, reliefPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x200}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm", offsetof(TypesRecord, cursorPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x400}, {TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left", offsetof(TypesRecord, justifyPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x800}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center", offsetof(TypesRecord, anchorPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x1000}, {TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel", "1", offsetof(TypesRecord, pixelPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x2000}, {TK_OPTION_CUSTOM, "-custom", NULL, NULL, "", offsetof(TypesRecord, customPtr), TCL_INDEX_NONE, |
︙ | ︙ | |||
664 665 666 667 668 669 670 671 672 673 674 675 676 | recordPtr->reliefPtr = NULL; recordPtr->cursorPtr = NULL; recordPtr->justifyPtr = NULL; recordPtr->anchorPtr = NULL; recordPtr->pixelPtr = NULL; recordPtr->mmPtr = NULL; recordPtr->stringTablePtr = NULL; recordPtr->customPtr = NULL; result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, | > | | | 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | recordPtr->reliefPtr = NULL; recordPtr->cursorPtr = NULL; recordPtr->justifyPtr = NULL; recordPtr->anchorPtr = NULL; recordPtr->pixelPtr = NULL; recordPtr->mmPtr = NULL; recordPtr->stringTablePtr = NULL; recordPtr->stringTablePtr2 = NULL; recordPtr->customPtr = NULL; result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, recordPtr, TrivialCmdDeletedProc); Tk_CreateEventHandler(tkwin, StructureNotifyMask, TrivialEventProc, recordPtr); result = Tk_SetOptions(interp, recordPtr, optionTable, objc-3, objv+3, tkwin, NULL, NULL); if (result != TCL_OK) { Tk_DestroyWindow(tkwin); } } else { Tk_DestroyWindow(tkwin); |
︙ | ︙ | |||
718 719 720 721 722 723 724 | if (result != TCL_OK) { Tk_FreeConfigOptions(recordPtr, optionTable, tkwin); } } if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, | | | | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | if (result != TCL_OK) { Tk_FreeConfigOptions(recordPtr, optionTable, tkwin); } } if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, recordPtr, TrivialCmdDeletedProc); Tk_CreateEventHandler(tkwin, StructureNotifyMask, TrivialEventProc, recordPtr); Tcl_SetObjResult(interp, objv[2]); } break; } case CHAIN2: case CHAIN3: { ExtensionWidgetRecord *recordPtr; static const Tk_OptionSpec extensionSpecs[] = { {TK_OPTION_STRING, "-three", "three", "Three", "three", offsetof(ExtensionWidgetRecord, extension3ObjPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_STRING, "-four", "four", "Four", "four", offsetof(ExtensionWidgetRecord, extension4ObjPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_STRING, "-two", "two", "Two", "two and a half", offsetof(ExtensionWidgetRecord, base2ObjPtr), TCL_INDEX_NONE, 0, NULL, 0}, {TK_OPTION_STRING, "-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, baseSpecs, 0} }; Tk_OptionTable optionTable; tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL); if (tkwin == NULL) { return TCL_ERROR; |
︙ | ︙ | |||
771 772 773 774 775 776 777 | if (result != TCL_OK) { Tk_FreeConfigOptions((char *) recordPtr, optionTable, tkwin); } } if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, | | | | | 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | if (result != TCL_OK) { Tk_FreeConfigOptions((char *) recordPtr, optionTable, tkwin); } } if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, recordPtr, TrivialCmdDeletedProc); Tk_CreateEventHandler(tkwin, StructureNotifyMask, TrivialEventProc, recordPtr); Tcl_SetObjResult(interp, objv[2]); } break; } case CONFIG_ERROR: { typedef struct { Tcl_Obj *intPtr; } ErrorWidgetRecord; ErrorWidgetRecord widgetRecord; static const Tk_OptionSpec errorSpecs[] = { {TK_OPTION_INT, "-int", "integer", "Integer", "bogus", offsetof(ErrorWidgetRecord, intPtr), 0, TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0} }; Tk_OptionTable optionTable; widgetRecord.intPtr = NULL; optionTable = Tk_CreateOptionTable(interp, errorSpecs); tables[index] = optionTable; |
︙ | ︙ | |||
860 861 862 863 864 865 866 | } InternalRecord; InternalRecord *recordPtr; static const char *const internalStringTable[] = { "one", "two", "three", "four", NULL }; static const Tk_OptionSpec internalSpecs[] = { {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1", | | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | } InternalRecord; InternalRecord *recordPtr; static const char *const internalStringTable[] = { "one", "two", "three", "four", NULL }; static const Tk_OptionSpec internalSpecs[] = { {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1", TCL_INDEX_NONE, offsetof(InternalRecord, boolean), TK_CONFIG_NULL_OK, 0, 0x1}, {TK_OPTION_INT, "-integer", "integer", "Integer", "148962237", TCL_INDEX_NONE, offsetof(InternalRecord, integer), 0, 0, 0x2}, {TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159", TCL_INDEX_NONE, offsetof(InternalRecord, doubleValue), 0, 0, 0x4}, {TK_OPTION_STRING, "-string", "string", "String", "foo", TCL_INDEX_NONE, offsetof(InternalRecord, string), TK_CONFIG_NULL_OK, 0, 0x8}, |
︙ | ︙ | |||
884 885 886 887 888 889 890 | TK_CONFIG_NULL_OK, 0, 0x40}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50", TCL_INDEX_NONE, offsetof(InternalRecord, bitmap), TK_CONFIG_NULL_OK, 0, 0x80}, {TK_OPTION_BORDER, "-border", "border", "Border", "blue", TCL_INDEX_NONE, offsetof(InternalRecord, border), TK_CONFIG_NULL_OK, "white", 0x100}, | | | | 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | TK_CONFIG_NULL_OK, 0, 0x40}, {TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50", TCL_INDEX_NONE, offsetof(InternalRecord, bitmap), TK_CONFIG_NULL_OK, 0, 0x80}, {TK_OPTION_BORDER, "-border", "border", "Border", "blue", TCL_INDEX_NONE, offsetof(InternalRecord, border), TK_CONFIG_NULL_OK, "white", 0x100}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL, TCL_INDEX_NONE, offsetof(InternalRecord, relief), TK_CONFIG_NULL_OK, 0, 0x200}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm", TCL_INDEX_NONE, offsetof(InternalRecord, cursor), TK_CONFIG_NULL_OK, 0, 0x400}, {TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left", TCL_INDEX_NONE, offsetof(InternalRecord, justify), TK_CONFIG_NULL_OK, 0, 0x800}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center", TCL_INDEX_NONE, offsetof(InternalRecord, anchor), TK_CONFIG_NULL_OK, 0, 0x1000}, {TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel", "1", TCL_INDEX_NONE, offsetof(InternalRecord, pixels), TK_CONFIG_NULL_OK, 0, 0x2000}, {TK_OPTION_WINDOW, "-window", "window", "Window", NULL, TCL_INDEX_NONE, offsetof(InternalRecord, tkwin), |
︙ | ︙ | |||
936 937 938 939 940 941 942 | recordPtr->colorPtr = NULL; recordPtr->tkfont = NULL; recordPtr->bitmap = None; recordPtr->border = NULL; recordPtr->relief = TK_RELIEF_FLAT; recordPtr->cursor = NULL; recordPtr->justify = TK_JUSTIFY_LEFT; | | | 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 | recordPtr->colorPtr = NULL; recordPtr->tkfont = NULL; recordPtr->bitmap = None; recordPtr->border = NULL; recordPtr->relief = TK_RELIEF_FLAT; recordPtr->cursor = NULL; recordPtr->justify = TK_JUSTIFY_LEFT; recordPtr->anchor = TK_ANCHOR_CENTER; recordPtr->pixels = 0; recordPtr->mm = 0.0; recordPtr->tkwin = NULL; recordPtr->custom = NULL; result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin); if (result == TCL_OK) { |
︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 | if (result == TCL_OK) { result = Tk_SetOptions(interp, recordPtr, recordPtr->header.optionTable, objc - 3, objv + 3, (Tk_Window) NULL, NULL, NULL); if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, | | | 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 | if (result == TCL_OK) { result = Tk_SetOptions(interp, recordPtr, recordPtr->header.optionTable, objc - 3, objv + 3, (Tk_Window) NULL, NULL, NULL); if (result == TCL_OK) { recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp, Tcl_GetString(objv[2]), TrivialConfigObjCmd, recordPtr, TrivialCmdDeletedProc); } else { Tk_FreeConfigOptions(recordPtr, recordPtr->header.optionTable, (Tk_Window) NULL); } } if (result != TCL_OK) { ckfree(recordPtr); |
︙ | ︙ | |||
1929 1930 1931 1932 1933 1934 1935 | ClientData dummy, /* Not used */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { char buffer[256]; Tcl_WideInt wideInt; | < < < < | | 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 | ClientData dummy, /* Not used */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { char buffer[256]; Tcl_WideInt wideInt; long long longLongInt; (void)dummy; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "wideint"); return TCL_ERROR; } if (Tcl_GetWideIntFromObj(interp, objv[1], &wideInt) != TCL_OK) { return TCL_ERROR; } longLongInt = wideInt; /* Just add a lot of arguments to sprintf. Reason: on AMD64, the first * 4 or 6 arguments (we assume 8, just in case) might be put in registers, * 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", "", "", "", "", "", "", "", "", longLongInt, (unsigned long long)longLongInt); Tcl_AppendResult(interp, buffer, NULL); return TCL_OK; } #if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__)) /* *---------------------------------------------------------------------- |
︙ | ︙ |
Changes to generic/tkText.c.
1 2 3 4 5 6 7 8 | /* * tkText.c -- * * 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. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * tkText.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkUndo.h" |
︙ | ︙ | |||
38 39 40 41 42 43 44 | /* * Used to avoid having to allocate and deallocate arrays on the fly for * commonly used functions. Must be > 0. */ #define PIXEL_CLIENTS 5 | < < < < < < < < < < | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | /* * Used to avoid having to allocate and deallocate arrays on the fly for * commonly used functions. Must be > 0. */ #define PIXEL_CLIENTS 5 /* * The 'TkWrapMode' enum in tkText.h is used to define a type for the -wrap * option of the Text widget. These values are used as indices into the string * table below. */ const char *const tkTextWrapStrings[] = { "char", "none", "word", NULL }; /* * The 'TkTextTabStyle' enum in tkText.h is used to define a type for the * -tabstyle option of the Text widget. These values are used as indices into * the string table below. */ const char *const tkTextTabStyleStrings[] = { "tabular", "wordprocessor", NULL }; /* * The 'TkTextInsertUnfocussed' enum in tkText.h is used to define a type for * the -insertunfocussed option of the Text widget. These values are used as * indice into the string table below. |
︙ | ︙ | |||
175 176 177 178 179 180 181 | {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_TEXT_INSERT_BG, TCL_INDEX_NONE, offsetof(TkText, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE, offsetof(TkText, insertBorderWidth), 0, | | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | {TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground", DEF_TEXT_INSERT_BG, TCL_INDEX_NONE, offsetof(TkText, insertBorder), 0, 0, 0}, {TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE, offsetof(TkText, insertBorderWidth), 0, DEF_TEXT_INSERT_BD_MONO, 0}, {TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime", DEF_TEXT_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOffTime), 0, 0, 0}, {TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime", DEF_TEXT_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOnTime), 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-insertunfocussed", "insertUnfocussed", "InsertUnfocussed", DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed), TK_OPTION_ENUM_VAR, insertUnfocussedStrings, 0}, {TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth", DEF_TEXT_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, insertWidth), 0, 0, 0}, {TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo", DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo), TK_OPTION_DONT_SET_DEFAULT, 0, 0}, {TK_OPTION_PIXELS, "-padx", "padX", "Pad", |
︙ | ︙ | |||
226 227 228 229 230 231 232 | DEF_TEXT_SPACING3, TCL_INDEX_NONE, offsetof(TkText, spacing3), 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, &lineOption, TK_TEXT_LINE_RANGE}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_TEXT_STATE, TCL_INDEX_NONE, offsetof(TkText, state), | | | | | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | DEF_TEXT_SPACING3, TCL_INDEX_NONE, offsetof(TkText, spacing3), 0, 0 , TK_TEXT_LINE_GEOMETRY }, {TK_OPTION_CUSTOM, "-startline", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK, &lineOption, TK_TEXT_LINE_RANGE}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", DEF_TEXT_STATE, TCL_INDEX_NONE, offsetof(TkText, state), 0, &tkStateStrings[1], 0}, {TK_OPTION_STRING, "-tabs", "tabs", "Tabs", DEF_TEXT_TABS, offsetof(TkText, tabOptionPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_STRING_TABLE, "-tabstyle", "tabStyle", "TabStyle", DEF_TEXT_TABSTYLE, TCL_INDEX_NONE, offsetof(TkText, tabStyle), 0, tkTextTabStyleStrings, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", DEF_TEXT_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(TkText, takeFocus), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-undo", "undo", "Undo", DEF_TEXT_UNDO, TCL_INDEX_NONE, offsetof(TkText, undo), TK_OPTION_DONT_SET_DEFAULT, 0 , 0}, {TK_OPTION_INT, "-width", "width", "Width", DEF_TEXT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, width), 0, 0, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap", DEF_TEXT_WRAP, TCL_INDEX_NONE, offsetof(TkText, wrapMode), TK_OPTION_ENUM_VAR, tkTextWrapStrings, TK_TEXT_LINE_GEOMETRY}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", DEF_TEXT_XSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, xScrollCmd), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand", DEF_TEXT_YSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, yScrollCmd), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0} |
︙ | ︙ | |||
861 862 863 864 865 866 867 | result = TCL_ERROR; goto done; } for (i = 2; i < objc-2; i++) { int value; TkSizeT length; | | | 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | result = TCL_ERROR; goto done; } for (i = 2; i < objc-2; i++) { int value; TkSizeT length; const char *option = Tcl_GetStringFromObj(objv[i], &length); char c; if (length < 2 || option[0] != '-') { goto badOption; } c = option[1]; if (c == 'c' && !strncmp("-chars", option, length)) { |
︙ | ︙ | |||
1271 1272 1273 1274 1275 1276 1277 | /* * Simple, restrictive argument parsing. The only options are -- and * -displaychars (or any unique prefix). */ i = 2; if (objc > 3) { | | | | 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 | /* * Simple, restrictive argument parsing. The only options are -- and * -displaychars (or any unique prefix). */ i = 2; if (objc > 3) { name = Tcl_GetStringFromObj(objv[i], &length); if (length > 1 && name[0] == '-') { if (strncmp("-displaychars", name, length) == 0) { i++; visible = 1; name = Tcl_GetStringFromObj(objv[i], &length); } if ((i < objc-1) && (length == 2) && !strcmp("--", name)) { i++; } } } |
︙ | ︙ | |||
1539 1540 1541 1542 1543 1544 1545 | if (TkTextPendingsync(textPtr)) { if (textPtr->afterSyncCmd) { Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; | | | 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 | if (TkTextPendingsync(textPtr)) { if (textPtr->afterSyncCmd) { Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, textPtr); } break; } else if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, "?-command command?"); result = TCL_ERROR; goto done; } |
︙ | ︙ | |||
2269 2270 2271 2272 2273 2274 2275 | if (textPtr->selTagPtr->selFgColor == NULL) { textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; } else { textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr; } textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; | | > > | > > | | | 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 | if (textPtr->selTagPtr->selFgColor == NULL) { textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; } else { textPtr->selTagPtr->selFgColor = textPtr->selFgColorPtr; } textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; if ((textPtr->selTagPtr->elide >= 0) || (textPtr->selTagPtr->tkfont != NULL) || (textPtr->selTagPtr->justifyString != NULL) || (textPtr->selTagPtr->lMargin1String != NULL) || (textPtr->selTagPtr->lMargin2String != NULL) || (textPtr->selTagPtr->offsetString != NULL) || (textPtr->selTagPtr->rMarginString != NULL) || (textPtr->selTagPtr->spacing1String != NULL) || (textPtr->selTagPtr->spacing2String != NULL) || (textPtr->selTagPtr->spacing3String != NULL) || (textPtr->selTagPtr->tabStringPtr != NULL) || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR) || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_CHAR) || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_NONE) || (textPtr->selTagPtr->wrapMode == TEXT_WRAPMODE_WORD)) { textPtr->selTagPtr->affectsDisplay = 1; textPtr->selTagPtr->affectsDisplayGeometry = 1; } if ((textPtr->selTagPtr->border != NULL) || (textPtr->selTagPtr->selBorder != NULL) || (textPtr->selTagPtr->reliefString != NULL) || (textPtr->selTagPtr->bgStipple != None) || (textPtr->selTagPtr->fgColor != NULL) || (textPtr->selTagPtr->selFgColor != NULL) || (textPtr->selTagPtr->fgStipple != None) || (textPtr->selTagPtr->overstrike >= 0) || (textPtr->selTagPtr->overstrikeColor != NULL) || (textPtr->selTagPtr->underline >= 0) || (textPtr->selTagPtr->underlineColor != NULL) || (textPtr->selTagPtr->lMarginColor != NULL) || (textPtr->selTagPtr->rMarginColor != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); |
︙ | ︙ | |||
2632 2633 2634 2635 2636 2637 2638 | { int lineIndex; TkSizeT length; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; | | | 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 | { int lineIndex; TkSizeT length; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; const char *string = Tcl_GetStringFromObj(stringPtr, &length); if (sharedTextPtr == NULL) { sharedTextPtr = textPtr->sharedTextPtr; } /* * Don't allow insertions on the last (dummy) line of the text. This is |
︙ | ︙ | |||
2958 2959 2960 2961 2962 2963 2964 | Tcl_Interp *interp, /* Current interpreter. */ ClientData clientData, /* Passed from undo code, but contains our * shared text data structure. */ Tcl_Obj *objPtr) /* Arguments of a command to be handled by the * shared text data structure. */ { TkSharedText *sharedPtr = (TkSharedText *)clientData; | | > | 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 | Tcl_Interp *interp, /* Current interpreter. */ ClientData clientData, /* Passed from undo code, but contains our * shared text data structure. */ Tcl_Obj *objPtr) /* Arguments of a command to be handled by the * shared text data structure. */ { TkSharedText *sharedPtr = (TkSharedText *)clientData; int res; TkSizeT objc; Tcl_Obj **objv; TkText *textPtr; res = Tcl_ListObjGetElements(interp, objPtr, &objc, &objv); if (res != TCL_OK) { return res; } |
︙ | ︙ | |||
3123 3124 3125 3126 3127 3128 3129 | TkTextIndex index1, index2; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; Tcl_HashSearch search; Tcl_HashEntry *hPtr; | | | 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 | TkTextIndex index1, index2; TkText *tPtr; int *lineAndByteIndex; int resetViewCount; int pixels[2*PIXEL_CLIENTS]; Tcl_HashSearch search; Tcl_HashEntry *hPtr; TkSizeT i; if (sharedTextPtr == NULL) { sharedTextPtr = textPtr->sharedTextPtr; } /* * Prepare the starting and stopping indices. |
︙ | ︙ | |||
3169 3170 3171 3172 3173 3174 3175 | * deleted but tags might be removed. */ line1 = TkBTreeLinesTo(textPtr, index1.linePtr); line2 = TkBTreeLinesTo(textPtr, index2.linePtr); if (line2 == TkBTreeNumLines(sharedTextPtr->tree, textPtr)) { TkTextTag **arrayPtr; | | | 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 | * deleted but tags might be removed. */ line1 = TkBTreeLinesTo(textPtr, index1.linePtr); line2 = TkBTreeLinesTo(textPtr, index2.linePtr); if (line2 == TkBTreeNumLines(sharedTextPtr->tree, textPtr)) { TkTextTag **arrayPtr; TkSizeT arraySize; TkTextIndex oldIndex2; oldIndex2 = index2; TkTextIndexBackChars(NULL, &oldIndex2, 1, &index2, COUNT_INDICES); line2--; if ((index1.byteIndex == 0) && (line1 != 0)) { TkTextIndexBackChars(NULL, &index1, 1, &index1, COUNT_INDICES); |
︙ | ︙ | |||
3342 3343 3344 3345 3346 3347 3348 | */ TkTextMakeByteIndex(sharedTextPtr->tree, textPtr, line, byteIndex, &indexTmp); TkTextSetYView(tPtr, &indexTmp, 0); } } else { | | | > < < < | < < < < < | < | 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 | */ TkTextMakeByteIndex(sharedTextPtr->tree, textPtr, line, byteIndex, &indexTmp); TkTextSetYView(tPtr, &indexTmp, 0); } } else { TkTextMakeByteIndex(sharedTextPtr->tree, NULL, line, byteIndex, &indexTmp); /* * line may be before -startline of tPtr and must be * clamped to -startline before providing it to * TkTextSetYView otherwise lines before -startline * would be displayed. * There is no need to worry about -endline however, * because the view will only be reset if the deletion * involves the TOP line of the screen. That said, * the following call adjusts to both. */ TkTextIndexAdjustToStartEnd(tPtr, &indexTmp, 0); TkTextSetYView(tPtr, &indexTmp, 0); } } resetViewCount += 2; } if (sharedTextPtr->refCount > PIXEL_CLIENTS) { ckfree(lineAndByteIndex); |
︙ | ︙ | |||
3739 3740 3741 3742 3743 3744 3745 | int length = InsertChars(sharedTextPtr, textPtr, &index1, objv[j], viewUpdate); if (objc > (j+1)) { Tcl_Obj **tagNamePtrs; TkTextTag **oldTagArrayPtr; | | | | | 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 | int length = InsertChars(sharedTextPtr, textPtr, &index1, objv[j], viewUpdate); if (objc > (j+1)) { Tcl_Obj **tagNamePtrs; TkTextTag **oldTagArrayPtr; TkSizeT numTags; TkTextIndexForwBytes(textPtr, &index1, length, &index2); oldTagArrayPtr = TkBTreeGetTags(&index1, NULL, &numTags); if (oldTagArrayPtr != NULL) { TkSizeT i; for (i = 0; i < numTags; i++) { TkBTreeTag(&index1, &index2, oldTagArrayPtr[i], 0); } ckfree(oldTagArrayPtr); } if (Tcl_ListObjGetElements(interp, objv[j+1], &numTags, &tagNamePtrs) != TCL_OK) { return TCL_ERROR; } else { TkSizeT i; for (i = 0; i < numTags; i++) { const char *strTag = Tcl_GetString(tagNamePtrs[i]); TkBTreeTag(&index1, &index2, TkTextCreateTag(textPtr, strTag, NULL), 1); } |
︙ | ︙ | |||
3986 3987 3988 3989 3990 3991 3992 | /* *---------------------------------------------------------------------- * * TextSearchGetLineIndex -- * * Extract a row, text offset index position from an objPtr * | | | 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 | /* *---------------------------------------------------------------------- * * TextSearchGetLineIndex -- * * Extract a row, text offset index position from an objPtr * * This means we ignore any embedded windows/images and elided text * (unless we are searching that). * * Results: * Standard Tcl error code (with a message in the interpreter on error * conditions). * * The offset placed in offsetPosPtr is a utf-8 char* byte index for |
︙ | ︙ | |||
4058 4059 4060 4061 4062 4063 4064 | *---------------------------------------------------------------------- * * TextSearchIndexInLine -- * * Find textual index of 'byteIndex' in the searchable characters of * 'linePtr'. * | | | 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 | *---------------------------------------------------------------------- * * TextSearchIndexInLine -- * * Find textual index of 'byteIndex' in the searchable characters of * 'linePtr'. * * This means we ignore any embedded windows/images and elided text * (unless we are searching that). * * Results: * The returned index is a utf-8 char* byte index for exact searches, and * a Unicode character index for regexp searches. * * Side effects: |
︙ | ︙ | |||
4291 4292 4293 4294 4295 4296 4297 | (matchOffset + 1 >= searchSpecPtr->stopOffset + 1)) { return 0; } } /* * Calculate the character count, which may need augmenting if there are | | | 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 | (matchOffset + 1 >= searchSpecPtr->stopOffset + 1)) { return 0; } } /* * Calculate the character count, which may need augmenting if there are * embedded windows or elided text. */ if (searchSpecPtr->exact) { const char *startOfLine = Tcl_GetString(theLine); numChars = Tcl_NumUtfChars(startOfLine + matchOffset, matchLength); } else { |
︙ | ︙ | |||
4501 4502 4503 4504 4505 4506 4507 | TkTextTabArray * TkTextGetTabs( Tcl_Interp *interp, /* Used for error reporting. */ TkText *textPtr, /* Information about the text widget. */ Tcl_Obj *stringPtr) /* Description of the tab stops. See the text * manual entry for details. */ { | | | 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 | TkTextTabArray * TkTextGetTabs( Tcl_Interp *interp, /* Used for error reporting. */ TkText *textPtr, /* Information about the text widget. */ Tcl_Obj *stringPtr) /* Description of the tab stops. See the text * manual entry for details. */ { TkSizeT objc, i, count; Tcl_Obj **objv; TkTextTabArray *tabArrayPtr; TkTextTab *tabPtr; int ch; double prevStop, lastStop; /* * Map these strings to TkTextTabAlign values. |
︙ | ︙ | |||
4755 4756 4757 4758 4759 4760 4761 | } else { TkSizeT length; const char *str; if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; } | | | 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 | } else { TkSizeT length; const char *str; if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) { return TCL_ERROR; } str = Tcl_GetStringFromObj(objv[arg], &length); if (strncmp(str, "end", length) == 0) { atEnd = 1; } } if (TkTextIndexCmp(&index1, &index2) >= 0) { return TCL_OK; } |
︙ | ︙ | |||
5609 5610 5611 5612 5613 5614 5615 | if (textPtr->refCount-- <= 1) { ckfree((char *) textPtr); } return; } | | | | 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 | if (textPtr->refCount-- <= 1) { ckfree((char *) textPtr); } return; } Tcl_Preserve(textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)"); Tcl_BackgroundException(textPtr->interp, TCL_ERROR); } Tcl_Release(textPtr->interp); Tcl_DecrRefCount(textPtr->afterSyncCmd); textPtr->afterSyncCmd = NULL; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
5824 5825 5826 5827 5828 5829 5830 | /* * 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. */ | | | 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 | /* * 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 = 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 * will work fine. */ |
︙ | ︙ |
Changes to generic/tkText.h.
︙ | ︙ | |||
278 279 280 281 282 283 284 | /* * One data structure of the following type is used for each tag in a text * widget. These structures are kept in sharedTextPtr->tagTable and referred * to in other structures. */ typedef enum { | | | > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | /* * One data structure of the following type is used for each tag in a text * widget. These structures are kept in sharedTextPtr->tagTable and referred * to in other structures. */ typedef enum { TEXT_WRAPMODE_NULL = -1, TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD } TkWrapMode; MODULE_SCOPE const char *const tkTextWrapStrings[]; typedef struct TkTextTag { const char *name; /* Name of this tag. This field is actually a * pointer to the key from the entry in * sharedTextPtr->tagTable, so it needn't be * freed explicitly. For 'sel' tags this is * just a static string, so again need not be |
︙ | ︙ | |||
331 332 333 334 335 336 337 | * value specified here. */ Pixmap fgStipple; /* Stipple bitmap for text and other * foreground stuff. None means no value * specified here.*/ char *justifyString; /* -justify option string (malloc-ed). NULL * means option not specified. */ Tk_Justify justify; /* How to justify text: TK_JUSTIFY_LEFT, | | | | | < | 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | * value specified here. */ Pixmap fgStipple; /* Stipple bitmap for text and other * foreground stuff. None means no value * specified here.*/ char *justifyString; /* -justify option string (malloc-ed). NULL * means option not specified. */ Tk_Justify justify; /* How to justify text: TK_JUSTIFY_LEFT, * TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER, or TK_JUSTIFY_NULL. * Only valid if justifyString is non-NULL. */ char *lMargin1String; /* -lmargin1 option string (malloc-ed). NULL * means option not specified. */ int lMargin1; /* Left margin for first display line of each * text line, in pixels. Only valid if * lMargin1String is non-NULL. */ char *lMargin2String; /* -lmargin2 option string (malloc-ed). NULL * means option not specified. */ int lMargin2; /* Left margin for second and later display * lines of each text line, in pixels. Only * valid if lMargin2String is non-NULL. */ Tk_3DBorder lMarginColor; /* Used for drawing background in left margins. * This is used for both lmargin1 and lmargin2. * NULL means no value specified here. */ char *offsetString; /* -offset option string (malloc-ed). NULL * means option not specified. */ int offset; /* Vertical offset of text's baseline from * baseline of line. Used for superscripts and * subscripts. Only valid if offsetString is * non-NULL. */ Tcl_Obj *overstrikePtr; /* -overstrike option. NULL * means option not specified. */ int overstrike; /* > 0 means draw horizontal line through * middle of text. -1 means not specified. */ XColor *overstrikeColor; /* Color for the overstrike. NULL means same * color as foreground. */ char *rMarginString; /* -rmargin option string (malloc-ed). NULL * means option not specified. */ int rMargin; /* Right margin for text, in pixels. Only * valid if rMarginString is non-NULL. */ Tk_3DBorder rMarginColor; /* Used for drawing background in right margin. |
︙ | ︙ | |||
389 390 391 392 393 394 395 | * text line. Only valid if spacing3String is * non-NULL. */ Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not * specified. */ struct TkTextTabArray *tabArrayPtr; /* Info about tabs for tag (malloc-ed) or * NULL. Corresponds to tabString. */ | | | | | | < | | | | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | * text line. Only valid if spacing3String is * non-NULL. */ Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not * specified. */ struct TkTextTabArray *tabArrayPtr; /* Info about tabs for tag (malloc-ed) or * NULL. Corresponds to tabString. */ int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR * or TK_TEXT_TABSTYLE_NULL (if not specified). */ Tcl_Obj *underlinePtr; /* -underline option. NULL * means option not specified. */ int underline; /* > 0 means draw underline underneath * text. -1 means not specified. */ XColor *underlineColor; /* Color for the underline. NULL means same * color as foreground. */ TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * Must be TEXT_WRAPMODE_CHAR, * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or * TEXT_WRAPMODE_NULL to use wrapmode for * whole widget. */ Tcl_Obj *elidePtr; /* -elide option. NULL * means option not specified. */ int elide; /* > 0 means that data under this tag * should not be displayed. -1 means not specified. */ int affectsDisplay; /* Non-zero means that this tag affects the * way information is displayed on the screen * (so need to redisplay if tag changes). */ Tk_OptionTable optionTable; /* Token representing the configuration * specifications. */ int affectsDisplayGeometry; /* Non-zero means that this tag affects the * size with which information is displayed on |
︙ | ︙ | |||
462 463 464 465 466 467 468 | * in sync with the 'tabOptionStrings' array in the function 'TkTextGetTabs' */ typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign; /* * The following are the supported styles of tabbing, used for the -tabstyle | | | | | > > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 | * in sync with the 'tabOptionStrings' array in the function 'TkTextGetTabs' */ typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign; /* * The following are the supported styles of tabbing, used for the -tabstyle * option of the text widget. The first element is only used for tag options. */ typedef enum { TK_TEXT_TABSTYLE_NULL = -1, TK_TEXT_TABSTYLE_TABULAR, TK_TEXT_TABSTYLE_WORDPROCESSOR } TkTextTabStyle; MODULE_SCOPE const char *const tkTextTabStyleStrings[]; typedef struct TkTextTab { int location; /* Offset in pixels of this tab stop from the * left margin (lmargin2) of the text. */ TkTextTabAlign alignment; /* Where the tab stop appears relative to the * text. */ } TkTextTab; |
︙ | ︙ | |||
691 692 693 694 695 696 697 | int spacing3; /* Default extra spacing below last display * line for each text line. */ Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */ TkTextTabArray *tabArrayPtr; /* Information about tab stops (malloc'ed). * NULL means perform default tabbing * behavior. */ | | | 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 | int spacing3; /* Default extra spacing below last display * line for each text line. */ Tcl_Obj *tabOptionPtr; /* Value of -tabs option string. */ TkTextTabArray *tabArrayPtr; /* Information about tab stops (malloc'ed). * NULL means perform default tabbing * behavior. */ int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */ /* * Additional information used for displaying: */ TkWrapMode wrapMode; /* How to handle wrap-around. Must be * TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or |
︙ | ︙ | |||
1020 1021 1022 1023 1024 1025 1026 | MODULE_SCOPE TkSizeT TkBTreeEpoch(TkTextBTree tree); MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree, const TkText *textPtr, int line); MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree, const TkText *textPtr, int pixels, int *pixelOffset); MODULE_SCOPE TkTextTag **TkBTreeGetTags(const TkTextIndex *indexPtr, | | | 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 | MODULE_SCOPE TkSizeT TkBTreeEpoch(TkTextBTree tree); MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree, const TkText *textPtr, int line); MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree, const TkText *textPtr, int pixels, int *pixelOffset); MODULE_SCOPE TkTextTag **TkBTreeGetTags(const TkTextIndex *indexPtr, const TkText *textPtr, TkSizeT *numTagsPtr); MODULE_SCOPE void TkBTreeInsertChars(TkTextBTree tree, TkTextIndex *indexPtr, const char *string); MODULE_SCOPE int TkBTreeLinesTo(const TkText *textPtr, TkTextLine *linePtr); MODULE_SCOPE int TkBTreePixelsTo(const TkText *textPtr, TkTextLine *linePtr); MODULE_SCOPE void TkBTreeLinkSegment(TkTextSegment *segPtr, |
︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | MODULE_SCOPE int TkTextWindowIndex(TkText *textPtr, const char *name, TkTextIndex *indexPtr); MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); #endif /* _TKTEXT */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > | 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 | MODULE_SCOPE int TkTextWindowIndex(TkText *textPtr, const char *name, TkTextIndex *indexPtr); MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); MODULE_SCOPE int TkTextIndexAdjustToStartEnd(TkText *textPtr, TkTextIndex *indexPtr, int err); #endif /* _TKTEXT */ /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkTextBTree.c.
1 2 3 4 5 6 7 | /* * tkTextBTree.c -- * * This file contains code that manages the B-tree representation of text * for Tk's text widget and implements character and toggle segment * types. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkTextBTree.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkText.h" |
︙ | ︙ | |||
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 | linePtr->pixels[2 * pixelReference] < pixels; linePtr = linePtr->nextPtr) { if (linePtr == NULL) { Tcl_Panic("TkBTreeFindPixelLine ran out of lines"); } pixels -= linePtr->pixels[2 * pixelReference]; } if (pixelOffset != NULL && linePtr != NULL) { *pixelOffset = pixels; } return linePtr; } /* | > > > > > > > > > > > > > > > > > > > > | 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 | linePtr->pixels[2 * pixelReference] < pixels; linePtr = linePtr->nextPtr) { if (linePtr == NULL) { Tcl_Panic("TkBTreeFindPixelLine ran out of lines"); } pixels -= linePtr->pixels[2 * pixelReference]; } /* * Check for any start/end offset for this text widget. */ if (textPtr->start != NULL) { int lineBoundary = TkBTreeLinesTo(NULL, textPtr->start); if (TkBTreeLinesTo(NULL, linePtr) < lineBoundary) { linePtr = TkBTreeFindLine(tree, NULL, lineBoundary); } } if (textPtr->end != NULL) { int lineBoundary = TkBTreeLinesTo(NULL, textPtr->end); if (TkBTreeLinesTo(NULL, linePtr) > lineBoundary) { linePtr = TkBTreeFindLine(tree, NULL, lineBoundary); } } if (pixelOffset != NULL && linePtr != NULL) { *pixelOffset = pixels; } return linePtr; } /* |
︙ | ︙ | |||
1874 1875 1876 1877 1878 1879 1880 | * TkBTreePixelsTo -- * * Given a pointer to a line in a B-tree, return the numerical pixel * index of the top of that line (i.e. the result does not include the * height of the given line). * * Since the last line of text (the artificial one) has zero height by | | | 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 | * TkBTreePixelsTo -- * * Given a pointer to a line in a B-tree, return the numerical pixel * index of the top of that line (i.e. the result does not include the * height of the given line). * * Since the last line of text (the artificial one) has zero height by * definition, calling this with the last line will return the total * number of pixels in the widget. * * Results: * The result is the pixel height of the top of the given line. * * Side effects: * None. |
︙ | ︙ | |||
3337 3338 3339 3340 3341 3342 3343 | TkTextTag ** TkBTreeGetTags( const TkTextIndex *indexPtr,/* Indicates a particular position in the * B-tree. */ const TkText *textPtr, /* If non-NULL, then only return tags for this * text widget (when there are peer * widgets). */ | | | 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 | TkTextTag ** TkBTreeGetTags( const TkTextIndex *indexPtr,/* Indicates a particular position in the * B-tree. */ const TkText *textPtr, /* If non-NULL, then only return tags for this * text widget (when there are peer * widgets). */ TkSizeT *numTagsPtr) /* Store number of tags found at this * location. */ { Node *nodePtr; TkTextLine *siblingLinePtr; TkTextSegment *segPtr; TkTextLine *linePtr; int src, dst, index; |
︙ | ︙ | |||
3528 3529 3530 3531 3532 3533 3534 | index = 0; linePtr = indexPtr->linePtr; segPtr = linePtr->segPtr; while ((index + (int)segPtr->size) <= indexPtr->byteIndex) { if ((segPtr->typePtr == &tkTextToggleOnType) || (segPtr->typePtr == &tkTextToggleOffType)) { tagPtr = segPtr->body.toggle.tagPtr; | | | 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 | index = 0; linePtr = indexPtr->linePtr; segPtr = linePtr->segPtr; while ((index + (int)segPtr->size) <= indexPtr->byteIndex) { if ((segPtr->typePtr == &tkTextToggleOnType) || (segPtr->typePtr == &tkTextToggleOffType)) { tagPtr = segPtr->body.toggle.tagPtr; if (tagPtr->elide >= 0) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; infoPtr->tagCnts[tagPtr->priority]++; } } index += segPtr->size; segPtr = segPtr->nextPtr; |
︙ | ︙ | |||
3568 3569 3570 3571 3572 3573 3574 | siblingLinePtr != indexPtr->linePtr; siblingLinePtr = siblingLinePtr->nextPtr) { for (segPtr = siblingLinePtr->segPtr; segPtr != NULL; segPtr = segPtr->nextPtr) { if ((segPtr->typePtr == &tkTextToggleOnType) || (segPtr->typePtr == &tkTextToggleOffType)) { tagPtr = segPtr->body.toggle.tagPtr; | | | 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 | siblingLinePtr != indexPtr->linePtr; siblingLinePtr = siblingLinePtr->nextPtr) { for (segPtr = siblingLinePtr->segPtr; segPtr != NULL; segPtr = segPtr->nextPtr) { if ((segPtr->typePtr == &tkTextToggleOnType) || (segPtr->typePtr == &tkTextToggleOffType)) { tagPtr = segPtr->body.toggle.tagPtr; if (tagPtr->elide >= 0) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; infoPtr->tagCnts[tagPtr->priority]++; } } } } |
︙ | ︙ | |||
3592 3593 3594 3595 3596 3597 3598 | for (siblingPtr = nodePtr->parentPtr->children.nodePtr; siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) { for (summaryPtr = siblingPtr->summaryPtr; summaryPtr != NULL; summaryPtr = summaryPtr->nextPtr) { if (summaryPtr->toggleCount & 1) { tagPtr = summaryPtr->tagPtr; | | | | 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 | for (siblingPtr = nodePtr->parentPtr->children.nodePtr; siblingPtr != nodePtr; siblingPtr = siblingPtr->nextPtr) { for (summaryPtr = siblingPtr->summaryPtr; summaryPtr != NULL; summaryPtr = summaryPtr->nextPtr) { if (summaryPtr->toggleCount & 1) { tagPtr = summaryPtr->tagPtr; if (tagPtr->elide >= 0) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; infoPtr->tagCnts[tagPtr->priority] += summaryPtr->toggleCount; } } } } } /* * Now traverse from highest priority to lowest, take elided value from * first odd count (= on). */ infoPtr->elidePriority = -1; for (i = infoPtr->numTags-1; i >=0; i--) { if (infoPtr->tagCnts[i] & 1) { infoPtr->elide = infoPtr->tagPtrs[i]->elide > 0; /* * Note: i == infoPtr->tagPtrs[i]->priority */ infoPtr->elidePriority = i; break; |
︙ | ︙ |
Changes to generic/tkTextDisp.c.
1 2 3 4 5 6 7 8 | /* * tkTextDisp.c -- * * 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). * | | | < < | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * tkTextDisp.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkText.h" #ifdef _WIN32 #include "tkWinInt.h" #elif defined(__CYGWIN__) #include "tkUnixInt.h" #elif defined(MAC_OSX_TK) #include "tkMacOSXInt.h" #endif #define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin)) /* * "Calculations of line pixel heights and the size of the vertical * scrollbar." * * Given that tag, font and elide changes can happen to large numbers of * diverse chunks in a text widget containing megabytes of text, it is not |
︙ | ︙ | |||
149 150 151 152 153 154 155 | int rMargin; /* Right margin, in pixels. */ Tk_3DBorder rMarginColor; /* Color of right margin. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ int spacing3; /* Spacing below last dline in text line. */ TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be * NULL). */ | | | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | int rMargin; /* Right margin, in pixels. */ Tk_3DBorder rMarginColor; /* Color of right margin. */ int spacing1; /* Spacing above first dline in text line. */ int spacing2; /* Spacing between lines of dline. */ int spacing3; /* Spacing below last dline in text line. */ TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be * NULL). */ int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */ int underline; /* Non-zero means draw underline underneath * text. */ XColor *underlineColor; /* Foreground color for underline underneath * text. */ int elide; /* Zero means draw text, otherwise not. */ TkWrapMode wrapMode; /* How to handle wrap-around for this tag. * One of TEXT_WRAPMODE_CHAR, |
︙ | ︙ | |||
436 437 438 439 440 441 442 | } TextDInfo; /* * In TkTextDispChunk structures for character segments, the clientData field * points to one of the following structures: */ | | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | } TextDInfo; /* * In TkTextDispChunk structures for character segments, the clientData field * points to one of the following structures: */ #ifndef TK_LAYOUT_WITH_BASE_CHUNKS typedef struct CharInfo { int numBytes; /* Number of bytes to display. */ char chars[TKFLEXARRAY]; /* UTF characters to display. * Allocated as large as necessary. THIS MUST BE THE LAST * FIELD IN THE STRUCTURE. */ } CharInfo; |
︙ | ︙ | |||
773 774 775 776 777 778 779 | * information is wanted. */ { TkTextTag **tagPtrs; TkTextTag *tagPtr; StyleValues styleValues; TextStyle *stylePtr; Tcl_HashEntry *hPtr; | | > | 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 | * information is wanted. */ { TkTextTag **tagPtrs; TkTextTag *tagPtr; StyleValues styleValues; TextStyle *stylePtr; Tcl_HashEntry *hPtr; TkSizeT numTags, i; int isNew; int isSelected; XGCValues gcValues; unsigned long mask; /* * The variables below keep track of the highest-priority specification * that has occurred for each of the various fields of the StyleValues. */ |
︙ | ︙ | |||
921 922 923 924 925 926 927 | lMarginColorPrio = tagPtr->priority; } if ((tagPtr->offsetString != NULL) && (tagPtr->priority > offsetPrio)) { styleValues.offset = tagPtr->offset; offsetPrio = tagPtr->priority; } | | | | 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | lMarginColorPrio = tagPtr->priority; } if ((tagPtr->offsetString != NULL) && (tagPtr->priority > offsetPrio)) { styleValues.offset = tagPtr->offset; offsetPrio = tagPtr->priority; } if ((tagPtr->overstrike >= 0) && (tagPtr->priority > overstrikePrio)) { styleValues.overstrike = tagPtr->overstrike > 0; overstrikePrio = tagPtr->priority; if (tagPtr->overstrikeColor != NULL) { styleValues.overstrikeColor = tagPtr->overstrikeColor; } else if (fgColor != NULL) { styleValues.overstrikeColor = fgColor; } } |
︙ | ︙ | |||
961 962 963 964 965 966 967 | spacing3Prio = tagPtr->priority; } if ((tagPtr->tabStringPtr != NULL) && (tagPtr->priority > tabPrio)) { styleValues.tabArrayPtr = tagPtr->tabArrayPtr; tabPrio = tagPtr->priority; } | > | | | | | > | > | 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 | spacing3Prio = tagPtr->priority; } if ((tagPtr->tabStringPtr != NULL) && (tagPtr->priority > tabPrio)) { styleValues.tabArrayPtr = tagPtr->tabArrayPtr; tabPrio = tagPtr->priority; } if (((tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR)) && (tagPtr->priority > tabStylePrio)) { styleValues.tabStyle = tagPtr->tabStyle; tabStylePrio = tagPtr->priority; } if ((tagPtr->underline >= 0) && (tagPtr->priority > underlinePrio)) { styleValues.underline = tagPtr->underline > 0; underlinePrio = tagPtr->priority; if (tagPtr->underlineColor != NULL) { styleValues.underlineColor = tagPtr->underlineColor; } else if (fgColor != NULL) { styleValues.underlineColor = fgColor; } } if ((tagPtr->elide >= 0) && (tagPtr->priority > elidePrio)) { styleValues.elide = tagPtr->elide > 0; elidePrio = tagPtr->priority; } if (((tagPtr->wrapMode == TEXT_WRAPMODE_CHAR) || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE) || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) && (tagPtr->priority > wrapPrio)) { styleValues.wrapMode = tagPtr->wrapMode; wrapPrio = tagPtr->priority; } } if (tagPtrs != NULL) { ckfree(tagPtrs); |
︙ | ︙ | |||
1166 1167 1168 1169 1170 1171 1172 | TkTextDispChunk *tabChunkPtr; /* Pointer to the chunk containing the * previous tab stop. */ int maxBytes; /* Maximum number of bytes to include in this * chunk. */ TkTextTabArray *tabArrayPtr;/* Tab stops for line; taken from style for * the first character on line. */ | | | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 | TkTextDispChunk *tabChunkPtr; /* Pointer to the chunk containing the * previous tab stop. */ int maxBytes; /* Maximum number of bytes to include in this * chunk. */ TkTextTabArray *tabArrayPtr;/* Tab stops for line; taken from style for * the first character on line. */ int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */ int tabSize; /* Number of pixels consumed by current tab * stop. */ TkTextDispChunk *lastCharChunkPtr; /* Pointer to last chunk in display lines with * numBytes > 0. Used to drop 0-sized chunks * from the end of the line. */ TkSizeT byteOffset; |
︙ | ︙ | |||
1240 1241 1242 1243 1244 1245 1246 | /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ | | | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 | /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ if (tagPtr->elide >= 0) { info.tagCnts[tagPtr->priority]++; if (info.tagCnts[tagPtr->priority] & 1) { info.tagPtrs[tagPtr->priority] = tagPtr; } if (tagPtr->priority >= info.elidePriority) { if (segPtr->typePtr == &tkTextToggleOffType) { /* |
︙ | ︙ | |||
1266 1267 1268 1269 1270 1271 1272 | * elide will be zero, of course). */ elide = 0; while (--info.elidePriority > 0) { if (info.tagCnts[info.elidePriority] & 1) { elide = info.tagPtrs[info.elidePriority] | | | | 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 | * elide will be zero, of course). */ elide = 0; while (--info.elidePriority > 0) { if (info.tagCnts[info.elidePriority] & 1) { elide = info.tagPtrs[info.elidePriority] ->elide > 0; break; } } } else { elide = tagPtr->elide > 0; info.elidePriority = tagPtr->priority; } } } } } |
︙ | ︙ | |||
1387 1388 1389 1390 1391 1392 1393 | /* * If have we have a tag toggle, there is a chance that * invisibility state changed, so bail out. */ } else if ((segPtr->typePtr == &tkTextToggleOffType) || (segPtr->typePtr == &tkTextToggleOnType)) { | | | | 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 | /* * If have we have a tag toggle, there is a chance that * invisibility state changed, so bail out. */ } else if ((segPtr->typePtr == &tkTextToggleOffType) || (segPtr->typePtr == &tkTextToggleOnType)) { if (segPtr->body.toggle.tagPtr->elide >= 0) { elide = (segPtr->typePtr == &tkTextToggleOffType) ^ (segPtr->body.toggle.tagPtr->elide > 0); } } byteOffset = 0; segPtr = segPtr->nextPtr; if (segPtr == NULL) { |
︙ | ︙ | |||
2461 2462 2463 2464 2465 2466 2467 | y_off = dInfoPtr->y - dlPtr->y; height -= y_off; } else { y_off = 0; } #ifdef TK_NO_DOUBLE_BUFFERING | | | 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 | y_off = dInfoPtr->y - dlPtr->y; height -= y_off; } else { y_off = 0; } #ifdef TK_NO_DOUBLE_BUFFERING Tk_ClipDrawableToRect(display, pixmap, dInfoPtr->x, y + y_off, dInfoPtr->maxX - dInfoPtr->x, height); #endif /* TK_NO_DOUBLE_BUFFERING */ /* * First, clear the area of the line to the background color for the text * widget. */ |
︙ | ︙ | |||
2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 | } chunkPtr->displayProc(textPtr, chunkPtr, x, y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, display, pixmap, dlPtr->y + dlPtr->spaceAbove); } if (dInfoPtr->dLinesInvalidated) { return; } } #ifndef TK_NO_DOUBLE_BUFFERING /* * Copy the pixmap onto the screen. If this is the first or last line on * the screen then copy a piece of the line, so that it doesn't overflow * into the border area. Another special trick: copy the padding area to * the left of the line; this is because the insertion cursor sometimes * overflows onto that area and we want to get as much of the cursor as * possible. */ XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC, dInfoPtr->x, y + y_off, (unsigned) (dInfoPtr->maxX - dInfoPtr->x), (unsigned) height, dInfoPtr->x, dlPtr->y + y_off); #else | > > > > > > > | | 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 | } chunkPtr->displayProc(textPtr, chunkPtr, x, y + dlPtr->spaceAbove, dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, display, pixmap, dlPtr->y + dlPtr->spaceAbove); } if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { /* * A displayProc called in the loop above invoked a binding * that caused the widget to be deleted. Don't do anything. */ return; } if (dInfoPtr->dLinesInvalidated) { return; } } #ifndef TK_NO_DOUBLE_BUFFERING /* * Copy the pixmap onto the screen. If this is the first or last line on * the screen then copy a piece of the line, so that it doesn't overflow * into the border area. Another special trick: copy the padding area to * the left of the line; this is because the insertion cursor sometimes * overflows onto that area and we want to get as much of the cursor as * possible. */ XCopyArea(display, pixmap, Tk_WindowId(textPtr->tkwin), dInfoPtr->copyGC, dInfoPtr->x, y + y_off, (unsigned) (dInfoPtr->maxX - dInfoPtr->x), (unsigned) height, dInfoPtr->x, dlPtr->y + y_off); #else Tk_ClipDrawableToRect(display, pixmap, 0, 0, -1, -1); #endif /* TK_NO_DOUBLE_BUFFERING */ linesRedrawn++; } /* *-------------------------------------------------------------- * |
︙ | ︙ | |||
3073 3074 3075 3076 3077 3078 3079 | * Cancel any pending idle task which would try to run the command * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { int code; Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); | | | | 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 | * Cancel any pending idle task which would try to run the command * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { int code; Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); Tcl_Preserve(textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)"); Tcl_BackgroundException(textPtr->interp, TCL_ERROR); } Tcl_Release(textPtr->interp); Tcl_DecrRefCount(textPtr->afterSyncCmd); textPtr->afterSyncCmd = NULL; } /* * Fire the <<WidgetViewSync>> event since the widget view is in sync * with its internal data (actually it will be after the next trip |
︙ | ︙ | |||
4216 4217 4218 4219 4220 4221 4222 | numRedisplays++; if (tkTextDebug) { CLEAR("tk_textRedraw"); } /* * Choose a new current item if that is needed (this could cause event | | | 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 | numRedisplays++; if (tkTextDebug) { CLEAR("tk_textRedraw"); } /* * Choose a new current item if that is needed (this could cause event * handlers to be invoked, hence the refcount management and the loop, * since the handlers could conceivably necessitate yet another current * item calculation). The tkwin check is because the whole window could go * away in the Tcl_Release call. */ while (dInfoPtr->flags & REPICK_NEEDED) { textPtr->refCount++; |
︙ | ︙ | |||
4410 4411 4412 4413 4414 4415 4416 | GC fgGC, bgGC; bgGC = Tk_GCForColor(textPtr->highlightBgColorPtr, Tk_WindowId(textPtr->tkwin)); if (textPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(textPtr->highlightColorPtr, Tk_WindowId(textPtr->tkwin)); | | | | 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 | GC fgGC, bgGC; bgGC = Tk_GCForColor(textPtr->highlightBgColorPtr, Tk_WindowId(textPtr->tkwin)); if (textPtr->flags & GOT_FOCUS) { fgGC = Tk_GCForColor(textPtr->highlightColorPtr, Tk_WindowId(textPtr->tkwin)); Tk_DrawHighlightBorder(textPtr->tkwin, fgGC, bgGC, textPtr->highlightWidth, Tk_WindowId(textPtr->tkwin)); } else { Tk_DrawHighlightBorder(textPtr->tkwin, bgGC, bgGC, textPtr->highlightWidth, Tk_WindowId(textPtr->tkwin)); } } borders = textPtr->borderWidth + textPtr->highlightWidth; if (textPtr->padY > 0) { Tk_Fill3DRectangle(textPtr->tkwin, Tk_WindowId(textPtr->tkwin), textPtr->border, borders, borders, |
︙ | ︙ | |||
4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 | if (tkTextDebug) { char string[TK_POS_CHARS]; TkTextPrintIndex(textPtr, &dlPtr->index, string); LOG("tk_textRedraw", string); } DisplayDLine(textPtr, dlPtr, prevPtr, pixmap); if (dInfoPtr->dLinesInvalidated) { #ifndef TK_NO_DOUBLE_BUFFERING Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap); #endif /* TK_NO_DOUBLE_BUFFERING */ | > > > > > > > | | 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 | if (tkTextDebug) { char string[TK_POS_CHARS]; TkTextPrintIndex(textPtr, &dlPtr->index, string); LOG("tk_textRedraw", string); } DisplayDLine(textPtr, dlPtr, prevPtr, pixmap); if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)) { /* * DisplayDLine called a displayProc which invoked a binding * that caused the widget to be deleted. Don't do anything. */ goto end; } if (dInfoPtr->dLinesInvalidated) { #ifndef TK_NO_DOUBLE_BUFFERING Tk_FreePixmap(Tk_Display(textPtr->tkwin), pixmap); #endif /* TK_NO_DOUBLE_BUFFERING */ goto end; } dlPtr->oldY = dlPtr->y; dlPtr->flags &= ~(NEW_LAYOUT | OLD_Y_INVALID); #ifdef MAC_OSX_TK } else if (dlPtr->chunkPtr != NULL) { /* * On macOS we need to redisplay all embedded windows which |
︙ | ︙ | |||
4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 | rect.x = x; rect.y = y; rect.width = width; rect.height = height; TkUnionRectWithRegion(&rect, damageRgn, damageRgn); TextInvalidateRegion(textPtr, damageRgn); if (!(dInfoPtr->flags & REDRAW_PENDING)) { dInfoPtr->flags |= REDRAW_PENDING; Tcl_DoWhenIdle(DisplayText, textPtr); } | > > > > > > < | 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 | rect.x = x; rect.y = y; rect.width = width; rect.height = height; TkUnionRectWithRegion(&rect, damageRgn, damageRgn); TextInvalidateRegion(textPtr, damageRgn); TkDestroyRegion(damageRgn); /* * Schedule the redisplay operation if there isn't one already scheduled. */ if (!(dInfoPtr->flags & REDRAW_PENDING)) { dInfoPtr->flags |= REDRAW_PENDING; Tcl_DoWhenIdle(DisplayText, textPtr); } } /* *---------------------------------------------------------------------- * * TextInvalidateRegion -- * |
︙ | ︙ | |||
4775 4776 4777 4778 4779 4780 4781 | dlPtr->flags |= OLD_Y_INVALID; } } if (dInfoPtr->topOfEof < maxY) { dInfoPtr->topOfEof = maxY; } | < < < < | 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 | dlPtr->flags |= OLD_Y_INVALID; } } if (dInfoPtr->topOfEof < maxY) { dInfoPtr->topOfEof = maxY; } inset = textPtr->borderWidth + textPtr->highlightWidth; if ((rect.x < (inset + textPtr->padX)) || (rect.y < (inset + textPtr->padY)) || ((int) (rect.x + rect.width) > (Tk_Width(textPtr->tkwin) - inset - textPtr->padX)) || (maxY > (Tk_Height(textPtr->tkwin) - inset - textPtr->padY))) { dInfoPtr->flags |= REDRAW_BORDERS; |
︙ | ︙ | |||
6178 6179 6180 6181 6182 6183 6184 | /* * Next, handle the old syntax: "pathName yview ?-pickplace? where" */ pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { const char *switchStr = | | | 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 | /* * Next, handle the old syntax: "pathName yview ?-pickplace? where" */ pickPlace = 0; if (Tcl_GetString(objv[2])[0] == '-') { const char *switchStr = Tcl_GetStringFromObj(objv[2], &switchLength); if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace", (unsigned) switchLength) == 0)) { pickPlace = 1; if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "lineNum|index"); return TCL_ERROR; |
︙ | ︙ | |||
6438 6439 6440 6441 6442 6443 6444 | } else if (c=='m' && strncmp(Tcl_GetString(objv[2]), "mark", length)==0) { dInfoPtr->scanMarkXPixel = dInfoPtr->newXPixelOffset; dInfoPtr->scanMarkX = x; dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = y; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( | | | 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 | } else if (c=='m' && strncmp(Tcl_GetString(objv[2]), "mark", length)==0) { dInfoPtr->scanMarkXPixel = dInfoPtr->newXPixelOffset; dInfoPtr->scanMarkX = x; dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = y; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad scan option \"%s\": must be dragto or mark", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option", Tcl_GetString(objv[2]), NULL); return TCL_ERROR; } return TCL_OK; } |
︙ | ︙ | |||
7652 7653 7654 7655 7656 7657 7658 | p = segPtr->body.chars + byteOffset; tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; #ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (baseCharChunkPtr == NULL) { baseCharChunkPtr = chunkPtr; | | | | | 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 | p = segPtr->body.chars + byteOffset; tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; #ifdef TK_LAYOUT_WITH_BASE_CHUNKS if (baseCharChunkPtr == NULL) { baseCharChunkPtr = chunkPtr; bciPtr = (BaseCharInfo *)ckalloc(sizeof(BaseCharInfo)); baseString = &bciPtr->baseChars; Tcl_DStringInit(baseString); bciPtr->width = 0; ciPtr = &bciPtr->ci; } else { bciPtr = (BaseCharInfo *)baseCharChunkPtr->clientData; ciPtr = (CharInfo *)ckalloc(sizeof(CharInfo)); baseString = &bciPtr->baseChars; } lineOffset = Tcl_DStringLength(baseString); line = Tcl_DStringAppend(baseString,p,maxBytes); chunkPtr->clientData = ciPtr; |
︙ | ︙ | |||
7763 7764 7765 7766 7767 7768 7769 | chunkPtr->numBytes = bytesThatFit; chunkPtr->minAscent = fm.ascent + chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minDescent = fm.descent - chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minHeight = 0; chunkPtr->width = nextX - chunkPtr->x; chunkPtr->breakIndex = -1; | | | 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 | chunkPtr->numBytes = bytesThatFit; chunkPtr->minAscent = fm.ascent + chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minDescent = fm.descent - chunkPtr->stylePtr->sValuePtr->offset; chunkPtr->minHeight = 0; chunkPtr->width = nextX - chunkPtr->x; chunkPtr->breakIndex = -1; #ifndef 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 */ ciPtr->numBytes = bytesThatFit; if (p[bytesThatFit - 1] == '\n') { |
︙ | ︙ | |||
7879 7880 7881 7882 7883 7884 7885 | int *nextXPtr) /* The function puts the newly calculated * right border x-position of the span * here. */ { Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; | | | 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 | int *nextXPtr) /* The function puts the newly calculated * right border x-position of the span * here. */ { Tk_Font tkfont = chunkPtr->stylePtr->sValuePtr->tkfont; CharInfo *ciPtr = (CharInfo *)chunkPtr->clientData; #ifndef TK_LAYOUT_WITH_BASE_CHUNKS if (chars == NULL) { chars = ciPtr->chars; charsLen = ciPtr->numBytes; } if (end == -1) { end = charsLen; } |
︙ | ︙ | |||
7984 7985 7986 7987 7988 7989 7990 | * The chunk is off-screen. */ return; } #ifdef TK_DRAW_IN_CONTEXT | | | 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 | * The chunk is off-screen. */ return; } #ifdef TK_DRAW_IN_CONTEXT bciPtr = (BaseCharInfo *)ciPtr->baseChunkPtr->clientData; numBytes = Tcl_DStringLength(&bciPtr->baseChars); string = Tcl_DStringValue(&bciPtr->baseChars); #elif defined(TK_LAYOUT_WITH_BASE_CHUNKS) if (ciPtr->baseChunkPtr != chunkPtr) { /* * Without context drawing only base chunks display their foreground. |
︙ | ︙ | |||
8895 8896 8897 8898 8899 8900 8901 | #ifdef TK_DRAW_IN_CONTEXT chunkPtr->x += widthAdjust; #endif /* TK_DRAW_IN_CONTEXT */ if (chunkPtr->displayProc != CharDisplayProc) { continue; } | | | | 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 | #ifdef TK_DRAW_IN_CONTEXT chunkPtr->x += widthAdjust; #endif /* TK_DRAW_IN_CONTEXT */ if (chunkPtr->displayProc != CharDisplayProc) { continue; } ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr->baseChunkPtr != baseCharChunkPtr) { break; } ciPtr->chars = baseChars + ciPtr->baseOffset; #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; } #endif /* TK_DRAW_IN_CONTEXT */ } if (addChunkPtr != NULL) { ciPtr = (CharInfo *)addChunkPtr->clientData; ciPtr->chars = baseChars + ciPtr->baseOffset; #ifdef TK_DRAW_IN_CONTEXT addChunkPtr->x += widthAdjust; CharChunkMeasureChars(addChunkPtr, NULL, 0, 0, -1, 0, -1, 0, &addChunkPtr->width); #endif /* TK_DRAW_IN_CONTEXT */ |
︙ | ︙ | |||
8963 8964 8965 8966 8967 8968 8969 | baseCharChunkPtr = NULL; } for (chunkPtr=baseChunkPtr; chunkPtr!=NULL; chunkPtr=chunkPtr->nextPtr) { if (chunkPtr->undisplayProc != CharUndisplayProc) { continue; } | | | 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 | baseCharChunkPtr = NULL; } for (chunkPtr=baseChunkPtr; chunkPtr!=NULL; chunkPtr=chunkPtr->nextPtr) { if (chunkPtr->undisplayProc != CharUndisplayProc) { continue; } ciPtr = (CharInfo *)chunkPtr->clientData; if (ciPtr->baseChunkPtr != baseChunkPtr) { break; } ciPtr->baseChunkPtr = NULL; ciPtr->chars = NULL; } |
︙ | ︙ | |||
9013 9014 9015 9016 9017 9018 9019 | StyleValues *sv1; StyleValues *sv2; if (style1 == style2) { return 1; } | | | 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 | StyleValues *sv1; StyleValues *sv2; if (style1 == style2) { return 1; } #ifndef TK_DRAW_IN_CONTEXT if ( #ifdef MAC_OSX_TK !TkMacOSXCompareColors(style1->fgGC->foreground, style2->fgGC->foreground) #else style1->fgGC->foreground != style2->fgGC->foreground #endif |
︙ | ︙ | |||
9083 9084 9085 9086 9087 9088 9089 | return; } /* * Reinstitute this base chunk for re-layout. */ | | | | 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 | return; } /* * Reinstitute this base chunk for re-layout. */ ciPtr = (CharInfo *)chunkPtr->clientData; baseCharChunkPtr = ciPtr->baseChunkPtr; /* * Remove the chunk data from the base chunk data. */ bciPtr = (BaseCharInfo *)baseCharChunkPtr->clientData; #ifdef DEBUG_LAYOUT_WITH_BASE_CHUNKS if ((ciPtr->baseOffset + ciPtr->numBytes) != Tcl_DStringLength(&bciPtr->baseChars)) { fprintf(stderr,"RemoveFromBaseChunk called with wrong chunk " "(not last)\n"); } |
︙ | ︙ |
Changes to generic/tkTextImage.c.
1 2 3 4 5 6 | /* * tkImage.c -- * * This file contains code that allows images to be nested inside text * widgets. It also implements the "image" widget command for texts. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * 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 © 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 "tkPort.h" #include "tkText.h" |
︙ | ︙ | |||
765 766 767 768 769 770 771 | * * TkTextImageIndex -- * * Given the name of an embedded image within a text widget, returns an * index corresponding to the image's position in the text. * * Results: | | | | | | > > > > > > > > > > > | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 | * * TkTextImageIndex -- * * Given the name of an embedded image within a text widget, returns an * index corresponding to the image's position in the text. * * Results: * The return value is TCL_OK if there is an embedded image by the given * name in the text widget, TCL_ERROR otherwise. If the image exists, * *indexPtr is filled in with its index. * * Side effects: * None. * *-------------------------------------------------------------- */ int TkTextImageIndex( TkText *textPtr, /* Text widget containing image. */ const char *name, /* Name of image. */ TkTextIndex *indexPtr) /* Index information gets stored here. */ { Tcl_HashEntry *hPtr; TkTextSegment *eiPtr; if (textPtr == NULL) { return TCL_ERROR; } hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->imageTable, name); if (hPtr == NULL) { return TCL_ERROR; } eiPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr); indexPtr->tree = textPtr->sharedTextPtr->tree; indexPtr->linePtr = eiPtr->body.ei.linePtr; indexPtr->byteIndex = TkTextSegToOffset(eiPtr, indexPtr->linePtr); /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the image indeed is not * reachable from this text widget (it may be reachable from a peer). */ if (TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 1) == TCL_ERROR) { return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- * * EmbImageProc -- * |
︙ | ︙ |
Changes to generic/tkTextIndex.c.
1 2 3 4 5 6 | /* * tkTextIndex.c -- * * This module provides functions that manipulate indices for text * widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkTextIndex.c -- * * This module provides functions that manipulate indices for text * widgets. * * 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. */ #include "tkInt.h" #include "tkText.h" |
︙ | ︙ | |||
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | TkTextIndex *indexPtr); static int GetIndex(Tcl_Interp *interp, TkSharedText *sharedPtr, TkText *textPtr, const char *string, TkTextIndex *indexPtr, int *canCachePtr); static int IndexCountBytesOrdered(const TkText *textPtr, const TkTextIndex *indexPtr1, const TkTextIndex *indexPtr2); /* * The "textindex" Tcl_Obj definition: */ static void DupTextIndexInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); | > > > > > > > > | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | TkTextIndex *indexPtr); static int GetIndex(Tcl_Interp *interp, TkSharedText *sharedPtr, TkText *textPtr, const char *string, TkTextIndex *indexPtr, int *canCachePtr); static int IndexCountBytesOrdered(const TkText *textPtr, const TkTextIndex *indexPtr1, const TkTextIndex *indexPtr2); #if defined(USE_TCL_STUBS) && (TCL_MAJOR_VERSION < 9) # undef Tcl_UtfPrev # define Tcl_UtfPrev (((&tclStubsPtr->tcl_PkgProvideEx)[631]) ? \ ((const char * (*)(const char *, const char *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[656])) \ : ((const char * (*)(const char *, const char *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[331]))) #endif /* * The "textindex" Tcl_Obj definition: */ static void DupTextIndexInternalRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr); |
︙ | ︙ | |||
432 433 434 435 436 437 438 | * Prevent UTF-8 character from being split up by ensuring * that byteIndex falls on a character boundary. If the index * falls in the middle of a UTF-8 character, it will be * adjusted to the end of that UTF-8 character. */ start = segPtr->body.chars + (byteIndex - index); | | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | * Prevent UTF-8 character from being split up by ensuring * that byteIndex falls on a character boundary. If the index * falls in the middle of a UTF-8 character, it will be * adjusted to the end of that UTF-8 character. */ start = segPtr->body.chars + (byteIndex - index); p = Tcl_UtfPrev(start, segPtr->body.chars); p += TkUtfToUniChar(p, &ch); indexPtr->byteIndex += p - start; } break; } index += segPtr->size; } |
︙ | ︙ | |||
476 477 478 479 480 481 482 | * of text). */ int charIndex, /* Index of desired character. */ TkTextIndex *indexPtr) /* Structure to fill in. */ { TkTextSegment *segPtr; char *p, *start, *end; int index, offset; | | | 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | * of text). */ int charIndex, /* Index of desired character. */ TkTextIndex *indexPtr) /* Structure to fill in. */ { TkTextSegment *segPtr; char *p, *start, *end; int index, offset; Tcl_UniChar ch = 0; indexPtr->tree = tree; if (lineIndex < 0) { lineIndex = 0; charIndex = 0; } if (charIndex < 0) { |
︙ | ︙ | |||
523 524 525 526 527 528 529 | end = start + segPtr->size; for (p = start; p < end; p += offset) { if (charIndex == 0) { indexPtr->byteIndex = index; return indexPtr; } charIndex--; | | | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | end = start + segPtr->size; for (p = start; p < end; p += offset) { if (charIndex == 0) { indexPtr->byteIndex = index; return indexPtr; } charIndex--; offset = Tcl_UtfToUniChar(p, &ch); index += offset; } } else { if (charIndex < (int)segPtr->size) { indexPtr->byteIndex = index; break; } |
︙ | ︙ | |||
757 758 759 760 761 762 763 | *--------------------------------------------------------------------- */ if (TkTextMarkNameToIndex(textPtr, string, indexPtr) == TCL_OK) { goto done; } | | | | 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | *--------------------------------------------------------------------- */ if (TkTextMarkNameToIndex(textPtr, string, indexPtr) == TCL_OK) { goto done; } if (TkTextWindowIndex(textPtr, string, indexPtr) == TCL_OK) { goto done; } if (TkTextImageIndex(textPtr, string, indexPtr) == TCL_OK) { goto done; } /* *------------------------------------------------ * Stage 2: start again by parsing the base index. *------------------------------------------------ |
︙ | ︙ | |||
913 914 915 916 917 918 919 | * See if the base position is the name of an embedded window. */ c = *endOfBase; *endOfBase = 0; result = TkTextWindowIndex(textPtr, Tcl_DStringValue(©), indexPtr); *endOfBase = c; | | | 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 | * See if the base position is the name of an embedded window. */ c = *endOfBase; *endOfBase = 0; result = TkTextWindowIndex(textPtr, Tcl_DStringValue(©), indexPtr); *endOfBase = c; if (result == TCL_OK) { goto gotBase; } } if ((string[0] == 'e') && (strncmp(string, "end", endOfBase-Tcl_DStringValue(©)) == 0)) { /* |
︙ | ︙ | |||
950 951 952 953 954 955 956 | * See if the base position is the name of an embedded image. */ c = *endOfBase; *endOfBase = 0; result = TkTextImageIndex(textPtr, Tcl_DStringValue(©), indexPtr); *endOfBase = c; | | | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | * See if the base position is the name of an embedded image. */ c = *endOfBase; *endOfBase = 0; result = TkTextImageIndex(textPtr, Tcl_DStringValue(©), indexPtr); *endOfBase = c; if (result == TCL_OK) { goto gotBase; } } goto error; /* *------------------------------------------------------------------- |
︙ | ︙ | |||
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | done: if (canCachePtr != NULL) { *canCachePtr = canCache; } if (indexPtr->linePtr == NULL) { Tcl_Panic("Bad index created"); } return TCL_OK; error: Tcl_DStringFree(©); Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad text index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", NULL); return TCL_ERROR; } /* *--------------------------------------------------------------------------- * * TkTextPrintIndex -- * * This function generates a string description of an index, suitable for | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 | done: if (canCachePtr != NULL) { *canCachePtr = canCache; } if (indexPtr->linePtr == NULL) { Tcl_Panic("Bad index created"); } TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 0); return TCL_OK; error: Tcl_DStringFree(©); Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad text index \"%s\"", string)); Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", NULL); return TCL_ERROR; } /* *--------------------------------------------------------------------------- * * TkTextIndexAdjustToStartEnd -- * * Adjust indexPtr to the -startline/-endline range, or just check * if indexPtr is out of this range. * * Results: * The return value is a standard Tcl return result. If check is true, * return TCL_ERROR if indexPtr is outside the -startline/-endline * range (indexPtr is not modified). * If check is false, adjust indexPtr to -startline/-endline. * * Side effects: * None. * *--------------------------------------------------------------------------- */ int TkTextIndexAdjustToStartEnd( TkText *textPtr, TkTextIndex *indexPtr, /* Pointer to index. */ int check) /* 1 means only check indexPtr against * the -startline/-endline range * 0 means adjust to this range */ { int bound; TkTextIndex indexBound; if (!textPtr) { return TCL_OK; } if (textPtr->start != NULL) { bound = TkBTreeLinesTo(NULL, textPtr->start); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0, &indexBound); if (TkTextIndexCmp(indexPtr, &indexBound) < 0) { if (check) { return TCL_ERROR; } TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0, indexPtr); } } if (textPtr->end != NULL) { bound = TkBTreeLinesTo(NULL, textPtr->end); TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0, &indexBound); if (TkTextIndexCmp(indexPtr, &indexBound) > 0) { if (check) { return TCL_ERROR; } TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, bound, 0, indexPtr); } } return TCL_OK; } /* *--------------------------------------------------------------------------- * * TkTextPrintIndex -- * * This function generates a string description of an index, suitable for |
︙ | ︙ | |||
1541 1542 1543 1544 1545 1546 1547 | /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ | | | 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 | /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ if (tagPtr->elide >= 0) { infoPtr->tagCnts[tagPtr->priority]++; if (infoPtr->tagCnts[tagPtr->priority] & 1) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; } if (tagPtr->priority >= infoPtr->elidePriority) { if (segPtr->typePtr == &tkTextToggleOffType) { |
︙ | ︙ | |||
1569 1570 1571 1572 1573 1574 1575 | */ elide = 0; while (--infoPtr->elidePriority > 0) { if (infoPtr->tagCnts[infoPtr->elidePriority] & 1) { elide = infoPtr->tagPtrs | | | | 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 | */ elide = 0; while (--infoPtr->elidePriority > 0) { if (infoPtr->tagCnts[infoPtr->elidePriority] & 1) { elide = infoPtr->tagPtrs [infoPtr->elidePriority]->elide > 0; break; } } } else { elide = tagPtr->elide > 0; infoPtr->elidePriority = tagPtr->priority; } } } } if (!elide) { |
︙ | ︙ | |||
1791 1792 1793 1794 1795 1796 1797 | /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ | | | 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 | /* * The elide state only changes if this tag is either the * current highest priority tag (and is therefore being * toggled off), or it's a new tag with higher priority. */ if (tagPtr->elide >= 0) { infoPtr->tagCnts[tagPtr->priority]++; if (infoPtr->tagCnts[tagPtr->priority] & 1) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; } if (tagPtr->priority >= infoPtr->elidePriority) { if (segPtr->typePtr == &tkTextToggleOffType) { /* |
︙ | ︙ | |||
1819 1820 1821 1822 1823 1824 1825 | */ elide = 0; while (--infoPtr->elidePriority > 0) { if (infoPtr->tagCnts[ infoPtr->elidePriority] & 1) { elide = infoPtr->tagPtrs[ | | | | 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 | */ elide = 0; while (--infoPtr->elidePriority > 0) { if (infoPtr->tagCnts[ infoPtr->elidePriority] & 1) { elide = infoPtr->tagPtrs[ infoPtr->elidePriority]->elide > 0; break; } } } else { elide = tagPtr->elide > 0; infoPtr->elidePriority = tagPtr->priority; } } } } if (elide) { if (segPtr == seg2Ptr) { |
︙ | ︙ | |||
2080 2081 2082 2083 2084 2085 2086 | /* * The elide state only changes if this tag is either the current * highest priority tag (and is therefore being toggled off), or * it's a new tag with higher priority. */ | | | 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 | /* * The elide state only changes if this tag is either the current * highest priority tag (and is therefore being toggled off), or * it's a new tag with higher priority. */ if (tagPtr->elide >= 0) { infoPtr->tagCnts[tagPtr->priority]++; if (infoPtr->tagCnts[tagPtr->priority] & 1) { infoPtr->tagPtrs[tagPtr->priority] = tagPtr; } if (tagPtr->priority >= infoPtr->elidePriority) { if (segPtr->typePtr == &tkTextToggleOnType) { /* |
︙ | ︙ | |||
2106 2107 2108 2109 2110 2111 2112 | * will be zero, of course). */ elide = 0; while (--infoPtr->elidePriority > 0) { if (infoPtr->tagCnts[infoPtr->elidePriority] & 1) { elide = infoPtr->tagPtrs[ | | | | > > > > | > | 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 | * will be zero, of course). */ elide = 0; while (--infoPtr->elidePriority > 0) { if (infoPtr->tagCnts[infoPtr->elidePriority] & 1) { elide = infoPtr->tagPtrs[ infoPtr->elidePriority]->elide > 0; break; } } } else { elide = tagPtr->elide > 0; infoPtr->elidePriority = tagPtr->priority; } } } } if (!elide) { if (segPtr->typePtr == &tkTextCharType) { start = segPtr->body.chars; end = segPtr->body.chars + segSize; for (p = end; ; p = Tcl_UtfPrev(p, start)) { if (charCount == 0) { dstPtr->byteIndex -= (end - p); goto backwardCharDone; } if (p == start) { break; } if ((sizeof(Tcl_UniChar) == 2) && (unsigned)(UCHAR(*p) - 0xF0) <= 5) { charCount--; /* Characters > U+FFFF count as 2 here */ } if (charCount != 0) { charCount--; } } } else { if (type & COUNT_INDICES) { if (charCount <= segSize) { dstPtr->byteIndex -= charCount; goto backwardCharDone; } |
︙ | ︙ | |||
2363 2364 2365 2366 2367 2368 2369 | int ch; TkUtfToUniChar(segPtr->body.chars + offset, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; } if (offset + 1 > 1) { chSize = (segPtr->body.chars + offset | | | | | | | | | | | | | | | 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 | int ch; TkUtfToUniChar(segPtr->body.chars + offset, &ch); if (!Tcl_UniCharIsWordChar(ch)) { break; } if (offset + 1 > 1) { chSize = (segPtr->body.chars + offset - Tcl_UtfPrev(segPtr->body.chars + offset, segPtr->body.chars)); } firstChar = 0; } if (offset == 0) { if (modifier == TKINDEX_DISPLAY) { TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr, COUNT_DISPLAY_INDICES); } else { TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES); } } else { indexPtr->byteIndex -= chSize; } offset -= chSize; if ((int)offset < 0) { if (indexPtr->byteIndex == 0) { goto done; } segPtr = TkTextIndexToSeg(indexPtr, &offset); } } |
︙ | ︙ |
Changes to generic/tkTextMark.c.
1 2 3 4 5 6 | /* * tkTextMark.c -- * * This file contains the functions that implement marks for text * widgets. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkTextMark.c -- * * This file contains the functions that implement marks for text * widgets. * * 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. */ #include "tkInt.h" #include "tkText.h" |
︙ | ︙ | |||
129 130 131 132 133 134 135 | TkSizeT length; const char *str; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?"); return TCL_ERROR; } | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | TkSizeT length; const char *str; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?"); return TCL_ERROR; } 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 { hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->markTable, str); if (hPtr == NULL) { |
︙ | ︙ | |||
156 157 158 159 160 161 162 | typeStr = "right"; } else { typeStr = "left"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1)); return TCL_OK; } | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | typeStr = "right"; } else { typeStr = "left"; } Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1)); return TCL_OK; } 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)) { newTypePtr = &tkTextRightMarkType; } else { |
︙ | ︙ | |||
430 431 432 433 434 435 436 | int TkTextMarkNameToIndex( TkText *textPtr, /* Text widget containing mark. */ const char *name, /* Name of mark. */ TkTextIndex *indexPtr) /* Index information gets stored here. */ { TkTextSegment *segPtr; | < < > | < < < < | | | | < < < < < < < < | 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | int TkTextMarkNameToIndex( TkText *textPtr, /* Text widget containing mark. */ const char *name, /* Name of mark. */ TkTextIndex *indexPtr) /* Index information gets stored here. */ { TkTextSegment *segPtr; if (textPtr == NULL) { return TCL_ERROR; } if (!strcmp(name, "insert")) { segPtr = textPtr->insertMarkPtr; } else if (!strcmp(name, "current")) { segPtr = textPtr->currentMarkPtr; } else { Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->markTable, name); if (hPtr == NULL) { return TCL_ERROR; } segPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr); } TkTextMarkSegToIndex(textPtr, segPtr, indexPtr); /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the mark indeed is not * reachable from this text widget (it may be reachable from a peer) * (bug 1630271). */ if (TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 1) == TCL_ERROR) { return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- * * MarkDeleteProc -- |
︙ | ︙ |
Changes to generic/tkTextTag.c.
1 2 3 4 5 6 7 | /* * tkTextTag.c -- * * This module implements the "tag" subcommand of the widget command for * text widgets, plus most of the other high-level functions related to * tags. * | | | < < < < < < < < < < < < < < < < < < < < < < | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | /* * tkTextTag.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkText.h" #include "default.h" static const Tk_OptionSpec tagOptionSpecs[] = { {TK_OPTION_BORDER, "-background", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-bgstipple", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_PIXELS, "-borderwidth", NULL, NULL, NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-elide", NULL, NULL, NULL, offsetof(TkTextTag, elidePtr), offsetof(TkTextTag, elide), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BITMAP, "-fgstipple", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_FONT, "-font", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-foreground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-justify", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, justifyString), TK_OPTION_NULL_OK, 0,0}, {TK_OPTION_STRING, "-lmargin1", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-lmargin2", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_BORDER, "-lmargincolor", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-offset", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BOOLEAN, "-overstrike", NULL, NULL, NULL, offsetof(TkTextTag, overstrikePtr), offsetof(TkTextTag, overstrike), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-overstrikefg", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-relief", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-rmargin", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0}, {TK_OPTION_BORDER, "-rmargincolor", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_BORDER, "-selectbackground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-selectforeground", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING, "-spacing1", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-spacing2", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing2String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-spacing3", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-tabs", NULL, NULL, NULL, offsetof(TkTextTag, tabStringPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-tabstyle", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tabStyle), TK_OPTION_NULL_OK, tkTextTabStyleStrings, 0}, {TK_OPTION_BOOLEAN, "-underline", NULL, NULL, NULL, offsetof(TkTextTag, underlinePtr), offsetof(TkTextTag, underline), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_COLOR, "-underlinefg", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineColor), TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL, NULL, TCL_INDEX_NONE, offsetof(TkTextTag, wrapMode), TK_OPTION_NULL_OK|TK_OPTION_ENUM_VAR, tkTextWrapStrings, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0} }; /* * Forward declarations for functions defined later in this file: */ |
︙ | ︙ | |||
149 150 151 152 153 154 155 | "nextrange", "prevrange", "raise", "ranges", "remove", NULL }; enum tagOptions { TAG_ADD, TAG_BIND, TAG_CGET, TAG_CONFIGURE, TAG_DELETE, TAG_LOWER, TAG_NAMES, TAG_NEXTRANGE, TAG_PREVRANGE, TAG_RAISE, TAG_RANGES, TAG_REMOVE }; | | > | 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | "nextrange", "prevrange", "raise", "ranges", "remove", NULL }; enum tagOptions { TAG_ADD, TAG_BIND, TAG_CGET, TAG_CONFIGURE, TAG_DELETE, TAG_LOWER, TAG_NAMES, TAG_NEXTRANGE, TAG_PREVRANGE, TAG_RAISE, TAG_RANGES, TAG_REMOVE }; int optionIndex; TkSizeT i; TkTextTag *tagPtr; TkTextIndex index1, index2; if (objc < 3) { Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?"); return TCL_ERROR; } |
︙ | ︙ | |||
179 180 181 182 183 184 185 | } if (objc < 5) { Tcl_WrongNumArgs(interp, 3, objv, "tagName index1 ?index2 index1 index2 ...?"); return TCL_ERROR; } tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), NULL); | | | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | } if (objc < 5) { Tcl_WrongNumArgs(interp, 3, objv, "tagName index1 ?index2 index1 index2 ...?"); return TCL_ERROR; } tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), NULL); if (tagPtr->elide > 0) { /* * Indices are potentially obsolete after adding or removing * elided character ranges, especially indices having "display" * or "any" submodifier, therefore increase the epoch. */ textPtr->sharedTextPtr->stateEpoch++; } for (i = 4; i < (TkSizeT)objc; i += 2) { if (TkTextGetObjIndex(interp, textPtr, objv[i], &index1) != TCL_OK) { return TCL_ERROR; } if ((TkSizeT)objc > (i+1)) { if (TkTextGetObjIndex(interp, textPtr, objv[i+1], &index2) != TCL_OK) { return TCL_ERROR; } if (TkTextIndexCmp(&index1, &index2) >= 0) { return TCL_OK; } |
︙ | ︙ | |||
275 276 277 278 279 280 281 | int append = 0; unsigned long mask; const char *fifth = Tcl_GetString(objv[5]); if (fifth[0] == 0) { return Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable, | | | | | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | int append = 0; unsigned long mask; const char *fifth = Tcl_GetString(objv[5]); if (fifth[0] == 0) { return Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable, (void *) tagPtr->name, Tcl_GetString(objv[4])); } if (fifth[0] == '+') { fifth++; append = 1; } mask = Tk_CreateBinding(interp, textPtr->sharedTextPtr->bindingTable, (void *) tagPtr->name, Tcl_GetString(objv[4]), fifth, append); if (mask == 0) { return TCL_ERROR; } if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) { Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable, (void *) tagPtr->name, Tcl_GetString(objv[4])); Tcl_SetObjResult(interp, Tcl_NewStringObj( "requested illegal events; only key, button, motion," " enter, leave, and virtual events may be used", -1)); Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT",NULL); return TCL_ERROR; } } else if (objc == 5) { const char *command; command = Tk_GetBinding(interp, textPtr->sharedTextPtr->bindingTable, (void *) tagPtr->name, Tcl_GetString(objv[4])); if (command == NULL) { const char *string = Tcl_GetString(Tcl_GetObjResult(interp)); /* * Ignore missing binding errors. This is a special hack that * relies on the error message returned by FindSequence in * tkBind.c. */ if (string[0] != '\0') { return TCL_ERROR; } Tcl_ResetResult(interp); } else { Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1)); } } else { Tk_GetAllBindings(interp, textPtr->sharedTextPtr->bindingTable, (void *) tagPtr->name); } break; case TAG_CGET: if (objc != 5) { Tcl_WrongNumArgs(interp, 1, objv, "tag cget tagName option"); return TCL_ERROR; } else { |
︙ | ︙ | |||
414 415 416 417 418 419 420 | } } if (tagPtr->offsetString != NULL) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->offsetString, &tagPtr->offset) != TCL_OK) { return TCL_ERROR; } | < < < < < < | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | } } if (tagPtr->offsetString != NULL) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->offsetString, &tagPtr->offset) != TCL_OK) { return TCL_ERROR; } } if (tagPtr->rMarginString != NULL) { if (Tk_GetPixels(interp, textPtr->tkwin, tagPtr->rMarginString, &tagPtr->rMargin) != TCL_OK) { return TCL_ERROR; } } |
︙ | ︙ | |||
465 466 467 468 469 470 471 | if (tagPtr->tabStringPtr != NULL) { tagPtr->tabArrayPtr = TkTextGetTabs(interp, textPtr, tagPtr->tabStringPtr); if (tagPtr->tabArrayPtr == NULL) { return TCL_ERROR; } } | < < < < < < | < < < < < | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | if (tagPtr->tabStringPtr != NULL) { tagPtr->tabArrayPtr = TkTextGetTabs(interp, textPtr, tagPtr->tabStringPtr); if (tagPtr->tabArrayPtr == NULL) { return TCL_ERROR; } } if (tagPtr->elide >= 0) { /* * Indices are potentially obsolete after changing -elide, * especially those computed with "display" or "any" * submodifier, therefore increase the epoch. */ textPtr->sharedTextPtr->stateEpoch++; |
︙ | ︙ | |||
511 512 513 514 515 516 517 | } else { textPtr->selFgColorPtr = tagPtr->selFgColor; } } tagPtr->affectsDisplay = 0; tagPtr->affectsDisplayGeometry = 0; | | | > | > > | | | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | } else { textPtr->selFgColorPtr = tagPtr->selFgColor; } } tagPtr->affectsDisplay = 0; tagPtr->affectsDisplayGeometry = 0; if ((tagPtr->elide >= 0) || (tagPtr->tkfont != NULL) || (tagPtr->justifyString != NULL) || (tagPtr->lMargin1String != NULL) || (tagPtr->lMargin2String != NULL) || (tagPtr->offsetString != NULL) || (tagPtr->rMarginString != NULL) || (tagPtr->spacing1String != NULL) || (tagPtr->spacing2String != NULL) || (tagPtr->spacing3String != NULL) || (tagPtr->tabStringPtr != NULL) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR) || (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR) || (tagPtr->wrapMode == TEXT_WRAPMODE_CHAR) || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE) || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) { tagPtr->affectsDisplay = 1; tagPtr->affectsDisplayGeometry = 1; } if ((tagPtr->border != NULL) || (tagPtr->selBorder != NULL) || (tagPtr->reliefString != NULL) || (tagPtr->bgStipple != None) || (tagPtr->fgColor != NULL) || (tagPtr->selFgColor != NULL) || (tagPtr->fgStipple != None) || (tagPtr->overstrike >= 0) || (tagPtr->overstrikeColor != NULL) || (tagPtr->underline >= 0) || (tagPtr->underlineColor != NULL) || (tagPtr->lMarginColor != NULL) || (tagPtr->rMarginColor != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { /* |
︙ | ︙ | |||
568 569 570 571 572 573 574 | case TAG_DELETE: { Tcl_HashEntry *hPtr; if (objc < 4) { Tcl_WrongNumArgs(interp, 3, objv, "tagName ?tagName ...?"); return TCL_ERROR; } | | | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 | case TAG_DELETE: { Tcl_HashEntry *hPtr; if (objc < 4) { Tcl_WrongNumArgs(interp, 3, objv, "tagName ?tagName ...?"); return TCL_ERROR; } for (i = 3; i < (TkSizeT)objc; i++) { hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable, Tcl_GetString(objv[i])); if (hPtr == NULL) { /* * Either this tag doesn't exist or it's the 'sel' tag (which * is not in the hash table). Either way we don't want to * delete it. |
︙ | ︙ | |||
630 631 632 633 634 635 636 | */ TkTextRedrawTag(textPtr->sharedTextPtr, NULL, NULL, NULL, tagPtr, 1); break; } case TAG_NAMES: { TkTextTag **arrayPtr; | | | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 | */ TkTextRedrawTag(textPtr->sharedTextPtr, NULL, NULL, NULL, tagPtr, 1); break; } case TAG_NAMES: { TkTextTag **arrayPtr; TkSizeT arraySize; Tcl_Obj *listObj; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 3, objv, "?index?"); return TCL_ERROR; } if (objc == 3) { |
︙ | ︙ | |||
1031 1032 1033 1034 1035 1036 1037 | tagPtr->reliefString = NULL; tagPtr->relief = TK_RELIEF_FLAT; tagPtr->bgStipple = None; tagPtr->fgColor = NULL; tagPtr->tkfont = NULL; tagPtr->fgStipple = None; tagPtr->justifyString = NULL; | | | | | | | | | | 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 | tagPtr->reliefString = NULL; tagPtr->relief = TK_RELIEF_FLAT; tagPtr->bgStipple = None; tagPtr->fgColor = NULL; tagPtr->tkfont = NULL; tagPtr->fgStipple = None; tagPtr->justifyString = NULL; tagPtr->justify = TK_JUSTIFY_NULL; tagPtr->lMargin1String = NULL; tagPtr->lMargin1 = 0; tagPtr->lMargin2String = NULL; tagPtr->lMargin2 = 0; tagPtr->lMarginColor = NULL; tagPtr->offsetString = NULL; tagPtr->offset = 0; tagPtr->overstrikePtr = NULL; tagPtr->overstrike = -1; tagPtr->overstrikeColor = NULL; tagPtr->rMarginString = NULL; tagPtr->rMargin = 0; tagPtr->rMarginColor = NULL; tagPtr->selBorder = NULL; tagPtr->selFgColor = NULL; tagPtr->spacing1String = NULL; tagPtr->spacing1 = 0; tagPtr->spacing2String = NULL; tagPtr->spacing2 = 0; tagPtr->spacing3String = NULL; tagPtr->spacing3 = 0; tagPtr->tabStringPtr = NULL; tagPtr->tabArrayPtr = NULL; tagPtr->tabStyle = TK_TEXT_TABSTYLE_NULL; tagPtr->underlinePtr = NULL; tagPtr->underline = -1; tagPtr->underlineColor = NULL; tagPtr->elidePtr = NULL; tagPtr->elide = -1; tagPtr->wrapMode = TEXT_WRAPMODE_NULL; tagPtr->affectsDisplay = 0; tagPtr->affectsDisplayGeometry = 0; textPtr->sharedTextPtr->numTags++; if (!strcmp(tagName, "sel")) { tagPtr->textPtr = textPtr; textPtr->refCount++; |
︙ | ︙ | |||
1107 1108 1109 1110 1111 1112 1113 | TkText *textPtr, /* Widget in which tag is being used. */ Tcl_Obj *tagName) /* Name of desired tag. */ { Tcl_HashEntry *hPtr; TkSizeT len; const char *str; | | | 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 | TkText *textPtr, /* Widget in which tag is being used. */ Tcl_Obj *tagName) /* Name of desired tag. */ { Tcl_HashEntry *hPtr; TkSizeT len; const char *str; str = Tcl_GetStringFromObj(tagName, &len); if (len == 3 && !strcmp(str, "sel")) { return textPtr->selTagPtr; } hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->tagTable, Tcl_GetString(tagName)); if (hPtr != NULL) { return (TkTextTag *)Tcl_GetHashValue(hPtr); |
︙ | ︙ | |||
1179 1180 1181 1182 1183 1184 1185 | * Since all peer widgets have an independent "sel" tag, we * don't want removal of one sel tag to remove bindings which * are still valid in other peer widgets. */ if (textPtr->sharedTextPtr->bindingTable != NULL) { Tk_DeleteAllBindings(textPtr->sharedTextPtr->bindingTable, | | | 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 | * Since all peer widgets have an independent "sel" tag, we * don't want removal of one sel tag to remove bindings which * are still valid in other peer widgets. */ if (textPtr->sharedTextPtr->bindingTable != NULL) { Tk_DeleteAllBindings(textPtr->sharedTextPtr->bindingTable, (void *) tagPtr->name); } } /* * Update the tag priorities to reflect the deletion of this tag. */ |
︙ | ︙ | |||
1477 1478 1479 1480 1481 1482 1483 | if (eventPtr->xmotion.state & ALL_BUTTONS) { textPtr->flags |= BUTTON_DOWN; } else { textPtr->flags &= ~BUTTON_DOWN; } TkTextPickCurrent(textPtr, eventPtr); } | | | > > > > > | > > > > > > > > > > > > > > > | 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 | if (eventPtr->xmotion.state & ALL_BUTTONS) { textPtr->flags |= BUTTON_DOWN; } else { textPtr->flags &= ~BUTTON_DOWN; } TkTextPickCurrent(textPtr, eventPtr); } if ((textPtr->sharedTextPtr->bindingTable != NULL) && (textPtr->tkwin != NULL) && !(textPtr->flags & DESTROYED)) { if (textPtr->numCurTags > 0) { /* * The mouse is inside the text widget, the 'current' mark was updated. */ TagBindEvent(textPtr, eventPtr, textPtr->numCurTags, textPtr->curTagArrayPtr); } else if ((eventPtr->type == KeyPress) || (eventPtr->type == KeyRelease)) { /* * Key events fire independently of the 'current' mark and use the * 'insert' mark. */ TkTextIndex index; TkTextTag** tagArrayPtr; TkSizeT numTags; TkTextMarkNameToIndex(textPtr, "insert", &index); tagArrayPtr = TkBTreeGetTags(&index, textPtr, &numTags); SortTags(numTags, tagArrayPtr); TagBindEvent(textPtr, eventPtr, numTags, tagArrayPtr); } } if (repick) { unsigned int oldState; oldState = eventPtr->xbutton.state; eventPtr->xbutton.state &= ~(unsigned long)ALL_BUTTONS; if (!(textPtr->flags & DESTROYED)) { |
︙ | ︙ | |||
1536 1537 1538 1539 1540 1541 1542 | * ButtonRelease, or MotionNotify. */ { TkTextIndex index; TkTextTag **oldArrayPtr, **newArrayPtr; TkTextTag **copyArrayPtr = NULL; /* Initialization needed to prevent compiler * warning. */ | | > | 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 | * ButtonRelease, or MotionNotify. */ { TkTextIndex index; TkTextTag **oldArrayPtr, **newArrayPtr; TkTextTag **copyArrayPtr = NULL; /* Initialization needed to prevent compiler * warning. */ int numOldTags, i, nearby; TkSizeT numNewTags, j; size_t size; XEvent event; /* * If a button is down, then don't do anything at all; we'll be called * again when all buttons are up, and we can repick then. This implements * a form of mouse grabbing. |
︙ | ︙ |
Changes to generic/tkTextWind.c.
1 2 3 4 5 6 7 | /* * tkTextWind.c -- * * This file contains code that allows arbitrary windows to be nested * inside text widgets. It also implements the "window" widget command * for texts. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkTextWind.c -- * * This file contains code that allows arbitrary windows to be nested * inside text widgets. It also implements the "window" widget command * for texts. * * 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. */ #include "tkPort.h" #include "tkText.h" |
︙ | ︙ | |||
522 523 524 525 526 527 528 | static void EmbWinStructureProc( ClientData clientData, /* Pointer to record describing window item. */ XEvent *eventPtr) /* Describes what just happened. */ { TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData; TkTextSegment *ewPtr = client->parent; | < < < < < | < | 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 | static void EmbWinStructureProc( ClientData clientData, /* Pointer to record describing window item. */ XEvent *eventPtr) /* Describes what just happened. */ { TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData; TkTextSegment *ewPtr = client->parent; Tcl_HashEntry *hPtr; if (eventPtr->type != DestroyNotify) { return; } hPtr = Tcl_FindHashEntry(&ewPtr->body.ew.sharedTextPtr->windowTable, Tk_PathName(client->tkwin)); if (hPtr != NULL) { /* * This may not exist if the entire widget is being deleted. */ Tcl_DeleteHashEntry(hPtr); } ewPtr->body.ew.tkwin = NULL; client->tkwin = NULL; EmbWinRequestProc(client, NULL); } /* *-------------------------------------------------------------- * * EmbWinRequestProc -- * |
︙ | ︙ | |||
570 571 572 573 574 575 576 | * *-------------------------------------------------------------- */ static void EmbWinRequestProc( ClientData clientData, /* Pointer to record for window item. */ | | > > > > > > > > | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | * *-------------------------------------------------------------- */ static void EmbWinRequestProc( ClientData clientData, /* Pointer to record for window item. */ TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */ { TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData; TkTextSegment *ewPtr = client->parent; TkTextIndex index; index.tree = ewPtr->body.ew.sharedTextPtr->tree; index.linePtr = ewPtr->body.ew.linePtr; /* * ewPtr->body.ew.tkwin == NULL means the embedded window is already * destroyed. The ewPtr segment is no longer linked, TkTextSegToOffset * cannot find it within the line pointed by ewPtr->body.ew.linePtr. */ index.byteIndex = ewPtr->body.ew.tkwin ? TkTextSegToOffset(ewPtr, ewPtr->body.ew.linePtr) : 0; TkTextChanged(ewPtr->body.ew.sharedTextPtr, NULL, &index, &index); TkTextInvalidateLineMetrics(ewPtr->body.ew.sharedTextPtr, NULL, index.linePtr, 0, TK_TEXT_INVALIDATE_ONLY); } /* *-------------------------------------------------------------- |
︙ | ︙ | |||
1316 1317 1318 1319 1320 1321 1322 | * * TkTextWindowIndex -- * * Given the name of an embedded window within a text widget, returns an * index corresponding to the window's position in the text. * * Results: | | | | | | > > > > > > > > > > > | | 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 | * * TkTextWindowIndex -- * * Given the name of an embedded window within a text widget, returns an * index corresponding to the window's position in the text. * * Results: * The return value is TCL_OK if there is an embedded window by the given * name in the text widget, TCL_ERROR otherwise. If the window exists, * *indexPtr is filled in with its index. * * Side effects: * None. * *-------------------------------------------------------------- */ int TkTextWindowIndex( TkText *textPtr, /* Text widget containing window. */ const char *name, /* Name of window. */ TkTextIndex *indexPtr) /* Index information gets stored here. */ { Tcl_HashEntry *hPtr; TkTextSegment *ewPtr; if (textPtr == NULL) { return TCL_ERROR; } hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->windowTable, name); if (hPtr == NULL) { return TCL_ERROR; } ewPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr); indexPtr->tree = textPtr->sharedTextPtr->tree; indexPtr->linePtr = ewPtr->body.ew.linePtr; indexPtr->byteIndex = TkTextSegToOffset(ewPtr, indexPtr->linePtr); /* * If indexPtr refers to somewhere outside the -startline/-endline * range limits of the widget, error out since the window indeed is not * reachable from this text widget (it may be reachable from a peer). */ if (TkTextIndexAdjustToStartEnd(textPtr, indexPtr, 1) == TCL_ERROR) { return TCL_ERROR; } return TCL_OK; } /* *-------------------------------------------------------------- * * EmbWinGetClient -- * |
︙ | ︙ |
Changes to generic/tkTrig.c.
1 2 3 4 5 6 7 | /* * tkTrig.c -- * * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkTrig.c -- * * 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 © 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. */ #include "tkInt.h" #include "tkCanvas.h" |
︙ | ︙ | |||
35 36 37 38 39 40 41 | * None. * *-------------------------------------------------------------- */ double TkLineToPoint( | | | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | * None. * *-------------------------------------------------------------- */ double TkLineToPoint( double end1Ptr[], /* Coordinates of first end-point of line. */ double end2Ptr[], /* Coordinates of second end-point of line. */ double pointPtr[]) /* Points to coords for point. */ { double x, y; /* * Compute the point on the line that is closest to the point. This must * be done separately for vertical edges, horizontal edges, and other * edges. |
︙ | ︙ | |||
139 140 141 142 143 144 145 | * None. * *-------------------------------------------------------------- */ int TkLineToArea( | | | | | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | * None. * *-------------------------------------------------------------- */ int TkLineToArea( double end1Ptr[], /* X and y coordinates for one endpoint of * line. */ double end2Ptr[], /* X and y coordinates for other endpoint of * line. */ double rectPtr[]) /* Points to coords for rectangle, in the * order x1, y1, x2, y2. X1 must be no larger * than x2, and y1 no larger than y2. */ { int inside1, inside2; /* * First check the two points individually to see whether they are inside |
︙ | ︙ | |||
649 650 651 652 653 654 655 | * None. * *-------------------------------------------------------------- */ double TkOvalToPoint( | | | | 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 | * None. * *-------------------------------------------------------------- */ double TkOvalToPoint( double ovalPtr[], /* Pointer to array of four coordinates (x1, * y1, x2, y2) defining oval's bounding * box. */ double width, /* Width of outline for oval. */ int filled, /* Non-zero means oval should be treated as * filled; zero means only consider * outline. */ double pointPtr[]) /* Coordinates of point. */ { double xDelta, yDelta, scaledDistance, distToOutline, distToCenter; double xDiam, yDiam; /* * Compute the distance between the center of the oval and the point in * question, using a coordinate system where the oval has been transformed |
︙ | ︙ |
Changes to generic/tkUndo.c.
1 2 3 4 5 | /* * tkUndo.c -- * * This module provides the implementation of an undo stack. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * tkUndo.c -- * * This module provides the implementation of an undo stack. * * 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. */ #include "tkInt.h" #include "tkUndo.h" |
︙ | ︙ |
Changes to generic/tkUndo.h.
1 2 3 4 5 | /* * tkUndo.h -- * * Declarations shared among the files that implement an undo stack. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkUndo.h -- * * Declarations shared among the files that implement an undo stack. * * 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. */ #ifndef _TKUNDO #define _TKUNDO |
︙ | ︙ |
Changes to generic/tkUtil.c.
1 2 3 4 5 6 | /* * 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. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * 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 © 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" |
︙ | ︙ | |||
580 581 582 583 584 585 586 | *---------------------------------------------------------------------- * * Tk_DrawFocusHighlight -- * * This function draws a rectangular ring around the outside of a widget * to indicate that it has received the input focus. * | | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | *---------------------------------------------------------------------- * * Tk_DrawFocusHighlight -- * * This function draws a rectangular ring around the outside of a widget * to indicate that it has received the input focus. * * This function is now deprecated. Use Tk_DrawHighlightBorder instead, * since this function does not handle drawing the Focus ring properly on * the Macintosh - you need to know the background GC as well as the * foreground since the Mac focus ring separated from the widget by a 1 * pixel border. * * Results: * None. |
︙ | ︙ | |||
727 728 729 730 731 732 733 | Tcl_Obj *const objv[], /* Arguments for command. */ double *dblPtr, /* Filled in with argument "moveto" option, if * any. */ int *intPtr) /* Filled in with number of pages or lines to * scroll, if any. */ { TkSizeT length; | | | 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | Tcl_Obj *const objv[], /* Arguments for command. */ double *dblPtr, /* Filled in with argument "moveto" option, if * any. */ int *intPtr) /* Filled in with number of pages or lines to * scroll, if any. */ { TkSizeT length; const char *arg = Tcl_GetStringFromObj(objv[2], &length); #define ArgPfxEq(str) \ ((arg[0] == str[0]) && !strncmp(arg, str, length)) if (ArgPfxEq("moveto")) { if (objc != 4) { Tcl_WrongNumArgs(interp, 2, objv, "moveto fraction"); |
︙ | ︙ | |||
755 756 757 758 759 760 761 | return TK_SCROLL_ERROR; } *intPtr = (d >= 0) ? ceil(d) : floor(d); if (dblPtr) { *dblPtr = d; } | | | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 | return TK_SCROLL_ERROR; } *intPtr = (d >= 0) ? ceil(d) : floor(d); if (dblPtr) { *dblPtr = d; } arg = Tcl_GetStringFromObj(objv[4], &length); if (ArgPfxEq("pages")) { return TK_SCROLL_PAGES; } else if (ArgPfxEq("units")) { return TK_SCROLL_UNITS; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( |
︙ | ︙ | |||
816 817 818 819 820 821 822 | switch (anchor) { case TK_ANCHOR_NW: case TK_ANCHOR_W: case TK_ANCHOR_SW: *xPtr = Tk_InternalBorderLeft(tkwin) + padX; break; | | | | < | | > | | | | | < | | > | | | 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | switch (anchor) { case TK_ANCHOR_NW: case TK_ANCHOR_W: case TK_ANCHOR_SW: *xPtr = Tk_InternalBorderLeft(tkwin) + padX; break; case TK_ANCHOR_NE: case TK_ANCHOR_E: case TK_ANCHOR_SE: *xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX - innerWidth; break; default: *xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) - Tk_InternalBorderRight(tkwin)) / 2 + Tk_InternalBorderLeft(tkwin); break; } /* * Handle the vertical parts. */ switch (anchor) { case TK_ANCHOR_NW: case TK_ANCHOR_N: case TK_ANCHOR_NE: *yPtr = Tk_InternalBorderTop(tkwin) + padY; break; case TK_ANCHOR_SW: case TK_ANCHOR_S: case TK_ANCHOR_SE: *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY - innerHeight; break; default: *yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) - Tk_InternalBorderBottom(tkwin)) / 2 + Tk_InternalBorderTop(tkwin); break; } } /* *--------------------------------------------------------------------------- * |
︙ | ︙ | |||
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 | event.general.xany.type = VirtualEvent; event.general.xany.serial = NextRequest(Tk_Display(target)); event.general.xany.send_event = False; event.general.xany.window = Tk_WindowId(target); event.general.xany.display = Tk_Display(target); event.virt.name = Tk_GetUid(eventName); event.virt.user_data = detail; Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } | > > | | 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 | event.general.xany.type = VirtualEvent; event.general.xany.serial = NextRequest(Tk_Display(target)); event.general.xany.send_event = False; event.general.xany.window = Tk_WindowId(target); event.general.xany.display = Tk_Display(target); event.virt.name = Tk_GetUid(eventName); event.virt.user_data = detail; if (detail) Tcl_IncrRefCount(detail); // Event code will DecrRefCount Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } /* Tcl 8.6 has a different definition of Tcl_UniChar than other Tcl versions for TCL_UTF_MAX > 3 */ #if TCL_UTF_MAX <= (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6)) /* *--------------------------------------------------------------------------- * * TkUtfToUniChar -- * * Almost the same as Tcl_UtfToUniChar but using int instead of Tcl_UniChar. * This function is capable of collapsing a upper/lower surrogate pair to a |
︙ | ︙ | |||
1221 1222 1223 1224 1225 1226 1227 | const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Unicode value represented by * the UTF-8 string. */ { Tcl_UniChar uniChar = 0; size_t len = Tcl_UtfToUniChar(src, &uniChar); | < | < < < < | | | 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Unicode value represented by * the UTF-8 string. */ { Tcl_UniChar uniChar = 0; size_t len = Tcl_UtfToUniChar(src, &uniChar); if ((uniChar & 0xFC00) == 0xD800) { Tcl_UniChar low = uniChar; /* This can only happen if sizeof(Tcl_UniChar)== 2 and src points * to a character > U+FFFF */ size_t len2 = Tcl_UtfToUniChar(src+len, &low); if ((low & 0xFC00) == 0xDC00) { *chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000; return len + len2; } } *chPtr = uniChar; |
︙ | ︙ | |||
1261 1262 1263 1264 1265 1266 1267 | * None. * *--------------------------------------------------------------------------- */ size_t TkUniCharToUtf(int ch, char *buf) { | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 | * None. * *--------------------------------------------------------------------------- */ size_t TkUniCharToUtf(int ch, char *buf) { if ((unsigned)(ch - 0x10000) <= 0xFFFFF) { /* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl * version and/or TCL_UTF_MAX build value */ int len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf); return len + Tcl_UniCharToUtf(0xDC00 | (ch & 0x7FF), buf + len); } return Tcl_UniCharToUtf(ch, buf); } #endif /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/tkVisual.c.
1 2 3 4 5 6 7 | /* * tkVisual.c -- * * This file contains library procedures for allocating and freeing * visuals and colormaps. This code is based on a prototype * implementation by Paul Mackerras. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkVisual.c -- * * This file contains library procedures for allocating and freeing * visuals and colormaps. This code is based on a prototype * implementation by Paul Mackerras. * * 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. */ #include "tkInt.h" |
︙ | ︙ |
Changes to generic/tkWindow.c.
1 2 3 4 5 6 7 | /* * tkWindow.c -- * * 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. * | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | /* * tkWindow.c -- * * 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 © 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 #include "tkUuid.h" /* * Type used to keep track of Window objects that were only partially * deallocated by Tk_DestroyWindow. */ #define HD_CLEANUP 1 |
︙ | ︙ | |||
89 90 91 92 93 94 95 96 | * the C functions that execute them. */ #define ISSAFE 1 #define PASSMAINWINDOW 2 #define WINMACONLY 4 #define USEINITPROC 8 | > | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | * the C functions that execute them. */ #define ISSAFE 1 #define PASSMAINWINDOW 2 #define WINMACONLY 4 #define USEINITPROC 8 #define SAVEUPDATECMD 16 /* better only be one of these! */ typedef int (TkInitProc)(Tcl_Interp *interp, void *clientData); typedef struct { const char *name; /* Name of command. */ Tcl_ObjCmdProc *objProc; /* Command's object- (or string-) based * function, or initProc. */ int flags; } TkCmd; |
︙ | ︙ | |||
122 123 124 125 126 127 128 | {"option", Tk_OptionObjCmd, PASSMAINWINDOW|ISSAFE}, {"pack", Tk_PackObjCmd, PASSMAINWINDOW|ISSAFE}, {"place", Tk_PlaceObjCmd, PASSMAINWINDOW|ISSAFE}, {"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE}, {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW}, {"tk", (Tcl_ObjCmdProc *)(void *)TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE}, {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, | | | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | {"option", Tk_OptionObjCmd, PASSMAINWINDOW|ISSAFE}, {"pack", Tk_PackObjCmd, PASSMAINWINDOW|ISSAFE}, {"place", Tk_PlaceObjCmd, PASSMAINWINDOW|ISSAFE}, {"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE}, {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW}, {"tk", (Tcl_ObjCmdProc *)(void *)TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE}, {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE|SAVEUPDATECMD}, {"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE}, {"wm", Tk_WmObjCmd, PASSMAINWINDOW}, /* * Default widget class commands. */ |
︙ | ︙ | |||
202 203 204 205 206 207 208 | /* * Forward declarations to functions defined later in this file: */ static Tk_Window CreateTopLevelWindow(Tcl_Interp *interp, Tk_Window parent, const char *name, const char *screenName, unsigned int flags); | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | /* * Forward declarations to functions defined later in this file: */ static Tk_Window CreateTopLevelWindow(Tcl_Interp *interp, Tk_Window parent, const char *name, const char *screenName, unsigned int flags); static void DeleteWindowsExitProc(void *clientData); static TkDisplay * GetScreen(Tcl_Interp *interp, const char *screenName, int *screenPtr); static int Initialize(Tcl_Interp *interp); static int NameWindow(Tcl_Interp *interp, TkWindow *winPtr, TkWindow *parentPtr, const char *name); static void UnlinkWindow(TkWindow *winPtr); |
︙ | ︙ | |||
330 331 332 333 334 335 336 | Tk_CreateImageType(&tkBitmapImageType); Tk_CreateImageType(&tkPhotoImageType); /* * Create built-in photo image formats. */ | | | | | 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | Tk_CreateImageType(&tkBitmapImageType); Tk_CreateImageType(&tkPhotoImageType); /* * Create built-in photo image formats. */ Tk_CreatePhotoImageFormat(&tkImgFmtDefault); Tk_CreatePhotoImageFormatVersion3(&tkImgFmtGIF); Tk_CreatePhotoImageFormatVersion3(&tkImgFmtPNG); Tk_CreatePhotoImageFormat(&tkImgFmtPPM); Tk_CreatePhotoImageFormat(&tkImgFmtSVGnano); } if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) { dispPtr = ((TkWindow *) parent)->dispPtr; screenId = Tk_ScreenNumber(parent); |
︙ | ︙ | |||
652 653 654 655 656 657 658 | winPtr->dirtyAtts = CWEventMask|CWColormap|CWBitGravity; winPtr->flags = 0; winPtr->handlerList = NULL; winPtr->ximGeneration = 0; winPtr->inputContext = NULL; winPtr->tagPtr = NULL; winPtr->numTags = 0; | | | 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | winPtr->dirtyAtts = CWEventMask|CWColormap|CWBitGravity; winPtr->flags = 0; winPtr->handlerList = NULL; winPtr->ximGeneration = 0; winPtr->inputContext = NULL; winPtr->tagPtr = NULL; winPtr->numTags = 0; winPtr->optionLevel = TCL_INDEX_NONE; winPtr->selHandlerList = NULL; winPtr->geomMgrPtr = NULL; winPtr->geomData = NULL; winPtr->geomMgrName = NULL; winPtr->maintainerPtr = NULL; winPtr->reqWidth = winPtr->reqHeight = 1; winPtr->internalBorderLeft = 0; |
︙ | ︙ | |||
811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | * with the window and registered for "send" commands under "baseName". * BaseName may be extended with an instance number in the form "#2" if * necessary to make it globally unique. Tk-related commands are bound * into interp. * *---------------------------------------------------------------------- */ Tk_Window TkCreateMainWindow( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ const char *screenName, /* Name of screen on which to create window. * Empty or NULL string means use DISPLAY * environment variable. */ const char *baseName) /* Base name for application; usually of the * form "prog instance". */ { Tk_Window tkwin; int dummy, isSafe; Tcl_HashEntry *hPtr; TkMainInfo *mainPtr; TkWindow *winPtr; const TkCmd *cmdPtr; | > > > > > | > | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 | * with the window and registered for "send" commands under "baseName". * BaseName may be extended with an instance number in the form "#2" if * necessary to make it globally unique. Tk-related commands are bound * into interp. * *---------------------------------------------------------------------- */ #ifndef STRINGIFY # define STRINGIFY(x) STRINGIFY1(x) # define STRINGIFY1(x) #x #endif Tk_Window TkCreateMainWindow( Tcl_Interp *interp, /* Interpreter to use for error reporting. */ const char *screenName, /* Name of screen on which to create window. * Empty or NULL string means use DISPLAY * environment variable. */ const char *baseName) /* Base name for application; usually of the * form "prog instance". */ { Tk_Window tkwin; int dummy, isSafe; Tcl_HashEntry *hPtr; TkMainInfo *mainPtr; TkWindow *winPtr; const TkCmd *cmdPtr; void *clientData; Tcl_CmdInfo info; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); /* * Panic if someone updated the TkWindow structure without also updating * the Tk_FakeWin structure (or vice versa). */ |
︙ | ︙ | |||
872 873 874 875 876 877 878 879 880 881 882 883 884 885 | TkStylePkgInit(mainPtr); mainPtr->tlFocusPtr = NULL; mainPtr->displayFocusPtr = NULL; mainPtr->optionRootPtr = NULL; Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS); mainPtr->strictMotif = 0; mainPtr->alwaysShowSelection = 0; if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } if (Tcl_CreateNamespace(interp, "::tk", NULL, NULL) == NULL) { Tcl_ResetResult(interp); } | > > > > | 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | TkStylePkgInit(mainPtr); mainPtr->tlFocusPtr = NULL; mainPtr->displayFocusPtr = NULL; mainPtr->optionRootPtr = NULL; Tcl_InitHashTable(&mainPtr->imageTable, TCL_STRING_KEYS); mainPtr->strictMotif = 0; mainPtr->alwaysShowSelection = 0; mainPtr->tclUpdateObjProc = NULL; #if TCL_MAJOR_VERSION > 8 mainPtr->tclUpdateObjProc2 = NULL; #endif if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif, TCL_LINK_BOOLEAN) != TCL_OK) { Tcl_ResetResult(interp); } if (Tcl_CreateNamespace(interp, "::tk", NULL, NULL) == NULL) { Tcl_ResetResult(interp); } |
︙ | ︙ | |||
911 912 913 914 915 916 917 918 919 920 921 922 | /* * Bind in Tk's commands. */ isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { if (cmdPtr->objProc == NULL) { Tcl_Panic("TkCreateMainWindow: builtin command with NULL string and object procs"); } #if defined(_WIN32) && !defined(STATIC_BUILD) | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 | /* * Bind in Tk's commands. */ isSafe = Tcl_IsSafe(interp); for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { Tcl_CmdInfo cmdInfo; 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->tcl_CreateFileHandler) { /* * We are running on Cygwin, so don't use the win32 dialogs. */ continue; } #endif /* _WIN32 && !STATIC_BUILD */ if (cmdPtr->flags & PASSMAINWINDOW) { clientData = tkwin; } else { clientData = NULL; } if ((cmdPtr->flags & SAVEUPDATECMD) && Tcl_GetCommandInfo(interp, cmdPtr->name, &cmdInfo) && cmdInfo.isNativeObjectProc && !cmdInfo.deleteProc) { #if TCL_MAJOR_VERSION > 8 if ((cmdInfo.isNativeObjectProc == 2) && !cmdInfo.objClientData2) { mainPtr->tclUpdateObjProc2 = cmdInfo.objProc2; } else #endif if (!cmdInfo.objClientData ) { mainPtr->tclUpdateObjProc = cmdInfo.objProc; } } if (cmdPtr->flags & USEINITPROC) { ((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData); } else { Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, clientData, NULL); } if (isSafe && !(cmdPtr->flags & ISSAFE)) { Tcl_HideCommand(interp, cmdPtr->name, cmdPtr->name); } } if (Tcl_GetCommandInfo(interp, "::tcl::build-info", &info)) { static const char version[] = TK_PATCH_LEVEL "+" STRINGIFY(TK_VERSION_UUID) #if defined(MAC_OSX_TK) ".aqua" #endif #if defined(__clang__) && defined(__clang_major__) ".clang-" STRINGIFY(__clang_major__) #if __clang_minor__ < 10 "0" #endif STRINGIFY(__clang_minor__) #endif #if defined(__cplusplus) && !defined(__OBJC__) ".cplusplus" #endif #ifndef NDEBUG ".debug" #endif #if !defined(__clang__) && !defined(__INTEL_COMPILER) && defined(__GNUC__) ".gcc-" STRINGIFY(__GNUC__) #if __GNUC_MINOR__ < 10 "0" #endif STRINGIFY(__GNUC_MINOR__) #endif #ifdef __INTEL_COMPILER ".icc-" STRINGIFY(__INTEL_COMPILER) #endif #ifdef TCL_MEM_DEBUG ".memdebug" #endif #if defined(_MSC_VER) ".msvc-" STRINGIFY(_MSC_VER) #endif #ifdef USE_NMAKE ".nmake" #endif #ifdef TK_NO_DEPRECATED ".no-deprecate" #endif #ifndef TCL_CFG_OPTIMIZED ".no-optimize" #endif #ifdef __OBJC__ ".objective-c" #if defined(__cplusplus) "plusplus" #endif #endif #ifdef TCL_CFG_PROFILED ".profile" #endif #ifdef PURIFY ".purify" #endif #ifdef STATIC_BUILD ".static" #endif #if TCL_UTF_MAX <= (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6)) ".utf-16" #endif #if defined(_WIN32) ".win32" #endif #if !defined(_WIN32) && !defined(MAC_OSX_TK) ".x11" #if !defined(HAVE_XFT) ".no-xft" #endif #endif ; #if TCL_MAJOR_VERSION > 8 if (info.isNativeObjectProc == 2) { Tcl_CreateObjCommand2(interp, "::tk::build-info", info.objProc2, (void *) version, NULL); } else #endif Tcl_CreateObjCommand(interp, "::tk::build-info", info.objProc, (void *) version, NULL); } /* * Set variables for the interpreter. */ Tcl_SetVar2(interp, "tk_patchLevel", NULL, TK_PATCH_LEVEL, TCL_GLOBAL_ONLY); |
︙ | ︙ | |||
1228 1229 1230 1231 1232 1233 1234 | *-------------------------------------------------------------- */ void Tk_DestroyWindow( Tk_Window tkwin) /* Window to destroy. */ { | | | 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 | *-------------------------------------------------------------- */ void Tk_DestroyWindow( Tk_Window tkwin) /* Window to destroy. */ { TkWindow *winPtr = (TkWindow *)tkwin; TkDisplay *dispPtr = winPtr->dispPtr; XEvent event; TkHalfdeadWindow *halfdeadPtr, *prev_halfdeadPtr; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); if (winPtr->flags & TK_ALREADY_DEAD) { |
︙ | ︙ | |||
1264 1265 1266 1267 1268 1269 1270 | halfdeadPtr->winPtr = winPtr; halfdeadPtr->nextPtr = tsdPtr->halfdeadWindowList; tsdPtr->halfdeadWindowList = halfdeadPtr; } /* * Some cleanup needs to be done immediately, rather than later, because | | | 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 | halfdeadPtr->winPtr = winPtr; halfdeadPtr->nextPtr = tsdPtr->halfdeadWindowList; tsdPtr->halfdeadWindowList = halfdeadPtr; } /* * Some cleanup needs to be done immediately, rather than later, because * it needs information that will be destroyed before we get to the main * cleanup point. For example, TkFocusDeadWindow needs to access the * parentPtr field from a window, but if a Destroy event handler deletes * the window's parent this field will be NULL before the main cleanup * point is reached. */ if (!(halfdeadPtr->flags & HD_FOCUS)) { |
︙ | ︙ | |||
1345 1346 1347 1348 1349 1350 1351 | /* * This is the container for an embedded application, and the embedded * application is also in this process. Delete the embedded window * in-line here, for the same reasons we delete children in-line * (otherwise, for example, the Tk window may appear to exist even * though its X window is gone; this could cause errors). Special * note: it's possible that the embedded window has already been | | | | 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 | /* * This is the container for an embedded application, and the embedded * application is also in this process. Delete the embedded window * in-line here, for the same reasons we delete children in-line * (otherwise, for example, the Tk window may appear to exist even * though its X window is gone; this could cause errors). Special * note: it's possible that the embedded window has already been * deleted, in which case Tk_GetOtherWindow will return NULL. */ TkWindow *childPtr = (TkWindow *)Tk_GetOtherWindow(tkwin); if (childPtr != NULL) { childPtr->flags |= TK_DONT_DESTROY_WINDOW; Tk_DestroyWindow((Tk_Window) childPtr); } } |
︙ | ︙ | |||
1492 1493 1494 1495 1496 1497 1498 | * * NOTE: Only replace the commands it if the interpreter is not * being deleted. If it *is*, the interpreter cleanup will do all * the needed work. */ if ((winPtr->mainPtr->interp != NULL) && | | > > > > > > > > > > > | > > | > > > > > > | 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 | * * NOTE: Only replace the commands it if the interpreter is not * being deleted. If it *is*, the interpreter cleanup will do all * the needed work. */ if ((winPtr->mainPtr->interp != NULL) && !Tcl_InterpDeleted(winPtr->mainPtr->interp)) { for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) { if (cmdPtr->flags & SAVEUPDATECMD) { /* Restore Tcl's version of [update] */ #if TCL_MAJOR_VERSION > 8 if (winPtr->mainPtr->tclUpdateObjProc2 != NULL) { Tcl_CreateObjCommand2(winPtr->mainPtr->interp, cmdPtr->name, winPtr->mainPtr->tclUpdateObjProc2, NULL, NULL); } else #endif if (winPtr->mainPtr->tclUpdateObjProc != NULL) { Tcl_CreateObjCommand(winPtr->mainPtr->interp, cmdPtr->name, winPtr->mainPtr->tclUpdateObjProc, NULL, NULL); } } else { Tcl_CreateObjCommand(winPtr->mainPtr->interp, cmdPtr->name, TkDeadAppObjCmd, NULL, NULL); } } Tcl_CreateObjCommand(winPtr->mainPtr->interp, "send", TkDeadAppObjCmd, NULL, NULL); Tcl_UnlinkVar(winPtr->mainPtr->interp, "tk_strictMotif"); Tcl_UnlinkVar(winPtr->mainPtr->interp, "::tk::AlwaysShowSelection"); } |
︙ | ︙ | |||
1638 1639 1640 1641 1642 1643 1644 | event.type = MapNotify; event.xmap.serial = LastKnownRequestProcessed(winPtr->display); 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; | | | 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 | event.type = MapNotify; event.xmap.serial = LastKnownRequestProcessed(winPtr->display); 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); } /* *-------------------------------------------------------------- * * Tk_MakeWindowExist -- * |
︙ | ︙ | |||
1689 1690 1691 1692 1693 1694 1695 | parent = winPtr->parentPtr->window; } createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc); if (createProc != NULL && parent != None) { winPtr->window = createProc(tkwin, parent, winPtr->instanceData); } else { | | | 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 | parent = winPtr->parentPtr->window; } createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc); if (createProc != NULL && parent != None) { winPtr->window = createProc(tkwin, parent, winPtr->instanceData); } else { winPtr->window = Tk_MakeWindow(tkwin, parent); } hPtr = Tcl_CreateHashEntry(&winPtr->dispPtr->winTable, (char *) winPtr->window, &isNew); Tcl_SetHashValue(hPtr, winPtr); winPtr->dirtyAtts = 0; winPtr->dirtyChanges = 0; |
︙ | ︙ | |||
1800 1801 1802 1803 1804 1805 1806 | event.type = UnmapNotify; event.xunmap.serial = LastKnownRequestProcessed(winPtr->display); 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; | | | 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 | event.type = UnmapNotify; event.xunmap.serial = LastKnownRequestProcessed(winPtr->display); 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); } } void Tk_ConfigureWindow( Tk_Window tkwin, /* Window to re-configure. */ unsigned int valueMask, /* Mask indicating which parts of *valuePtr |
︙ | ︙ | |||
2245 2246 2247 2248 2249 2250 2251 | *---------------------------------------------------------------------- */ void Tk_SetClassProcs( Tk_Window tkwin, /* Token for window to modify. */ const Tk_ClassProcs *procs, /* Class procs structure. */ | | | 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 | *---------------------------------------------------------------------- */ void Tk_SetClassProcs( Tk_Window tkwin, /* Token for window to modify. */ const Tk_ClassProcs *procs, /* Class procs structure. */ void *instanceData) /* Data to be passed to class functions. */ { TkWindow *winPtr = (TkWindow *) tkwin; winPtr->classProcsPtr = procs; winPtr->instanceData = instanceData; } |
︙ | ︙ | |||
2734 2735 2736 2737 2738 2739 2740 | * None. * *---------------------------------------------------------------------- */ static void DeleteWindowsExitProc( | | | 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 | * None. * *---------------------------------------------------------------------- */ static void DeleteWindowsExitProc( void *clientData) /* tsdPtr when handler was created. */ { TkDisplay *dispPtr, *nextPtr; Tcl_Interp *interp; ThreadSpecificData *tsdPtr = (ThreadSpecificData *)clientData; if (tsdPtr == NULL) { return; |
︙ | ︙ | |||
2840 2841 2842 2843 2844 2845 2846 | Tcl_Interp *interp) { WCHAR name[MAX_PATH]; size_t len; void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *); /* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */ | | | 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 | Tcl_Interp *interp) { WCHAR name[MAX_PATH]; size_t len; void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *); /* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */ len = GetModuleFileNameW((HINSTANCE)Tk_GetHINSTANCE(), name, MAX_PATH); name[len-2] = '.'; name[len-1] = name[len-5]; wcscpy(name+len, L".dll"); memcpy(name+len-8, L"libtk8", 6 * sizeof(WCHAR)); tkcygwindll = LoadLibraryW(name); if (!tkcygwindll) { |
︙ | ︙ | |||
2997 2998 2999 3000 3001 3002 3003 | * Depends on the initialization scripts that are invoked. * *---------------------------------------------------------------------- */ static int CopyValue( | | < < | 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 | * Depends on the initialization scripts that are invoked. * *---------------------------------------------------------------------- */ static int CopyValue( TCL_UNUSED(void *), Tcl_Obj *objPtr, void *dstPtr) { *(Tcl_Obj **)dstPtr = objPtr; return 1; } static int Initialize( Tcl_Interp *interp) /* Interpreter to initialize. */ |
︙ | ︙ | |||
3146 3147 3148 3149 3150 3151 3152 | * that we used. */ value = Tcl_GetVar2Ex(interp, "argv", NULL, TCL_GLOBAL_ONLY); } if (value) { | | | 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 | * that we used. */ value = Tcl_GetVar2Ex(interp, "argv", NULL, TCL_GLOBAL_ONLY); } if (value) { TkSizeT objc; Tcl_Obj **objv, **rest; Tcl_Obj *parseList = Tcl_NewListObj(1, NULL); Tcl_ListObjAppendElement(NULL, parseList, Tcl_NewObj()); Tcl_IncrRefCount(value); if (TCL_OK != Tcl_ListObjAppendList(interp, parseList, value) || |
︙ | ︙ | |||
3197 3198 3199 3200 3201 3202 3203 | /* * The -class argument is always the ToTitle of the -name */ { TkSizeT numBytes; | | | 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 | /* * The -class argument is always the ToTitle of the -name */ { TkSizeT numBytes; const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes); classObj = Tcl_NewStringObj(bytes, numBytes); numBytes = Tcl_UtfToTitle(Tcl_GetString(classObj)); Tcl_SetObjLength(classObj, numBytes); } |
︙ | ︙ | |||
3279 3280 3281 3282 3283 3284 3285 | geometryObj = NULL; if (code != TCL_OK) { goto done; } } /* | | > | | > > > | 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 | geometryObj = NULL; if (code != TCL_OK) { goto done; } } /* * Provide "tk" and its stub table. */ #ifndef TK_NO_DEPRECATED Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL, (void *)&tkStubs); #endif code = Tcl_PkgProvideEx(interp, "tk", TK_PATCH_LEVEL, (void *)&tkStubs); if (code != TCL_OK) { goto done; } /* * If we were able to provide ourselves as a package, then set the main * loop function in Tcl to our main loop proc. This will cause tclsh to be |
︙ | ︙ | |||
3377 3378 3379 3380 3381 3382 3383 | const char * Tk_PkgInitStubsCheck( Tcl_Interp *interp, const char * version, int exact) { | | | | | 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 | const char * Tk_PkgInitStubsCheck( Tcl_Interp *interp, const char * version, int exact) { const char *actualVersion = Tcl_PkgRequireEx(interp, "tk", version, 0, NULL); if (exact && actualVersion) { const char *p = version; int count = 0; while (*p) { count += !isdigit(UCHAR(*p++)); } if (count == 1) { if (0 != strncmp(version, actualVersion, strlen(version))) { /* Construct error message */ Tcl_PkgPresentEx(interp, "tk", version, 1, NULL); return NULL; } } else { return Tcl_PkgPresentEx(interp, "tk", version, 1, NULL); } } return actualVersion; } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/ttk/ttkButton.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2003, Joe English * * label, button, checkbutton, radiobutton, and menubutton widgets. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" |
︙ | ︙ | |||
20 21 22 23 24 25 26 | { /* * Text element resources: */ Tcl_Obj *textObj; Tcl_Obj *justifyObj; Tcl_Obj *textVariableObj; | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | { /* * Text element resources: */ Tcl_Obj *textObj; Tcl_Obj *justifyObj; Tcl_Obj *textVariableObj; int underline; Tcl_Obj *widthObj; Ttk_TraceHandle *textVariableTrace; Ttk_ImageSpec *imageSpec; /* * Image element resources: |
︙ | ︙ | |||
53 54 55 56 57 58 59 | WidgetCore core; BasePart base; } Base; static const Tk_OptionSpec BaseOptionSpecs[] = { {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", | | | | | < | | | | | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | WidgetCore core; BasePart base; } Base; static const Tk_OptionSpec BaseOptionSpecs[] = { {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "left", offsetof(Base,base.justifyObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(Base,base.textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "", offsetof(Base,base.textVariableObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(Base, base.underline), 0}, /* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */ {TK_OPTION_STRING, "-width", "width", "Width", NULL, offsetof(Base,base.widthObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, /* * Image options */ {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/, offsetof(Base,base.imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, /* * Compound base/image options */ {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, ttkCompoundStrings, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, offsetof(Base,base.paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED}, /* * Compatibility/legacy options */ {TK_OPTION_STRING, "-state", "state", "State", "normal", offsetof(Base,base.stateObj), TCL_INDEX_NONE, 0,0,STATE_CHANGED }, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; /* * Variable trace procedure for -textvariable option: */ |
︙ | ︙ | |||
255 256 257 258 259 260 261 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", NULL, offsetof(Label,label.borderWidthObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL, offsetof(Label,label.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", | | | | | > | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", NULL, offsetof(Label,label.borderWidthObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL, offsetof(Label,label.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", offsetof(Label,label.anchorObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "left", offsetof(Label, label.justifyObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength", NULL, offsetof(Label, label.wrapLengthObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; static const Ttk_Ensemble LabelCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec LabelWidgetSpec = { "TLabel", /* className */ sizeof(Label), /* recordSize */ |
︙ | ︙ | |||
326 327 328 329 330 331 332 | */ static const Tk_OptionSpec ButtonOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", offsetof(Button, button.commandObj), TCL_INDEX_NONE, 0,0,0}, {TK_OPTION_STRING_TABLE, "-default", "default", "Default", "normal", offsetof(Button, button.defaultStateObj), TCL_INDEX_NONE, | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | */ static const Tk_OptionSpec ButtonOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", offsetof(Button, button.commandObj), TCL_INDEX_NONE, 0,0,0}, {TK_OPTION_STRING_TABLE, "-default", "default", "Default", "normal", offsetof(Button, button.defaultStateObj), TCL_INDEX_NONE, 0, ttkDefaultStrings, DEFAULTSTATE_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask) { |
︙ | ︙ | |||
374 375 376 377 378 379 380 381 | if (buttonPtr->core.state & TTK_STATE_DISABLED) { return TCL_OK; } return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble ButtonCommands[] = { { "configure", TtkWidgetConfigureCommand,0 }, | > | < > | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | if (buttonPtr->core.state & TTK_STATE_DISABLED) { return TCL_OK; } return Tcl_EvalObjEx(interp, buttonPtr->button.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble ButtonCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "invoke", ButtonInvokeCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec ButtonWidgetSpec = { "TButton", /* className */ sizeof(Button), /* recordSize */ |
︙ | ︙ | |||
581 582 583 584 585 586 587 588 | return TCL_ERROR; return Tcl_EvalObjEx(interp, checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble CheckbuttonCommands[] = { { "configure", TtkWidgetConfigureCommand,0 }, | > | < > | | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | return TCL_ERROR; return Tcl_EvalObjEx(interp, checkPtr->checkbutton.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble CheckbuttonCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "invoke", CheckbuttonInvokeCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, /* MISSING: select, deselect, toggle */ { 0,0,0 } }; static const WidgetSpec CheckbuttonWidgetSpec = { "TCheckbutton", /* className */ |
︙ | ︙ | |||
757 758 759 760 761 762 763 764 | return TCL_ERROR; return Tcl_EvalObjEx(interp, radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble RadiobuttonCommands[] = { { "configure", TtkWidgetConfigureCommand,0 }, | > | < > | | 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | return TCL_ERROR; return Tcl_EvalObjEx(interp, radioPtr->radiobutton.commandObj, TCL_EVAL_GLOBAL); } static const Ttk_Ensemble RadiobuttonCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "invoke", RadiobuttonInvokeCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, /* MISSING: select, deselect */ { 0,0,0 } }; static const WidgetSpec RadiobuttonWidgetSpec = { "TRadiobutton", /* className */ |
︙ | ︙ | |||
819 820 821 822 823 824 825 | }; static const Tk_OptionSpec MenubuttonOptionSpecs[] = { {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, | | > | 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | }; static const Tk_OptionSpec MenubuttonOptionSpecs[] = { {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, directionStrings, GEOMETRY_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) }; static const Ttk_Ensemble MenubuttonCommands[] = { { "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 = { "TMenubutton", /* className */ sizeof(Menubutton), /* recordSize */ |
︙ | ︙ |
Changes to generic/ttk/ttkCache.c.
1 2 3 | /* * Theme engine resource cache. * | | | 1 2 3 4 5 6 7 8 9 10 11 | /* * Theme engine resource cache. * * 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. * With the theme engine, resources are allocated right before * drawing an element and released immediately after. |
︙ | ︙ |
Changes to generic/ttk/ttkClamTheme.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2004 Joe English * * "clam" theme; inspired by the XFCE family of Gnome themes. */ #include "tkInt.h" #include "ttkTheme.h" |
︙ | ︙ |
Changes to generic/ttk/ttkClassicTheme.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2004, Joe English * * "classic" theme; implements the classic Motif-like Tk look. * */ #include "tkInt.h" #include "ttkTheme.h" |
︙ | ︙ |
Changes to generic/ttk/ttkDecls.h.
︙ | ︙ | |||
9 10 11 12 13 14 15 | extern const char *TtkInitializeStubs( Tcl_Interp *, const char *version, int epoch, int revision); #define Ttk_InitStubs(interp) TtkInitializeStubs( \ interp, TTK_VERSION, TTK_STUBS_EPOCH, TTK_STUBS_REVISION) #else | > | > > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | extern const char *TtkInitializeStubs( Tcl_Interp *, const char *version, int epoch, int revision); #define Ttk_InitStubs(interp) TtkInitializeStubs( \ interp, TTK_VERSION, TTK_STUBS_EPOCH, TTK_STUBS_REVISION) #else #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) #elif defined(TK_NO_DEPRECATED) # define TTK_DEPRECATED(msg) MODULE_SCOPE |
︙ | ︙ |
Changes to generic/ttk/ttkDefaultTheme.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2003 Joe English * * Tk alternate theme, intended to match the MSUE and Gtk's (old) default theme */ #include "tkInt.h" #include "ttkTheme.h" |
︙ | ︙ |
Changes to generic/ttk/ttkElements.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2003 Joe English * * Default implementation for themed elements. * */ #include "tkInt.h" #include "ttkTheme.h" |
︙ | ︙ |
Changes to generic/ttk/ttkEntry.c.
1 2 3 | /* * DERIVED FROM: tk/generic/tkEntry.c r1.35. * | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * DERIVED FROM: tk/generic/tkEntry.c r1.35. * * 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" /* |
︙ | ︙ | |||
177 178 179 180 181 182 183 | "normal", offsetof(Entry, entry.stateObj), TCL_INDEX_NONE, 0,0,STATE_CHANGED}, {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), | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | "normal", offsetof(Entry, entry.stateObj), TCL_INDEX_NONE, 0,0,STATE_CHANGED}, {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), TK_OPTION_ENUM_VAR, 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, 0,0,GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", |
︙ | ︙ | |||
321 322 323 324 325 326 327 | if ((entryPtr->entry.numChars != 0) || (entryPtr->entry.placeholderObj == NULL)) { entryPtr->entry.textLayout = Tk_ComputeTextLayout( 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 { | | | 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | if ((entryPtr->entry.numChars != 0) || (entryPtr->entry.placeholderObj == NULL)) { entryPtr->entry.textLayout = Tk_ComputeTextLayout( 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 = 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); } } |
︙ | ︙ | |||
1304 1305 1306 1307 1308 1309 1310 | */ if ((*(entryPtr->entry.displayString) == '\0') && (entryPtr->entry.placeholderObj != NULL)) { /* No text displayed, but -placeholder is given */ if (Tcl_GetCharLength(es.placeholderForegroundObj) > 0) { foregroundObj = es.placeholderForegroundObj; } else { | | | | 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | */ if ((*(entryPtr->entry.displayString) == '\0') && (entryPtr->entry.placeholderObj != NULL)) { /* No text displayed, but -placeholder is given */ if (Tcl_GetCharLength(es.placeholderForegroundObj) > 0) { foregroundObj = es.placeholderForegroundObj; } else { foregroundObj = es.foregroundObj; } /* Use placeholder text width */ leftIndex = 0; (void)Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex); } else { foregroundObj = es.foregroundObj; } gc = EntryGetGC(entryPtr, foregroundObj, clipRegion); if (showSelection) { /* Draw the selected and unselected portions separately. |
︙ | ︙ | |||
1389 1390 1391 1392 1393 1394 1395 | TkSizeT *indexPtr) /* Return value */ { # 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)) { | > > | | | | | | | 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 | TkSizeT *indexPtr) /* Return value */ { # 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 == TCL_INDEX_NONE) { idx = 0; } else if (idx > entryPtr->entry.numChars) { idx = entryPtr->entry.numChars; } *indexPtr = idx; return TCL_OK; } 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; } else if (strncmp(string, "right", length) == 0) { /* for debugging */ *indexPtr = entryPtr->entry.xscroll.last; |
︙ | ︙ | |||
1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 | { "icursor", EntryICursorCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, { "state", TtkWidgetStateCommand,0 }, { "validate", EntryValidateCommand,0 }, { "xview", EntryXViewCommand,0 }, { 0,0,0 } }; /*------------------------------------------------------------------------ * +++ Entry widget definition. | > | 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 | { "icursor", EntryICursorCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "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 } }; /*------------------------------------------------------------------------ * +++ Entry widget definition. |
︙ | ︙ | |||
1869 1870 1871 1872 1873 1874 1875 | cbPtr->combobox.currentIndex = 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)) { | | | | 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 | cbPtr->combobox.currentIndex = 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)) { if (idx == TCL_INDEX_NONE || idx >= (TkSizeT)nValues) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "index \"%s\" out of range", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL); return TCL_ERROR; } currentIndex = idx; } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad index \"%s\"", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL); return TCL_ERROR; } cbPtr->combobox.currentIndex = currentIndex; return EntrySetValue((Entry *)recordPtr, Tcl_GetString(values[currentIndex])); |
︙ | ︙ | |||
1909 1910 1911 1912 1913 1914 1915 1916 | { "get", EntryGetCommand,0 }, { "icursor", EntryICursorCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, { "state", TtkWidgetStateCommand,0 }, | > | | 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 | { "get", EntryGetCommand,0 }, { "icursor", EntryICursorCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, { "set", EntrySetCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { "validate", EntryValidateCommand,0 }, { "xview", EntryXViewCommand,0 }, { 0,0,0 } }; static const WidgetSpec ComboboxWidgetSpec = { "TCombobox", /* className */ |
︙ | ︙ | |||
2021 2022 2023 2024 2025 2026 2027 2028 | { "get", EntryGetCommand,0 }, { "icursor", EntryICursorCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, { "state", TtkWidgetStateCommand,0 }, | > | | 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 | { "get", EntryGetCommand,0 }, { "icursor", EntryICursorCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "index", EntryIndexCommand,0 }, { "insert", EntryInsertCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "selection", 0,EntrySelectionCommands }, { "set", EntrySetCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { "validate", EntryValidateCommand,0 }, { "xview", EntryXViewCommand,0 }, { 0,0,0 } }; static const WidgetSpec SpinboxWidgetSpec = { "TSpinbox", /* className */ |
︙ | ︙ |
Changes to generic/ttk/ttkFrame.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2004 Joe English * * ttk::frame and ttk::labelframe widgets. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" |
︙ | ︙ | |||
44 45 46 47 48 49 50 51 | 0,0,GEOMETRY_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; static const Ttk_Ensemble FrameCommands[] = { { "configure", TtkWidgetConfigureCommand,0 }, | > | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 0,0,GEOMETRY_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; static const Ttk_Ensemble FrameCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /* * FrameMargins -- * Compute internal margins for a frame widget. * This includes the -borderWidth, plus any additional -padding. |
︙ | ︙ | |||
230 231 232 233 234 235 236 | /* * Labelframe widget record: */ typedef struct { Tcl_Obj *labelAnchorObj; Tcl_Obj *textObj; | | | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | /* * Labelframe widget record: */ typedef struct { Tcl_Obj *labelAnchorObj; Tcl_Obj *textObj; int underline; Tk_Window labelWidget; Ttk_Manager *mgr; Ttk_Layout labelLayout; /* Sublayout for label */ Ttk_Box labelParcel; /* Set in layoutProc */ } LabelframePart; |
︙ | ︙ | |||
253 254 255 256 257 258 259 | static const Tk_OptionSpec LabelframeOptionSpecs[] = { {TK_OPTION_STRING, "-labelanchor", "labelAnchor", "LabelAnchor", "nw", offsetof(Labelframe, label.labelAnchorObj),TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(Labelframe,label.textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, | | | < | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | static const Tk_OptionSpec LabelframeOptionSpecs[] = { {TK_OPTION_STRING, "-labelanchor", "labelAnchor", "LabelAnchor", "nw", offsetof(Labelframe, label.labelAnchorObj),TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(Labelframe,label.textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(Labelframe, label.underline), 0}, {TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL, TCL_INDEX_NONE, offsetof(Labelframe,label.labelWidget), TK_OPTION_NULL_OK,0,LABELWIDGET_CHANGED|GEOMETRY_CHANGED }, WIDGET_INHERIT_OPTIONS(FrameOptionSpecs) }; |
︙ | ︙ |
Changes to generic/ttk/ttkImage.c.
1 2 3 | /* * Image specifications and image element factory. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 | /* * Image specifications and image element factory. * * Copyright © 2004 Pat Thoyts <[email protected]> * 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]. */ |
︙ | ︙ | |||
254 255 256 257 258 259 260 | /*------------------------------------------------------------------------ * +++ Image element definition. */ typedef struct { /* ClientData for image elements */ Ttk_ImageSpec *imageSpec; /* Image(s) to use */ int minWidth; /* Minimum width; overrides image width */ | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | /*------------------------------------------------------------------------ * +++ Image element definition. */ typedef struct { /* ClientData for image elements */ Ttk_ImageSpec *imageSpec; /* Image(s) to use */ int minWidth; /* Minimum width; overrides image width */ int minHeight; /* Minimum height; overrides image height */ Ttk_Sticky sticky; /* -stickiness specification */ Ttk_Padding border; /* Fixed border region */ Ttk_Padding padding; /* Internal padding */ #ifdef TILE_07_COMPAT Ttk_ResourceCache cache; /* Resource cache for images */ Ttk_StateMap imageMap; /* State-based lookup table for images */ |
︙ | ︙ |
Changes to generic/ttk/ttkInit.c.
1 | /* | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | /* * Copyright © 2003 Joe English * * Ttk package: initialization routine and miscellaneous utilities. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" /* * Legal values for the button -default option. * See also: enum Ttk_ButtonDefaultState. */ const char *const ttkDefaultStrings[] = { "active", "disabled", "normal", NULL }; int Ttk_GetButtonDefaultStateFromObj( Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_ButtonDefaultState *statePtr) { int state = (int)TTK_BUTTON_DEFAULT_DISABLED; int result = Tcl_GetIndexFromObj(interp, objPtr, ttkDefaultStrings, "default state", 0, &state); *statePtr = (Ttk_ButtonDefaultState)state; return result; } /* * Legal values for the -compound option. * See also: enum Ttk_Compound. */ const char *const ttkCompoundStrings[] = { "none", "text", "image", "center", "top", "bottom", "left", "right", NULL }; int Ttk_GetCompoundFromObj( Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Compound *compoundPtr) { int compound = (int)TTK_COMPOUND_NONE; int result = Tcl_GetIndexFromObj(interp, objPtr, ttkCompoundStrings, "compound layout", 0, &compound); *compoundPtr = (Ttk_Compound)compound; return result; } /* * Legal values for the -orient option. * See also: enum Ttk_Orient. */ const char *const ttkOrientStrings[] = { "horizontal", "vertical", NULL }; #if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9 int Ttk_GetOrientFromObj( Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr) { *resultPtr = TTK_ORIENT_HORIZONTAL; return Tcl_GetIndexFromObj(interp, objPtr, ttkOrientStrings, "orientation", 0, resultPtr); } #endif int TtkGetOrientFromObj( Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Orient *resultPtr) { int orient = (int)TTK_ORIENT_HORIZONTAL; int result = Tcl_GetIndexFromObj(interp, objPtr, ttkOrientStrings, "orientation", 0, &orient); *resultPtr = (Ttk_Orient)orient; return result; } /* * Recognized values for the -state compatibility option. * Other options are accepted and interpreted as synonyms for "normal". */ static const char *const ttkStateStrings[] = { "active", "disabled", "normal", "readonly", NULL }; enum { TTK_COMPAT_STATE_ACTIVE, TTK_COMPAT_STATE_DISABLED, TTK_COMPAT_STATE_NORMAL, TTK_COMPAT_STATE_READONLY }; /* TtkCheckStateOption -- * Handle -state compatibility option. * * NOTE: setting -state disabled / -state enabled affects the * widget state, but the internal widget state does *not* affect * the value of the -state option. * This option is present for compatibility only. */ void TtkCheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr) { int stateOption = TTK_COMPAT_STATE_NORMAL; unsigned all = TTK_STATE_DISABLED|TTK_STATE_READONLY|TTK_STATE_ACTIVE; # define SETFLAGS(f) TtkWidgetChangeState(corePtr, f, all^f) Tcl_GetIndexFromObj(NULL, objPtr, ttkStateStrings, "", 0, &stateOption); switch (stateOption) { case TTK_COMPAT_STATE_NORMAL: default: SETFLAGS(0); break; case TTK_COMPAT_STATE_READONLY: SETFLAGS(TTK_STATE_READONLY); |
︙ | ︙ | |||
267 268 269 270 271 272 273 274 275 276 277 278 279 | RegisterElements(interp); RegisterWidgets(interp); RegisterThemes(interp); Ttk_PlatformInit(interp); Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs); return TCL_OK; } /*EOF*/ | > > > | 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | RegisterElements(interp); 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*/ |
Changes to generic/ttk/ttkLabel.c.
︙ | ︙ | |||
26 27 28 29 30 31 32 | Tcl_Obj *fontObj; Tcl_Obj *foregroundObj; Tcl_Obj *underlineObj; Tcl_Obj *widthObj; Tcl_Obj *anchorObj; Tcl_Obj *justifyObj; Tcl_Obj *wrapLengthObj; | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | Tcl_Obj *fontObj; Tcl_Obj *foregroundObj; Tcl_Obj *underlineObj; Tcl_Obj *widthObj; Tcl_Obj *anchorObj; Tcl_Obj *justifyObj; Tcl_Obj *wrapLengthObj; Tcl_Obj *embossedObj; /* * Computed resources: */ Tk_Font tkfont; Tk_TextLayout textLayout; int width; |
︙ | ︙ | |||
49 50 51 52 53 54 55 | static const Ttk_ElementOptionSpec TextElementOptions[] = { { "-text", TK_OPTION_STRING, offsetof(TextElement,textObj), "" }, { "-font", TK_OPTION_FONT, offsetof(TextElement,fontObj), DEFAULT_FONT }, { "-foreground", TK_OPTION_COLOR, offsetof(TextElement,foregroundObj), "black" }, | | > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | static const Ttk_ElementOptionSpec TextElementOptions[] = { { "-text", TK_OPTION_STRING, offsetof(TextElement,textObj), "" }, { "-font", TK_OPTION_FONT, offsetof(TextElement,fontObj), DEFAULT_FONT }, { "-foreground", TK_OPTION_COLOR, offsetof(TextElement,foregroundObj), "black" }, { "-underline", TK_OPTION_INDEX, #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) offsetof(TextElement,underlineObj), "-1"}, #else offsetof(TextElement,underlineObj), NULL}, #endif { "-width", TK_OPTION_INT, offsetof(TextElement,widthObj), "-1"}, { "-anchor", TK_OPTION_ANCHOR, offsetof(TextElement,anchorObj), "w"}, { "-justify", TK_OPTION_JUSTIFY, offsetof(TextElement,justifyObj), "left" }, { "-wraplength", TK_OPTION_PIXELS, |
︙ | ︙ | |||
122 123 124 125 126 127 128 | * TextDraw -- * Draw a text element. * Called by TextElementDraw() and LabelElementDraw(). */ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) { XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj); | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | * TextDraw -- * Draw a text element. * Called by TextElementDraw() and LabelElementDraw(). */ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) { XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj); TkSizeT underline = TCL_INDEX_NONE; XGCValues gcValues; GC gc1, gc2; Tk_Anchor anchor = TK_ANCHOR_CENTER; TkRegion clipRegion = NULL; gcValues.font = Tk_FontId(text->tkfont); gcValues.foreground = color->pixel; |
︙ | ︙ | |||
166 167 168 169 170 171 172 | if (text->embossed) { Tk_DrawTextLayout(Tk_Display(tkwin), d, gc2, text->textLayout, b.x+1, b.y+1, 0/*firstChar*/, -1/*lastChar*/); } Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1, text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/); | | > | > > > | | | | | | > | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | if (text->embossed) { Tk_DrawTextLayout(Tk_Display(tkwin), d, gc2, text->textLayout, b.x+1, b.y+1, 0/*firstChar*/, -1/*lastChar*/); } Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1, text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/); if (text->underlineObj != NULL) { TkGetIntForIndex(text->underlineObj, TCL_INDEX_END, 0, &underline); if (underline != TCL_INDEX_NONE) { if ((size_t)underline > (size_t)TCL_INDEX_END>>1) { underline++; } if (text->embossed) { Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2, text->textLayout, b.x+1, b.y+1, underline); } Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1, text->textLayout, b.x, b.y, underline); } } if (clipRegion != NULL) { #ifdef HAVE_XFT TkUnixSetXftClipRegion(NULL); #endif XSetClipMask(Tk_Display(tkwin), gc1, None); |
︙ | ︙ | |||
459 460 461 462 463 464 465 | */ { "-text", TK_OPTION_STRING, offsetof(LabelElement,text.textObj), "" }, { "-font", TK_OPTION_FONT, offsetof(LabelElement,text.fontObj), DEFAULT_FONT }, { "-foreground", TK_OPTION_COLOR, offsetof(LabelElement,text.foregroundObj), "black" }, | | > > > > | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | */ { "-text", TK_OPTION_STRING, offsetof(LabelElement,text.textObj), "" }, { "-font", TK_OPTION_FONT, offsetof(LabelElement,text.fontObj), DEFAULT_FONT }, { "-foreground", TK_OPTION_COLOR, offsetof(LabelElement,text.foregroundObj), "black" }, { "-underline", TK_OPTION_INDEX, #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) offsetof(LabelElement,text.underlineObj), "-1"}, #else offsetof(LabelElement,text.underlineObj), NULL}, #endif { "-width", TK_OPTION_INT, offsetof(LabelElement,text.widthObj), ""}, { "-anchor", TK_OPTION_ANCHOR, offsetof(LabelElement,text.anchorObj), "w"}, { "-justify", TK_OPTION_JUSTIFY, offsetof(LabelElement,text.justifyObj), "left" }, { "-wraplength", TK_OPTION_PIXELS, |
︙ | ︙ |
Changes to generic/ttk/ttkLayout.c.
1 2 3 4 5 | /* * ttkLayout.c -- * * Generic layout processing. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * ttkLayout.c -- * * Generic layout processing. * * Copyright © 2003 Joe English. Freely redistributable. */ #include "tkInt.h" #include "ttkThemeInt.h" #define MAX(a,b) (a > b ? a : b) #define MIN(a,b) (a < b ? a : b) |
︙ | ︙ | |||
216 217 218 219 220 221 222 | case TK_ANCHOR_NE: return TTK_STICK_N | TTK_STICK_E; case TK_ANCHOR_E: return TTK_STICK_E; case TK_ANCHOR_SE: return TTK_STICK_S | TTK_STICK_E; case TK_ANCHOR_S: return TTK_STICK_S; case TK_ANCHOR_SW: return TTK_STICK_S | TTK_STICK_W; case TK_ANCHOR_W: return TTK_STICK_W; case TK_ANCHOR_NW: return TTK_STICK_N | TTK_STICK_W; | | < | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | case TK_ANCHOR_NE: return TTK_STICK_N | TTK_STICK_E; case TK_ANCHOR_E: return TTK_STICK_E; case TK_ANCHOR_SE: return TTK_STICK_S | TTK_STICK_E; case TK_ANCHOR_S: return TTK_STICK_S; case TK_ANCHOR_SW: return TTK_STICK_S | TTK_STICK_W; case TK_ANCHOR_W: return TTK_STICK_W; case TK_ANCHOR_NW: return TTK_STICK_N | TTK_STICK_W; default: return 0; } } /* * Ttk_AnchorBox -- * Place a box of size w * h in the specified parcel, * according to the specified anchor. |
︙ | ︙ | |||
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | { node->parcel = b; if (node->child) { Ttk_PlaceNodeList(layout, node->child, 0, Ttk_PadBox(b, Ttk_LayoutNodeInternalPadding(layout, node))); } } /* * Ttk_ChangeElementState -- */ void Ttk_ChangeElementState(Ttk_LayoutNode *node,unsigned set,unsigned clr) { node->state = (node->state | set) & ~clr; } /*EOF*/ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 | { node->parcel = b; if (node->child) { Ttk_PlaceNodeList(layout, node->child, 0, Ttk_PadBox(b, Ttk_LayoutNodeInternalPadding(layout, node))); } } /* * AnchorToPosition -- * Convert a Tk_Anchor enum to a position bitmask. */ static Ttk_PositionSpec AnchorToPosition(Tk_Anchor anchor) { switch (anchor) { case TK_ANCHOR_N: return TTK_PACK_TOP; case TK_ANCHOR_S: return TTK_PACK_BOTTOM; case TK_ANCHOR_NE: return TTK_PACK_RIGHT|TTK_STICK_N; case TK_ANCHOR_SE: return TTK_PACK_RIGHT|TTK_STICK_S; case TK_ANCHOR_E: return TTK_PACK_RIGHT; case TK_ANCHOR_NW: return TTK_PACK_LEFT|TTK_STICK_N; case TK_ANCHOR_SW: return TTK_PACK_LEFT|TTK_STICK_S; case TK_ANCHOR_W: return TTK_PACK_LEFT; case TK_ANCHOR_CENTER: return 0; default:; } return TTK_PACK_LEFT; } /* * Ttk_AnchorElement -- * Explicitly specify an element's anchoring. */ void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor) { node->flags = AnchorToPosition(anchor); } /* * Ttk_ChangeElementState -- */ void Ttk_ChangeElementState(Ttk_LayoutNode *node,unsigned set,unsigned clr) { node->state = (node->state | set) & ~clr; } /*EOF*/ |
Changes to generic/ttk/ttkManager.c.
︙ | ︙ | |||
310 311 312 313 314 315 316 | * +++ Tk_GeomMgr hooks. */ void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; TkSizeT index = Ttk_ContentIndex(mgr, window); | > > | | < | | < | > | | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | * +++ Tk_GeomMgr hooks. */ void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; TkSizeT index = Ttk_ContentIndex(mgr, window); if (index != TCL_INDEX_NONE) { int reqWidth = Tk_ReqWidth(window); int reqHeight= Tk_ReqHeight(window); if (mgr->managerSpec->ContentRequest( mgr->managerData, index, reqWidth, reqHeight)) { ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } } } void Ttk_LostContentProc(ClientData clientData, Tk_Window window) { Ttk_Manager *mgr = (Ttk_Manager *)clientData; TkSizeT index = Ttk_ContentIndex(mgr, window); /* ASSERT: index != TCL_INDEX_NONE */ RemoveContent(mgr, index); } /*------------------------------------------------------------------------ * +++ Public API. */ |
︙ | ︙ | |||
418 419 420 421 422 423 424 | } /*------------------------------------------------------------------------ * +++ Utility routines. */ /* ++ Ttk_ContentIndex -- | | | 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | } /*------------------------------------------------------------------------ * +++ Utility routines. */ /* ++ Ttk_ContentIndex -- * Returns the index of specified content window, TCL_INDEX_NONE if not found. */ TkSizeT Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window) { TkSizeT index; for (index = 0; index < mgr->nContent; ++index) if (mgr->content[index]->window == window) return index; |
︙ | ︙ | |||
448 449 450 451 452 453 454 | 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) { | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | 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 == TCL_INDEX_NONE || index > mgr->nContent) { 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; |
︙ | ︙ |
Changes to generic/ttk/ttkManager.h.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2005 Joe English. Freely redistributable. * * Geometry manager utilities. */ #ifndef _TTKMANAGER #define _TTKMANAGER |
︙ | ︙ |
Changes to generic/ttk/ttkNotebook.c.
1 | /* | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* * Copyright © 2004 Joe English */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" #include "ttkManager.h" #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) /*------------------------------------------------------------------------ * +++ Tab resources. */ #define DEFAULT_MIN_TAB_WIDTH 24 static const char *const TabStateStrings[] = { "disabled", "hidden", "normal", 0 }; typedef enum { TAB_STATE_DISABLED, TAB_STATE_HIDDEN, TAB_STATE_NORMAL } TAB_STATE; typedef struct { /* Internal data: */ int width, height; /* Requested size of tab */ |
︙ | ︙ | |||
40 41 42 43 44 45 46 | Ttk_Sticky sticky; /* Label options: */ Tcl_Obj *textObj; Tcl_Obj *imageObj; Tcl_Obj *compoundObj; | | | | | | | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | Ttk_Sticky sticky; /* Label options: */ Tcl_Obj *textObj; Tcl_Obj *imageObj; Tcl_Obj *compoundObj; int underline; } Tab; /* 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 pane. */ static const Tk_OptionSpec TabOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-state", "", "", "normal", TCL_INDEX_NONE, offsetof(Tab,state), TK_OPTION_ENUM_VAR, TabStateStrings, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", 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 }, {TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound", NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,ttkCompoundStrings,GEOMETRY_CHANGED }, {TK_OPTION_INDEX, "-underline", "underline", "Underline", TK_OPTION_UNDERLINE_DEF(Tab, underline), 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 }, |
︙ | ︙ | |||
895 896 897 898 899 900 901 | /* $nb add window ?options ... ? */ static int NotebookAddCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = (Notebook *)recordPtr; Tk_Window window; | | | | 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 | /* $nb add window ?options ... ? */ static int NotebookAddCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Notebook *nb = (Notebook *)recordPtr; Tk_Window window; TkSizeT index; Tab *tab; if (objc <= 2 || objc % 2 != 1) { Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?"); return TCL_ERROR; } window = Tk_NameToWindow(interp,Tcl_GetString(objv[2]),nb->core.tkwin); if (!window) { return TCL_ERROR; } index = Ttk_ContentIndex(nb->notebook.mgr, window); if (index == TCL_INDEX_NONE) { /* New tab */ return AddTab(interp, nb, Ttk_NumberContent(nb->notebook.mgr), window, objc-3,objv+3); } tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); if (tab->state == TAB_STATE_HIDDEN) { tab->state = TAB_STATE_NORMAL; } |
︙ | ︙ | |||
1047 1048 1049 1050 1051 1052 1053 | return TCL_ERROR; } tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); tab->state = TAB_STATE_HIDDEN; if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); | < | | | > | 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 | return TCL_ERROR; } tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index); tab->state = TAB_STATE_HIDDEN; if (index == nb->notebook.currentIndex) { SelectNearestTab(nb); } else { TtkRedisplayWidget(&nb->core); } return TCL_OK; } /* $nb identify $x $y -- * Returns name of tab element at $x,$y; empty string if none. */ static int NotebookIdentifyCommand( |
︙ | ︙ | |||
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 | if (element) { const char *elementName = Ttk_ElementName(element); Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1)); } break; case IDENTIFY_TAB: if (tabIndex != TCL_INDEX_NONE) Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex)); break; } return TCL_OK; } /* $nb index $item -- | > > | 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 | if (element) { const char *elementName = Ttk_ElementName(element); Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1)); } break; case IDENTIFY_TAB: #if !defined TK_NO_DEPRECATED && (TCL_MAJOR_VERSION < 9) if (tabIndex != TCL_INDEX_NONE) #endif Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex)); break; } return TCL_OK; } /* $nb index $item -- |
︙ | ︙ | |||
1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "tab"); return TCL_ERROR; } status = FindTabIndex(interp, nb, objv[2], &index); if (status == TCL_OK) { if (index != TCL_INDEX_NONE) Tcl_SetObjResult(interp, TkNewIndexObj(index)); } return status; } /* $nb select ?$item? -- | > > | 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 | if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "tab"); return TCL_ERROR; } status = FindTabIndex(interp, nb, objv[2], &index); if (status == TCL_OK) { #if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9) if (index != TCL_INDEX_NONE) #endif Tcl_SetObjResult(interp, TkNewIndexObj(index)); } return status; } /* $nb select ?$item? -- |
︙ | ︙ | |||
1238 1239 1240 1241 1242 1243 1244 | return TCL_OK; } /* Subcommand table: */ static const Ttk_Ensemble NotebookCommands[] = { { "add", NotebookAddCommand,0 }, | < > > | 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 | return TCL_OK; } /* Subcommand table: */ static const Ttk_Ensemble NotebookCommands[] = { { "add", NotebookAddCommand,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 } }; /*------------------------------------------------------------------------ * +++ Widget class hooks. |
︙ | ︙ |
Changes to generic/ttk/ttkPanedwindow.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2005 Joe English. Freely redistributable. * * ttk::panedwindow widget implementation. * * TODO: track active/pressed sash. */ #include "tkInt.h" |
︙ | ︙ | |||
73 74 75 76 77 78 79 | } Paned; /* @@@ 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), | | | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | } Paned; /* @@@ 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, ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED }, {TK_OPTION_INT, "-width", "width", "Width", "0", 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 }, |
︙ | ︙ | |||
878 879 880 881 882 883 884 | Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos)); return TCL_OK; } static const Ttk_Ensemble PanedCommands[] = { { "add", PanedAddCommand,0 }, | < > > | 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos)); return TCL_OK; } static const Ttk_Ensemble PanedCommands[] = { { "add", PanedAddCommand,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. */ |
︙ | ︙ |
Changes to generic/ttk/ttkProgress.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © Joe English, Pat Thoyts, Michael Kirkham * * ttk::progressbar widget. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" |
︙ | ︙ | |||
59 60 61 62 63 64 65 | {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", "black", offsetof(Progressbar,progress.foregroundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "left", offsetof(Progressbar,progress.justifyObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_PIXELS, "-length", "length", "Length", | | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", "black", offsetof(Progressbar,progress.foregroundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "left", offsetof(Progressbar,progress.justifyObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_PIXELS, "-length", "length", "Length", DEF_PROGRESSBAR_LENGTH, offsetof(Progressbar,progress.lengthObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum", "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, ProgressbarModeStrings, 0 }, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Progressbar,progress.orientObj), TCL_INDEX_NONE, 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", "", |
︙ | ︙ | |||
121 122 123 124 125 126 127 | * and reschedules itself if animation still enabled. */ static void AnimateProgressProc(ClientData clientData) { Progressbar *pb = (Progressbar *)clientData; pb->progress.timer = 0; | < > | | > > < | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | * and reschedules itself if animation still enabled. */ 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 (phase > pb->progress.maxPhase) { phase = 0; } Tcl_DecrRefCount(pb->progress.phaseObj); 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 -- * If animation is enabled and not scheduled, schedule it. * If animation is disabled but scheduled, cancel it. |
︙ | ︙ | |||
514 515 516 517 518 519 520 | Tcl_Obj *const objv[]) { return ProgressbarStartStopCommand( interp, "::ttk::progressbar::stop", objc, objv); } static const Ttk_Ensemble ProgressbarCommands[] = { | < > > | 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 | Tcl_Obj *const objv[]) { return ProgressbarStartStopCommand( interp, "::ttk::progressbar::stop", objc, objv); } static const Ttk_Ensemble ProgressbarCommands[] = { { "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: */ static const WidgetSpec ProgressbarWidgetSpec = |
︙ | ︙ |
Changes to generic/ttk/ttkScale.c.
1 | /* | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * Copyright © 2004 Pat Thoyts <[email protected]> * * ttk::scale widget. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" #define DEF_SCALE_LENGTH "100" #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
︙ | ︙ | |||
57 58 59 60 61 62 63 | 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}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Scale,scale.orientObj), | | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | 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}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Scale,scale.orientObj), offsetof(Scale,scale.orient), 0, 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}, {TK_OPTION_DOUBLE, "-value", "value", "Value", "0", offsetof(Scale,scale.valueObj), TCL_INDEX_NONE, 0, 0, 0}, |
︙ | ︙ | |||
479 480 481 482 483 484 485 486 | pt.x = troughBox.x + troughBox.width / 2; pt.y = troughBox.y + (int)(fraction * troughBox.height); } return pt; } static const Ttk_Ensemble ScaleCommands[] = { { "configure", TtkWidgetConfigureCommand,0 }, | > > | | < | | | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | pt.x = troughBox.x + troughBox.width / 2; pt.y = troughBox.y + (int)(fraction * troughBox.height); } return pt; } static const Ttk_Ensemble ScaleCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "coords", ScaleCoordsCommand,0 }, { "get", ScaleGetCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "set", ScaleSetCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; static const WidgetSpec ScaleWidgetSpec = { "TScale", /* Class name */ sizeof(Scale), /* record size */ |
︙ | ︙ |
Changes to generic/ttk/ttkScrollbar.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2003 Joe English * * ttk::scrollbar widget. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" |
︙ | ︙ | |||
35 36 37 38 39 40 41 | { {TK_OPTION_STRING, "-command", "command", "Command", "", 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), | | | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | { {TK_OPTION_STRING, "-command", "command", "Command", "", 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, ttkOrientStrings, STYLE_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; /*------------------------------------------------------------------------ * +++ Widget hooks. |
︙ | ︙ | |||
278 279 280 281 282 283 284 | } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); return TCL_OK; } static const Ttk_Ensemble ScrollbarCommands[] = { | < > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | } Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fraction)); return TCL_OK; } static const Ttk_Ensemble ScrollbarCommands[] = { { "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. */ static const WidgetSpec ScrollbarWidgetSpec = |
︙ | ︙ |
Changes to generic/ttk/ttkSeparator.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * Copyright © 2004 Joe English * * ttk::separator and ttk::sizegrip widgets. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" |
︙ | ︙ | |||
22 23 24 25 26 27 28 | SeparatorPart separator; } Separator; static const Tk_OptionSpec SeparatorOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Separator,separator.orientObj), offsetof(Separator,separator.orient), | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | SeparatorPart separator; } Separator; static const Tk_OptionSpec SeparatorOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Separator,separator.orientObj), offsetof(Separator,separator.orient), 0, ttkOrientStrings, STYLE_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; /* * GetLayout hook -- |
︙ | ︙ | |||
44 45 46 47 48 49 50 | interp, theme, recordPtr, sep->separator.orientObj); } /* * Widget commands: */ static const Ttk_Ensemble SeparatorCommands[] = { | < > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | interp, theme, recordPtr, sep->separator.orientObj); } /* * Widget commands: */ static const Ttk_Ensemble SeparatorCommands[] = { { "cget", TtkWidgetCgetCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "identify", TtkWidgetIdentifyCommand,0 }, { "instate", TtkWidgetInstateCommand,0 }, { "state", TtkWidgetStateCommand,0 }, { "style", TtkWidgetStyleCommand,0 }, { 0,0,0 } }; /* * Widget specification: */ static const WidgetSpec SeparatorWidgetSpec = |
︙ | ︙ | |||
85 86 87 88 89 90 91 | static const Tk_OptionSpec SizegripOptionSpecs[] = { WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; static const Ttk_Ensemble SizegripCommands[] = { | < > > | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | static const Tk_OptionSpec SizegripOptionSpecs[] = { WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; static const Ttk_Ensemble SizegripCommands[] = { { "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 = { "TSizegrip", /* className */ sizeof(WidgetCore), /* recordSize */ |
︙ | ︙ |
Changes to generic/ttk/ttkSquare.c.
|
| | | 1 2 3 4 5 6 7 8 | /* square.c - Copyright © 2004 Pat Thoyts <[email protected]> * * Minimal sample ttk widget. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" |
︙ | ︙ | |||
68 69 70 71 72 73 74 | offsetof(Square,square.paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL, offsetof(Square,square.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", | | | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | offsetof(Square,square.paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL, offsetof(Square,square.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0}, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center", offsetof(Square,square.anchorObj), TCL_INDEX_NONE, 0, 0, 0}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) }; /* * Almost all of the widget functionality is handled by the default Ttk |
︙ | ︙ | |||
125 126 127 128 129 130 131 | /* * Widget commands. A widget is impelemented as an ensemble and the * subcommands are listed here. Ttk provides default implementations * that are sufficient for our needs. */ static const Ttk_Ensemble SquareCommands[] = { | < > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /* * Widget commands. A widget is impelemented as an ensemble and the * subcommands are listed here. Ttk provides default implementations * that are sufficient for our needs. */ static const Ttk_Ensemble SquareCommands[] = { { "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 * information about this widget and this is what must be registered * with Tk in the package initialization code (see bottom). |
︙ | ︙ |
Changes to generic/ttk/ttkState.c.
1 2 3 | /* * Tk widget state utilities. * | | | 1 2 3 4 5 6 7 8 9 10 11 | /* * Tk widget state utilities. * * Copyright © 2003 Joe English. Freely redistributable. * */ #include "tkInt.h" #include "ttkTheme.h" /* |
︙ | ︙ |
Changes to generic/ttk/ttkStubLib.c.
︙ | ︙ | |||
30 31 32 33 34 35 36 | * */ MODULE_SCOPE const char * TtkInitializeStubs( Tcl_Interp *interp, const char *version, int epoch, int revision) { int exact = 0; | | | > > > > | | | > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | * */ MODULE_SCOPE const char * TtkInitializeStubs( Tcl_Interp *interp, const char *version, int epoch, int revision) { int exact = 0; const char *packageName = "ttk"; const char *errMsg = NULL; void *pkgClientData = NULL; const char *actualVersion = Tcl_PkgRequireEx( interp, packageName, version, exact, &pkgClientData); const TtkStubs *stubsPtr; if (!actualVersion) { 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) { errMsg = "epoch number mismatch"; goto error; |
︙ | ︙ |
Changes to generic/ttk/ttkTagSet.c.
1 2 3 | /* * Tag tables. 3/4-baked, work in progress. * | | | 1 2 3 4 5 6 7 8 9 10 11 | /* * Tag tables. 3/4-baked, work in progress. * * Copyright © 2005, Joe English. Freely redistributable. */ #include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" /*------------------------------------------------------------------------ |
︙ | ︙ | |||
136 137 138 139 140 141 142 | if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { ckfree(tagset); return NULL; } tagset->tags = (Ttk_Tag *)ckalloc((objc+1) * sizeof(Ttk_Tag)); | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { ckfree(tagset); return NULL; } tagset->tags = (Ttk_Tag *)ckalloc((objc+1) * sizeof(Ttk_Tag)); for (i = 0; i < objc; ++i) { tagset->tags[i] = Ttk_GetTagFromObj(tagTable, objv[i]); } tagset->tags[i] = NULL; tagset->nTags = objc; return tagset; } |
︙ | ︙ | |||
197 198 199 200 201 202 203 204 205 206 207 208 209 210 | } } tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags, (tagset->nTags+1)*sizeof(tagset->tags[0])); tagset->tags[tagset->nTags++] = tag; return 1; } /* Ttk_TagSetRemove -- remove a tag from a tag set. * * Returns: 0 if tagset did not contain tag, * 1 if tagset was modified. */ int Ttk_TagSetRemove(Ttk_TagSet tagset, Ttk_Tag tag) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | } } tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags, (tagset->nTags+1)*sizeof(tagset->tags[0])); tagset->tags[tagset->nTags++] = tag; return 1; } /* Ttk_TagSetAddSet -- add a tag set to a tag set. * * Returns: 0 if tagset already contained tags, * 1 if tagset was modified. */ int Ttk_TagSetAddSet(Ttk_TagSet tagset, Ttk_TagSet tagsetFrom) { int i, j, result = 0, found, total, nTags = tagset->nTags; Ttk_Tag tag; total = tagsetFrom->nTags + tagset->nTags; tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags, (total)*sizeof(tagset->tags[0])); for (j = 0; j < tagsetFrom->nTags; ++j) { tag = tagsetFrom->tags[j]; found = 0; for (i = 0; i < nTags; ++i) { if (tagset->tags[i] == tag) { found = 1; break; } } if (found) continue; tagset->tags[tagset->nTags++] = tag; result = 1; } return result; } /* Ttk_TagSetRemove -- remove a tag from a tag set. * * Returns: 0 if tagset did not contain tag, * 1 if tagset was modified. */ int Ttk_TagSetRemove(Ttk_TagSet tagset, Ttk_Tag tag) |
︙ | ︙ | |||
267 268 269 270 271 272 273 274 275 276 277 278 279 | } /*------------------------------------------------------------------------ * +++ Tag values. */ #define OBJ_AT(record, offset) (*(Tcl_Obj**)(((char*)record)+offset)) void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record) { const int LOWEST_PRIORITY = 0x7FFFFFFF; int i, j; | > > > > > > > > > > > > > < < | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | } /*------------------------------------------------------------------------ * +++ Tag values. */ #define OBJ_AT(record, offset) (*(Tcl_Obj**)(((char*)record)+offset)) void Ttk_TagSetDefaults(Ttk_TagTable tagTable, Ttk_Style style, void *record) { const Tk_OptionSpec *optionSpec = tagTable->optionSpecs; memset(record, 0, tagTable->recordSize); while (optionSpec->type != TK_OPTION_END) { int offset = optionSpec->objOffset; const char *optionName = optionSpec->optionName; OBJ_AT(record, offset) = Ttk_StyleDefault(style, optionName); ++optionSpec; } } void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record) { const int LOWEST_PRIORITY = 0x7FFFFFFF; int i, j; for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) { const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i; TkSizeT offset = optionSpec->objOffset; int prio = LOWEST_PRIORITY; for (j = 0; j < tagSet->nTags; ++j) { Ttk_Tag tag = tagSet->tags[j]; |
︙ | ︙ | |||
301 302 303 304 305 306 307 | while (optionSpec->type != TK_OPTION_END) { TkSizeT offset = optionSpec->objOffset; const char *optionName = optionSpec->optionName; Tcl_Obj *val = Ttk_StyleMap(style, optionName, state); if (val) { OBJ_AT(record, offset) = val; | < < | 341 342 343 344 345 346 347 348 349 350 351 352 | while (optionSpec->type != TK_OPTION_END) { TkSizeT offset = optionSpec->objOffset; const char *optionName = optionSpec->optionName; Tcl_Obj *val = Ttk_StyleMap(style, optionName, state); if (val) { OBJ_AT(record, offset) = val; } ++optionSpec; } } |
Changes to generic/ttk/ttkTheme.c.
1 2 3 4 5 | /* * ttkTheme.c -- * * This file implements the widget styles and themes support. * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* * ttkTheme.c -- * * This file implements the widget styles and themes support. * * 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. */ #include "tkInt.h" #include "ttkThemeInt.h" |
︙ | ︙ | |||
91 92 93 94 95 96 97 | style = style->parentStyle; } return 0; } /* * Ttk_StyleDefault -- | | | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | style = style->parentStyle; } return 0; } /* * Ttk_StyleDefault -- * Look up default resource setting in the specified style. */ Tcl_Obj *Ttk_StyleDefault(Ttk_Style style, const char *optionName) { while (style) { Tcl_HashEntry *entryPtr = Tcl_FindHashEntry(&style->defaultsTable, optionName); if (entryPtr) |
︙ | ︙ | |||
1258 1259 1260 1261 1262 1263 1264 | Tcl_WrongNumArgs(interp,2,objv,"style ?-option ?value...??"); return TCL_ERROR; } styleName = Tcl_GetString(objv[2]); stylePtr = Ttk_GetStyle(theme, styleName); | | | | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 | Tcl_WrongNumArgs(interp,2,objv,"style ?-option ?value...??"); return TCL_ERROR; } styleName = Tcl_GetString(objv[2]); stylePtr = Ttk_GetStyle(theme, styleName); if (objc == 3) { /* style configure $styleName */ Tcl_SetObjResult(interp, HashTableToDict(&stylePtr->defaultsTable)); return TCL_OK; } 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)); } return TCL_OK; |
︙ | ︙ | |||
1311 1312 1313 1314 1315 1316 1317 | if (objc < 4 || objc > 6) { Tcl_WrongNumArgs(interp, 2, objv, "style -option ?state? ?default?"); return TCL_ERROR; } style = Ttk_GetStyle(theme, Tcl_GetString(objv[2])); | < < | | 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 | if (objc < 4 || objc > 6) { Tcl_WrongNumArgs(interp, 2, objv, "style -option ?state? ?default?"); return TCL_ERROR; } style = Ttk_GetStyle(theme, Tcl_GetString(objv[2])); optionName = Tcl_GetString(objv[3]); if (objc >= 5) { Ttk_StateSpec stateSpec; /* @@@ SB: Ttk_GetStateFromObj(); 'offbits' spec is ignored */ if (Ttk_GetStateSpecFromObj(interp, objv[4], &stateSpec) != TCL_OK) { return TCL_ERROR; |
︙ | ︙ | |||
1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 | return TCL_ERROR; } Ttk_RegisterLayoutTemplate(theme, layoutName, layoutTemplate); ThemeChanged(pkgPtr); } return TCL_OK; } /* + style theme use $theme -- * Sets the current theme to $theme */ static int StyleThemeUseCmd( ClientData clientData, /* StylePackageData pointer */ | > > > > > > > > > > > > > > > > > > > > > > > > > | 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 | return TCL_ERROR; } 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(void *), 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, /* StylePackageData pointer */ |
︙ | ︙ | |||
1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 | * Implementation of the [style] command. */ static const Ttk_Ensemble StyleThemeEnsemble[] = { { "create", StyleThemeCreateCmd, 0 }, { "names", StyleThemeNamesCmd, 0 }, { "settings", StyleThemeSettingsCmd, 0 }, { "use", StyleThemeUseCmd, 0 }, { NULL, 0, 0 } }; static const Ttk_Ensemble StyleElementEnsemble[] = { { "create", StyleElementCreateCmd, 0 }, { "names", StyleElementNamesCmd, 0 }, | > | 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 | * Implementation of the [style] command. */ 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[] = { { "create", StyleElementCreateCmd, 0 }, { "names", StyleElementNamesCmd, 0 }, |
︙ | ︙ |
Changes to generic/ttk/ttkTheme.h.
︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 314 315 316 317 | MODULE_SCOPE Ttk_Box Ttk_ClientRegion(Ttk_Layout, const char *elementName); MODULE_SCOPE Ttk_Box Ttk_LayoutNodeInternalParcel(Ttk_Layout,Ttk_Element); MODULE_SCOPE Ttk_Padding Ttk_LayoutNodeInternalPadding(Ttk_Layout,Ttk_Element); MODULE_SCOPE void Ttk_LayoutNodeReqSize(Ttk_Layout, Ttk_Element, int *w, int *h); MODULE_SCOPE void Ttk_PlaceElement(Ttk_Layout, Ttk_Element, Ttk_Box); MODULE_SCOPE void Ttk_ChangeElementState(Ttk_Element,unsigned set,unsigned clr); MODULE_SCOPE Tcl_Obj *Ttk_QueryOption(Ttk_Layout, const char *, Ttk_State); TTKAPI Ttk_Style Ttk_LayoutStyle(Ttk_Layout); TTKAPI Tcl_Obj *Ttk_StyleDefault(Ttk_Style, const char *optionName); TTKAPI Tcl_Obj *Ttk_StyleMap(Ttk_Style, const char *optionName, Ttk_State); | > | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | MODULE_SCOPE Ttk_Box Ttk_ClientRegion(Ttk_Layout, const char *elementName); MODULE_SCOPE Ttk_Box Ttk_LayoutNodeInternalParcel(Ttk_Layout,Ttk_Element); MODULE_SCOPE Ttk_Padding Ttk_LayoutNodeInternalPadding(Ttk_Layout,Ttk_Element); MODULE_SCOPE void Ttk_LayoutNodeReqSize(Ttk_Layout, Ttk_Element, int *w, int *h); MODULE_SCOPE void Ttk_PlaceElement(Ttk_Layout, Ttk_Element, Ttk_Box); MODULE_SCOPE void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor); MODULE_SCOPE void Ttk_ChangeElementState(Ttk_Element,unsigned set,unsigned clr); MODULE_SCOPE Tcl_Obj *Ttk_QueryOption(Ttk_Layout, const char *, Ttk_State); TTKAPI Ttk_Style Ttk_LayoutStyle(Ttk_Layout); TTKAPI Tcl_Obj *Ttk_StyleDefault(Ttk_Style, const char *optionName); TTKAPI Tcl_Obj *Ttk_StyleMap(Ttk_Style, const char *optionName, Ttk_State); |
︙ | ︙ | |||
346 347 348 349 350 351 352 | /*------------------------------------------------------------------------ * +++ Miscellaneous enumerations. * Other stuff that element implementations need to know about. */ typedef enum /* -default option values */ { | < | > | 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | /*------------------------------------------------------------------------ * +++ Miscellaneous enumerations. * Other stuff that element implementations need to know about. */ typedef enum /* -default option values */ { TTK_BUTTON_DEFAULT_ACTIVE, /* currently the default widget */ TTK_BUTTON_DEFAULT_DISABLED, /* not defaultable */ TTK_BUTTON_DEFAULT_NORMAL /* widget defaultable */ } Ttk_ButtonDefaultState; TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_ButtonDefaultState *); typedef enum /* -compound option values */ { TTK_COMPOUND_NONE, /* image if specified, otherwise text */ |
︙ | ︙ |
Changes to generic/ttk/ttkTrack.c.
1 | /* | | | 1 2 3 4 5 6 7 8 9 | /* * 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. * * Usage: * TtkTrackElementState(&recordPtr->core); |
︙ | ︙ |
Changes to generic/ttk/ttkTreeview.c.
1 | /* | | | > > > | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | /* * Copyright © 2004, Joe English * * ttk::treeview widget implementation. */ #include "tkInt.h" #include "ttkThemeInt.h" #include "ttkWidget.h" #define DEF_TREE_ROWS "10" #define DEF_TITLECOLUMNS "0" #define DEF_TITLEITEMS "0" #define DEF_STRIPED "0" #define DEF_COLWIDTH "200" #define DEF_MINWIDTH "20" static const Tk_Anchor DEFAULT_IMAGEANCHOR = TK_ANCHOR_W; static const int DEFAULT_INDENT = 20; static const int HALO = 4; /* heading separator */ #define TTK_STATE_OPEN TTK_STATE_USER1 #define TTK_STATE_LEAF TTK_STATE_USER2 #define STATE_CHANGED (0x100) /* item state option changed */ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) /*------------------------------------------------------------------------ * +++ Tree items. * * INVARIANTS: * item->children ==> item->children->parent == item * item->next ==> item->next->parent == item->parent |
︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | */ Ttk_State state; Tcl_Obj *textObj; Tcl_Obj *imageObj; Tcl_Obj *valuesObj; Tcl_Obj *openObj; Tcl_Obj *tagsObj; /* * Derived resources: */ Ttk_TagSet tagset; Ttk_ImageSpec *imagespec; }; #define ITEM_OPTION_TAGS_CHANGED 0x100 #define ITEM_OPTION_IMAGE_CHANGED 0x200 static const Tk_OptionSpec ItemOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(TreeItem,textObj), TCL_INDEX_NONE, 0,0,0 }, {TK_OPTION_STRING, "-image", "image", "Image", NULL, offsetof(TreeItem,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,ITEM_OPTION_IMAGE_CHANGED }, {TK_OPTION_STRING, "-values", "values", "Values", NULL, offsetof(TreeItem,valuesObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_BOOLEAN, "-open", "open", "Open", "0", offsetof(TreeItem,openObj), TCL_INDEX_NONE, 0,0,0 }, {TK_OPTION_STRING, "-tags", "tags", "Tags", NULL, offsetof(TreeItem,tagsObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,ITEM_OPTION_TAGS_CHANGED }, {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0} }; | > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | */ Ttk_State state; Tcl_Obj *textObj; Tcl_Obj *imageObj; Tcl_Obj *valuesObj; Tcl_Obj *openObj; Tcl_Obj *tagsObj; Tcl_Obj *selObj; Tcl_Obj *imageAnchorObj; int hidden; int height; /* Height is in number of row heights */ Ttk_TagSet *cellTagSets; TkSizeT nTagSets; /* * Derived resources: */ Ttk_TagSet tagset; Ttk_ImageSpec *imagespec; int itemPos; /* Counting items */ int visiblePos; /* Counting visible items */ int rowPos; /* Counting rows (visible physical space) */ }; #define ITEM_OPTION_TAGS_CHANGED 0x100 #define ITEM_OPTION_IMAGE_CHANGED 0x200 static const Tk_OptionSpec ItemOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", "", offsetof(TreeItem,textObj), TCL_INDEX_NONE, 0,0,0 }, {TK_OPTION_INT, "-height", "height", "Height", "1", TCL_INDEX_NONE, offsetof(TreeItem,height), 0,0,0 }, {TK_OPTION_BOOLEAN, "-hidden", "hidden", "Hidden", "0", TCL_INDEX_NONE, offsetof(TreeItem,hidden), 0,0,0 }, {TK_OPTION_STRING, "-image", "image", "Image", NULL, offsetof(TreeItem,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,ITEM_OPTION_IMAGE_CHANGED }, {TK_OPTION_ANCHOR, "-imageanchor", "imageAnchor", "ImageAnchor", NULL, offsetof(TreeItem,imageAnchorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_STRING, "-values", "values", "Values", NULL, offsetof(TreeItem,valuesObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_BOOLEAN, "-open", "open", "Open", "0", offsetof(TreeItem,openObj), TCL_INDEX_NONE, 0,0,0 }, {TK_OPTION_STRING, "-tags", "tags", "Tags", NULL, offsetof(TreeItem,tagsObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,ITEM_OPTION_TAGS_CHANGED }, {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0} }; /* Forward declarations */ static void RemoveTag(TreeItem *, Ttk_Tag); static void RemoveTagFromCellsAtItem(TreeItem *, Ttk_Tag); /* + NewItem -- * Allocate a new, uninitialized, unlinked item */ static TreeItem *NewItem(void) { TreeItem *item = (TreeItem *)ckalloc(sizeof(*item)); item->entryPtr = 0; item->parent = item->children = item->next = item->prev = NULL; item->state = 0ul; item->textObj = NULL; item->imageObj = NULL; item->valuesObj = NULL; item->openObj = NULL; item->tagsObj = NULL; item->selObj = NULL; item->imageAnchorObj = NULL; item->hidden = 0; item->height = 1; item->cellTagSets = NULL; item->nTagSets = 0; item->tagset = NULL; item->imagespec = NULL; return item; } /* + FreeItem -- * Destroy an item */ static void FreeItem(TreeItem *item) { TkSizeT i; if (item->textObj) { Tcl_DecrRefCount(item->textObj); } if (item->imageObj) { Tcl_DecrRefCount(item->imageObj); } if (item->valuesObj) { Tcl_DecrRefCount(item->valuesObj); } if (item->openObj) { Tcl_DecrRefCount(item->openObj); } if (item->tagsObj) { Tcl_DecrRefCount(item->tagsObj); } if (item->selObj) { Tcl_DecrRefCount(item->selObj); } if (item->imageAnchorObj) { Tcl_DecrRefCount(item->imageAnchorObj); } if (item->tagset) { Ttk_FreeTagSet(item->tagset); } if (item->imagespec) { TtkFreeImageSpec(item->imagespec); } if (item->cellTagSets) { for (i = 0; i < item->nTagSets; ++i) { if (item->cellTagSets[i] != NULL) { Ttk_FreeTagSet(item->cellTagSets[i]); } } ckfree(item->cellTagSets); } ckfree(item); } static void FreeItemCB(void *clientData) { FreeItem((TreeItem *)clientData); } /* + DetachItem -- |
︙ | ︙ | |||
179 180 181 182 183 184 185 | /*------------------------------------------------------------------------ * +++ Display items and tag options. */ typedef struct { Tcl_Obj *textObj; /* taken from item / data cell */ | | > > > | > > > > > > | | | > > > > > > > > > > > | | > > | 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | /*------------------------------------------------------------------------ * +++ Display items and tag options. */ typedef struct { Tcl_Obj *textObj; /* taken from item / data cell */ Tcl_Obj *imageObj; /* taken from item or tag*/ Tcl_Obj *imageAnchorObj; /* taken from item or tag */ Tcl_Obj *anchorObj; /* from column <<NOTE-ANCHOR>> */ Tcl_Obj *backgroundObj; /* remainder from tag */ Tcl_Obj *stripedBgObj; Tcl_Obj *foregroundObj; Tcl_Obj *fontObj; Tcl_Obj *paddingObj; } DisplayItem; static const Tk_OptionSpec DisplayOptionSpecs[] = { {TK_OPTION_STRING, "-text", "text", "Text", NULL, offsetof(DisplayItem,textObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center", offsetof(DisplayItem,anchorObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED}, /* <<NOTE-ANCHOR>> */ /* From here down are the tags options. The index in TagOptionSpecs * below should be kept in synch with this position. */ {TK_OPTION_STRING, "-image", "image", "Image", NULL, offsetof(DisplayItem,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_ANCHOR, "-imageanchor", "imageAnchor", "ImageAnchor", NULL, offsetof(DisplayItem,imageAnchorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_COLOR, "-background", "windowColor", "WindowColor", NULL, offsetof(DisplayItem,backgroundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_COLOR, "-stripedbackground", "windowColor", "WindowColor", NULL, offsetof(DisplayItem,stripedBgObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor", NULL, offsetof(DisplayItem,foregroundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 }, {TK_OPTION_FONT, "-font", "font", "Font", NULL, offsetof(DisplayItem,fontObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, offsetof(DisplayItem,paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0} }; static const Tk_OptionSpec *TagOptionSpecs = &DisplayOptionSpecs[2]; /*------------------------------------------------------------------------ * +++ Columns. * * There are separate option tables associated with the column record: * ColumnOptionSpecs is for configuring the column, * and HeadingOptionSpecs is for drawing headings. */ typedef struct { int width; /* Column width, in pixels */ int minWidth; /* Minimum column width, in pixels */ int stretch; /* Should column stretch while resizing? */ int separator; /* Should this column have a separator? */ Tcl_Obj *idObj; /* Column identifier, from -columns option */ Tcl_Obj *anchorObj; /* -anchor for cell data <<NOTE-ANCHOR>> */ /* Column heading data: */ Tcl_Obj *headingObj; /* Heading label */ Tcl_Obj *headingImageObj; /* Heading image */ Tcl_Obj *headingAnchorObj; /* -anchor for heading label */ Tcl_Obj *headingCommandObj; /* Command to execute */ Tcl_Obj *headingStateObj; /* @@@ testing ... */ Ttk_State headingState; /* ... */ /* Temporary storage for cell data */ Tcl_Obj *data; int selected; Ttk_TagSet tagset; } TreeColumn; static void InitColumn(TreeColumn *column) { column->width = atoi(DEF_COLWIDTH); column->minWidth = atoi(DEF_MINWIDTH); column->stretch = 1; column->separator = 0; column->idObj = 0; column->anchorObj = 0; column->headingState = 0; column->headingObj = 0; column->headingImageObj = 0; column->headingAnchorObj = 0; column->headingStateObj = 0; column->headingCommandObj = 0; column->data = 0; column->tagset = NULL; } static void FreeColumn(TreeColumn *column) { if (column->idObj) { Tcl_DecrRefCount(column->idObj); } if (column->anchorObj) { Tcl_DecrRefCount(column->anchorObj); } |
︙ | ︙ | |||
276 277 278 279 280 281 282 283 284 285 286 287 288 289 | static const Tk_OptionSpec ColumnOptionSpecs[] = { {TK_OPTION_INT, "-width", "width", "Width", DEF_COLWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,width), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth", DEF_MINWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,minWidth), 0,0,0 }, {TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch", "1", TCL_INDEX_NONE, offsetof(TreeColumn,stretch), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", offsetof(TreeColumn,anchorObj), TCL_INDEX_NONE, /* <<NOTE-ANCHOR>> */ 0,0,0 }, | > > > | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | static const Tk_OptionSpec ColumnOptionSpecs[] = { {TK_OPTION_INT, "-width", "width", "Width", DEF_COLWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,width), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth", DEF_MINWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,minWidth), 0,0,0 }, {TK_OPTION_BOOLEAN, "-separator", "separator", "Separator", "0", TCL_INDEX_NONE, offsetof(TreeColumn,separator), 0,0,0 }, {TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch", "1", TCL_INDEX_NONE, offsetof(TreeColumn,stretch), 0,0,GEOMETRY_CHANGED }, {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "w", offsetof(TreeColumn,anchorObj), TCL_INDEX_NONE, /* <<NOTE-ANCHOR>> */ 0,0,0 }, |
︙ | ︙ | |||
364 365 366 367 368 369 370 | */ typedef struct { /* Resources acquired at initialization-time: */ Tk_OptionTable itemOptionTable; Tk_OptionTable columnOptionTable; Tk_OptionTable headingOptionTable; | | > > | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | */ typedef struct { /* Resources acquired at initialization-time: */ Tk_OptionTable itemOptionTable; Tk_OptionTable columnOptionTable; Tk_OptionTable headingOptionTable; Tk_OptionTable displayOptionTable; Tk_BindingTable bindingTable; Ttk_TagTable tagTable; /* Acquired in GetLayout hook: */ Ttk_Layout itemLayout; Ttk_Layout cellLayout; Ttk_Layout headingLayout; Ttk_Layout rowLayout; Ttk_Layout separatorLayout; int headingHeight; /* Space for headings */ int rowHeight; /* Height of each item */ int colSeparatorWidth; /* Width of column separator, if used */ int indent; /* #pixels horizontal offset for child items */ /* Tree data: */ Tcl_HashTable items; /* Map: item name -> item */ int serial; /* Next item # for autogenerated names */ TreeItem *root; /* Root item */ |
︙ | ︙ | |||
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | /* Widget options: */ Tcl_Obj *columnsObj; /* List of symbolic column names */ Tcl_Obj *displayColumnsObj; /* List of columns to display */ Tcl_Obj *heightObj; /* height (rows) */ Tcl_Obj *paddingObj; /* internal padding */ Tcl_Obj *showObj; /* -show list */ Tcl_Obj *selectModeObj; /* -selectmode option */ Scrollable xscroll; ScrollHandle xscrollHandle; Scrollable yscroll; ScrollHandle yscrollHandle; /* Derived resources: */ Tcl_HashTable columnNames; /* Map: column name -> column table entry */ | > > > > | < | | > > > | > | > > > > > > > > > > > > | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | /* Widget options: */ Tcl_Obj *columnsObj; /* List of symbolic column names */ Tcl_Obj *displayColumnsObj; /* List of columns to display */ Tcl_Obj *heightObj; /* height (rows) */ Tcl_Obj *paddingObj; /* internal padding */ int nTitleColumns; /* -titlecolumns */ int nTitleItems; /* -titleitems */ int striped; /* -striped option */ Tcl_Obj *showObj; /* -show list */ Tcl_Obj *selectModeObj; /* -selectmode option */ Tcl_Obj *selectTypeObj; /* -selecttype option */ Scrollable xscroll; ScrollHandle xscrollHandle; Scrollable yscroll; ScrollHandle yscrollHandle; /* Derived resources: */ Tcl_HashTable columnNames; /* Map: column name -> column table entry */ TkSizeT nColumns; /* #columns */ TkSizeT nDisplayColumns; /* #display columns */ TreeColumn **displayColumns; /* List of columns for display (incl tree) */ int titleWidth; /* Width of non-scrolled columns */ int titleRows; /* Height of non-scrolled items, in rows */ int totalRows; /* Height of non-hidden items, in rows */ int rowPosNeedsUpdate; /* Internal rowPos data needs update */ Ttk_Box headingArea; /* Display area for column headings */ Ttk_Box treeArea; /* Display area for tree */ int slack; /* Slack space (see Resizing section) */ unsigned showFlags; /* bitmask of subparts to display */ } TreePart; typedef struct { WidgetCore core; TreePart tree; } Treeview; #define USER_MASK 0x0100 #define COLUMNS_CHANGED (USER_MASK) #define DCOLUMNS_CHANGED (USER_MASK<<1) #define SCROLLCMD_CHANGED (USER_MASK<<2) #define SHOW_CHANGED (USER_MASK<<3) static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL }; static const char *const SelectTypeStrings[] = { "item", "cell", 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*/ }, {TK_OPTION_STRING, "-displaycolumns","displayColumns","DisplayColumns", "#all", offsetof(Treeview,tree.displayColumnsObj), TCL_INDEX_NONE, 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 }, {TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode", "extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE, 0, SelectModeStrings, 0 }, {TK_OPTION_STRING_TABLE, "-selecttype", "selectType", "SelectType", "item", offsetof(Treeview,tree.selectTypeObj), TCL_INDEX_NONE, 0, SelectTypeStrings, 0 }, {TK_OPTION_PIXELS, "-height", "height", "Height", DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE, 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_INT, "-titlecolumns", "titlecolumns", "Titlecolumns", DEF_TITLECOLUMNS, TCL_INDEX_NONE, offsetof(Treeview,tree.nTitleColumns), 0,0,GEOMETRY_CHANGED}, {TK_OPTION_INT, "-titleitems", "titleitems", "Titleitems", DEF_TITLEITEMS, TCL_INDEX_NONE, offsetof(Treeview,tree.nTitleItems), 0,0,GEOMETRY_CHANGED}, {TK_OPTION_BOOLEAN, "-striped", "striped", "Striped", DEF_STRIPED, TCL_INDEX_NONE, offsetof(Treeview,tree.striped), 0,0,GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand", NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.xscroll.scrollCmd), TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED}, {TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand", NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.yscroll.scrollCmd), TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED}, |
︙ | ︙ | |||
481 482 483 484 485 486 487 488 489 490 491 492 493 494 | Tcl_HashSearch search; Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search); while (entryPtr != NULL) { func(Tcl_GetHashValue(entryPtr)); entryPtr = Tcl_NextHashEntry(&search); } } /* + unshareObj(objPtr) -- * Ensure that a Tcl_Obj * has refcount 1 -- either return objPtr * itself, or a duplicated copy. */ static Tcl_Obj *unshareObj(Tcl_Obj *objPtr) { | > > > > > > > > > > > > > > | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | Tcl_HashSearch search; Tcl_HashEntry *entryPtr = Tcl_FirstHashEntry(ht, &search); while (entryPtr != NULL) { func(Tcl_GetHashValue(entryPtr)); entryPtr = Tcl_NextHashEntry(&search); } } static int CellSelectionClear(Treeview *tv) { TreeItem *item; int anyChange = 0; for (item=tv->tree.root; item; item = NextPreorder(item)) { if (item->selObj != NULL) { Tcl_DecrRefCount(item->selObj); item->selObj = NULL; anyChange = 1; } } return anyChange; } /* + unshareObj(objPtr) -- * Ensure that a Tcl_Obj * has refcount 1 -- either return objPtr * itself, or a duplicated copy. */ static Tcl_Obj *unshareObj(Tcl_Obj *objPtr) { |
︙ | ︙ | |||
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | static void DisplayLayout( Ttk_Layout layout, void *recordPtr, Ttk_State state, Ttk_Box b, Drawable d) { Ttk_RebindSublayout(layout, recordPtr); Ttk_PlaceLayout(layout, state, b); Ttk_DrawLayout(layout, state, d); } /* + GetColumn -- * Look up column by name or number. * Returns: pointer to column table entry, NULL if not found. * Leaves an error message in interp->result on error. */ static TreeColumn *GetColumn( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj) { Tcl_HashEntry *entryPtr; | > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 | static void DisplayLayout( Ttk_Layout layout, void *recordPtr, Ttk_State state, Ttk_Box b, Drawable d) { Ttk_RebindSublayout(layout, recordPtr); Ttk_PlaceLayout(layout, state, b); Ttk_DrawLayout(layout, state, d); } /* DisplayLayoutTree -- * Like DisplayLayout, but for the tree column. */ static void DisplayLayoutTree( Tk_Anchor imageAnchor, Tk_Anchor textAnchor, Ttk_Layout layout, void *recordPtr, Ttk_State state, Ttk_Box b, Drawable d) { Ttk_Element elem; Ttk_RebindSublayout(layout, recordPtr); elem = Ttk_FindElement(layout, "image"); if (elem != NULL) { Ttk_AnchorElement(elem, imageAnchor); } elem = Ttk_FindElement(layout, "text"); if (elem != NULL) { Ttk_AnchorElement(elem, textAnchor); } elem = Ttk_FindElement(layout, "focus"); if (elem != NULL) { Ttk_AnchorElement(elem, textAnchor); } Ttk_PlaceLayout(layout, state, b); Ttk_DrawLayout(layout, state, d); } /* + GetColumn -- * Look up column by name or number. * Returns: pointer to column table entry, NULL if not found. * Leaves an error message in interp->result on error. */ static TreeColumn *GetColumn( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj) { Tcl_HashEntry *entryPtr; TkSizeT columnIndex; /* Check for named column: */ entryPtr = Tcl_FindHashEntry( &tv->tree.columnNames, Tcl_GetString(columnIDObj)); if (entryPtr) { return (TreeColumn *)Tcl_GetHashValue(entryPtr); } /* Check for index: */ if (TkGetIntForIndex(columnIDObj, tv->tree.nColumns - 1, 1, &columnIndex) == TCL_OK) { if (columnIndex == TCL_INDEX_NONE || columnIndex >= tv->tree.nColumns) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Column index \"%s\" out of bounds", Tcl_GetString(columnIDObj))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLBOUND", NULL); return NULL; } return tv->tree.columns + columnIndex; } Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Invalid column index %s", Tcl_GetString(columnIDObj))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL); return NULL; } /* + FindColumn -- * Look up column by name, number, or display index. */ static TreeColumn *FindColumn( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj) { TkSizeT colno; if (sscanf(Tcl_GetString(columnIDObj), "#%" TKSIZET_MODIFIER "d", &colno) == 1) { /* Display column specification, #n */ if (colno != TCL_INDEX_NONE && (TkSizeT)colno < tv->tree.nDisplayColumns) { return tv->tree.displayColumns[colno]; } /* else */ Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Column %s out of range", Tcl_GetString(columnIDObj))); Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL); return NULL; |
︙ | ︙ | |||
600 601 602 603 604 605 606 | */ static TreeItem **GetItemListFromObj( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *objPtr) { TreeItem **items; Tcl_Obj **elements; | | | 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 | */ static TreeItem **GetItemListFromObj( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *objPtr) { TreeItem **items; Tcl_Obj **elements; TkSizeT i, nElements; if (Tcl_ListObjGetElements(interp,objPtr,&nElements,&elements) != TCL_OK) { return NULL; } items = (TreeItem **)ckalloc((nElements + 1)*sizeof(TreeItem*)); for (i = 0; i < nElements; ++i) { |
︙ | ︙ | |||
644 645 646 647 648 649 650 | */ /* + TreeviewFreeColumns -- * Free column data. */ static void TreeviewFreeColumns(Treeview *tv) { | | | 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 | */ /* + TreeviewFreeColumns -- * Free column data. */ static void TreeviewFreeColumns(Treeview *tv) { TkSizeT i; Tcl_DeleteHashTable(&tv->tree.columnNames); Tcl_InitHashTable(&tv->tree.columnNames, TCL_STRING_KEYS); if (tv->tree.columns) { for (i = 0; i < tv->tree.nColumns; ++i) FreeColumn(tv->tree.columns + i); |
︙ | ︙ | |||
693 694 695 696 697 698 699 | Tcl_HashEntry *entryPtr = Tcl_CreateHashEntry( &tv->tree.columnNames, Tcl_GetString(columnName), &isNew); Tcl_SetHashValue(entryPtr, tv->tree.columns + i); InitColumn(tv->tree.columns + i); Tk_InitOptions( | | | | 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 | Tcl_HashEntry *entryPtr = Tcl_CreateHashEntry( &tv->tree.columnNames, Tcl_GetString(columnName), &isNew); Tcl_SetHashValue(entryPtr, tv->tree.columns + i); InitColumn(tv->tree.columns + i); Tk_InitOptions( interp, tv->tree.columns + i, tv->tree.columnOptionTable, tv->core.tkwin); Tk_InitOptions( interp, tv->tree.columns + i, tv->tree.headingOptionTable, tv->core.tkwin); Tcl_IncrRefCount(columnName); tv->tree.columns[i].idObj = columnName; } return TCL_OK; } |
︙ | ︙ | |||
762 763 764 765 766 767 768 | #define FirstColumn(tv) ((tv->tree.showFlags&SHOW_TREE) ? 0 : 1) /* + TreeWidth -- * Compute the requested tree width from the sum of visible column widths. */ static int TreeWidth(Treeview *tv) { | | > > > > > > > | 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 | #define FirstColumn(tv) ((tv->tree.showFlags&SHOW_TREE) ? 0 : 1) /* + TreeWidth -- * Compute the requested tree width from the sum of visible column widths. */ static int TreeWidth(Treeview *tv) { TkSizeT i = FirstColumn(tv); int width = 0; tv->tree.titleWidth = 0; while (i < tv->tree.nDisplayColumns) { if (i == (TkSizeT)tv->tree.nTitleColumns) { tv->tree.titleWidth = width; } width += tv->tree.displayColumns[i++]->width; } if ((TkSizeT)tv->tree.nTitleColumns >= tv->tree.nDisplayColumns) { tv->tree.titleWidth = width; } return width; } /* + RecomputeSlack -- */ static void RecomputeSlack(Treeview *tv) |
︙ | ︙ | |||
842 843 844 845 846 847 848 | /* + ShoveRight -- * Adjust width of (stretchable) columns to the right by N pixels. * Returns: leftover slack. */ static int ShoveRight(Treeview *tv, int i, int n) { | | > | | 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | /* + ShoveRight -- * Adjust width of (stretchable) columns to the right by N pixels. * Returns: leftover slack. */ static int ShoveRight(Treeview *tv, int i, int n) { while (n != 0 && (TkSizeT)i < tv->tree.nDisplayColumns) { TreeColumn *c = tv->tree.displayColumns[i]; if (c->stretch) { n -= Stretch(c, n); } ++i; } return n; } /* + DistributeWidth -- * Distribute n pixels evenly across all stretchable display columns. * Returns: leftover slack. * Notes: * The "((++w % m) < r)" term is there so that the remainder r = n % m * is distributed round-robin. */ static int DistributeWidth(Treeview *tv, int n) { int w = TreeWidth(tv); int m = 0; TkSizeT i; int d, r; for (i = FirstColumn(tv); i < tv->tree.nDisplayColumns; ++i) { if (tv->tree.displayColumns[i]->stretch) { ++m; } } if (m == 0) { |
︙ | ︙ | |||
912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | static void DragColumn(Treeview *tv, int i, int delta) { TreeColumn *c = tv->tree.displayColumns[i]; int dl = delta - ShoveLeft(tv, i-1, delta - Stretch(c, delta)); int dr = ShoveRight(tv, i+1, PickupSlack(tv, -dl)); DepositSlack(tv, dr); } /*------------------------------------------------------------------------ * +++ Event handlers. */ static TreeItem *IdentifyItem(Treeview *tv, int y); /*forward*/ static const unsigned long TreeviewBindEventMask = KeyPressMask|KeyReleaseMask | ButtonPressMask|ButtonReleaseMask | PointerMotionMask|ButtonMotionMask | VirtualEventMask ; static void TreeviewBindEventProc(void *clientData, XEvent *event) { Treeview *tv = (Treeview *)clientData; TreeItem *item = NULL; Ttk_TagSet tagset; /* * Figure out where to deliver the event. */ switch (event->type) { case KeyPress: case KeyRelease: case VirtualEvent: item = tv->tree.focus; break; case ButtonPress: case ButtonRelease: item = IdentifyItem(tv, event->xbutton.y); break; case MotionNotify: item = IdentifyItem(tv, event->xmotion.y); break; default: break; } if (!item) { return; } /* ASSERT: Ttk_GetTagSetFromObj succeeds. * NB: must use a local copy of the tagset, * in case a binding script stomps on -tags. */ tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, item->tagsObj); /* * Fire binding: */ Tcl_Preserve(clientData); Tk_BindEvent(tv->tree.bindingTable, event, tv->core.tkwin, tagset->nTags, (void **)tagset->tags); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 | static void DragColumn(Treeview *tv, int i, int delta) { TreeColumn *c = tv->tree.displayColumns[i]; int dl = delta - ShoveLeft(tv, i-1, delta - Stretch(c, delta)); int dr = ShoveRight(tv, i+1, PickupSlack(tv, -dl)); DepositSlack(tv, dr); } /*------------------------------------------------------------------------ * +++ Cells. */ typedef struct { TreeItem *item; TreeColumn *column; Tcl_Obj *colObj; } TreeCell; /* + GetCellFromObj * Get Row and Column from a cell ID. */ static int GetCellFromObj( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *obj, int displayColumnOnly, int *displayColumn, TreeCell *cell) { int nElements; Tcl_Obj **elements; if (Tcl_ListObjGetElements(interp, obj, &nElements, &elements) != TCL_OK) { return TCL_ERROR; } if (nElements != 2) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "Cell id must be a list of two elements", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "CELL", NULL); return TCL_ERROR; } /* Valid item/column in each pair? */ cell->item = FindItem(interp, tv, elements[0]); if (!cell->item) { return TCL_ERROR; } cell->column = FindColumn(interp, tv, elements[1]); if (!cell->column) { return TCL_ERROR; } /* colObj is short lived and do not keep a reference counted */ cell->colObj = elements[1]; if (displayColumnOnly) { TkSizeT i = FirstColumn(tv); while (i < tv->tree.nDisplayColumns) { if (tv->tree.displayColumns[i] == cell->column) { break; } ++i; } if (i == tv->tree.nDisplayColumns) { /* specified column unviewable */ Tcl_SetObjResult(interp, Tcl_NewStringObj( "Cell id must be in a visible column", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "CELL", NULL); return TCL_ERROR; } if (displayColumn != NULL) { *displayColumn = i; } } return TCL_OK; } /* + GetCellListFromObj -- * Parse a Tcl_Obj * as a list of cells. * Returns an array of cells; result must be ckfree()d. * On error, returns NULL and leaves an error * message in interp. */ static TreeCell *GetCellListFromObj( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *objPtr, TkSizeT *nCells) { TreeCell *cells; TreeCell cell; Tcl_Obj **elements; Tcl_Obj *oneCell; TkSizeT i; int n; if (Tcl_ListObjGetElements(interp, objPtr, &n, &elements) != TCL_OK) { return NULL; } /* A two element list might be a single cell */ if (n == 2) { if (GetCellFromObj(interp, tv, objPtr, 0, NULL, &cell) == TCL_OK) { n = 1; oneCell = objPtr; elements = &oneCell; } else { Tcl_ResetResult(interp); } } cells = (TreeCell *) ckalloc(n * sizeof(TreeCell)); for (i = 0; i < (TkSizeT)n; ++i) { if (GetCellFromObj(interp, tv, elements[i], 0, NULL, &cells[i]) != TCL_OK) { ckfree(cells); return NULL; } } if (nCells) { *nCells = n; } return cells; } /*------------------------------------------------------------------------ * +++ Event handlers. */ static TreeItem *IdentifyItem(Treeview *tv, int y); /*forward*/ static TkSizeT IdentifyDisplayColumn(Treeview *tv, int x, int *x1); /*forward*/ static const unsigned long TreeviewBindEventMask = KeyPressMask|KeyReleaseMask | ButtonPressMask|ButtonReleaseMask | PointerMotionMask|ButtonMotionMask | VirtualEventMask ; static void TreeviewBindEventProc(void *clientData, XEvent *event) { Treeview *tv = (Treeview *)clientData; TreeItem *item = NULL; Ttk_TagSet tagset; int unused; TkSizeT colno = TCL_INDEX_NONE; TreeColumn *column = NULL; /* * Figure out where to deliver the event. */ switch (event->type) { case KeyPress: case KeyRelease: case VirtualEvent: item = tv->tree.focus; break; case ButtonPress: case ButtonRelease: item = IdentifyItem(tv, event->xbutton.y); colno = IdentifyDisplayColumn(tv, event->xbutton.x, &unused); break; case MotionNotify: item = IdentifyItem(tv, event->xmotion.y); colno = IdentifyDisplayColumn(tv, event->xmotion.x, &unused); break; default: break; } if (!item) { return; } /* ASSERT: Ttk_GetTagSetFromObj succeeds. * NB: must use a local copy of the tagset, * in case a binding script stomps on -tags. */ tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, item->tagsObj); /* * Pick up any cell tags. */ if (colno != TCL_INDEX_NONE) { column = tv->tree.displayColumns[colno]; if (column == &tv->tree.column0) { colno = 0; } else { colno = column - tv->tree.columns + 1; } if (colno < item->nTagSets) { if (item->cellTagSets[colno] != NULL) { Ttk_TagSetAddSet(tagset, item->cellTagSets[colno]); } } } /* * Fire binding: */ Tcl_Preserve(clientData); Tk_BindEvent(tv->tree.bindingTable, event, tv->core.tkwin, tagset->nTags, (void **)tagset->tags); |
︙ | ︙ | |||
989 990 991 992 993 994 995 | tv->tree.itemOptionTable = Tk_CreateOptionTable(interp, ItemOptionSpecs); tv->tree.columnOptionTable = Tk_CreateOptionTable(interp, ColumnOptionSpecs); tv->tree.headingOptionTable = Tk_CreateOptionTable(interp, HeadingOptionSpecs); | | | > | > > > > > > > > > > | | | | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | tv->tree.itemOptionTable = Tk_CreateOptionTable(interp, ItemOptionSpecs); tv->tree.columnOptionTable = Tk_CreateOptionTable(interp, ColumnOptionSpecs); tv->tree.headingOptionTable = Tk_CreateOptionTable(interp, HeadingOptionSpecs); tv->tree.displayOptionTable = Tk_CreateOptionTable(interp, DisplayOptionSpecs); tv->tree.tagTable = Ttk_CreateTagTable( interp, tv->core.tkwin, TagOptionSpecs, sizeof(DisplayItem)); tv->tree.bindingTable = Tk_CreateBindingTable(interp); Tk_CreateEventHandler(tv->core.tkwin, TreeviewBindEventMask, TreeviewBindEventProc, tv); tv->tree.itemLayout = tv->tree.cellLayout = tv->tree.headingLayout = tv->tree.rowLayout = tv->tree.separatorLayout = 0; tv->tree.headingHeight = tv->tree.rowHeight = 0; tv->tree.colSeparatorWidth = 1; tv->tree.indent = DEFAULT_INDENT; Tcl_InitHashTable(&tv->tree.columnNames, TCL_STRING_KEYS); tv->tree.nColumns = tv->tree.nDisplayColumns = 0; tv->tree.nTitleColumns = 0; tv->tree.nTitleItems = 0; tv->tree.titleWidth = 0; tv->tree.titleRows = 0; tv->tree.totalRows = 0; tv->tree.rowPosNeedsUpdate = 1; tv->tree.striped = 0; tv->tree.columns = NULL; tv->tree.displayColumns = NULL; tv->tree.showFlags = ~0; InitColumn(&tv->tree.column0); tv->tree.column0.idObj = Tcl_NewStringObj("#0", 2); Tcl_IncrRefCount(tv->tree.column0.idObj); Tk_InitOptions( interp, &tv->tree.column0, tv->tree.columnOptionTable, tv->core.tkwin); Tk_InitOptions( interp, &tv->tree.column0, tv->tree.headingOptionTable, tv->core.tkwin); Tcl_InitHashTable(&tv->tree.items, TCL_STRING_KEYS); tv->tree.serial = 0; tv->tree.focus = tv->tree.endPtr = 0; /* Create root item "": */ tv->tree.root = NewItem(); Tk_InitOptions(interp, tv->tree.root, tv->tree.itemOptionTable, tv->core.tkwin); tv->tree.root->tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL); tv->tree.root->entryPtr = Tcl_CreateHashEntry(&tv->tree.items, "", &unused); Tcl_SetHashValue(tv->tree.root->entryPtr, tv->tree.root); /* Scroll handles: */ |
︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | Tk_DeleteBindingTable(tv->tree.bindingTable); Ttk_DeleteTagTable(tv->tree.tagTable); if (tv->tree.itemLayout) Ttk_FreeLayout(tv->tree.itemLayout); if (tv->tree.cellLayout) Ttk_FreeLayout(tv->tree.cellLayout); if (tv->tree.headingLayout) Ttk_FreeLayout(tv->tree.headingLayout); if (tv->tree.rowLayout) Ttk_FreeLayout(tv->tree.rowLayout); TreeviewFreeColumns(tv); if (tv->tree.displayColumns) | > > | | 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 | Tk_DeleteBindingTable(tv->tree.bindingTable); Ttk_DeleteTagTable(tv->tree.tagTable); if (tv->tree.itemLayout) Ttk_FreeLayout(tv->tree.itemLayout); if (tv->tree.cellLayout) Ttk_FreeLayout(tv->tree.cellLayout); if (tv->tree.headingLayout) Ttk_FreeLayout(tv->tree.headingLayout); if (tv->tree.rowLayout) Ttk_FreeLayout(tv->tree.rowLayout); if (tv->tree.separatorLayout) Ttk_FreeLayout(tv->tree.separatorLayout); FreeColumn(&tv->tree.column0); TreeviewFreeColumns(tv); if (tv->tree.displayColumns) ckfree(tv->tree.displayColumns); foreachHashEntry(&tv->tree.items, FreeItemCB); Tcl_DeleteHashTable(&tv->tree.items); TtkFreeScrollHandle(tv->tree.xscrollHandle); TtkFreeScrollHandle(tv->tree.yscrollHandle); } |
︙ | ︙ | |||
1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 | if (TreeviewInitColumns(interp, tv) != TCL_OK) return TCL_ERROR; mask |= DCOLUMNS_CHANGED; } if (mask & DCOLUMNS_CHANGED) { if (TreeviewInitDisplayColumns(interp, tv) != TCL_OK) return TCL_ERROR; } 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) { return TCL_ERROR; } if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) { return TCL_ERROR; } tv->tree.showFlags = showFlags; if (mask & (SHOW_CHANGED | DCOLUMNS_CHANGED)) { RecomputeSlack(tv); } return TCL_OK; } | > > > > > > > > > > > > > > > > > > | 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 | if (TreeviewInitColumns(interp, tv) != TCL_OK) return TCL_ERROR; mask |= DCOLUMNS_CHANGED; } if (mask & DCOLUMNS_CHANGED) { if (TreeviewInitDisplayColumns(interp, tv) != TCL_OK) return TCL_ERROR; } if (mask & COLUMNS_CHANGED) { CellSelectionClear(tv); } if (tv->tree.nTitleColumns < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"#%d\" is out of range", tv->tree.nTitleColumns)); Tcl_SetErrorCode(interp, "TTK", "TREE", "TITLECOLUMNS", NULL); return TCL_ERROR; } if (tv->tree.nTitleItems < 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "\"%d\" is out of range", tv->tree.nTitleItems)); Tcl_SetErrorCode(interp, "TTK", "TREE", "TITLEITEMS", NULL); return TCL_ERROR; } 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) { return TCL_ERROR; } if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) { return TCL_ERROR; } tv->tree.rowPosNeedsUpdate = 1; tv->tree.showFlags = showFlags; if (mask & (SHOW_CHANGED | DCOLUMNS_CHANGED)) { RecomputeSlack(tv); } return TCL_OK; } |
︙ | ︙ | |||
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 | /* Make sure that -values is a valid list: */ if (item->valuesObj) { int unused; if (Tcl_ListObjLength(interp, item->valuesObj, &unused) != TCL_OK) goto error; } /* Check -image. */ if ((mask & ITEM_OPTION_IMAGE_CHANGED) && item->imageObj) { newImageSpec = TtkGetImageSpec(interp, tv->core.tkwin, item->imageObj); if (!newImageSpec) { goto error; | > > > > > > > > > | 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 | /* Make sure that -values is a valid list: */ if (item->valuesObj) { int unused; if (Tcl_ListObjLength(interp, item->valuesObj, &unused) != TCL_OK) goto error; } /* Check -height */ if (item->height < 1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "Invalid item height %d", item->height)); Tcl_SetErrorCode(interp, "TTK", "TREE", "HEIGHT", NULL); goto error; } /* Check -image. */ if ((mask & ITEM_OPTION_IMAGE_CHANGED) && item->imageObj) { newImageSpec = TtkGetImageSpec(interp, tv->core.tkwin, item->imageObj); if (!newImageSpec) { goto error; |
︙ | ︙ | |||
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | if (item->tagset) { Ttk_FreeTagSet(item->tagset); } item->tagset = newTagSet; } if (mask & ITEM_OPTION_IMAGE_CHANGED) { if (item->imagespec) { TtkFreeImageSpec(item->imagespec); } item->imagespec = newImageSpec; } TtkRedisplayWidget(&tv->core); return TCL_OK; error: Tk_RestoreSavedOptions(&savedOptions); if (newTagSet) { Ttk_FreeTagSet(newTagSet); } if (newImageSpec) { TtkFreeImageSpec(newImageSpec); } | > | 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 | if (item->tagset) { Ttk_FreeTagSet(item->tagset); } item->tagset = newTagSet; } if (mask & ITEM_OPTION_IMAGE_CHANGED) { if (item->imagespec) { TtkFreeImageSpec(item->imagespec); } item->imagespec = newImageSpec; } tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); return TCL_OK; error: Tk_RestoreSavedOptions(&savedOptions); if (newTagSet) { Ttk_FreeTagSet(newTagSet); } if (newImageSpec) { TtkFreeImageSpec(newImageSpec); } |
︙ | ︙ | |||
1286 1287 1288 1289 1290 1291 1292 | return TCL_ERROR; } /*------------------------------------------------------------------------ * +++ Geometry routines. */ | | | > | > > > | | < < < | | | > | > > > > > > | < < < < < < < < < < | < < | | | | < < | | > > > | < | | > > > > > > > > > > > > | > > > > > > > > > > > | > > > > | | | > > > > < | < < | < < < < < < < < < | < < < | < < < < < < < < < < < < < | | | < | | < | < | < < < < < < | | > | > > | | < < < > | | > > > > | | | > > > > > > | 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 | return TCL_ERROR; } /*------------------------------------------------------------------------ * +++ Geometry routines. */ /* + UpdatePositionItem -- * Update position data for all visible items. */ static void UpdatePositionItem( Treeview *tv, TreeItem *item, int hidden, int *rowPos, int *itemPos, int *visiblePos) { TreeItem *child = item->children; item->itemPos = *itemPos; *itemPos += 1; if (item->hidden) { hidden = 1; } if (hidden) { item->rowPos = -1; item->visiblePos = -1; } else { item->rowPos = *rowPos; item->visiblePos = *visiblePos; if (*visiblePos == tv->tree.nTitleItems) { tv->tree.titleRows = *rowPos; } *visiblePos += 1; *rowPos += item->height; } if (!(item->state & TTK_STATE_OPEN)) { hidden = 1; } while (child) { UpdatePositionItem(tv, child, hidden, rowPos, itemPos, visiblePos); child = child->next; } } /* + UpdatePositionTree -- * Update position data for all visible items. */ static void UpdatePositionTree(Treeview *tv) { /* -1 for the invisible root */ int rowPos = -1, itemPos = -1, visiblePos = -1; tv->tree.titleRows = 0; UpdatePositionItem(tv, tv->tree.root, 0, &rowPos, &itemPos, &visiblePos); tv->tree.totalRows = rowPos; tv->tree.rowPosNeedsUpdate = 0; } /* + IdentifyItem -- * Locate the item at the specified y position, if any. */ static TreeItem *IdentifyItem(Treeview *tv, int y) { TreeItem *item; int rowHeight = tv->tree.rowHeight; int ypos = tv->tree.treeArea.y; int nextRow, row; if (y < ypos) { return NULL; } if (tv->tree.rowPosNeedsUpdate) { UpdatePositionTree(tv); } row = (y - ypos) / rowHeight; if (row >= tv->tree.titleRows) { row += tv->tree.yscroll.first; } for (item = tv->tree.root->children; item; item = NextPreorder(item)) { nextRow = item->rowPos + item->height; if (item->rowPos <= row && row < nextRow) break; } return item; } /* + IdentifyDisplayColumn -- * Returns the display column number at the specified x position, * or -1 if x is outside any columns. */ static TkSizeT IdentifyDisplayColumn(Treeview *tv, int x, int *x1) { TkSizeT colno = FirstColumn(tv); int xpos = tv->tree.treeArea.x; if ((TkSizeT)tv->tree.nTitleColumns <= colno) { xpos -= tv->tree.xscroll.first; } while (colno < tv->tree.nDisplayColumns) { TreeColumn *column = tv->tree.displayColumns[colno]; int next_xpos = xpos + column->width; if (xpos <= x && x <= next_xpos + HALO) { *x1 = next_xpos; return colno; } ++colno; xpos = next_xpos; if ((TkSizeT)tv->tree.nTitleColumns == colno) { xpos -= tv->tree.xscroll.first; } } return TCL_INDEX_NONE; } /* + ItemDepth -- return the depth of a tree item. * The depth of an item is equal to the number of proper ancestors, * not counting the root node. */ static int ItemDepth(TreeItem *item) { int depth = 0; while (item->parent) { ++depth; item = item->parent; } return depth-1; } /* + DisplayRow -- * Returns the position row has on screen, or -1 if off-screen. */ static int DisplayRow(int row, Treeview *tv) { int visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight - tv->tree.titleRows; if (row < tv->tree.titleRows) { return row; } row -= tv->tree.titleRows; if (row < tv->tree.yscroll.first || row > tv->tree.yscroll.first + visibleRows) { /* not viewable, or off-screen */ return -1; } return row - tv->tree.yscroll.first + tv->tree.titleRows; } /* + BoundingBox -- * Compute the parcel of the specified column of the specified item, * (or the entire item if column is NULL) * Returns: 0 if item or column is not viewable, 1 otherwise. */ static int BoundingBox( Treeview *tv, /* treeview widget */ TreeItem *item, /* desired item */ TreeColumn *column, /* desired column */ Ttk_Box *bbox_rtn) /* bounding box of item */ { int dispRow; Ttk_Box bbox = tv->tree.treeArea; if (tv->tree.rowPosNeedsUpdate) { UpdatePositionTree(tv); } dispRow = DisplayRow(item->rowPos, tv); if (dispRow < 0) { /* not viewable, or off-screen */ return 0; } bbox.y += dispRow * tv->tree.rowHeight; bbox.height = tv->tree.rowHeight * item->height; bbox.x -= tv->tree.xscroll.first; bbox.width = TreeWidth(tv); if (column) { int xpos = 0; TkSizeT i = FirstColumn(tv); while (i < tv->tree.nDisplayColumns) { if (tv->tree.displayColumns[i] == column) { break; } xpos += tv->tree.displayColumns[i]->width; ++i; } if (i == tv->tree.nDisplayColumns) { /* specified column unviewable */ return 0; } bbox.x += xpos; bbox.width = column->width; if (i < (TkSizeT)tv->tree.nTitleColumns) { /* Unscrollable column, remove scroll shift */ bbox.x += tv->tree.xscroll.first; } /* Account for indentation in tree column: */ if (column == &tv->tree.column0) { int indent = tv->tree.indent * ItemDepth(item); bbox.x += indent; bbox.width -= indent; |
︙ | ︙ | |||
1504 1505 1506 1507 1508 1509 1510 | static const char *const regionStrings[] = { "nothing", "heading", "separator", "tree", "cell", 0 }; static TreeRegion IdentifyRegion(Treeview *tv, int x, int y) { | | > < | | 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 | static const char *const regionStrings[] = { "nothing", "heading", "separator", "tree", "cell", 0 }; static TreeRegion IdentifyRegion(Treeview *tv, int x, int y) { int x1 = 0; TkSizeT colno = IdentifyDisplayColumn(tv, x, &x1); if (Ttk_BoxContains(tv->tree.headingArea, x, y)) { if (colno == TCL_INDEX_NONE) { return REGION_NOTHING; } else if (-HALO <= x1 - x && x1 - x <= HALO) { return REGION_SEPARATOR; } else { return REGION_HEADING; } } else if (Ttk_BoxContains(tv->tree.treeArea, x, y)) { |
︙ | ︙ | |||
1561 1562 1563 1564 1565 1566 1567 | */ static Ttk_Layout TreeviewGetLayout( Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr) { Treeview *tv = (Treeview *)recordPtr; Ttk_Layout treeLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr); Tcl_Obj *objPtr; | | > > | | | > > | | > > > > > > > > > > | > | > > > > > > > > > < | | | > | | | > | | 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 | */ static Ttk_Layout TreeviewGetLayout( Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr) { Treeview *tv = (Treeview *)recordPtr; Ttk_Layout treeLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr); Tcl_Obj *objPtr; int unused, cellHeight; DisplayItem displayItem; Ttk_Style style; if (!( treeLayout && GetSublayout(interp, themePtr, treeLayout, ".Item", tv->tree.displayOptionTable, &tv->tree.itemLayout) && GetSublayout(interp, themePtr, treeLayout, ".Cell", tv->tree.displayOptionTable, &tv->tree.cellLayout) && GetSublayout(interp, themePtr, treeLayout, ".Heading", tv->tree.headingOptionTable, &tv->tree.headingLayout) && GetSublayout(interp, themePtr, treeLayout, ".Row", tv->tree.displayOptionTable, &tv->tree.rowLayout) && GetSublayout(interp, themePtr, treeLayout, ".Separator", tv->tree.displayOptionTable, &tv->tree.separatorLayout) )) { return 0; } /* Compute heading height. */ Ttk_RebindSublayout(tv->tree.headingLayout, &tv->tree.column0); Ttk_LayoutSize(tv->tree.headingLayout, 0, &unused, &tv->tree.headingHeight); /* Get row height from style, or compute it to fit Item and Cell. * Pick up default font from the Treeview style. */ style = Ttk_LayoutStyle(treeLayout); Ttk_TagSetDefaults(tv->tree.tagTable, style, &displayItem); Ttk_RebindSublayout(tv->tree.itemLayout, &displayItem); Ttk_LayoutSize(tv->tree.itemLayout, 0, &unused, &tv->tree.rowHeight); Ttk_RebindSublayout(tv->tree.cellLayout, &displayItem); Ttk_LayoutSize(tv->tree.cellLayout, 0, &unused, &cellHeight); if (cellHeight > tv->tree.rowHeight) { tv->tree.rowHeight = cellHeight; } if ((objPtr = Ttk_QueryOption(treeLayout, "-rowheight", 0))) { (void)Tcl_GetIntFromObj(NULL, objPtr, &tv->tree.rowHeight); } if ((objPtr = Ttk_QueryOption(treeLayout, "-columnseparatorwidth", 0))) { (void)Tcl_GetIntFromObj(NULL, objPtr, &tv->tree.colSeparatorWidth); } /* Get item indent from style: * @@@ TODO: sanity-check. */ tv->tree.indent = DEFAULT_INDENT; if ((objPtr = Ttk_QueryOption(treeLayout, "-indent", 0))) { (void)Tcl_GetIntFromObj(NULL, objPtr, &tv->tree.indent); } return treeLayout; } /* + TreeviewDoLayout -- * DoLayout() widget hook. Computes widget layout. * * Side effects: * Computes headingArea and treeArea. * Computes subtree height. * Invokes scroll callbacks. */ static void TreeviewDoLayout(void *clientData) { Treeview *tv = (Treeview *)clientData; int visibleRows; int first, last, total; Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin)); tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea"); ResizeColumns(tv, tv->tree.treeArea.width); first = tv->tree.xscroll.first; last = first + tv->tree.treeArea.width - tv->tree.titleWidth; total = TreeWidth(tv) - tv->tree.titleWidth; TtkScrolled(tv->tree.xscrollHandle, first, last, total); if (tv->tree.showFlags & SHOW_HEADINGS) { tv->tree.headingArea = Ttk_PackBox( &tv->tree.treeArea, 1, tv->tree.headingHeight, TTK_SIDE_TOP); } else { tv->tree.headingArea = Ttk_MakeBox(0,0,0,0); } visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight; tv->tree.root->state |= TTK_STATE_OPEN; UpdatePositionTree(tv); first = tv->tree.yscroll.first; last = tv->tree.yscroll.first + visibleRows - tv->tree.titleRows; total = tv->tree.totalRows - tv->tree.titleRows; TtkScrolled(tv->tree.yscrollHandle, first, last, total); } /* + TreeviewSize -- * SizeProc() widget hook. Size is determined by * -height option and column widths. */ static int TreeviewSize(void *clientData, int *widthPtr, int *heightPtr) |
︙ | ︙ | |||
1676 1677 1678 1679 1680 1681 1682 | } /* + DrawHeadings -- * Draw tree headings. */ static void DrawHeadings(Treeview *tv, Drawable d) { | | | > > > > > > | | > | > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > | > > > | | < | | > | > > > > > > > > | > | | > > > > | > > > > > | > > > > > > > > > > > > > > > > > > | | > > > > > > > > > > | > | > > > > > > > | > | | > > | < | | | < | < < < < < < < > | | > > > > > > | | > > > > > > > > > > > > > > | > > > > | > > > > > > > > > | > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > | | | | > | | | < < < < < | | | | < | > | 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 | } /* + DrawHeadings -- * Draw tree headings. */ static void DrawHeadings(Treeview *tv, Drawable d) { int x0 = tv->tree.headingArea.x - tv->tree.xscroll.first; const int y0 = tv->tree.headingArea.y; const int h0 = tv->tree.headingArea.height; TkSizeT i = FirstColumn(tv); int x = 0; if ((TkSizeT)tv->tree.nTitleColumns > i) { x = tv->tree.titleWidth; i = tv->tree.nTitleColumns; } while (i < tv->tree.nDisplayColumns) { TreeColumn *column = tv->tree.displayColumns[i]; Ttk_Box parcel = Ttk_MakeBox(x0+x, y0, column->width, h0); if (x0+x+column->width > tv->tree.titleWidth) { DisplayLayout(tv->tree.headingLayout, column, column->headingState, parcel, d); } x += column->width; ++i; } x0 = tv->tree.headingArea.x; i = FirstColumn(tv); x = 0; while ((i < (TkSizeT)tv->tree.nTitleColumns) && (i < tv->tree.nDisplayColumns)) { TreeColumn *column = tv->tree.displayColumns[i]; Ttk_Box parcel = Ttk_MakeBox(x0+x, y0, column->width, h0); DisplayLayout(tv->tree.headingLayout, column, column->headingState, parcel, d); x += column->width; ++i; } } /* + DrawSeparators -- * Draw separators between columns */ static void DrawSeparators(Treeview *tv, Drawable d) { const int y0 = tv->tree.treeArea.y; const int h0 = tv->tree.treeArea.height; DisplayItem displayItem; Ttk_Style style = Ttk_LayoutStyle(tv->tree.separatorLayout); int x = tv->tree.treeArea.x; TkSizeT i; Ttk_TagSetDefaults(tv->tree.tagTable, style, &displayItem); for (i = FirstColumn(tv); i < tv->tree.nDisplayColumns; ++i) { TreeColumn *column = tv->tree.displayColumns[i]; Ttk_Box parcel; int xDraw = x + column->width; x += column->width; if (!column->separator) continue; if (i >= (TkSizeT)tv->tree.nTitleColumns) { xDraw -= tv->tree.xscroll.first; if (xDraw < tv->tree.titleWidth) continue; } parcel = Ttk_MakeBox(xDraw - (tv->tree.colSeparatorWidth+1)/2, y0, tv->tree.colSeparatorWidth, h0); DisplayLayout(tv->tree.separatorLayout, &displayItem, 0, parcel, d); } } /* + OverrideStriped -- * Each level of settings might add stripedbackground, and it should * override background if this is indeed on a striped item. * By copying it between each level, and NULL-ing stripedBgObj, * it can be detected if the next level overrides it. */ static void OverrideStriped( Treeview *tv, TreeItem *item, DisplayItem *displayItem) { int striped = item->visiblePos % 2 && tv->tree.striped; if (striped && displayItem->stripedBgObj) { displayItem->backgroundObj = displayItem->stripedBgObj; displayItem->stripedBgObj = NULL; } } /* + PrepareItem -- * Fill in a displayItem record. */ static void PrepareItem( Treeview *tv, TreeItem *item, DisplayItem *displayItem, Ttk_State state) { Ttk_Style style = Ttk_LayoutStyle(tv->core.layout); Ttk_TagSetDefaults(tv->tree.tagTable, style, displayItem); OverrideStriped(tv, item, displayItem); Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); OverrideStriped(tv, item, displayItem); Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); } /* Fill in data from item to temporary storage in columns. */ static void PrepareCells( Treeview *tv, TreeItem *item) { TkSizeT i; int nValues = 0; Tcl_Obj **values = NULL; TreeColumn *column; if (item->valuesObj) { Tcl_ListObjGetElements(NULL, item->valuesObj, &nValues, &values); } for (i = 0; i < tv->tree.nColumns; ++i) { tv->tree.columns[i].data = (i < (TkSizeT)nValues) ? values[i] : 0; tv->tree.columns[i].selected = 0; tv->tree.columns[i].tagset = NULL; } tv->tree.column0.data = NULL; tv->tree.column0.selected = 0; tv->tree.column0.tagset = NULL; if (item->selObj != NULL) { Tcl_ListObjGetElements(NULL, item->selObj, &nValues, &values); for (i = 0; i < (TkSizeT)nValues; ++i) { column = FindColumn(NULL, tv, values[i]); /* Just in case. It should not be possible for column to be NULL */ if (column != NULL) { column->selected = 1; } } } if (item->nTagSets > 0) { tv->tree.column0.tagset = item->cellTagSets[0]; } for (i = 1; i < item->nTagSets && i <= tv->tree.nColumns; ++i) { tv->tree.columns[i-1].tagset = item->cellTagSets[i]; } } /* + DrawCells -- * Draw data cells for specified item. */ static void DrawCells( Treeview *tv, TreeItem *item, DisplayItem *displayItem, DisplayItem *displayItemSel, Drawable d, int x, int y, int title) { Ttk_Layout layout = tv->tree.cellLayout; Ttk_Style style = Ttk_LayoutStyle(tv->core.layout); Ttk_State state = ItemState(tv, item); Ttk_Padding cellPadding = {4, 0, 4, 0}; DisplayItem displayItemLocal; DisplayItem displayItemCell, displayItemCellSel; int rowHeight = tv->tree.rowHeight * item->height; int xPad = 0, defaultPadding = 1; TkSizeT i; /* Adjust if the tree column has a separator */ if (tv->tree.showFlags & SHOW_TREE && tv->tree.column0.separator) { xPad = tv->tree.colSeparatorWidth/2; } /* An Item's image should not propagate to a Cell. A Cell's image can only be set by cell tags. */ displayItemCell = *displayItem; displayItemCellSel = *displayItemSel; displayItemCell.imageObj = NULL; displayItemCellSel.imageObj = NULL; displayItemCell.imageAnchorObj = NULL; displayItemCellSel.imageAnchorObj = NULL; /* If explicit padding was asked for, skip default. */ if (Ttk_QueryStyle(Ttk_LayoutStyle(tv->tree.cellLayout), &displayItemCell, tv->tree.displayOptionTable, "-padding", state) != NULL) { defaultPadding = 0; } for (i = 1; i < tv->tree.nDisplayColumns; ++i) { TreeColumn *column = tv->tree.displayColumns[i]; int parcelX = x + xPad; int parcelWidth = column->separator ? column->width - tv->tree.colSeparatorWidth : column->width; Ttk_Box parcel = Ttk_MakeBox(parcelX, y, parcelWidth, rowHeight); DisplayItem *displayItemUsed = &displayItemCell; Ttk_State stateCell = state; Tk_Anchor textAnchor, imageAnchor; xPad = column->separator ? tv->tree.colSeparatorWidth/2 : 0; x += column->width; if (title && i >= (TkSizeT)tv->tree.nTitleColumns) break; if (!title && i < (TkSizeT)tv->tree.nTitleColumns) continue; if (!title && x < tv->tree.titleWidth) continue; if (column->selected) { displayItemUsed = &displayItemCellSel; stateCell |= TTK_STATE_SELECTED; } if (column->tagset) { displayItemLocal = *displayItemUsed; displayItemUsed = &displayItemLocal; Ttk_TagSetValues(tv->tree.tagTable, column->tagset, displayItemUsed); OverrideStriped(tv, item, displayItemUsed); Ttk_TagSetApplyStyle(tv->tree.tagTable, style, stateCell, displayItemUsed); } displayItemUsed->textObj = column->data; displayItemUsed->anchorObj = column->anchorObj;/* <<NOTE-ANCHOR>> */ Tk_GetAnchorFromObj(NULL, column->anchorObj, &textAnchor); imageAnchor = DEFAULT_IMAGEANCHOR; if (displayItemUsed->imageAnchorObj) { Tk_GetAnchorFromObj(NULL, displayItemUsed->imageAnchorObj, &imageAnchor); } /* displayItem was used to draw the full item backgound. Redraw cell background if needed. */ if (displayItemUsed != &displayItemCell) { DisplayLayout(tv->tree.rowLayout, displayItemUsed, stateCell, parcel, d); } if (defaultPadding && displayItemUsed->paddingObj == NULL) { /* If no explicit padding was asked for, add some default. */ parcel = Ttk_PadBox(parcel, cellPadding); } DisplayLayoutTree(imageAnchor, textAnchor, layout, displayItemUsed, state, parcel, d); } } /* + DrawItem -- * Draw an item (row background, tree label, and cells). */ static void DrawItem( Treeview *tv, TreeItem *item, Drawable d, int depth) { Ttk_Style style = Ttk_LayoutStyle(tv->core.layout); Ttk_State state = ItemState(tv, item); DisplayItem displayItem, displayItemSel, displayItemLocal; int rowHeight = tv->tree.rowHeight * item->height; int x = tv->tree.treeArea.x - tv->tree.xscroll.first; int xTitle = tv->tree.treeArea.x; int dispRow = DisplayRow(item->rowPos, tv); int y = tv->tree.treeArea.y + tv->tree.rowHeight * dispRow; PrepareItem(tv, item, &displayItem, state); PrepareItem(tv, item, &displayItemSel, state | TTK_STATE_SELECTED); /* Draw row background: */ { Ttk_Box rowBox = Ttk_MakeBox(x, y, TreeWidth(tv), rowHeight); DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d); } /* Make room for tree label: */ if (tv->tree.showFlags & SHOW_TREE) { x += tv->tree.column0.width; } /* Draw data cells: */ PrepareCells(tv, item); DrawCells(tv, item, &displayItem, &displayItemSel, d, x, y, 0); /* Draw row background for non-scrolled area: */ if ((TkSizeT)tv->tree.nTitleColumns >= 1) { Ttk_Box rowBox = Ttk_MakeBox(tv->tree.treeArea.x, y, tv->tree.titleWidth, rowHeight); DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d); } /* Draw tree label: */ x = tv->tree.treeArea.x - tv->tree.xscroll.first; if (tv->tree.showFlags & SHOW_TREE) { TreeColumn *column = &tv->tree.column0; int indent = depth * tv->tree.indent; int colwidth = tv->tree.column0.width - (tv->tree.column0.separator ? tv->tree.colSeparatorWidth/2 : 0); int xTree = tv->tree.nTitleColumns >= 1 ? xTitle : x; Ttk_Box parcel = Ttk_MakeBox(xTree, y, colwidth, rowHeight); DisplayItem *displayItemUsed = &displayItem; Ttk_State stateCell = state; Tk_Anchor textAnchor, imageAnchor = DEFAULT_IMAGEANCHOR; Ttk_Padding cellPadding = {indent, 0, 0, 0}; if (column->selected) { displayItemUsed = &displayItemSel; stateCell |= TTK_STATE_SELECTED; } if (column->tagset) { displayItemLocal = *displayItemUsed; displayItemUsed = &displayItemLocal; Ttk_TagSetValues(tv->tree.tagTable, column->tagset, displayItemUsed); OverrideStriped(tv, item, displayItemUsed); Ttk_TagSetApplyStyle(tv->tree.tagTable, style, stateCell, displayItemUsed); } displayItem.anchorObj = tv->tree.column0.anchorObj; Tk_GetAnchorFromObj(NULL, column->anchorObj, &textAnchor); displayItemUsed->textObj = item->textObj; /* Item's image can be null, and may come from the tag */ if (item->imageObj) { displayItemUsed->imageObj = item->imageObj; } if (item->imageAnchorObj) { displayItemUsed->imageAnchorObj = item->imageAnchorObj; } if (displayItemUsed->imageAnchorObj) { Tk_GetAnchorFromObj(NULL, displayItemUsed->imageAnchorObj, &imageAnchor); } if (displayItemUsed != &displayItem) { DisplayLayout(tv->tree.rowLayout, displayItemUsed, stateCell, parcel, d); } parcel = Ttk_PadBox(parcel, cellPadding); DisplayLayoutTree(imageAnchor, textAnchor, tv->tree.itemLayout, displayItemUsed, state, parcel, d); xTitle += colwidth; } /* Draw non-scrolled data cells: */ if ((TkSizeT)tv->tree.nTitleColumns > 1) { DrawCells(tv, item, &displayItem, &displayItemSel, d, xTitle, y, 1); } } /* + DrawSubtree -- * Draw an item and all of its (viewable) descendants. */ static void DrawForest( /* forward */ Treeview *tv, TreeItem *item, Drawable d, int depth); static void DrawSubtree( Treeview *tv, TreeItem *item, Drawable d, int depth) { int dispRow = DisplayRow(item->rowPos, tv); if (dispRow >= 0) { DrawItem(tv, item, d, depth); } if (item->state & TTK_STATE_OPEN) { DrawForest(tv, item->children, d, depth + 1); } } /* + DrawForest -- * Draw a sequence of items and their visible descendants. */ static void DrawForest( Treeview *tv, TreeItem *item, Drawable d, int depth) { while (item) { DrawSubtree(tv, item, d, depth); item = item->next; } } /* + TreeviewDisplay -- * Display() widget hook. Draw the widget contents. */ static void TreeviewDisplay(void *clientData, Drawable d) { Treeview *tv = (Treeview *)clientData; Ttk_DrawLayout(tv->core.layout, tv->core.state, d); if (tv->tree.showFlags & SHOW_HEADINGS) { DrawHeadings(tv, d); } DrawForest(tv, tv->tree.root->children, d, 0); DrawSeparators(tv, d); } /*------------------------------------------------------------------------ * +++ Utilities for widget commands */ /* + InsertPosition -- |
︙ | ︙ | |||
1972 1973 1974 1975 1976 1977 1978 | int i; if (!newChildren) return TCL_ERROR; /* Sanity-check: */ | | | | > | 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 | int i; if (!newChildren) return TCL_ERROR; /* Sanity-check: */ for (i = 0; newChildren[i]; ++i) { if (!AncestryCheck(interp, tv, newChildren[i], item)) { ckfree(newChildren); return TCL_ERROR; } } /* Detach old children: */ child = item->children; while (child) { TreeItem *next = child->next; DetachItem(child); child = next; } /* Detach new children from their current locations: */ for (i = 0; newChildren[i]; ++i) { DetachItem(newChildren[i]); } /* Reinsert new children: * Note: it is not an error for an item to be listed more than once, * though it probably should be... */ child = 0; for (i = 0; newChildren[i]; ++i) { if (newChildren[i]->parent) { /* This is a duplicate element which has already been * inserted. Ignore it. */ continue; } InsertItem(item, child, newChildren[i]); child = newChildren[i]; } ckfree(newChildren); tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); } return TCL_OK; } /* + $tv parent $item -- |
︙ | ︙ | |||
2162 2163 2164 2165 2166 2167 2168 | return TCL_ERROR; } item = FindItem(interp, tv, objv[2]); if (!item) { return TCL_ERROR; } | | | 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 | return TCL_ERROR; } item = FindItem(interp, tv, objv[2]); if (!item) { return TCL_ERROR; } if (objc >= 4 && (column = FindColumn(interp,tv,objv[3])) == NULL) { return TCL_ERROR; } if (BoundingBox(tv, item, column, &bbox)) { Tcl_SetObjResult(interp, Ttk_NewBoxObj(bbox)); } |
︙ | ︙ | |||
2188 2189 2190 2191 2192 2193 2194 | */ static int TreeviewHorribleIdentify( Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], Treeview *tv) { const char *what = "nothing", *detail = NULL; TreeItem *item = 0; Tcl_Obj *result; | | | | | > | | | 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 | */ static int TreeviewHorribleIdentify( Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], Treeview *tv) { const char *what = "nothing", *detail = NULL; TreeItem *item = 0; Tcl_Obj *result; TkSizeT dColumnNumber; char dcolbuf[32]; 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) { return TCL_ERROR; } dColumnNumber = IdentifyDisplayColumn(tv, x, &x1); if (dColumnNumber == TCL_INDEX_NONE) { goto done; } sprintf(dcolbuf, "#%" TKSIZET_MODIFIER "u", dColumnNumber); if (Ttk_BoxContains(tv->tree.headingArea,x,y)) { if (-HALO <= x1 - x && x1 - x <= HALO) { what = "separator"; } else { what = "heading"; } detail = dcolbuf; } else if (Ttk_BoxContains(tv->tree.treeArea,x,y)) { item = IdentifyItem(tv, y); if (item && dColumnNumber > 0) { what = "cell"; detail = dcolbuf; } else if (item) { Ttk_Layout layout = tv->tree.itemLayout; Ttk_Box itemBox; DisplayItem displayItem; Ttk_Element element; Ttk_State state = ItemState(tv, item); BoundingBox(tv, item, NULL, &itemBox); PrepareItem(tv, item, &displayItem, state); if (item->textObj) { displayItem.textObj = item->textObj; } if (item->imageObj) { displayItem.imageObj = item->imageObj; } Ttk_RebindSublayout(layout, &displayItem); Ttk_PlaceLayout(layout, state, itemBox); element = Ttk_IdentifyElement(layout, x, y); if (element) { what = "item"; detail = Ttk_ElementName(element); } else { what = "row"; |
︙ | ︙ | |||
2261 2262 2263 2264 2265 2266 2267 | * Identify the component at position x,y. */ static int TreeviewIdentifyCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { static const char *const submethodStrings[] = | | | | > | | | > > > > > > > > > > > > > | | | | 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 | * Identify the component at position x,y. */ static int TreeviewIdentifyCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { static const char *const submethodStrings[] = { "region", "item", "column", "row", "element", "cell", NULL }; enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT, I_CELL }; Treeview *tv = (Treeview *)recordPtr; int submethod; int x, y; TreeRegion region; Ttk_Box bbox; TreeItem *item; TreeColumn *column = 0; TkSizeT colno; int x1; if (objc == 4) { /* Old form */ return TreeviewHorribleIdentify(interp, objc, objv, tv); } else if (objc != 5) { Tcl_WrongNumArgs(interp, 2, objv, "command x y"); return TCL_ERROR; } if (Tcl_GetIndexFromObjStruct(interp, objv[2], submethodStrings, sizeof(char *), "command", TCL_EXACT, &submethod) != TCL_OK || Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK ) { return TCL_ERROR; } region = IdentifyRegion(tv, x, y); item = IdentifyItem(tv, y); colno = IdentifyDisplayColumn(tv, x, &x1); column = (colno != TCL_INDEX_NONE) ? tv->tree.displayColumns[colno] : NULL; switch (submethod) { case I_REGION : Tcl_SetObjResult(interp,Tcl_NewStringObj(regionStrings[region],-1)); break; case I_ITEM : case I_ROW : if (item) { Tcl_SetObjResult(interp, ItemID(tv, item)); } break; case I_COLUMN : if (colno != TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%" TKSIZET_MODIFIER "u", colno)); } break; case I_CELL : if (item && colno != TCL_INDEX_NONE) { Tcl_Obj *elem[2]; elem[0] = ItemID(tv, item); elem[1] = Tcl_ObjPrintf("#%" TKSIZET_MODIFIER "u", colno); Tcl_SetObjResult(interp, Tcl_NewListObj(2, elem)); } break; case I_ELEMENT : { Ttk_Layout layout = 0; DisplayItem displayItem; Ttk_Element element; Ttk_State state; switch (region) { case REGION_NOTHING: layout = tv->core.layout; return TCL_OK; /* @@@ NYI */ case REGION_HEADING: case REGION_SEPARATOR: layout = tv->tree.headingLayout; return TCL_OK; /* @@@ NYI */ case REGION_TREE: layout = tv->tree.itemLayout; break; case REGION_CELL: layout = tv->tree.cellLayout; break; } if (item == NULL) { return TCL_OK; } if (!BoundingBox(tv, item, column, &bbox)) { return TCL_OK; } state = ItemState(tv, item); PrepareItem(tv, item, &displayItem, state); if (item->textObj) { displayItem.textObj = item->textObj; } if (item->imageObj) { displayItem.imageObj = item->imageObj; } Ttk_RebindSublayout(layout, &displayItem); Ttk_PlaceLayout(layout, state, bbox); element = Ttk_IdentifyElement(layout, x, y); if (element) { const char *elementName = Ttk_ElementName(element); Tcl_SetObjResult(interp, Tcl_NewStringObj(elementName, -1)); } break; |
︙ | ︙ | |||
2455 2456 2457 2458 2459 2460 2461 | */ static int TreeviewSetCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem *item; TreeColumn *column; | | | | 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 | */ static int TreeviewSetCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem *item; TreeColumn *column; TkSizeT columnNumber; if (objc < 3 || objc > 5) { Tcl_WrongNumArgs(interp, 2, objv, "item ?column ?value??"); return TCL_ERROR; } if (!(item = FindItem(interp, tv, objv[2]))) return TCL_ERROR; /* Make sure -values exists: */ if (!item->valuesObj) { item->valuesObj = Tcl_NewListObj(0,0); Tcl_IncrRefCount(item->valuesObj); } if (objc == 3) { /* Return dictionary: */ Tcl_Obj *result = Tcl_NewListObj(0,0); Tcl_Obj *value; for (columnNumber = 0; columnNumber < tv->tree.nColumns; ++columnNumber) { Tcl_ListObjIndex(interp, item->valuesObj, columnNumber, &value); if (value) { Tcl_ListObjAppendElement(NULL, result, tv->tree.columns[columnNumber].idObj); Tcl_ListObjAppendElement(NULL, result, value); } } |
︙ | ︙ | |||
2522 2523 2524 2525 2526 2527 2528 | int length; item->valuesObj = unshareObj(item->valuesObj); /* Make sure -values is fully populated: */ Tcl_ListObjLength(interp, item->valuesObj, &length); | | | 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 | int length; item->valuesObj = unshareObj(item->valuesObj); /* Make sure -values is fully populated: */ Tcl_ListObjLength(interp, item->valuesObj, &length); while ((TkSizeT)length < tv->tree.nColumns) { Tcl_Obj *empty = Tcl_NewStringObj("",0); Tcl_ListObjAppendElement(interp, item->valuesObj, empty); ++length; } /* Set value: */ |
︙ | ︙ | |||
2602 2603 2604 2605 2606 2607 2608 | } while (!isNew); } /* Create and configure new item: */ newItem = NewItem(); Tk_InitOptions( | | > | | | 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 | } while (!isNew); } /* Create and configure new item: */ newItem = NewItem(); Tk_InitOptions( interp, newItem, tv->tree.itemOptionTable, tv->core.tkwin); newItem->tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL); if (ConfigureItem(interp, tv, newItem, objc, objv) != TCL_OK) { Tcl_DeleteHashEntry(entryPtr); FreeItem(newItem); return TCL_ERROR; } /* Store in hash table, link into tree: */ Tcl_SetHashValue(entryPtr, newItem); newItem->entryPtr = entryPtr; InsertItem(parent, sibling, newItem); tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); Tcl_SetObjResult(interp, ItemID(tv, newItem)); return TCL_OK; } /* + $tv detach $items -- * Unlink each item in $items from the tree. */ static int TreeviewDetachCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem **items; int i; |
︙ | ︙ | |||
2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 | } } for (i = 0; items[i]; ++i) { DetachItem(items[i]); } TtkRedisplayWidget(&tv->core); ckfree(items); return TCL_OK; } /* + $tv delete $items -- * Delete each item in $items. | > | 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 | } } for (i = 0; items[i]; ++i) { DetachItem(items[i]); } tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); ckfree(items); return TCL_OK; } /* + $tv delete $items -- * Delete each item in $items. |
︙ | ︙ | |||
2676 2677 2678 2679 2680 2681 2682 | */ static int TreeviewDeleteCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem **items, *delq; | | | | | > > > > > | > | > | 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 | */ static int TreeviewDeleteCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem **items, *delq; int i, selChange = 0; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "items"); return TCL_ERROR; } if (!(items = GetItemListFromObj(interp, tv, objv[2]))) { return TCL_ERROR; } /* Sanity-check: */ for (i = 0; items[i]; ++i) { if (items[i] == tv->tree.root) { ckfree(items); Tcl_SetObjResult(interp, Tcl_NewStringObj( "Cannot delete root item", -1)); Tcl_SetErrorCode(interp, "TTK", "TREE", "ROOT", NULL); return TCL_ERROR; } } /* Remove items from hash table. */ delq = 0; for (i = 0; items[i]; ++i) { if (items[i]->state & TTK_STATE_SELECTED) { selChange = 1; } else if (items[i]->selObj != NULL) { int length; Tcl_ListObjLength(interp, items[i]->selObj, &length); if (length > 0) { selChange = 1; } } delq = DeleteItems(items[i], delq); } /* Free items: */ while (delq) { TreeItem *next = delq->next; if (tv->tree.focus == delq) tv->tree.focus = 0; if (tv->tree.endPtr == delq) tv->tree.endPtr = 0; FreeItem(delq); delq = next; } ckfree(items); if (selChange) { Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); } tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); return TCL_OK; } /* + $tv move $item $parent $index * Move $item to the specified $index in $parent's child list. */ |
︙ | ︙ | |||
2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 | } /* Move item: */ DetachItem(item); InsertItem(parent, sibling, item); TtkRedisplayWidget(&tv->core); return TCL_OK; } /*------------------------------------------------------------------------ * +++ Widget commands -- scrolling */ | > | 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 | } /* Move item: */ DetachItem(item); InsertItem(parent, sibling, item); tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); return TCL_OK; } /*------------------------------------------------------------------------ * +++ Widget commands -- scrolling */ |
︙ | ︙ | |||
2816 2817 2818 2819 2820 2821 2822 | * Ensure that $item is visible. */ static int TreeviewSeeCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem *item, *parent; | | > > > > > > > > | > > | | | > | < | > > > > | 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 | * Ensure that $item is visible. */ static int TreeviewSeeCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeItem *item, *parent; int scrollRow1, scrollRow2, visibleRows; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "item"); return TCL_ERROR; } if (!(item = FindItem(interp, tv, objv[2]))) { return TCL_ERROR; } /* Make sure all ancestors are open: */ for (parent = item->parent; parent; parent = parent->parent) { if (!(parent->state & TTK_STATE_OPEN)) { parent->openObj = unshareObj(parent->openObj); Tcl_SetBooleanObj(parent->openObj, 1); parent->state |= TTK_STATE_OPEN; tv->tree.rowPosNeedsUpdate = 1; TtkRedisplayWidget(&tv->core); } } if (tv->tree.rowPosNeedsUpdate) { UpdatePositionTree(tv); } /* Make sure item is visible: */ if (item->rowPos < tv->tree.titleRows) { return TCL_OK; } visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight - tv->tree.titleRows; scrollRow1 = item->rowPos - tv->tree.titleRows; scrollRow2 = scrollRow1 + item->height - 1; if (scrollRow1 < tv->tree.yscroll.first || item->height > visibleRows) { TtkScrollTo(tv->tree.yscrollHandle, scrollRow1, 1); } else if (scrollRow2 >= tv->tree.yscroll.first + visibleRows) { scrollRow1 = 1 + scrollRow2 - visibleRows; TtkScrollTo(tv->tree.yscrollHandle, scrollRow1, 1); } return TCL_OK; } /*------------------------------------------------------------------------ * +++ Widget commands -- interactive column resize */ /* + $tree drag $column $newX -- * Set right edge of display column $column to x position $X */ static int TreeviewDragCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; int left = tv->tree.treeArea.x - tv->tree.xscroll.first; TkSizeT i = FirstColumn(tv); TreeColumn *column; int newx; 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) { return TCL_ERROR; } for (;i < tv->tree.nDisplayColumns; ++i) { TreeColumn *c = tv->tree.displayColumns[i]; int right = left + c->width; if (c == column) { if (i < (TkSizeT)tv->tree.nTitleColumns) { /* Unscrollable column, remove scroll shift */ right += tv->tree.xscroll.first; } DragColumn(tv, i, newx - right); TtkRedisplayWidget(&tv->core); return TCL_OK; } left = right; } |
︙ | ︙ | |||
2949 2950 2951 2952 2953 2954 2955 | SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE }; static const char *const selopStrings[] = { "set", "add", "remove", "toggle", NULL }; Treeview *tv = (Treeview *)recordPtr; | | | 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 | SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE }; static const char *const selopStrings[] = { "set", "add", "remove", "toggle", NULL }; Treeview *tv = (Treeview *)recordPtr; int selop, i, selChange = 0; TreeItem *item, **items; if (objc == 2) { Tcl_Obj *result = Tcl_NewListObj(0,0); for (item = tv->tree.root->children; item; item = NextPreorder(item)) { if (item->state & TTK_STATE_SELECTED) Tcl_ListObjAppendElement(NULL, result, ItemID(tv, item)); |
︙ | ︙ | |||
2980 2981 2982 2983 2984 2985 2986 2987 | if (!items) { return TCL_ERROR; } switch (selop) { case SELECTION_SET: for (item=tv->tree.root; item; item = NextPreorder(item)) { | > > | > | < > > > > > > > | > > > | > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 | if (!items) { return TCL_ERROR; } switch (selop) { case SELECTION_SET: /* Clear */ for (item=tv->tree.root; item; item = NextPreorder(item)) { if (item->state & TTK_STATE_SELECTED) { item->state &= ~TTK_STATE_SELECTED; selChange = 1; } } for (i=0; items[i]; ++i) { items[i]->state |= TTK_STATE_SELECTED; selChange = 1; } break; case SELECTION_ADD: for (i=0; items[i]; ++i) { if (!(items[i]->state & TTK_STATE_SELECTED)) { items[i]->state |= TTK_STATE_SELECTED; selChange = 1; } } break; case SELECTION_REMOVE: for (i=0; items[i]; ++i) { if (items[i]->state & TTK_STATE_SELECTED) { items[i]->state &= ~TTK_STATE_SELECTED; selChange = 1; } } break; case SELECTION_TOGGLE: for (i=0; items[i]; ++i) { items[i]->state ^= TTK_STATE_SELECTED; selChange = 1; } break; } ckfree(items); if (selChange) { Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); } TtkRedisplayWidget(&tv->core); return TCL_OK; } /* + SelObjChangeElement -- * Change an element in a cell selection list. */ static int SelObjChangeElement( Treeview *tv, Tcl_Obj *listPtr, Tcl_Obj *elemPtr, int add, TCL_UNUSED(int) /*remove*/, int toggle) { int i, nElements, anyChange = 0; TreeColumn *column, *elemColumn; Tcl_Obj **elements; elemColumn = FindColumn(NULL, tv, elemPtr); Tcl_ListObjGetElements(NULL, listPtr, &nElements, &elements); for (i = 0; i < nElements; i++) { column = FindColumn(NULL, tv, elements[i]); if (column == elemColumn) { if (add) { return anyChange; } Tcl_ListObjReplace(NULL, listPtr, i, 1, 0, NULL); anyChange = 1; return anyChange; } } if (add || toggle) { Tcl_ListObjAppendElement(NULL, listPtr, elemColumn->idObj); anyChange = 1; } return anyChange; } /* + $tree cellselection ?add|remove|set|toggle $items? */ static int CellSelectionRange( Tcl_Interp *interp, Treeview *tv, Tcl_Obj *fromCell, Tcl_Obj *toCell, int add, int remove, int toggle) { TreeCell cellFrom, cellTo; TreeItem *item; Tcl_Obj *columns, **elements; int colno, nElements, i, fromNo, toNo, anyChange = 0; int set = !(add || remove || toggle); if (GetCellFromObj(interp, tv, fromCell, 1, &fromNo, &cellFrom) != TCL_OK) { return TCL_ERROR; } if (GetCellFromObj(interp, tv, toCell, 1, &toNo, &cellTo) != TCL_OK) { return TCL_ERROR; } /* Correct order. */ if (fromNo > toNo) { colno = fromNo; fromNo = toNo; toNo = colno; } /* Make a list of columns in this rectangle. */ columns = Tcl_NewListObj(0, 0); Tcl_IncrRefCount(columns); for (colno = fromNo; colno <= toNo; colno++) { Tcl_ListObjAppendElement(NULL, columns, tv->tree.displayColumns[colno]->idObj); } /* Set is the only operation that affects items outside its rectangle. * Start with clearing out. */ if (set) { anyChange = CellSelectionClear(tv); } /* Correct order. */ if (tv->tree.rowPosNeedsUpdate) { UpdatePositionTree(tv); } if (cellFrom.item->itemPos > cellTo.item->itemPos) { item = cellFrom.item; cellFrom.item = cellTo.item; cellTo.item = item; } /* Go through all items in this rectangle. */ for (item = cellFrom.item; item; item = NextPreorder(item)) { if (item->selObj != NULL) { item->selObj = unshareObj(item->selObj); Tcl_ListObjGetElements(NULL, columns, &nElements, &elements); for (i = 0; i < nElements; ++i) { anyChange |= SelObjChangeElement(tv, item->selObj, elements[i], add, remove, toggle); } } else { /* Set, add and toggle do the same thing when empty before. */ if (!remove) { item->selObj = columns; Tcl_IncrRefCount(item->selObj); anyChange = 1; } } if (item == cellTo.item) { break; } } Tcl_DecrRefCount(columns); if (anyChange) { Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); } TtkRedisplayWidget(&tv->core); return TCL_OK; } /* + $tree cellselection ?add|remove|set|toggle $items? */ static int TreeviewCellSelectionCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { enum { SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE }; static const char *const selopStrings[] = { "set", "add", "remove", "toggle", NULL }; Treeview *tv = (Treeview *)recordPtr; int selop, anyChange = 0; TkSizeT i, nCells; TreeCell *cells; TreeItem *item; if (objc == 2) { Tcl_Obj *result = Tcl_NewListObj(0,0); for (item = tv->tree.root->children; item; item = NextPreorder(item)) { if (item->selObj != NULL) { int n; TkSizeT elemc; Tcl_Obj **elemv; Tcl_ListObjGetElements(interp, item->selObj, &n, &elemv); elemc = n; for (i = 0; i < elemc; ++i) { Tcl_Obj *elem[2]; elem[0] = ItemID(tv, item); elem[1] = elemv[i]; Tcl_ListObjAppendElement(NULL, result, Tcl_NewListObj(2, elem)); } } } Tcl_SetObjResult(interp, result); return TCL_OK; } if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 2, objv, "?add|remove|set|toggle arg...?"); return TCL_ERROR; } if (Tcl_GetIndexFromObjStruct(interp, objv[2], selopStrings, sizeof(char *), "cellselection operation", 0, &selop) != TCL_OK) { return TCL_ERROR; } if (objc == 5) { switch (selop) { case SELECTION_SET: return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 0, 0); case SELECTION_ADD: return CellSelectionRange(interp, tv, objv[3], objv[4], 1, 0, 0); case SELECTION_REMOVE: return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 1, 0); case SELECTION_TOGGLE: return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 0, 1); } } cells = GetCellListFromObj(interp, tv, objv[3], &nCells); if (cells == NULL) { return TCL_ERROR; } switch (selop) { case SELECTION_SET: anyChange = CellSelectionClear(tv); /*FALLTHRU*/ case SELECTION_ADD: for (i = 0; i < nCells; i++) { item = cells[i].item; if (item->selObj == NULL) { item->selObj = Tcl_NewListObj(0, 0); Tcl_IncrRefCount(item->selObj); } item->selObj = unshareObj(item->selObj); anyChange |= SelObjChangeElement(tv, item->selObj, cells[i].colObj, 1, 0, 0); } break; case SELECTION_REMOVE: for (i = 0; i < nCells; i++) { item = cells[i].item; if (item->selObj == NULL) { continue; } item->selObj = unshareObj(item->selObj); anyChange |= SelObjChangeElement(tv, item->selObj, cells[i].colObj, 0, 1, 0); } break; case SELECTION_TOGGLE: for (i = 0; i < nCells; i++) { item = cells[i].item; if (item->selObj == NULL) { item->selObj = Tcl_NewListObj(0, 0); Tcl_IncrRefCount(item->selObj); } item->selObj = unshareObj(item->selObj); anyChange = SelObjChangeElement(tv, item->selObj, cells[i].colObj, 0, 0, 1); } break; } ckfree(cells); if (anyChange) { Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL); } TtkRedisplayWidget(&tv->core); return TCL_OK; } /*------------------------------------------------------------------------ * +++ Widget commands -- tags and bindings. |
︙ | ︙ | |||
3112 3113 3114 3115 3116 3117 3118 | if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "tagName"); return TCL_ERROR; } tag = Ttk_GetTagFromObj(tagTable, objv[3]); | | > > | 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 | if (objc != 4) { Tcl_WrongNumArgs(interp, 3, objv, "tagName"); return TCL_ERROR; } tag = Ttk_GetTagFromObj(tagTable, objv[3]); /* remove the tag from all cells and items */ while (item) { RemoveTagFromCellsAtItem(item, tag); RemoveTag(item, tag); item = NextPreorder(item); } /* then remove the tag from the tag table */ Tk_DeleteAllBindings(tv->tree.bindingTable, tag); Ttk_DeleteTagFromTable(tagTable, tag); TtkRedisplayWidget(&tv->core); return TCL_OK; } /* + $tv tag has $tag ?$item? |
︙ | ︙ | |||
3160 3161 3162 3163 3164 3165 3166 | return TCL_OK; } else { Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?"); return TCL_ERROR; } } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 | return TCL_OK; } else { Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?"); return TCL_ERROR; } } /* + $tv tag cell has $tag ?$cell? */ static int TreeviewCtagHasCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; TreeCell cell; TkSizeT i, columnNumber; if (objc == 5) { /* Return list of all cells with tag */ Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]); TreeItem *item = tv->tree.root; Tcl_Obj *result = Tcl_NewListObj(0,0); while (item) { for (i = 0; i < item->nTagSets && i <= tv->tree.nColumns; ++i) { if (item->cellTagSets[i] != NULL) { if (Ttk_TagSetContains(item->cellTagSets[i], tag)) { Tcl_Obj *elem[2]; elem[0] = ItemID(tv, item); if (i == 0) { elem[1] = tv->tree.column0.idObj; } else { elem[1] = tv->tree.columns[i-1].idObj; } Tcl_ListObjAppendElement(NULL, result, Tcl_NewListObj(2, elem)); } } } item = NextPreorder(item); } Tcl_SetObjResult(interp, result); return TCL_OK; } else if (objc == 6) { /* Test if cell has specified tag */ Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]); int result = 0; if (GetCellFromObj(interp, tv, objv[5], 0, NULL, &cell) != TCL_OK) { return TCL_ERROR; } if (cell.column == &tv->tree.column0) { columnNumber = 0; } else { columnNumber = cell.column - tv->tree.columns + 1; } if (columnNumber < cell.item->nTagSets) { if (cell.item->cellTagSets[columnNumber] != NULL) { result = Ttk_TagSetContains( cell.item->cellTagSets[columnNumber], tag); } } Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result)); return TCL_OK; } else { Tcl_WrongNumArgs(interp, 4, objv, "tagName ?cell?"); return TCL_ERROR; } } /* + $tv tag names */ static int TreeviewTagNamesCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; if (objc != 3) { |
︙ | ︙ | |||
3206 3207 3208 3209 3210 3211 3212 | tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]); items = GetItemListFromObj(interp, tv, objv[4]); if (!items) { return TCL_ERROR; } | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > < > > | 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 | tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]); items = GetItemListFromObj(interp, tv, objv[4]); if (!items) { return TCL_ERROR; } for (i = 0; items[i]; ++i) { AddTag(items[i], tag); } ckfree(items); TtkRedisplayWidget(&tv->core); return TCL_OK; } /* Make sure tagset at column is allocated and initialised */ static void AllocCellTagSets(Treeview *tv, TreeItem *item, TkSizeT columnNumber) { TkSizeT i, newSize = MAX(columnNumber + 1, tv->tree.nColumns + 1); if (item->nTagSets < newSize) { if (item->cellTagSets == NULL) { item->cellTagSets = (Ttk_TagSet *) ckalloc(sizeof(Ttk_TagSet)*newSize); } else { item->cellTagSets = (Ttk_TagSet *) ckrealloc(item->cellTagSets, sizeof(Ttk_TagSet) * newSize); } for (i = item->nTagSets; i < newSize; i++) { item->cellTagSets[i] = NULL; } item->nTagSets = newSize; } if (item->cellTagSets[columnNumber] == NULL) { item->cellTagSets[columnNumber] = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL); } } /* + $tv tag cell add $tag $cells */ static int TreeviewCtagAddCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; Ttk_Tag tag; TreeCell *cells; TreeItem *item; TkSizeT i, nCells, columnNumber; if (objc != 6) { Tcl_WrongNumArgs(interp, 4, objv, "tagName cells"); return TCL_ERROR; } cells = GetCellListFromObj(interp, tv, objv[5], &nCells); if (cells == NULL) { return TCL_ERROR; } tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]); for (i = 0; i < nCells; i++) { if (cells[i].column == &tv->tree.column0) { columnNumber = 0; } else { columnNumber = cells[i].column - tv->tree.columns + 1; } item = cells[i].item; AllocCellTagSets(tv, item, columnNumber); Ttk_TagSetAdd(item->cellTagSets[columnNumber], tag); } ckfree(cells); TtkRedisplayWidget(&tv->core); return TCL_OK; } /* + $tv tag remove $tag ?$items? */ static void RemoveTag(TreeItem *item, Ttk_Tag tag) { if (Ttk_TagSetRemove(item->tagset, tag)) { if (item->tagsObj) Tcl_DecrRefCount(item->tagsObj); item->tagsObj = Ttk_NewTagSetObj(item->tagset); Tcl_IncrRefCount(item->tagsObj); } } /* Remove tag from all cells at row 'item' */ static void RemoveTagFromCellsAtItem(TreeItem *item, Ttk_Tag tag) { TkSizeT i; for (i = 0; i < item->nTagSets; i++) { if (item->cellTagSets[i] != NULL) { Ttk_TagSetRemove(item->cellTagSets[i], tag); } } } static int TreeviewTagRemoveCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; Ttk_Tag tag; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 3, objv, "tagName ?items?"); return TCL_ERROR; } tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]); if (objc == 5) { TreeItem **items = GetItemListFromObj(interp, tv, objv[4]); int i; if (!items) { return TCL_ERROR; } for (i = 0; items[i]; ++i) { RemoveTag(items[i], tag); } ckfree(items); } else if (objc == 4) { TreeItem *item = tv->tree.root; while (item) { RemoveTag(item, tag); item = NextPreorder(item); } } TtkRedisplayWidget(&tv->core); return TCL_OK; } /* + $tv tag cell remove $tag ?$cells? */ static int TreeviewCtagRemoveCommand( void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Treeview *tv = (Treeview *)recordPtr; Ttk_Tag tag; TreeCell *cells; TreeItem *item; TkSizeT i, nCells, columnNumber; if (objc < 5 || objc > 6) { Tcl_WrongNumArgs(interp, 4, objv, "tagName ?cells?"); return TCL_ERROR; } tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]); if (objc == 6) { cells = GetCellListFromObj(interp, tv, objv[5], &nCells); if (cells == NULL) { return TCL_ERROR; } for (i = 0; i < nCells; i++) { if (cells[i].column == &tv->tree.column0) { columnNumber = 0; } else { columnNumber = cells[i].column - tv->tree.columns + 1; } item = cells[i].item; AllocCellTagSets(tv, item, columnNumber); Ttk_TagSetRemove(item->cellTagSets[columnNumber], tag); } ckfree(cells); } else { item = tv->tree.root; while (item) { RemoveTagFromCellsAtItem(item, tag); item = NextPreorder(item); } } TtkRedisplayWidget(&tv->core); return TCL_OK; } static const Ttk_Ensemble TreeviewCtagCommands[] = { { "add", TreeviewCtagAddCommand,0 }, { "has", TreeviewCtagHasCommand,0 }, { "remove", TreeviewCtagRemoveCommand,0 }, { 0,0,0 } }; static const Ttk_Ensemble TreeviewTagCommands[] = { { "add", TreeviewTagAddCommand,0 }, { "bind", TreeviewTagBindCommand,0 }, { "cell", 0,TreeviewCtagCommands }, { "configure", TreeviewTagConfigureCommand,0 }, { "delete", TreeviewTagDeleteCommand,0 }, { "has", TreeviewTagHasCommand,0 }, { "names", TreeviewTagNamesCommand,0 }, { "remove", TreeviewTagRemoveCommand,0 }, { 0,0,0 } }; /*------------------------------------------------------------------------ * +++ Widget commands record. */ static const Ttk_Ensemble TreeviewCommands[] = { { "bbox", TreeviewBBoxCommand,0 }, { "cellselection" , TreeviewCellSelectionCommand,0 }, { "children", TreeviewChildrenCommand,0 }, { "cget", TtkWidgetCgetCommand,0 }, { "column", TreeviewColumnCommand,0 }, { "configure", TtkWidgetConfigureCommand,0 }, { "delete", TreeviewDeleteCommand,0 }, { "detach", TreeviewDetachCommand,0 }, { "drag", TreeviewDragCommand,0 }, { "drop", TreeviewDropCommand,0 }, { "exists", TreeviewExistsCommand,0 }, { "focus", TreeviewFocusCommand,0 }, { "heading", TreeviewHeadingCommand,0 }, { "identify", TreeviewIdentifyCommand,0 }, { "index", TreeviewIndexCommand,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 } }; /*------------------------------------------------------------------------ |
︙ | ︙ | |||
3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 | TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT) TTK_NODE("Treeitem.image", 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))) TTK_LAYOUT("Heading", TTK_NODE("Treeheading.cell", TTK_FILL_BOTH) TTK_GROUP("Treeheading.border", TTK_FILL_BOTH, TTK_GROUP("Treeheading.padding", TTK_FILL_BOTH, TTK_NODE("Treeheading.image", TTK_PACK_RIGHT) TTK_NODE("Treeheading.text", TTK_FILL_X)))) TTK_LAYOUT("Row", TTK_NODE("Treeitem.row", TTK_FILL_BOTH)) TTK_END_LAYOUT_TABLE /*------------------------------------------------------------------------ * +++ Tree indicator element. */ typedef struct { | > > > > | 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 | TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT) TTK_NODE("Treeitem.image", TTK_PACK_LEFT) TTK_NODE("Treeitem.text", TTK_FILL_BOTH))) TTK_LAYOUT("Cell", TTK_GROUP("Treedata.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.image", TTK_PACK_LEFT) TTK_NODE("Treeitem.text", TTK_FILL_BOTH))) TTK_LAYOUT("Heading", TTK_NODE("Treeheading.cell", TTK_FILL_BOTH) TTK_GROUP("Treeheading.border", TTK_FILL_BOTH, TTK_GROUP("Treeheading.padding", TTK_FILL_BOTH, TTK_NODE("Treeheading.image", TTK_PACK_RIGHT) TTK_NODE("Treeheading.text", TTK_FILL_X)))) TTK_LAYOUT("Row", TTK_NODE("Treeitem.row", TTK_FILL_BOTH)) TTK_LAYOUT("Separator", TTK_NODE("Treeitem.separator", TTK_FILL_BOTH)) TTK_END_LAYOUT_TABLE /*------------------------------------------------------------------------ * +++ Tree indicator element. */ typedef struct { |
︙ | ︙ | |||
3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 | Ttk_Theme theme = Ttk_GetDefaultTheme(interp); RegisterWidget(interp, "ttk::treeview", &TreeviewWidgetSpec); Ttk_RegisterElement(interp, theme, "Treeitem.indicator", &TreeitemIndicatorElementSpec, 0); Ttk_RegisterElement(interp, theme, "Treeitem.row", &RowElementSpec, 0); Ttk_RegisterElement(interp, theme, "Treeheading.cell", &RowElementSpec, 0); Ttk_RegisterElement(interp, theme, "treearea", &ttkNullElementSpec, 0); Ttk_RegisterLayouts(theme, LayoutTable); } /*EOF*/ | > | 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 | Ttk_Theme theme = Ttk_GetDefaultTheme(interp); RegisterWidget(interp, "ttk::treeview", &TreeviewWidgetSpec); Ttk_RegisterElement(interp, theme, "Treeitem.indicator", &TreeitemIndicatorElementSpec, 0); Ttk_RegisterElement(interp, theme, "Treeitem.row", &RowElementSpec, 0); Ttk_RegisterElement(interp, theme, "Treeitem.separator", &RowElementSpec, 0); Ttk_RegisterElement(interp, theme, "Treeheading.cell", &RowElementSpec, 0); Ttk_RegisterElement(interp, theme, "treearea", &ttkNullElementSpec, 0); Ttk_RegisterLayouts(theme, LayoutTable); } /*EOF*/ |
Changes to generic/ttk/ttkWidget.c.
1 | /* | | | < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * Copyright © 2003, Joe English * * Core widget utilities. */ #include "tkInt.h" #include "ttkThemeInt.h" #include "ttkWidget.h" /*------------------------------------------------------------------------ * +++ Internal helper routines. */ /* UpdateLayout -- * Call the widget's get-layout hook to recompute corePtr->layout. * Returns TCL_OK if successful, returns TCL_ERROR and leaves |
︙ | ︙ | |||
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | } if (!(corePtr->flags & REDISPLAY_PENDING)) { Tcl_DoWhenIdle(DrawWidget, corePtr); corePtr->flags |= REDISPLAY_PENDING; } } /* TtkResizeWidget -- * Recompute widget size, schedule geometry propagation and redisplay. */ void TtkResizeWidget(WidgetCore *corePtr) { if (corePtr->flags & WIDGET_DESTROYED) { return; } | > > > > > > > > > > > > > > | < | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | } if (!(corePtr->flags & REDISPLAY_PENDING)) { Tcl_DoWhenIdle(DrawWidget, corePtr); corePtr->flags |= REDISPLAY_PENDING; } } /* * WidgetWorldChanged -- * Default Tk_ClassWorldChangedProc() for widgets. * Invoked whenever fonts or other system resources are changed; * recomputes geometry. */ static void WidgetWorldChanged(ClientData clientData) { WidgetCore *corePtr = (WidgetCore *)clientData; (void)UpdateLayout(corePtr->interp, corePtr); SizeChanged(corePtr); TtkRedisplayWidget(corePtr); } /* TtkResizeWidget -- * Recompute widget size, schedule geometry propagation and redisplay. */ void TtkResizeWidget(WidgetCore *corePtr) { if (corePtr->flags & WIDGET_DESTROYED) { return; } WidgetWorldChanged(corePtr); } /* TtkWidgetChangeState -- * Set / clear the specified bits in the 'state' flag, */ void TtkWidgetChangeState(WidgetCore *corePtr, unsigned int setBits, unsigned int clearBits) |
︙ | ︙ | |||
308 309 310 311 312 313 314 | case EnterNotify: corePtr->state |= TTK_STATE_HOVER; TtkRedisplayWidget(corePtr); break; case VirtualEvent: { const char *name = ((XVirtualEvent *)eventPtr)->name; if ((name != NULL) && !strcmp("ThemeChanged", name)) { | < | < < < < < < < < < < < < < < | | | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 | case EnterNotify: corePtr->state |= TTK_STATE_HOVER; TtkRedisplayWidget(corePtr); break; case VirtualEvent: { const char *name = ((XVirtualEvent *)eventPtr)->name; if ((name != NULL) && !strcmp("ThemeChanged", name)) { WidgetWorldChanged(corePtr); } break; } default: /* can't happen... */ break; } } static const Tk_ClassProcs widgetClassProcs = { sizeof(Tk_ClassProcs), /* size */ WidgetWorldChanged, /* worldChangedProc */ NULL, /* createProc */ NULL /* modalProc */ }; /* * TtkWidgetConstructorObjCmd -- * General-purpose widget constructor command implementation. * ClientData is a WidgetSpec *. */ |
︙ | ︙ | |||
790 791 792 793 794 795 796 797 798 799 800 | element = Ttk_IdentifyElement(corePtr->layout, x, y); if (element) { const char *elementName = Ttk_ElementName(element); Tcl_SetObjResult(interp,Tcl_NewStringObj(elementName,-1)); } return TCL_OK; } /*EOF*/ | > > > > > > > > > > > > > > > > > > > > | 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | element = Ttk_IdentifyElement(corePtr->layout, x, y); 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*/ |
Changes to generic/ttk/ttkWidget.h.
︙ | ︙ | |||
85 86 87 88 89 90 91 92 93 | MODULE_SCOPE void TtkWidgetDoLayout(void *recordPtr); MODULE_SCOPE void TtkWidgetDisplay(void *recordPtr, Drawable); MODULE_SCOPE int TtkCoreConfigure(Tcl_Interp*, void *, int mask); /* Common widget commands: */ MODULE_SCOPE int TtkWidgetConfigureCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); | > > | | | | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | MODULE_SCOPE void TtkWidgetDoLayout(void *recordPtr); MODULE_SCOPE void TtkWidgetDisplay(void *recordPtr, Drawable); 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 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 TtkWidgetStyleCommand( void *,Tcl_Interp *, int, Tcl_Obj*const[]); /* Widget constructor: */ MODULE_SCOPE int TtkWidgetConstructorObjCmd( ClientData, Tcl_Interp*, int, Tcl_Obj*const[]); #define RegisterWidget(interp, name, specPtr) \ Tcl_CreateObjCommand(interp, name, \ TtkWidgetConstructorObjCmd, (void *)specPtr,NULL) /* WIDGET_TAKEFOCUS_TRUE -- * WIDGET_TAKEFOCUS_FALSE -- * Add one or the other of these to each OptionSpecs table * to indicate whether the widget should take focus * during keyboard traversal. */ |
︙ | ︙ | |||
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | Tcl_Interp *interp, Ttk_TagTable, Tcl_Obj *objPtr); MODULE_SCOPE Tcl_Obj *Ttk_NewTagSetObj(Ttk_TagSet); MODULE_SCOPE void Ttk_FreeTagSet(Ttk_TagSet); MODULE_SCOPE int Ttk_TagSetContains(Ttk_TagSet, Ttk_Tag tag); MODULE_SCOPE int Ttk_TagSetAdd(Ttk_TagSet, Ttk_Tag tag); MODULE_SCOPE int Ttk_TagSetRemove(Ttk_TagSet, Ttk_Tag tag); MODULE_SCOPE void Ttk_TagSetValues(Ttk_TagTable, Ttk_TagSet, void *record); MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*); /* * String tables for widget resource specifications: */ | > > | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | Tcl_Interp *interp, Ttk_TagTable, Tcl_Obj *objPtr); MODULE_SCOPE Tcl_Obj *Ttk_NewTagSetObj(Ttk_TagSet); MODULE_SCOPE void Ttk_FreeTagSet(Ttk_TagSet); MODULE_SCOPE int Ttk_TagSetContains(Ttk_TagSet, Ttk_Tag tag); MODULE_SCOPE int Ttk_TagSetAdd(Ttk_TagSet, Ttk_Tag tag); MODULE_SCOPE int Ttk_TagSetAddSet(Ttk_TagSet, Ttk_TagSet); MODULE_SCOPE int Ttk_TagSetRemove(Ttk_TagSet, Ttk_Tag tag); MODULE_SCOPE void Ttk_TagSetDefaults(Ttk_TagTable, Ttk_Style, void *); MODULE_SCOPE void Ttk_TagSetValues(Ttk_TagTable, Ttk_TagSet, void *record); MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*); /* * String tables for widget resource specifications: */ |
︙ | ︙ |
Changes to library/bgerror.tcl.
1 2 3 4 5 6 7 8 | # bgerror.tcl -- # # Implementation of the bgerror procedure. It posts a dialog box with # 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. # | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # bgerror.tcl -- # # Implementation of the bgerror procedure. It posts a dialog box with # 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 © 1998-2000 Ajuba Solutions. # Copyright © 2007 ActiveState Software Inc. # Copyright © 2007 Daniel A. Steffen <[email protected]> # Copyright © 2009 Pat Thoyts <[email protected]> namespace eval ::tk::dialog::error { namespace import -force ::tk::msgcat::* namespace export bgerror option add *ErrorDialog.function.text [mc "Save To Log"] \ |
︙ | ︙ |
Changes to library/button.tcl.
︙ | ︙ | |||
37 38 39 40 41 42 43 | tk::ButtonUp %W } bind Checkbutton <Leave> { tk::ButtonLeave %W } } if {"win32" eq [tk windowingsystem]} { | | | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | tk::ButtonUp %W } bind Checkbutton <Leave> { tk::ButtonLeave %W } } if {"win32" eq [tk windowingsystem]} { bind Checkbutton <=> { tk::CheckRadioInvoke %W select } bind Checkbutton <+> { tk::CheckRadioInvoke %W select } bind Checkbutton <minus> { tk::CheckRadioInvoke %W deselect } bind Checkbutton <Button-1> { tk::CheckRadioDown %W |
︙ | ︙ |
Changes to library/choosedir.tcl.
1 2 3 4 | # choosedir.tcl -- # # Choose directory dialog implementation for Unix/Mac. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 | # choosedir.tcl -- # # Choose directory dialog implementation for Unix/Mac. # # 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 {} # Make the chooseDir namespace inside the dialog namespace |
︙ | ︙ |
Changes to library/comdlg.tcl.
︙ | ︙ | |||
25 26 27 28 29 30 31 | # w = widget record to modify. Must be the pathname of a widget. # # specs = { # {-commandlineswitch resourceName ResourceClass defaultValue verifier} # {....} # } # | | > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # w = widget record to modify. Must be the pathname of a widget. # # specs = { # {-commandlineswitch resourceName ResourceClass defaultValue verifier} # {....} # } # # 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 # 1: Put the specs in associative arrays for faster access |
︙ | ︙ | |||
59 60 61 62 63 64 65 | } return -code error -errorcode {TK VALUE_MISSING} \ "value for \"$cmdsw\" missing" } # 2: set the default values # | > | | > | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | } return -code error -errorcode {TK VALUE_MISSING} \ "value for \"$cmdsw\" missing" } # 2: set the default values # if {"DONTSETDEFAULTS" ni $flags} { foreach cmdsw [array names cmd] { set data($cmdsw) $def($cmdsw) } } # 3: parse the argument list # foreach {cmdsw value} $argList { if {![info exists cmd($cmdsw)]} { return -code error -errorcode [list TK LOOKUP OPTION $cmdsw] \ |
︙ | ︙ |
Changes to library/console.tcl.
︙ | ︙ | |||
87 88 89 90 91 92 93 | menu .menubar.help -tearoff 0 AmpMenuArgs .menubar.help add command -label [mc &About...] \ -command tk::ConsoleAbout } AmpMenuArgs .menubar.edit add separator if {$::tk::console::useFontchooser} { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | menu .menubar.help -tearoff 0 AmpMenuArgs .menubar.help add command -label [mc &About...] \ -command tk::ConsoleAbout } AmpMenuArgs .menubar.edit add separator if {$::tk::console::useFontchooser} { if {[tk windowingsystem] eq "aqua"} { .menubar.edit add command -label tk_choose_font_marker set index [.menubar.edit index tk_choose_font_marker] .menubar.edit entryconfigure $index \ -label [mc "Show Fonts"]\ -accelerator "$mod-T"\ -command [list ::tk::console::FontchooserToggle] bind Console <<TkFontchooserVisibility>> \ [list ::tk::console::FontchooserVisibility $index] ::tk::console::FontchooserVisibility $index } else { AmpMenuArgs .menubar.edit add command -label [mc "&Font..."] \ -command [list ::tk::console::FontchooserToggle] } bind Console <FocusIn> [list ::tk::console::FontchooserFocus %W 1] bind Console <FocusOut> [list ::tk::console::FontchooserFocus %W 0] } AmpMenuArgs .menubar.edit add command -label [mc "&Increase Font Size"] \ -accel "$mod++" -command {event generate .console <<Console_FontSizeIncr>>} AmpMenuArgs .menubar.edit add command -label [mc "&Decrease Font Size"] \ -accel "$mod+-" -command {event generate .console <<Console_FontSizeDecr>>} AmpMenuArgs .menubar.edit add command -label [mc "Fit To Screen Width"] \ -command {event generate .console <<Console_FitScreenWidth>>} if {[tk windowingsystem] eq "aqua"} { .menubar add cascade -label [mc Window] -menu [menu .menubar.window] .menubar add cascade -label [mc Help] -menu [menu .menubar.help] } . configure -menu .menubar # See if we can find a better font than the TkFixedFont catch {font create TkConsoleFont {*}[font configure TkFixedFont]} set families [font families] switch -exact -- [tk windowingsystem] { aqua { set preferred {Monaco 10} } win32 { set preferred {ProFontWindows 8 Consolas 8} } default { set preferred {} } } foreach {family size} $preferred { if {$family in $families} { font configure TkConsoleFont -family $family -size $size break } } # Provide the right border for the text widget (platform dependent). ::ttk::style layout ConsoleFrame { Entry.field -sticky news -border 1 -children { ConsoleFrame.padding -sticky news } } ::ttk::frame .consoleframe -style ConsoleFrame set con [text .console -yscrollcommand [list .sb set] -setgrid true \ -borderwidth 0 -highlightthickness 0 -font TkConsoleFont] if {[tk windowingsystem] eq "aqua"} { scrollbar .sb -command [list $con yview] } else { ::ttk::scrollbar .sb -command [list $con yview] } pack .sb -in .consoleframe -fill both -side right -padx 1 -pady 1 pack $con -in .consoleframe -fill both -expand 1 -side left -padx 1 -pady 1 pack .consoleframe -fill both -expand 1 -side left ConsoleBind $con |
︙ | ︙ | |||
211 212 213 214 215 216 217 | proc ::tk::ConsoleSource {} { set filename [tk_getOpenFile -defaultextension .tcl -parent . \ -title [mc "Select a file to source"] \ -filetypes [list \ [list [mc "Tcl Scripts"] .tcl] \ [list [mc "All Files"] *]]] if {$filename ne ""} { | | | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | proc ::tk::ConsoleSource {} { set filename [tk_getOpenFile -defaultextension .tcl -parent . \ -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 -encoding utf-8 $filename] if {[catch {consoleinterp eval $cmd} result]} { ConsoleOutput stderr "$result\n" } } } # ::tk::ConsoleInvoke -- |
︙ | ︙ | |||
269 270 271 272 273 274 275 | # cmd - Which action to take: prev, next, reset. set ::tk::HistNum 1 proc ::tk::ConsoleHistory {cmd} { variable HistNum switch $cmd { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | # cmd - Which action to take: prev, next, reset. set ::tk::HistNum 1 proc ::tk::ConsoleHistory {cmd} { variable HistNum switch $cmd { prev { incr HistNum -1 if {$HistNum == 0} { set cmd {history event [expr {[history nextid] -1}]} } else { set cmd "history event $HistNum" } if {[catch {consoleinterp eval $cmd} cmd]} { incr HistNum return } .console delete promptEnd end .console insert promptEnd $cmd {input stdin} .console see end } next { incr HistNum if {$HistNum == 0} { set cmd {history event [expr {[history nextid] -1}]} } elseif {$HistNum > 0} { set cmd "" set HistNum 1 } else { set cmd "history event $HistNum" } if {$cmd ne ""} { catch {consoleinterp eval $cmd} cmd } .console delete promptEnd end .console insert promptEnd $cmd {input stdin} .console see end } reset { set HistNum 1 } } } # ::tk::ConsolePrompt -- # This procedure draws the prompt. If tcl_prompt1 or tcl_prompt2 # exists in the main interpreter it will be called to generate the # prompt. Otherwise, a hard coded default prompt is printed. # # Arguments: # partial - Flag to specify which prompt to print. proc ::tk::ConsolePrompt {{partial normal}} { set w .console if {$partial eq "normal"} { set temp [$w index "end - 1 char"] $w mark set output end if {[consoleinterp eval "info exists tcl_prompt1"]} { consoleinterp eval "eval \[set tcl_prompt1\]" } else { puts -nonewline [EvalAttached $::tk::console::defaultPrompt] } } else { set temp [$w index output] $w mark set output end if {[consoleinterp eval "info exists tcl_prompt2"]} { consoleinterp eval "eval \[set tcl_prompt2\]" } else { puts -nonewline "> " } } flush stdout $w mark set output $temp ::tk::TextSetCursor $w end $w mark set promptEnd insert $w mark gravity promptEnd left ::tk::console::ConstrainBuffer $w $::tk::console::maxLines $w see end } # Copy selected text from the console proc ::tk::console::Copy {w} { if {![catch {set data [$w get sel.first sel.last]}]} { clipboard clear -displayof $w clipboard append -displayof $w $data } } # Copies selected text. If the selection is within the current active edit # region then it will be cut, if not it is only copied. proc ::tk::console::Cut {w} { if {![catch {set data [$w get sel.first sel.last]}]} { clipboard clear -displayof $w clipboard append -displayof $w $data if {[$w compare sel.first >= output]} { $w delete sel.first sel.last } } } # Paste text from the clipboard proc ::tk::console::Paste {w} { catch { set clip [::tk::GetSelection $w CLIPBOARD] set list [split $clip \n\r] tk::ConsoleInsert $w [lindex $list 0] foreach x [lrange $list 1 end] { $w mark set insert {end - 1c} tk::ConsoleInsert $w "\n" tk::ConsoleInvoke tk::ConsoleInsert $w $x } } } # Fit TkConsoleFont to window width proc ::tk::console::FitScreenWidth {w} { set width [winfo screenwidth $w] set cwidth [$w cget -width] set s -50 set fit 0 array set fi [font configure TkConsoleFont] while {$s < 0} { set fi(-size) $s set f [font create {*}[array get fi]] set c [font measure $f "eM"] font delete $f if {$c * $cwidth < 1.667 * $width} { font configure TkConsoleFont -size $s break } incr s 2 } } # ::tk::ConsoleBind -- # This procedure first ensures that the default bindings for the Text # class have been defined. Then certain bindings are overridden for |
︙ | ︙ | |||
420 421 422 423 424 425 426 | ## ...or any Control-v binding (would block <<Paste>>) bind Console <Control-v> {} # For the moment, transpose isn't enabled until the console # gets and overhaul of how it handles input -- hobbs bind Console <Control-t> {} | | > > | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | ## ...or any Control-v binding (would block <<Paste>>) bind Console <Control-v> {} # For the moment, transpose isn't enabled until the console # gets and overhaul of how it handles input -- hobbs bind Console <Control-t> {} # Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the # <Keypress> class binding will also fire and insert the character # which is wrong. bind Console <Alt-Key> {# nothing } bind Console <Meta-Key> {# nothing} bind Console <Control-Key> {# nothing} bind Console <Command-Key> {# nothing} bind Console <Fn-Key> {# nothing} foreach {ev key} { <<Console_NextImmediate>> <Control-n> <<Console_PrevImmediate>> <Control-p> <<Console_PrevSearch>> <Control-r> <<Console_NextSearch>> <Control-s> |
︙ | ︙ | |||
450 451 452 453 454 455 456 | <<Console_Eval>> <KP_Enter> <<Console_Clear>> <Control-l> <<Console_KillLine>> <Control-k> <<Console_Transpose>> <Control-t> <<Console_ClearLine>> <Control-u> <<Console_SaveCommand>> <Control-z> | | > > < < < < < < < < | | < | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | <<Console_Eval>> <KP_Enter> <<Console_Clear>> <Control-l> <<Console_KillLine>> <Control-k> <<Console_Transpose>> <Control-t> <<Console_ClearLine>> <Control-u> <<Console_SaveCommand>> <Control-z> <<Console_FontSizeIncr>> <Control-+> <<Console_FontSizeDecr>> <Control-minus> <<Console_FontSizeIncr>> <Command-+> <<Console_FontSizeDecr>> <Command-minus> } { event add $ev $key bind Console $key {} } if {$::tk::console::useFontchooser} { bind Console <Command-t> [list ::tk::console::FontchooserToggle] } bind Console <<Console_Expand>> { if {[%W compare insert > promptEnd]} { ::tk::console::Expand %W } } bind Console <<Console_ExpandFile>> { |
︙ | ︙ | |||
590 591 592 593 594 595 596 | bind Console <Key> { tk::ConsoleInsert %W %A } bind Console <F9> { eval destroy [winfo child .] source -encoding utf-8 [file join $tk_library console.tcl] } | < | | < | | | | | | | | | | 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | bind Console <Key> { tk::ConsoleInsert %W %A } bind Console <F9> { eval destroy [winfo child .] source -encoding utf-8 [file join $tk_library console.tcl] } bind Console <Command-q> { exit } bind Console <<Cut>> { ::tk::console::Cut %W } bind Console <<Copy>> { ::tk::console::Copy %W } bind Console <<Paste>> { ::tk::console::Paste %W } bind Console <<Console_FontSizeIncr>> { set size [font configure TkConsoleFont -size] if {$size < 0} {set sign -1} else {set sign 1} set size [expr {(abs($size) + 1) * $sign}] font configure TkConsoleFont -size $size if {$::tk::console::useFontchooser} { tk fontchooser configure -font TkConsoleFont } } bind Console <<Console_FontSizeDecr>> { set size [font configure TkConsoleFont -size] if {abs($size) < 2} { return } if {$size < 0} {set sign -1} else {set sign 1} set size [expr {(abs($size) - 1) * $sign}] font configure TkConsoleFont -size $size if {$::tk::console::useFontchooser} { tk fontchooser configure -font TkConsoleFont } } bind Console <<Console_FitScreenWidth>> { ::tk::console::FitScreenWidth %W } |
︙ | ︙ |
Changes to library/demos/cscroll.tcl.
︙ | ︙ | |||
110 111 112 113 114 115 116 | } } 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: | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | } } 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: # https://linuxreviews.org/HOWTO_change_the_mouse_speed_in_X bind $c <Button-4> { if {!$tk_strictMotif} { %W yview scroll -5 units } } bind $c <Shift-Button-4> { if {!$tk_strictMotif} { |
︙ | ︙ |
Changes to library/demos/en.msg.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ::msgcat::mcset en "Widget Demonstration" ::msgcat::mcset en "tkWidgetDemo" ::msgcat::mcset en "&File" ::msgcat::mcset en "About..." ::msgcat::mcset en "&About..." ::msgcat::mcset en "<F1>" ::msgcat::mcset en "&Quit" ::msgcat::mcset en "Meta+Q" ;# Displayed hotkey ::msgcat::mcset en "Meta-q" ;# Actual binding sequence ::msgcat::mcset en "Ctrl+Q" ;# Displayed hotkey ::msgcat::mcset en "Control-q" ;# Actual binding sequence ::msgcat::mcset en "Variable values" ::msgcat::mcset en "Variable values:" ::msgcat::mcset en "OK" ::msgcat::mcset en "Run the \"%s\" sample program" ::msgcat::mcset en "Dismiss" ::msgcat::mcset en "Rerun Demo" ::msgcat::mcset en "Demo code: %s" ::msgcat::mcset en "About Widget Demo" | > > | < < < < < < > | | | | | < | < | | < < < | | < | > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | ::msgcat::mcset en "Widget Demonstration" ::msgcat::mcset en "tkWidgetDemo" ::msgcat::mcset en "&File" ::msgcat::mcset en "About..." ::msgcat::mcset en "&About..." ::msgcat::mcset en "<F1>" ::msgcat::mcset en "&Quit" ::msgcat::mcset en "Meta+Q" ;# Displayed hotkey ::msgcat::mcset en "Meta-q" ;# Actual binding sequence ::msgcat::mcset en "Ctrl+Q" ;# Displayed hotkey ::msgcat::mcset en "Control-q" ;# Actual binding sequence ::msgcat::mcset en "See Variables" ::msgcat::mcset en "Variable values" ::msgcat::mcset en "Variable values:" ::msgcat::mcset en "OK" ::msgcat::mcset en "Run the \"%s\" sample program" ::msgcat::mcset en "Dismiss" ::msgcat::mcset en "Rerun Demo" ::msgcat::mcset en "Print Code" ::msgcat::mcset en "Demo code: %s" ::msgcat::mcset en "About Widget Demo" ::msgcat::mcset en "Tk widget demonstration" ::msgcat::mcset en "Copyright © %s" ::msgcat::mcset en "Tk Widget Demonstrations" ::msgcat::mcset en "This application provides a front end for several short scripts" ::msgcat::mcset en "that demonstrate what you can do with Tk widgets. Each of the" ::msgcat::mcset en "numbered lines below describes a demonstration; you can click on" ::msgcat::mcset en "it to invoke the demonstration. Once the demonstration window" ::msgcat::mcset en "appears, you can click the" ::msgcat::mcset en "See Code" "See Code" ;# This is also button text! ::msgcat::mcset en "button to see the Tcl/Tk code that created the demonstration. If" ::msgcat::mcset en "you wish, you can edit the code and click the" ::msgcat::mcset en "button in the code window to reinvoke the demonstration with the" ::msgcat::mcset en "modified code." ::msgcat::mcset en "Labels, buttons, checkbuttons, and radiobuttons" ::msgcat::mcset en "Labels (text and bitmaps)" ::msgcat::mcset en "Labels and UNICODE text" ::msgcat::mcset en "Buttons" ::msgcat::mcset en "Check-buttons (select any of a group)" ::msgcat::mcset en "Radio-buttons (select one of a group)" ::msgcat::mcset en "A 15-puzzle game made out of buttons" ::msgcat::mcset en "Iconic buttons that use bitmaps" ::msgcat::mcset en "Two labels displaying images" ::msgcat::mcset en "A simple user interface for viewing images" ::msgcat::mcset en "Labelled frames" ::msgcat::mcset en "Listboxes" ::msgcat::mcset en "The 50 states" ::msgcat::mcset en "Colors: change the color scheme for the application" ::msgcat::mcset en "A collection of famous and infamous sayings" ::msgcat::mcset en "Entries and Spin-boxes" ::msgcat::mcset en "Entries without scrollbars" ::msgcat::mcset en "Entries with scrollbars" ::msgcat::mcset en "Validated entries and password fields" ::msgcat::mcset en "Spin-boxes" ::msgcat::mcset en "Simple Rolodex-like form" ::msgcat::mcset en "Text" ::msgcat::mcset en "Basic editable text" ::msgcat::mcset en "Text display styles" ::msgcat::mcset en "Hypertext (tag bindings)" ::msgcat::mcset en "A text widget with embedded windows" ::msgcat::mcset en "A search tool built with a text widget" ::msgcat::mcset en "Canvases" ::msgcat::mcset en "The canvas item types" ::msgcat::mcset en "A simple 2-D plot" ::msgcat::mcset en "Text items in canvases" ::msgcat::mcset en "An editor for arrowheads on canvas lines" ::msgcat::mcset en "A ruler with adjustable tab stops" ::msgcat::mcset en "A building floor plan" ::msgcat::mcset en "A simple scrollable canvas" ::msgcat::mcset en "Scales" ::msgcat::mcset en "Horizontal scale" ::msgcat::mcset en "Vertical scale" ::msgcat::mcset en "Paned Windows" ::msgcat::mcset en "Horizontal paned window" ::msgcat::mcset en "Vertical paned window" ::msgcat::mcset en "Menus" ::msgcat::mcset en "Menus and cascades (sub-menus)" ::msgcat::mcset en "Menu-buttons" ::msgcat::mcset en "Common Dialogs" ::msgcat::mcset en "Message boxes" ::msgcat::mcset en "File selection dialog" ::msgcat::mcset en "Color picker" ::msgcat::mcset en "Font selection dialog" ::msgcat::mcset en "System tray icon and notification" ::msgcat::mcset en "Printing from canvas and text widgets" ::msgcat::mcset en "Animation" ::msgcat::mcset en "Animated labels" ::msgcat::mcset en "Animated wave" ::msgcat::mcset en "Pendulum simulation" ::msgcat::mcset en "A celebration of Rube Goldberg" ::msgcat::mcset en "Miscellaneous" ::msgcat::mcset en "The built-in bitmaps" ::msgcat::mcset en "A dialog box with a local grab" ::msgcat::mcset en "A dialog box with a global grab" ::msgcat::mcset en "Window icons and badges" |
Changes to library/demos/entry3.tcl.
︙ | ︙ | |||
60 61 62 63 64 65 66 | after 200 [list focusAndFlash $W $fg $bg [expr {$count-1}]] } } labelframe $w.l1 -text "Integer Entry" # Alternatively try using {string is digit} for arbitrary length numbers, # and not just 32-bit ones. | | | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | after 200 [list focusAndFlash $W $fg $bg [expr {$count-1}]] } } 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 -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 -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. # Initial content for the third entry widget |
︙ | ︙ | |||
157 158 159 160 161 162 163 | bell return -code break } } labelframe $w.l3 -text "US Phone-Number Entry" entry $w.l3.e -validate key -invcmd bell -textvariable entry3content \ | | | | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | bell return -code break } } labelframe $w.l3 -text "US Phone-Number Entry" entry $w.l3.e -validate key -invcmd bell -textvariable entry3content \ -validatecommand {validatePhoneChange %W %v %i %S} # Click to focus goes to the first editable character... bind $w.l3.e <FocusIn> { if {"%d" ne "NotifyAncestor"} { %W icursor 3 after idle {%W selection clear} } } bind $w.l3.e <<PrevChar>> {phoneSkipLeft %W} bind $w.l3.e <<NextChar>> {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 "*" -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 |
Changes to library/demos/floor.tcl.
︙ | ︙ | |||
329 330 331 332 333 334 335 | # # Arguments: # w - The canvas window. # color - Color to use for drawing foreground information. proc fg1 {w color} { global floorLabels floorItems | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | # # Arguments: # w - The canvas window. # color - Color to use for drawing foreground information. proc fg1 {w color} { global floorLabels floorItems set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 101 set {floorItems(101)} $i $w create text 358 209 -text 101 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) {Pub Lift1} set {floorItems(Pub Lift1)} $i $w create text 323 223 -text {Pub Lift1} -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) {Priv Lift1} set {floorItems(Priv Lift1)} $i $w create text 323 188 -text {Priv Lift1} -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 42 389 42 337 1 337 1 389 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 110 set {floorItems(110)} $i $w create text 21.5 363 -text 110 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 59 389 59 385 90 385 90 337 44 337 44 389 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 109 set {floorItems(109)} $i $w create text 67 363 -text 109 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 51 300 51 253 6 253 6 300 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 111 set {floorItems(111)} $i $w create text 28.5 276.5 -text 111 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 98 248 98 309 79 309 79 248 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 117B set {floorItems(117B)} $i $w create text 88.5 278.5 -text 117B -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 51 251 51 204 6 204 6 251 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 112 set {floorItems(112)} $i $w create text 28.5 227.5 -text 112 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 6 156 51 156 51 203 6 203 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 113 set {floorItems(113)} $i $w create text 28.5 179.5 -text 113 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 85 169 79 169 79 192 85 192 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 117A set {floorItems(117A)} $i $w create text 82 180.5 -text 117A -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 77 302 77 168 53 168 53 302 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 117 set {floorItems(117)} $i $w create text 65 235 -text 117 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 51 155 51 115 6 115 6 155 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 114 set {floorItems(114)} $i $w create text 28.5 135 -text 114 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 95 115 53 115 53 168 95 168 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 115 set {floorItems(115)} $i $w create text 74 141.5 -text 115 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 87 113 87 27 10 27 10 113 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 116 set {floorItems(116)} $i $w create text 48.5 70 -text 116 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 89 91 128 91 128 113 89 113 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 118 set {floorItems(118)} $i $w create text 108.5 102 -text 118 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 178 128 178 132 216 132 216 91 163 91 163 112 149 112 149 128 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 120 set {floorItems(120)} $i $w create text 189.5 111.5 -text 120 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 79 193 87 193 87 169 136 169 136 192 156 192 156 169 175 169 175 246 79 246 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 122 set {floorItems(122)} $i $w create text 131 207.5 -text 122 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 138 169 154 169 154 191 138 191 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 121 set {floorItems(121)} $i $w create text 146 180 -text 121 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 99 300 126 300 126 309 99 309 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 106A set {floorItems(106A)} $i $w create text 112.5 304.5 -text 106A -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 128 299 128 309 150 309 150 248 99 248 99 299 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 105 set {floorItems(105)} $i $w create text 124.5 278.5 -text 105 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 174 309 174 300 152 300 152 309 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 106B set {floorItems(106B)} $i $w create text 163 304.5 -text 106B -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 176 299 176 309 216 309 216 248 152 248 152 299 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 104 set {floorItems(104)} $i $w create text 184 278.5 -text 104 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 138 385 138 337 91 337 91 385 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 108 set {floorItems(108)} $i $w create text 114.5 361 -text 108 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 256 337 140 337 140 385 256 385 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 107 set {floorItems(107)} $i $w create text 198 361 -text 107 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 300 353 300 329 260 329 260 353 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) Smoking set {floorItems(Smoking)} $i $w create text 280 341 -text Smoking -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 314 135 314 170 306 170 306 246 177 246 177 135 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 123 set {floorItems(123)} $i $w create text 245.5 190.5 -text 123 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 217 248 301 248 301 326 257 326 257 310 217 310 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 103 set {floorItems(103)} $i $w create text 259 287 -text 103 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 396 188 377 188 377 169 316 169 316 131 396 131 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 124 set {floorItems(124)} $i $w create text 356 150 -text 124 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 397 226 407 226 407 189 377 189 377 246 397 246 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 125 set {floorItems(125)} $i $w create text 392 217.5 -text 125 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 399 187 409 187 409 207 474 207 474 164 399 164 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 126 set {floorItems(126)} $i $w create text 436.5 185.5 -text 126 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 409 209 409 229 399 229 399 253 486 253 486 239 474 239 474 209 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 127 set {floorItems(127)} $i $w create text 436.5 231 -text 127 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 501 164 501 174 495 174 495 188 490 188 490 204 476 204 476 164 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) MShower set {floorItems(MShower)} $i $w create text 488.5 184 -text MShower -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 497 176 513 176 513 204 492 204 492 190 497 190 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) Closet set {floorItems(Closet)} $i $w create text 502.5 190 -text Closet -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 476 237 476 206 513 206 513 254 488 254 488 237 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) WShower set {floorItems(WShower)} $i $w create text 494.5 230 -text WShower -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 486 131 558 131 558 135 724 135 724 166 697 166 697 275 553 275 531 254 515 254 515 174 503 174 503 161 486 161 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 130 set {floorItems(130)} $i $w create text 638.5 205 -text 130 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 308 242 339 242 339 248 342 248 342 246 397 246 397 276 393 276 393 309 300 309 300 248 308 248 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 102 set {floorItems(102)} $i $w create text 367.5 278.5 -text 102 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 397 255 486 255 486 276 397 276 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 128 set {floorItems(128)} $i $w create text 441.5 265.5 -text 128 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 510 309 486 309 486 255 530 255 552 277 561 277 561 325 510 325 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 129 set {floorItems(129)} $i $w create text 535.5 293 -text 129 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 696 281 740 281 740 387 642 387 642 389 561 389 561 277 696 277 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 133 set {floorItems(133)} $i $w create text 628.5 335 -text 133 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 742 387 742 281 800 281 800 387 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 132 set {floorItems(132)} $i $w create text 771 334 -text 132 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 800 168 800 280 699 280 699 168 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 134 set {floorItems(134)} $i $w create text 749.5 224 -text 134 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 726 131 726 166 800 166 800 131 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 135 set {floorItems(135)} $i $w create text 763 148.5 -text 135 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 340 360 335 363 331 365 326 366 304 366 304 312 396 312 396 288 400 288 404 288 409 290 413 292 418 297 421 302 422 309 421 318 417 325 411 330 405 332 397 333 344 333 340 334 336 336 335 338 332 342 331 347 332 351 334 354 336 357 341 359 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) {Ramona Stair} set {floorItems(Ramona Stair)} $i $w create text 368 323 -text {Ramona Stair} -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 30 23 30 5 93 5 98 5 104 7 110 10 116 16 119 20 122 28 123 32 123 68 220 68 220 87 90 87 90 23 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) {University Stair} set {floorItems(University Stair)} $i $w create text 155 77.5 -text {University Stair} -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 282 37 295 40 312 49 323 56 337 70 352 56 358 48 363 39 365 29 348 25 335 22 321 14 300 5 283 1 260 0 246 0 242 2 236 4 231 8 227 13 223 17 221 22 220 34 260 34 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) {Plaza Stair} set {floorItems(Plaza Stair)} $i $w create text 317.5 28.5 -text {Plaza Stair} -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 220 34 260 34 282 37 295 40 312 49 323 56 337 70 350 83 365 94 377 100 386 104 386 128 220 128 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) {Plaza Deck} set {floorItems(Plaza Deck)} $i $w create text 303 81 -text {Plaza Deck} -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 257 336 77 336 6 336 6 301 77 301 77 310 257 310 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 106 set {floorItems(106)} $i $w create text 131.5 318.5 -text 106 -fill $color -anchor c -tags {floor1 label} set i [$w create polygon 146 110 162 110 162 91 130 91 130 115 95 115 95 128 114 128 114 151 157 151 157 153 112 153 112 130 97 130 97 168 175 168 175 131 146 131 -fill {} -outline {} -tags {floor1 room}] set floorLabels($i) 119 set {floorItems(119)} $i $w create text 143.5 133 -text 119 -fill $color -anchor c -tags {floor1 label} $w create line 155 191 155 189 -fill $color -tags {floor1 wall} $w create line 155 177 155 169 -fill $color -tags {floor1 wall} $w create line 96 129 96 169 -fill $color -tags {floor1 wall} $w create line 78 169 176 169 -fill $color -tags {floor1 wall} |
︙ | ︙ | |||
692 693 694 695 696 697 698 | # # Arguments: # w - The canvas window. # color - Color to use for drawing foreground information. proc fg2 {w color} { global floorLabels floorItems | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | # # Arguments: # w - The canvas window. # color - Color to use for drawing foreground information. proc fg2 {w color} { global floorLabels floorItems set i [$w create polygon 748 188 755 188 755 205 758 205 758 222 800 222 800 168 748 168 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 238 set {floorItems(238)} $i $w create text 774 195 -text 238 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 726 188 746 188 746 166 800 166 800 131 726 131 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 237 set {floorItems(237)} $i $w create text 763 148.5 -text 237 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 497 187 497 204 559 204 559 324 641 324 643 324 643 291 641 291 641 205 696 205 696 291 694 291 694 314 715 314 715 291 715 205 755 205 755 190 724 190 724 187 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 246 set {floorItems(246)} $i $w create text 600 264 -text 246 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 694 279 643 279 643 314 694 314 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 247 set {floorItems(247)} $i $w create text 668.5 296.5 -text 247 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 232 250 308 250 308 242 339 242 339 246 397 246 397 255 476 255 476 250 482 250 559 250 559 274 482 274 482 278 396 278 396 274 232 274 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 202 set {floorItems(202)} $i $w create text 285.5 260 -text 202 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 53 228 53 338 176 338 233 338 233 196 306 196 306 180 175 180 175 169 156 169 156 196 176 196 176 228 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 206 set {floorItems(206)} $i $w create text 143 267 -text 206 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 51 277 6 277 6 338 51 338 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 212 set {floorItems(212)} $i $w create text 28.5 307.5 -text 212 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 557 276 486 276 486 309 510 309 510 325 557 325 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 245 set {floorItems(245)} $i $w create text 521.5 300.5 -text 245 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 560 389 599 389 599 326 560 326 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 244 set {floorItems(244)} $i $w create text 579.5 357.5 -text 244 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 601 389 601 326 643 326 643 389 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 243 set {floorItems(243)} $i $w create text 622 357.5 -text 243 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 688 316 645 316 645 365 688 365 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 242 set {floorItems(242)} $i $w create text 666.5 340.5 -text 242 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 802 367 759 367 759 226 802 226 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) {Barbecue Deck} set {floorItems(Barbecue Deck)} $i $w create text 780.5 296.5 -text {Barbecue Deck} -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 755 262 755 314 717 314 717 262 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 240 set {floorItems(240)} $i $w create text 736 288 -text 240 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 755 316 689 316 689 365 755 365 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 241 set {floorItems(241)} $i $w create text 722 340.5 -text 241 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 755 206 717 206 717 261 755 261 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 239 set {floorItems(239)} $i $w create text 736 233.5 -text 239 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 695 277 643 277 643 206 695 206 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 248 set {floorItems(248)} $i $w create text 669 241.5 -text 248 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 676 135 676 185 724 185 724 135 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 236 set {floorItems(236)} $i $w create text 700 160 -text 236 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 675 135 635 135 635 145 628 145 628 185 675 185 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 235 set {floorItems(235)} $i $w create text 651.5 160 -text 235 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 626 143 633 143 633 135 572 135 572 143 579 143 579 185 626 185 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 234 set {floorItems(234)} $i $w create text 606 160 -text 234 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 557 135 571 135 571 145 578 145 578 185 527 185 527 131 557 131 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 233 set {floorItems(233)} $i $w create text 552.5 158 -text 233 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 476 249 557 249 557 205 476 205 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 230 set {floorItems(230)} $i $w create text 516.5 227 -text 230 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 476 164 486 164 486 131 525 131 525 185 476 185 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 232 set {floorItems(232)} $i $w create text 500.5 158 -text 232 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 476 186 495 186 495 204 476 204 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 229 set {floorItems(229)} $i $w create text 485.5 195 -text 229 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 474 207 409 207 409 187 399 187 399 164 474 164 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 227 set {floorItems(227)} $i $w create text 436.5 185.5 -text 227 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 399 228 399 253 474 253 474 209 409 209 409 228 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 228 set {floorItems(228)} $i $w create text 436.5 231 -text 228 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 397 246 397 226 407 226 407 189 377 189 377 246 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 226 set {floorItems(226)} $i $w create text 392 217.5 -text 226 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 377 169 316 169 316 131 397 131 397 188 377 188 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 225 set {floorItems(225)} $i $w create text 356.5 150 -text 225 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 234 198 306 198 306 249 234 249 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 224 set {floorItems(224)} $i $w create text 270 223.5 -text 224 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 270 179 306 179 306 170 314 170 314 135 270 135 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 223 set {floorItems(223)} $i $w create text 292 157 -text 223 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 268 179 221 179 221 135 268 135 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 222 set {floorItems(222)} $i $w create text 244.5 157 -text 222 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 177 179 219 179 219 135 177 135 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 221 set {floorItems(221)} $i $w create text 198 157 -text 221 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 299 327 349 327 349 284 341 284 341 276 299 276 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 204 set {floorItems(204)} $i $w create text 324 301.5 -text 204 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 234 276 297 276 297 327 257 327 257 338 234 338 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 205 set {floorItems(205)} $i $w create text 265.5 307 -text 205 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 256 385 256 340 212 340 212 385 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 207 set {floorItems(207)} $i $w create text 234 362.5 -text 207 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 210 340 164 340 164 385 210 385 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 208 set {floorItems(208)} $i $w create text 187 362.5 -text 208 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 115 340 162 340 162 385 115 385 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 209 set {floorItems(209)} $i $w create text 138.5 362.5 -text 209 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 89 228 89 156 53 156 53 228 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 217 set {floorItems(217)} $i $w create text 71 192 -text 217 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 89 169 97 169 97 190 89 190 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 217A set {floorItems(217A)} $i $w create text 93 179.5 -text 217A -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 89 156 89 168 95 168 95 135 53 135 53 156 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 216 set {floorItems(216)} $i $w create text 71 145.5 -text 216 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 51 179 51 135 6 135 6 179 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 215 set {floorItems(215)} $i $w create text 28.5 157 -text 215 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 51 227 6 227 6 180 51 180 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 214 set {floorItems(214)} $i $w create text 28.5 203.5 -text 214 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 51 275 6 275 6 229 51 229 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 213 set {floorItems(213)} $i $w create text 28.5 252 -text 213 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 114 340 67 340 67 385 114 385 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 210 set {floorItems(210)} $i $w create text 90.5 362.5 -text 210 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 59 389 59 385 65 385 65 340 1 340 1 389 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 211 set {floorItems(211)} $i $w create text 33 364.5 -text 211 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 393 309 350 309 350 282 342 282 342 276 393 276 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 203 set {floorItems(203)} $i $w create text 367.5 292.5 -text 203 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 99 191 91 191 91 226 174 226 174 198 154 198 154 192 109 192 109 169 99 169 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 220 set {floorItems(220)} $i $w create text 132.5 208.5 -text 220 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) {Priv Lift2} set {floorItems(Priv Lift2)} $i $w create text 323 188 -text {Priv Lift2} -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) {Pub Lift 2} set {floorItems(Pub Lift 2)} $i $w create text 323 223 -text {Pub Lift 2} -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 218 set {floorItems(218)} $i $w create text 136 149.5 -text 218 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 219 set {floorItems(219)} $i $w create text 132.5 180 -text 219 -fill $color -anchor c -tags {floor2 label} set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor2 room}] set floorLabels($i) 201 set {floorItems(201)} $i $w create text 358 209 -text 201 -fill $color -anchor c -tags {floor2 label} $w create line 641 186 678 186 -fill $color -tags {floor2 wall} $w create line 757 350 757 367 -fill $color -tags {floor2 wall} $w create line 634 133 634 144 -fill $color -tags {floor2 wall} $w create line 634 144 627 144 -fill $color -tags {floor2 wall} |
︙ | ︙ | |||
1062 1063 1064 1065 1066 1067 1068 | # # Arguments: # w - The canvas window. # color - Color to use for drawing foreground information. proc fg3 {w color} { global floorLabels floorItems | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 | # # Arguments: # w - The canvas window. # color - Color to use for drawing foreground information. proc fg3 {w color} { global floorLabels floorItems set i [$w create polygon 89 228 89 180 70 180 70 228 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 316 set {floorItems(316)} $i $w create text 79.5 204 -text 316 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 115 368 162 368 162 323 115 323 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 309 set {floorItems(309)} $i $w create text 138.5 345.5 -text 309 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 164 323 164 368 211 368 211 323 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 308 set {floorItems(308)} $i $w create text 187.5 345.5 -text 308 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 256 368 212 368 212 323 256 323 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 307 set {floorItems(307)} $i $w create text 234 345.5 -text 307 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 244 276 297 276 297 327 260 327 260 321 244 321 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 305 set {floorItems(305)} $i $w create text 270.5 301.5 -text 305 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 251 219 251 203 244 203 244 219 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 324B set {floorItems(324B)} $i $w create text 247.5 211 -text 324B -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 251 249 244 249 244 232 251 232 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 324A set {floorItems(324A)} $i $w create text 247.5 240.5 -text 324A -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 223 135 223 179 177 179 177 135 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 320 set {floorItems(320)} $i $w create text 200 157 -text 320 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 114 368 114 323 67 323 67 368 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 310 set {floorItems(310)} $i $w create text 90.5 345.5 -text 310 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 23 277 23 321 68 321 68 277 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 312 set {floorItems(312)} $i $w create text 45.5 299 -text 312 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 23 229 68 229 68 275 23 275 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 313 set {floorItems(313)} $i $w create text 45.5 252 -text 313 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 68 227 23 227 23 180 68 180 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 314 set {floorItems(314)} $i $w create text 45.5 203.5 -text 314 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 95 179 95 135 23 135 23 179 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 315 set {floorItems(315)} $i $w create text 59 157 -text 315 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 99 226 99 204 91 204 91 226 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 316B set {floorItems(316B)} $i $w create text 95 215 -text 316B -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 91 202 99 202 99 180 91 180 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 316A set {floorItems(316A)} $i $w create text 95 191 -text 316A -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 97 169 109 169 109 192 154 192 154 198 174 198 174 226 101 226 101 179 97 179 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 319 set {floorItems(319)} $i $w create text 141.5 209 -text 319 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 65 368 58 368 58 389 1 389 1 333 23 333 23 323 65 323 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 311 set {floorItems(311)} $i $w create text 29.5 361 -text 311 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 154 191 111 191 111 169 154 169 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 318 set {floorItems(318)} $i $w create text 132.5 180 -text 318 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 175 168 97 168 97 131 175 131 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 317 set {floorItems(317)} $i $w create text 136 149.5 -text 317 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 274 194 274 221 306 221 306 194 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 323 set {floorItems(323)} $i $w create text 290 207.5 -text 323 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 306 222 274 222 274 249 306 249 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 325 set {floorItems(325)} $i $w create text 290 235.5 -text 325 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 263 179 224 179 224 135 263 135 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 321 set {floorItems(321)} $i $w create text 243.5 157 -text 321 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 314 169 306 169 306 192 273 192 264 181 264 135 314 135 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 322 set {floorItems(322)} $i $w create text 293.5 163.5 -text 322 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 307 240 339 240 339 206 307 206 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) {Pub Lift3} set {floorItems(Pub Lift3)} $i $w create text 323 223 -text {Pub Lift3} -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 339 205 307 205 307 171 339 171 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) {Priv Lift3} set {floorItems(Priv Lift3)} $i $w create text 323 188 -text {Priv Lift3} -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 350 284 376 284 376 276 397 276 397 309 350 309 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 303 set {floorItems(303)} $i $w create text 373.5 292.5 -text 303 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 272 203 272 249 252 249 252 230 244 230 244 221 252 221 252 203 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 324 set {floorItems(324)} $i $w create text 262 226 -text 324 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 299 276 299 327 349 327 349 284 341 284 341 276 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 304 set {floorItems(304)} $i $w create text 324 301.5 -text 304 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 375 246 375 172 341 172 341 246 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 301 set {floorItems(301)} $i $w create text 358 209 -text 301 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 397 246 377 246 377 185 397 185 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 327 set {floorItems(327)} $i $w create text 387 215.5 -text 327 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 316 131 316 169 377 169 377 185 397 185 397 131 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 326 set {floorItems(326)} $i $w create text 356.5 150 -text 326 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 308 251 242 251 242 274 342 274 342 282 375 282 375 274 397 274 397 248 339 248 339 242 308 242 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 302 set {floorItems(302)} $i $w create text 319.5 261 -text 302 -fill $color -anchor c -tags {floor3 label} set i [$w create polygon 70 321 242 321 242 200 259 200 259 203 272 203 272 193 263 180 242 180 175 180 175 169 156 169 156 196 177 196 177 228 107 228 70 228 70 275 107 275 107 248 160 248 160 301 107 301 107 275 70 275 -fill {} -outline {} -tags {floor3 room}] set floorLabels($i) 306 set {floorItems(306)} $i $w create text 200.5 284.5 -text 306 -fill $color -anchor c -tags {floor3 label} $w create line 341 275 341 283 -fill $color -tags {floor3 wall} $w create line 162 197 155 197 -fill $color -tags {floor3 wall} $w create line 396 247 399 247 -fill $color -tags {floor3 wall} $w create line 399 129 399 311 -fill $color -tags {floor3 wall} |
︙ | ︙ |
Changes to library/demos/goldberg.tcl.
︙ | ︙ | |||
73 74 75 76 77 78 79 | array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500} set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5 set S(mode) $::MSTART # Colors for everything set C(fg) black | < > | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | array set speed {1 10 2 20 3 50 4 80 5 100 6 150 7 200 8 300 9 400 10 500} set MSTART 0; set MGO 1; set MPAUSE 2; set MSSTEP 3; set MBSTEP 4; set MDONE 5 set S(mode) $::MSTART # Colors for everything set C(fg) black set C(bg) cornflowerblue set C(0) white; set C(1a) darkgreen; set C(1b) yellow set C(2) red; set C(3a) green; set C(3b) darkblue set C(4) $C(fg); set C(5a) brown; set C(5b) white set C(6) magenta; set C(7) green; set C(8) $C(fg) set C(9) blue4; set C(10a) white; set C(10b) cyan set C(11a) yellow; set C(11b) mediumblue; set C(12) tan2 set C(13a) yellow; set C(13b) red; set C(14) white set C(15a) green; set C(15b) yellow; set C(16) gray65 set C(17) \#A65353; set C(18) $C(fg); set C(19) gray50 set C(20) cyan; set C(21) gray65; set C(22) $C(20) set C(23a) blue; set C(23b) red; set C(23c) yellow set C(24a) red; set C(24b) white; set C(24c) black; set C(26) $C(0); proc DoDisplay {w} { global S C ttk::frame $w.ctrl -relief ridge -borderwidth 2 -padding 5 pack [frame $w.screen -bd 2 -relief raised] \ -side left -fill both -expand 1 |
︙ | ︙ | |||
1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 | 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508 431 441 431 440 400 502 347 465 347 465 } $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \ -width 10 -smooth 1 set msg [subst $S(message)] $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \ -justify center -font {{Times Roman} 18 bold} return 1 } $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold] $w.c move I24 0 -60 $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25 | > | 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 | 494 627 548 613 548 613 480 574 577 473 577 473 474 538 445 508 431 441 431 440 400 502 347 465 347 465 } $w.c create poly $xy -tag I24 -fill $::C(24b) -outline $::C(24a) \ -width 10 -smooth 1 set msg [subst $S(message)] $w.c create text [Centroid $w I24] -text $msg -tag {I24 I24t} \ -fill $::C(24c) \ -justify center -font {{Times Roman} 18 bold} return 1 } $w.c itemconfig I24t -font [list {Times Roman} [expr {18 + 6*$step}] bold] $w.c move I24 0 -60 $w.c scale I24 {*}[Centroid $w I24] 1.25 1.25 |
︙ | ︙ | |||
1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 | proc Move26 {w {step {}}} { global S set step [GetStep 26 $step] if {$step >= 3} { $w.c delete I24 I26 $w.c create text 430 755 -anchor s -tag I26 \ -text "click to continue" -font {{Times Roman} 24 bold} bind $w.c <Button-1> [list Reset $w] return 4 } $w.c scale I24 {*}[Centroid $w I24] .8 .8 $w.c move I24 0 60 | > | 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 | proc Move26 {w {step {}}} { global S set step [GetStep 26 $step] if {$step >= 3} { $w.c delete I24 I26 $w.c create text 430 755 -anchor s -tag I26 \ -fill $::C(26) \ -text "click to continue" -font {{Times Roman} 24 bold} bind $w.c <Button-1> [list Reset $w] return 4 } $w.c scale I24 {*}[Centroid $w I24] .8 .8 $w.c move I24 0 60 |
︙ | ︙ |
Changes to library/demos/image2.tcl.
︙ | ︙ | |||
90 91 92 93 94 95 96 | pack $w.dir.e -side left -fill both -padx 2m -pady 2m -expand true pack $w.dir.b -side left -fill y -padx {0 2m} -pady 2m labelframe $w.f -text "File:" -padx 2m -pady 2m listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set" ttk::scrollbar $w.f.scroll -command "$w.f.list yview" pack $w.f.list $w.f.scroll -side left -fill y -expand 1 | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | pack $w.dir.e -side left -fill both -padx 2m -pady 2m -expand true pack $w.dir.b -side left -fill y -padx {0 2m} -pady 2m labelframe $w.f -text "File:" -padx 2m -pady 2m listbox $w.f.list -width 20 -height 10 -yscrollcommand "$w.f.scroll set" ttk::scrollbar $w.f.scroll -command "$w.f.list yview" pack $w.f.list $w.f.scroll -side left -fill y -expand 1 $w.f.list insert 0 earth.gif earthris.gif teapot.ppm Tcl.svg bind $w.f.list <Double-Button-1> "loadImage $w %x %y" catch {image delete image2a} image create photo image2a labelframe $w.image -text "Image:" label $w.image.image -image image2a pack $w.image.image -padx 2m -pady 2m |
︙ | ︙ |
Added library/demos/images/Tcl.svg.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://web.resource.org/cc/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="124.98526" height="264.6875" id="svg2309" sodipodi:version="0.32" inkscape:version="0.45" sodipodi:modified="true" version="1.0"> <defs id="defs2311" /> <sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" gridtolerance="10000" guidetolerance="10" objecttolerance="10" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.35" inkscape:cx="375" inkscape:cy="520" inkscape:document-units="px" inkscape:current-layer="layer1" inkscape:window-width="910" inkscape:window-height="626" inkscape:window-x="5" inkscape:window-y="49" /> <metadata id="metadata2314"> <rdf:RDF> <cc:Work rdf:about=""> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> </cc:Work> </rdf:RDF> </metadata> <g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" transform="translate(-311.79308,-365.73272)"> <g style="opacity:1;display:inline" id="g2244" transform="translate(308.95998,366.42022)"> <path id="path4426" d="M 445.52492,372.22514 C 445.90652,395.55723 445.21415,418.63757 425.02492,440.56889 L 424.27492,441.41264 L 425.39992,441.41264 L 433.64992,441.53764 C 420.24442,469.42405 411.52244,497.23134 392.24367,525.00639 L 391.55617,526.00639 L 392.74367,525.78764 L 402.93117,523.85014 C 395.71427,542.16045 383.37359,554.28293 369.99367,558.35014 C 366.31107,506.78151 392.04593,461.26308 413.89992,415.88139 C 413.92002,415.83965 413.94233,415.79813 413.96242,415.75639 L 413.14992,415.19389 C 377.36425,455.2074 361.23872,511.6427 355.14992,558.19389 C 343.02146,551.34666 338.97913,542.28079 334.86867,529.94389 L 343.33742,533.50639 L 344.21242,533.88139 L 344.02492,532.94389 C 337.58858,504.32416 347.5814,483.78143 357.27492,456.78764 L 364.24367,461.44389 L 365.05617,462.00639 L 365.02492,461.03764 C 364.47892,439.10645 379.24595,417.08983 398.83742,397.44389 L 401.55617,404.72514 L 401.93117,405.69389 L 402.46242,404.78764 L 408.43117,394.85014 L 408.46242,394.78764 C 418.31429,381.21812 428.72988,376.80082 445.52492,372.22514 z " style="fill:#c3b15f;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline" transform="translate(-324.02492,-364.63139)" /> <path sodipodi:nodetypes="ccccccccccccccccccccccc" id="path7600" d="M 121.54988,7.5808058 C 104.81215,12.147023 94.270242,16.613077 84.4375,30.15625 L 84.40625,30.21875 L 78.4375,40.15625 L 77.90625,41.0625 L 77.53125,40.09375 L 74.8125,32.8125 C 55.22103,52.45844 40.454,74.47506 41,96.40625 L 41.03125,97.375 L 40.21875,96.8125 L 33.25,92.15625 C 23.55648,119.15004 13.56366,139.69277 20,168.3125 L 20.1875,169.25 L 19.3125,168.875 L 10.9375,165.34375 C 10.96447,165.51523 11.003113,165.67421 11.03125,165.84375 C 15.080346,177.9015 19.176955,186.81713 31.125,193.5625 C 31.596616,189.95681 32.122231,186.27456 32.71875,182.5625 C 18.12816,148.39836 30.79293,123.2814 36.5625,100.6875 L 45.4375,105.8125 C 44.211577,84.657017 56.63174,61.842112 72.78125,41.9375 L 77.46875,50.1875 C 89.477498,25.486664 98.97512,15.57175 121.54988,7.5808058 z " style="opacity:1;fill:#eff1cb;fill-opacity:1;fill-rule:evenodd;stroke:#eff1cb;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline" /> <path style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;display:inline" d="M 126.9375,-0.6875 L 126.40625,-0.59375 C 106.72165,2.83976 87.4508,10.07244 79,27.375 L 75.4375,21.15625 L 75.125,20.59375 L 74.65625,21.0625 C 64.96254,30.33838 54.55574,42.35306 46.875,54.15625 C 39.66528,65.23562 34.88327,76.07934 35.40625,84.375 L 30.375,78.09375 L 29.875,77.46875 L 29.53125,78.1875 C 23.40732,91.41649 17.22694,107.69157 13.53125,122.625 C 10.02725,136.78385 8.77244,149.67206 12.03125,157.78125 L 3.75,152.96875 L 3.0625,152.5625 L 3,153.375 C 1.44089,176.99202 11.0382,188.26833 22.0625,199.15625 L 12.875,201.4375 L 11.03125,201.90625 L 12.875,202.40625 C 18.14953,203.83558 23.15023,205.44485 26.625,208.125 C 30.09977,210.80515 32.09598,214.49082 31.5,220.375 L 31.5,220.40625 L 31.5,245.90625 L 31.5,246.0625 L 31.59375,246.1875 L 43.09375,262.6875 L 44,264 L 44,262.40625 L 44,223.53125 C 45.52181,216.98735 47.30807,212.4833 49.875,209.5 C 52.44193,206.5167 55.78211,204.98483 60.5625,204.40625 L 62.28125,204.1875 L 60.71875,203.46875 L 54.65625,200.59375 C 69.11174,191.89001 85.3013,170.55445 89.5625,150.28125 L 89.75,149.46875 L 88.96875,149.6875 L 81.46875,151.71875 C 88.13174,145.46249 94.84392,133.06721 101.21875,118.625 C 107.9798,103.3078 114.29247,85.96032 119.46875,72.09375 L 119.75,71.34375 L 118.96875,71.40625 L 113.1875,71.8125 C 120.3346,64.22669 124.30703,51.6996 126.25,38.46875 C 128.27227,24.69793 128.13035,10.1977 127,-0.15625 L 126.9375,-0.6875 z M 121.5,7.59375 C 121.8816,30.92584 121.18923,54.00618 101,75.9375 L 100.25,76.78125 L 101.375,76.78125 L 109.625,76.90625 C 96.2195,104.79266 87.49752,132.59995 68.21875,160.375 L 67.53125,161.375 L 68.71875,161.15625 L 78.90625,159.21875 C 71.68935,177.52906 59.34867,189.65154 45.96875,193.71875 C 42.28615,142.15012 68.02101,96.63169 89.875,51.25 C 89.8951,51.20826 89.91741,51.16674 89.9375,51.125 L 89.125,50.5625 C 53.33933,90.57601 37.2138,147.01131 31.125,193.5625 C 18.99654,186.71527 14.95421,177.6494 10.84375,165.3125 L 19.3125,168.875 L 20.1875,169.25 L 20,168.3125 C 13.56366,139.69277 23.55648,119.15004 33.25,92.15625 L 40.21875,96.8125 L 41.03125,97.375 L 41,96.40625 C 40.454,74.47506 55.22103,52.45844 74.8125,32.8125 L 77.53125,40.09375 L 77.90625,41.0625 L 78.4375,40.15625 L 84.40625,30.21875 L 84.4375,30.15625 C 94.28937,16.58673 104.70496,12.16943 121.5,7.59375 z " id="path2177" /> </g> </g> </svg> |
Changes to library/demos/images/earth.gif.
cannot compute difference between binary files
Changes to library/demos/mclist.tcl.
︙ | ︙ | |||
17 18 19 20 21 22 23 | positionWindow $w ## Explanatory text ttk::label $w.msg -font $font -wraplength 4i -justify left -anchor n -padding {10 2 10 6} -text "Ttk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which can be configured to display multiple columns of informational data without displaying the tree itself. This is a simple way to build a listbox that has multiple columns. Clicking on the heading for a column will sort the data by that column. You can also change the width of the columns by dragging the boundary between them." pack $w.msg -fill x ## See Code / Dismiss | | > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | positionWindow $w ## Explanatory text ttk::label $w.msg -font $font -wraplength 4i -justify left -anchor n -padding {10 2 10 6} -text "Ttk is the new Tk themed widget set. One of the widgets it includes is a tree widget, which can be configured to display multiple columns of informational data without displaying the tree itself. This is a simple way to build a listbox that has multiple columns. Clicking on the heading for a column will sort the data by that column. You can also change the width of the columns by dragging the boundary between them." pack $w.msg -fill x ## See Code / Dismiss pack [addSeeDismiss $w.seeDismiss $w {} { ttk::checkbutton $w.seeDismiss.cb1 -text Grid -variable mclistGrid -command tglGrid }] -side bottom -fill x ttk::frame $w.container ttk::treeview $w.tree -columns {country capital currency} -show headings \ -yscroll "$w.vsb set" -xscroll "$w.hsb set" ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview" ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview" pack $w.container -fill both -expand 1 |
︙ | ︙ | |||
113 114 115 116 117 118 119 | if {[ttk::style theme use] eq "aqua"} { # Aqua theme displays native sort arrows when user1 state is set $tree heading $col state "user1" } else { $tree heading $col -image [expr {$direction?"upArrow":"downArrow"}] } } | > > > > > > > > > > > > > > > | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | if {[ttk::style theme use] eq "aqua"} { # Aqua theme displays native sort arrows when user1 state is set $tree heading $col state "user1" } else { $tree heading $col -image [expr {$direction?"upArrow":"downArrow"}] } } set mclistGrid 0 proc tglGrid {} { if {$::mclistGrid} { .mclist.tree configure -stripe 1 foreach col [.mclist.tree cget -columns] { .mclist.tree column $col -separator 1 } } else { .mclist.tree configure -stripe 0 foreach col [.mclist.tree cget -columns] { .mclist.tree column $col -separator 0 } } } |
Changes to library/demos/menu.tcl.
︙ | ︙ | |||
14 15 16 17 18 19 20 | toplevel $w wm title $w "Menu Demonstration" wm iconname $w "menu" positionWindow $w label $w.msg -font $font -wraplength 4i -justify left if {[tk windowingsystem] eq "aqua"} { | < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | toplevel $w wm title $w "Menu Demonstration" wm iconname $w "menu" positionWindow $w label $w.msg -font $font -wraplength 4i -justify left if {[tk windowingsystem] eq "aqua"} { $w.msg configure -text "This window has a menubar with cascaded menus. You can invoke entries with an accelerator by typing Command+x, where \"x\" is the character next to the command key symbol. The rightmost menu can be torn off into a palette by selecting the first item in the menu." } else { $w.msg configure -text "This window contains a menubar with cascaded menus. You can post a menu from the keyboard by typing Alt+x, where \"x\" is the character underlined on the menu. You can then traverse among the menus using the arrow keys. When a menu is posted, you can invoke the current entry by typing space, or you can invoke any entry by typing its underlined character. If a menu entry has an accelerator, you can invoke the entry without posting the menu just by typing the accelerator. The rightmost menu can be torn off into a palette by selecting the first item in the menu." } pack $w.msg -side top set menustatus " " |
︙ | ︙ | |||
59 60 61 62 63 64 65 | } elseif {[tk windowingsystem] == "win32"} { set modifier Control } else { set modifier Meta } foreach i {A B C D E F} { $m add command -label "Print letter \"$i\"" -underline 14 \ | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | } elseif {[tk windowingsystem] == "win32"} { set modifier Control } else { set modifier Meta } foreach i {A B C D E F} { $m add command -label "Print letter \"$i\"" -underline 14 \ -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 menu $m -tearoff 0 $m add command -label "Print hello" \ |
︙ | ︙ | |||
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | set m $w.menu.more $w.menu add cascade -label "More" -menu $m -underline 0 menu $m -tearoff 0 foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Does almost nothing also} {Make life meaningful}} { $m add command -label $i -command [list puts "You invoked \"$i\""] } $m entryconfigure "Does almost nothing" -bitmap questhead -compound left \ -command [list \ tk_dialog $w.compound {Compound Menu Entry} \ "The menu entry you invoked displays both a bitmap and a\ text string. Other than this, it is just like any other\ menu entry." {} 0 OK ] $m entryconfigure "Does almost nothing also" -image lilearth -compound left \ -command [list \ tk_dialog $w.compound {Compound Menu Entry} \ "The menu entry you invoked displays both a image and a\ text string. Other than this, it is just like any other\ menu entry." {} 0 OK ] set m $w.menu.colors $w.menu add cascade -label "Colors" -menu $m -underline 1 menu $m -tearoff 1 | > > > > > | > > > > > > > > > > > | | > < < | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | set m $w.menu.more $w.menu add cascade -label "More" -menu $m -underline 0 menu $m -tearoff 0 foreach i {{An entry} {Another entry} {Does nothing} {Does almost nothing} {Does almost nothing also} {Make life meaningful}} { $m add command -label $i -command [list puts "You invoked \"$i\""] } set emojiLabel [encoding convertfrom utf-8 "\xF0\x9F\x98\x8D Make friends"] $m add command -label $emojiLabel -command [list puts "Menu labels can include non-BMP characters."] $m entryconfigure "Does almost nothing" -bitmap questhead -compound left \ -command [list \ tk_dialog $w.compound {Compound Menu Entry} \ "The menu entry you invoked displays both a bitmap and a\ text string. Other than this, it is just like any other\ menu entry." {} 0 OK ] $m entryconfigure "Does almost nothing also" -image lilearth -compound left \ -command [list \ tk_dialog $w.compound {Compound Menu Entry} \ "The menu entry you invoked displays both a image and a\ text string. Other than this, it is just like any other\ menu entry." {} 0 OK ] set m $w.menu.colors $w.menu add cascade -label "Colors" -menu $m -underline 1 menu $m -tearoff 1 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 <<MenuSelect>> { global $menustatus if {[catch {%W entrycget active -label} label]} { set label " " } set menustatus $label update idletasks } |
Changes to library/demos/menubu.tcl.
︙ | ︙ | |||
14 15 16 17 18 19 20 | toplevel $w wm title $w "Menu Button Demonstration" wm iconname $w "menubutton" positionWindow $w frame $w.body pack $w.body -expand 1 -fill both | < | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | toplevel $w wm title $w "Menu Button Demonstration" wm iconname $w "menubutton" positionWindow $w frame $w.body pack $w.body -expand 1 -fill both menubutton $w.body.below -text "Below" -underline 0 -direction below -menu $w.body.below.m -relief raised menu $w.body.below.m -tearoff 0 $w.body.below.m add command -label "Below menu: first item" -command "puts \"You have selected the first item from the Below menu.\"" $w.body.below.m add command -label "Below menu: second item" -command "puts \"You have selected the second item from the Below menu.\"" grid $w.body.below -row 0 -column 1 -sticky n menubutton $w.body.right -text "Right" -underline 0 -direction right -menu $w.body.right.m -relief raised |
︙ | ︙ | |||
82 83 84 85 86 87 88 | } $m configure -tearoff 1 foreach i {Black gray75 gray50 White} { $m entryconfigure $i -columnbreak 1 } pack $body.buttons.colors -side left -padx 25 -pady 25 | < < | 81 82 83 84 85 86 87 | } $m configure -tearoff 1 foreach i {Black gray75 gray50 White} { $m entryconfigure $i -columnbreak 1 } pack $body.buttons.colors -side left -padx 25 -pady 25 |
Changes to library/demos/nl.msg.
1 | ::msgcat::mcset nl "Widget Demonstration" "Demonstratie van widgets" | | < | > | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ::msgcat::mcset nl "Widget Demonstration" "Demonstratie van widgets" ::msgcat::mcset nl "tkWidgetDemo" ::msgcat::mcset nl "&File" "&Bestand" ::msgcat::mcset nl "About..." "Info..." ::msgcat::mcset nl "&About..." "&Info..." ::msgcat::mcset nl "<F1>" "<F1>" ::msgcat::mcset nl "&Quit" "&Einde" ::msgcat::mcset nl "Meta+Q" "Meta+E" ;# Displayed hotkey ::msgcat::mcset nl "Meta-q" "Meta-e" ;# Actual binding sequence ::msgcat::mcset nl "Ctrl+Q" "Ctrl+E" ;# Displayed hotkey ::msgcat::mcset nl "Control-q" "Control-e" ;# Actual binding sequence ::msgcat::mcset nl "See Variables" "Bekijk Variabelen" ::msgcat::mcset nl "Variable values" "Waarden variabelen" ::msgcat::mcset nl "Variable values:" "Waarden variabelen" ::msgcat::mcset nl "OK" ::msgcat::mcset nl "Run the \"%s\" sample program" "Start voorbeeld \"%s\"" ::msgcat::mcset nl "Dismiss" "Sluiten" ::msgcat::mcset nl "Rerun Demo" "Herstart Demo" ;# This is also button text! ::msgcat::mcset nl "Print Code" "Code Afdrukken" ::msgcat::mcset nl "Demo code: %s" "Code van Demo %s" ::msgcat::mcset nl "About Widget Demo" "Over deze demonstratie" ::msgcat::mcset nl "Tk widget demonstration" "Demonstratie van Tk widgets" ::msgcat::mcset nl "Copyright © %s" ::msgcat::mcset nl "Tk Widget Demonstrations" "Demonstratie van Tk widgets" |
︙ | ︙ | |||
32 33 34 35 36 37 38 | ::msgcat::mcset nl "appears, you can click the" \ "Zodra het nieuwe venster verschijnt, kun je op de knop" ::msgcat::mcset nl "See Code" "Bekijk Code" ;# This is also button text! ::msgcat::mcset nl "button to see the Tcl/Tk code that created the demonstration. If" \ "drukken om de achterliggende Tcl/Tk code te zien. Als je dat wilt," ::msgcat::mcset nl "you wish, you can edit the code and click the" \ "kun je de code wijzigen en op de knop" | < < | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | ::msgcat::mcset nl "appears, you can click the" \ "Zodra het nieuwe venster verschijnt, kun je op de knop" ::msgcat::mcset nl "See Code" "Bekijk Code" ;# This is also button text! ::msgcat::mcset nl "button to see the Tcl/Tk code that created the demonstration. If" \ "drukken om de achterliggende Tcl/Tk code te zien. Als je dat wilt," ::msgcat::mcset nl "you wish, you can edit the code and click the" \ "kun je de code wijzigen en op de knop" ::msgcat::mcset nl "button in the code window to reinvoke the demonstration with the" \ "drukken in het codevenster om de demonstratie uit te voeren met de" ::msgcat::mcset nl "modified code." \ "nieuwe code." ::msgcat::mcset nl "Labels, buttons, checkbuttons, and radiobuttons" \ "Labels, knoppen, vinkjes/aankruishokjes en radioknoppen" ::msgcat::mcset nl "Labels (text and bitmaps)" "Labels (tekst en plaatjes)" ::msgcat::mcset nl "Labels and UNICODE text" "Labels en tekst in UNICODE" ::msgcat::mcset nl "Buttons" "Buttons (drukknoppen)" ::msgcat::mcset nl "Check-buttons (select any of a group)" \ "Check-buttons (een of meer uit een groep)" ::msgcat::mcset nl "Radio-buttons (select one of a group)" \ "Radio-buttons (een van een groep)" |
︙ | ︙ | |||
102 103 104 105 106 107 108 | ::msgcat::mcset nl "Scales" "Schaalverdelingen" ::msgcat::mcset nl "Horizontal scale" "Horizontale schaal" ::msgcat::mcset nl "Vertical scale" "Verticale schaal" ::msgcat::mcset nl "Paned Windows" "Vensters opgedeeld in stukken" ::msgcat::mcset nl "Horizontal paned window" "Horizontaal gedeeld venster" ::msgcat::mcset nl "Vertical paned window" "Verticaal gedeeld venster" | < < | > > > > > > > > > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | ::msgcat::mcset nl "Scales" "Schaalverdelingen" ::msgcat::mcset nl "Horizontal scale" "Horizontale schaal" ::msgcat::mcset nl "Vertical scale" "Verticale schaal" ::msgcat::mcset nl "Paned Windows" "Vensters opgedeeld in stukken" ::msgcat::mcset nl "Horizontal paned window" "Horizontaal gedeeld venster" ::msgcat::mcset nl "Vertical paned window" "Verticaal gedeeld venster" ::msgcat::mcset nl "Menus" "Menu's" ::msgcat::mcset nl "Menus and cascades (sub-menus)" \ "Menu's en cascades (submenu's)" ::msgcat::mcset nl "Menu-buttons" "Menu-buttons" ::msgcat::mcset nl "Common Dialogs" "Veel voorkomende dialoogvensters" ::msgcat::mcset nl "Message boxes" "Mededeling (message box)" ::msgcat::mcset nl "File selection dialog" "Selectie van bestanden" ::msgcat::mcset nl "Color picker" "Kleurenpalet" ::msgcat::mcset nl "Font selection dialog" "Selectie van fonts" ::msgcat::mcset nl "System tray icon and notification" "Systeemvakpictogram en melding" ::msgcat::mcset nl "Printing from canvas and text widgets" "Afdrukken van canvas en tekst widgets" ::msgcat::mcset nl "Animation" "Animaties" ::msgcat::mcset nl "Animated labels" "Geanimeerde labels" ::msgcat::mcset nl "Animated wave" "Geanimeerde golf" ::msgcat::mcset nl "Pendulum simulation" "Pendulum simulatie" ::msgcat::mcset nl "A celebration of Rube Goldberg" "Een viering van Rube Goldberg" ::msgcat::mcset nl "Miscellaneous" "Diversen" ::msgcat::mcset nl "The built-in bitmaps" "Ingebouwde plaatjes" ::msgcat::mcset nl "A dialog box with a local grab" \ "Een dialoogvenster met een locale \"grab\"" ::msgcat::mcset nl "A dialog box with a global grab" \ "Een dialoogvenster met een globale \"grab\"" ::msgcat::mcset nl "Window icons and badges" "Vensterpictogrammen en badges" |
Changes to library/demos/pendulum.tcl.
︙ | ︙ | |||
90 91 92 93 94 95 96 | # Update the phase-space graph according to the current angle and the # rate at which the angle is changing (the first derivative with # respect to time.) proc showPhase {canvas} { global Theta dTheta points psw psh lappend points [expr {$Theta+$psw}] [expr {-20*$dTheta+$psh}] if {[llength $points] > 100} { | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | # Update the phase-space graph according to the current angle and the # rate at which the angle is changing (the first derivative with # respect to time.) proc showPhase {canvas} { global Theta dTheta points psw psh lappend points [expr {$Theta+$psw}] [expr {-20*$dTheta+$psh}] if {[llength $points] > 100} { set points [lrange $points end-99 end] } for {set i 0} {$i<100} {incr i 10} { set list [lrange $points end-[expr {$i-1}] end-[expr {$i-12}]] if {[llength $list] >= 4} { $canvas coords graph$i $list } } |
︙ | ︙ |
Added library/demos/print.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | # print.tcl -- # # This demonstration script showcases the tk print commands. # if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." } set w .print destroy $w toplevel $w wm title $w "Printing Demonstration" positionWindow $w image create photo logo -data {R0lGODlhMABLAPUAAP//////zP//mf//AP/MzP/Mmf/MAP+Zmf+ZZv+ZAMz//8zM/8zMzMyZzMyZmcyZZsyZAMxmZsxmM8xmAMwzM8wzAJnMzJmZzJmZmZlmmZlmZplmM5kzZpkzM5kzAGaZzGZmzGZmmWYzZmYzMzNmzDNmmTMzmTMzZgAzmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+BSAtZGwtACH5BAEKAAIALAAAAAAwAEsAAAb+QIFwSCwahY9HRMI8Op/JJVNSqVqv2OvjyRU8slbIJGwYg60S5ZR6jRi/4ITBOhkYIOd8dltEnAdmFQMJeoVXCEd/VnKGjRVOZ3NVgHlsjpBxVRCEYBIEAAARl4lgZmVgEQAKFx8Mo0ZnpqgAFyi2JqKGmGebWRIAILbCIo27cYFWASTCtievRXqSVwQfzLYeeYESxlnSVRIW1igjWHJmjBXbpKXeFQTizlh1eJNVHbYf0LGc39XW2PIoVZE0whasWPSqFBBHrkKEA3QG0DFTEMXBUsjCWesg4oMFAGwgtKsiwqA+jGiCiRPGAM6pLCVLGKHQ6EGJlc0IuDxzAgX+CCOW9DjAaUsEyAoT+GHpeSRoHgxEUWgAUEUpFhMWgTbKEPUBAU15TBZxekYD0RMEqCDLIpYIWTAcmGEd9rWQBxQyjeQqdK/ZTWEO3mK5l+9No75SrcHhm9WwnlzNoA5zdM+JHz0HCPQdUauZowoFnSw+c2CBvw6dUXT4LMKE6EIHUqMexgCiIREknOwl7Q+FhNQoLuzOc6Kw3kIIVOLqjYKBYCwinmgo9CBEswfMAziK7mRDoQhcUZxwoBKFibq3n3jXI0GyCPLC0DrS8GR1oaEoRBRYVhT99/qG4DcCA/yNU4Ajbjhhnx4P2DJggR3YZog6RyyYxwM9PSgMBaP+sQdgIRL0JAKBwnTooRMAFWLdiPyJ8JwvTnyQoh5midCASh149ZkTIFAmHnzOZOBfIU6U4Mhd4zF34DNEoDAhARGY50BvJkioyxFOGkKAShGkFsJwejiR5Xf8aZAaBp89coQJjuDXAQOApekEm45ANaAtIbyYxREf0OlICCK841uaahZBQjyfjXCACYjuaASjhFagRKSFNtloHg+hYWIxRohnBQWCSSAhBVZ+hkgRnlbxwJIVgIqGlaU6wkeTxHxjm6gVLImrFbHWVEQ1taZjWxJX7KqqnqgUEUxDwtqajrOaRkqhEDcxWwECbEjxTYe9gojqOJQ6JO231ob72bSqAjh4RgfsjiDCCfDCK8K8I9TL7r33nvGtCO7CO1dUAONk3LcBFxzwwEMwZ/DC4iAsRIE+CWNCbzeV8FfEtoDwVwnlacxMkcKQYIE/F5TQ2QcedUZCagyc3NsFGrXVZMipWVBCzKv4Q0JvCviDsjAwf4ylxBeX0KcwGs81ccgqGS3MBxc3RjDDVAvdBRcfeFy1MFd3bcQHJEQdlddkP5E1Cf9yXfbaV2d9RBAAOw== } pack [label $w.l -text "This demonstration showcases the tk print command. Clicking the buttons below print the data from the canvas and text widgets using platform-native dialogs."] -side top pack [frame $w.m] -fill both -expand yes -side top set c [canvas $w.m.c -bg white] pack $c -fill both -expand no -side left $c create rectangle 30 10 200 50 -fill blue -outline black $c create oval 30 60 200 110 -fill green $c create image 130 150 -image logo $c create text 150 250 -anchor n -font {Helvetica 12} \ -text "A short demo of simple canvas elements." set txt { Tcl, or Tool Command Language, is an open-source multi-purpose C library which includes a powerful dynamic scripting language. Together they provide ideal cross-platform development environment for any programming project. It has served for decades as an essential system component in organizations ranging from NASA to Cisco Systems, is a must-know language in the fields of EDA, and powers companies such as FlightAware and F5 Networks. Tcl is fit for both the smallest and largest programming tasks, obviating the need to decide whether it is overkill for a given job or whether a system written in Tcl will scale up as needed. Wherever a shell script might be used Tcl is a better choice, and entire web ecosystems and mission-critical control and testing systems have also been written in Tcl. Tcl excels in all these roles due to the minimal syntax of the language, the unique programming paradigm exposed at the script level, and the careful engineering that has gone into the design of the Tcl internals. } set t [text $w.m.t -wrap word] pack $t -side right -fill both -expand no $t insert end $txt pack [frame $w.f] -side top -fill both -expand no pack [button $w.f.b -text "Print Canvas" -command [list tk print $w.m.c]] -expand no pack [button $w.f.x -text "Print Text" -command [list tk print $w.m.t]] -expand no ## See Code / Dismiss buttons pack [addSeeDismiss $w.buttons $w] -side bottom -fill x |
Changes to library/demos/puzzle.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # puzzle.tcl -- # # This demonstration script creates a 15-puzzle game using a collection # of buttons. if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." } package require Tk # puzzleSwitch -- # This procedure is invoked when the user clicks on a particular button; | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # puzzle.tcl -- # # This demonstration script creates a 15-puzzle game using a collection # of buttons. if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." } package require Tk # puzzleSwitch -- # This procedure is invoked when the user clicks on a particular button; # if the button is next to the empty space, it moves the button into the # empty space. proc puzzleSwitch {w num} { global xpos ypos if {(($ypos($num) >= ($ypos(space) - .01)) && ($ypos($num) <= ($ypos(space) + .01)) && ($xpos($num) >= ($xpos(space) - .26)) |
︙ | ︙ |
Changes to library/demos/spin.tcl.
︙ | ︙ | |||
34 35 36 37 38 39 40 | set australianCities { Canberra Sydney Melbourne Perth Adelaide Brisbane Hobart Darwin "Alice Springs" } spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | set australianCities { Canberra Sydney Melbourne Perth Adelaide Brisbane Hobart Darwin "Alice Springs" } spinbox $w.s1 -from 1 -to 10 -width 10 -validate key \ -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 #entry $w.e3 pack $w.s1 $w.s2 $w.s3 -side top -pady 5 -padx 10 ;#-fill x |
︙ | ︙ |
Changes to library/demos/square.
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/sh # the next line restarts using wish \ exec wish "$0" ${1+"$@"} # square -- # This script generates a demo application containing only a "square" # widget. It's only usable in the "tktest" application or if Tk has # been compiled with tkSquare.c. This demo arranges the following # bindings for the widget: # # Button-1 press/drag: moves square to mouse # "a": toggle size animation on/off | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #!/bin/sh # the next line restarts using wish \ exec wish "$0" ${1+"$@"} # square -- # This script generates a demo application containing only a "square" # widget. It's only usable in the "tktest" application or if Tk has # been compiled with tkSquare.c. This demo arranges the following # 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 tk::test ;# ... we use the square widget too. square .s pack .s -expand yes -fill both wm minsize . 1 1 bind .s <Button-1> {center %x %y} bind .s <B1-Motion> {center %x %y} |
︙ | ︙ |
Added library/demos/systray.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 |
Changes to library/demos/tclIndex.
︙ | ︙ | |||
61 62 63 64 65 66 67 | 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]] | > > > | 61 62 63 64 65 66 67 68 69 70 | 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]] set auto_index(windoicons [list source -encoding utf-8 [file join $dir windowicons.tcl]] |
Changes to library/demos/widget.
︙ | ︙ | |||
362 363 364 365 366 367 368 | @@demo floor A building floor plan @@demo cscroll A simple scrollable canvas @@demo knightstour A Knight's tour of the chess board @@subtitle Scales and Progress Bars @@demo hscale Horizontal scale @@demo vscale Vertical scale | < > > > > > > | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | @@demo floor A building floor plan @@demo cscroll A simple scrollable canvas @@demo knightstour A Knight's tour of the chess board @@subtitle Scales and Progress Bars @@demo hscale Horizontal scale @@demo vscale Vertical scale @@demo ttkscale Themed scale linked to a label with traces @@demo ttkprogress Progress bar @@subtitle Paned Windows and Notebooks @@demo paned1 Horizontal paned window @@demo paned2 Vertical paned window @@demo ttkpane Themed nested panes @@demo ttknote Notebook widget @@subtitle Menus and Toolbars @@demo menu Menus and cascades (sub-menus) @@demo menubu Menu-buttons @@demo ttkmenu Themed menu buttons @@demo toolbar Themed toolbar @@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 @@new @@demo print Printing from canvas and text widgets @@subtitle Animation @@demo anilabel Animated labels @@demo aniwave Animated wave @@demo pendulum Pendulum simulation @@demo goldberg A celebration of Rube Goldberg @@subtitle Miscellaneous @@demo bitmap The built-in bitmaps @@demo dialog1 A dialog box with a local grab @@demo dialog2 A dialog box with a global grab @@new @@demo windowicons Window icons and badges } ############################################################################## .t configure -state disabled focus .s |
︙ | ︙ | |||
620 621 622 623 624 625 626 | } else { wm deiconify $top 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]] | | < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | > | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 | } else { wm deiconify $top 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 } # printCode -- # Prints the source code currently displayed in the See Code dialog. Much # thanks to Arjen Markus for this. # # Arguments: # w - Name of text widget containing code to print # file - Name of the original file (implicitly for title) proc printCode {w file} { tk print $w } # tkAboutDialog -- # # 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 © %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}] [mc "Copyright © %s" {2021 Kevin Walzer}]" } # Local Variables: # mode: tcl # End: |
Added library/demos/windowicons.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | # windowicons.tcl -- # # This demonstration script showcases the wm iconphoto and wm iconbadge commands. # if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo." } set w .windowicons destroy $w toplevel $w wm title $w "Window Icon Demonstration" positionWindow $w image create photo icon -data { iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGP C/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3Cc ulE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAArQNAAK0DQEdFIm+AAAJ QElEQVRYw+WXW2xdV5nHf/ty7lcf2/FxYsdOnMSNC0HTpDiRKJWAQjWCEQNU SEAFfUOiQqrEC2+IxwpemDLSzNBBCCQeQEKqRJgBSikiuGlN22TqhsR27OPL 8eWc43Pdt7X22osHHydOm4FBPM6Slr69paX9/32Xtb614f/7MP6vC3O5f8L3 G7HJyZPHBwfz5wrF7HQ6nRwxLTOhQuU4PW+z3eq9Xa+33rq9cms7k8pHjvfS 3w8wOfk52u1u8oHpiUff897JJ8+dO/nI6LHho6OjQ3ahkMYwTTZ2O2zXutS3 G/7ayubq7Vtr/7Ve2f7RytLam4ViXq1t/vRvB0ilPsjzz3+LZ5/9j7MzM5Nf /8hj5//5H97/YNbK5hkfTFLMxAEQQvD766v0yBGIEBEEuPUGi9dv7lx77cb3 Vm9vfqc0WNi9evUKWr/xLh3rfuLj45+l0bjM7m768U98/OJ/fulLH/3wiemx eCafxRcKw7TJxKC+12RpbYdAx7HsOCrSRNpg+sQQj1w8nS0N5h8JAvm+rWr9 9ZmZB2qWdZq9vWt/GWBm5im+9rUn6HRGPv7EE4/++2P/eOFkV0FkJTDQgCaX TbO1tcV2R2EmCxBJQixs2+R9EwV00MFAceJE2ZiZOT7VaTsPLyxU5orFTK1c fphq9bX7A8zOfoV8Ps3c3NsXPvWpD37vc5//0ETNt8gNjDAzlsdAE0vliTCR xEhnC2CaRIZNMmZiaonv9mh1PcrDJQZzCfK5OGNjQ8e2tvZO37y5+ctk0naq 1fn7A4yOnmd5uVp4/PGHn/vylz8xe+zoEIP5JAMpA0OHeK6DG4TEk2li8Tha QxRpIg0q6DGUNjg6UuLYSInhYoYoigiCgHQ6TrGYnlpd3Q1ffvk3L128+ITe 2Hj1XoBLl55menqcbDb1haeeevyrDz102tJaE7ctLBMqG1X23Ag7kcKOJzAA DSilCVWEZdmMDaXJJCxSiRimaaK1RkqJ7/uUSlk6Hed0oxG9HI9bm+Pjs2xs vIp5AKC15oUX/lA8f/7MF2dnz8YADMNASslypYqrUxSHyqSy+f31hzaRZRpM DKVYr+7y4usVri1WWavWCWSIZZkYhoFSIRcuTI1MTAw9OTf33Tu7zz54SCRi nD17/Pzs7AMPFQqZPlTE8vo2DlmGhgbo12BffD/8SmukitiuNxHKoDwyzPJG nTdXmtiWwdnRNCN5GxWGDA/nOH26/NGpqSfHgPU7AJcuPc0nP/kBrl698YGZ mYmMEIJmx6Hn+my0DUZGC6gIzEOnhu4Lh2GEbRocGyxRSO/7c3QgiRuEVOtd EvEQrSN8IVEq5MSJ4YlSKX3OMKJ14G4KnnnmM9bkZPk92VyKy3M3eentJjd3 FUYyjxuEeELt7/NoP+eBVAipCFXEsYE4xcydYFIeSHKynOXhUwM0mh32egH1 tsdL16oo007kcskHs7kYly49fRcALqby+fQopklkZ4jHY3g6gQgjHF/QcgQd V+7DHJoGmnzSQuvD0QGlIsJQkU4luLXR4kgxxcRgjM1mQCyZHrv0sUe4JwKF XMmu7/VSXV9xaXqI0YzC8328QOJ4gq4raHQDGt2AtitwfIEbSAwibOvdJ7pS CiElR3IxGh2X5Y0GV66v0wnAsq3MN5759L1FqKMoCkQoX19u0QkkD47lKSYi Th1NoSLYafu0ehrTNNBaE2mNUop2z+DEUJKBbPxecSEIgoAoUjwwmmZpdZPl muL4oIFWkbx8rXIvQMfZ9p2e1xBCstOJcFe6nB1NcWokhW1ZHMkazK90qXXD fZFII0NFIBW/XQiZHraoNbsU81mmjhbxfZ8gCAiCgELKQitJGCoIQ6SQO//2 ze/fm4Kf/Px50dzr3Aoch1Ap2o4kn8tgW/sHynAxzcVTBQYzFp4v6boBjidw fcFCpcmPf7/Oz+ZrvPBalb12D9/370DUGk1evr6NacWIfD/yveDmXq3F3Nxz dwH+5dkfUq8155rb9dA2QcqQcjFx57DRGgaySR47d4RHZ0pYeh/C9QSOJ3EE CGWw3fJZ323j+x6e5xH4Pgu3d6g0FMWUjdvu7bo9/5oK1d0IzM09hwhCGrvN ubXFylI2pum4AZXtDqEURFGE1hoNxGMW5ZyB22nS8wQ9r1+QvsDzBc1uQGW7 jee6eN4+RMfxMdHkYgatWmtur9ZaOnD8TgQMA27c+uH68s3KT8O9BoYBv3pj kxuVGo7Tw+1/MAh83lreYm1P9r3fT4XjSVxf4voC1/NwHAfXdXFcB891KGVj hO2e16q3fzR2cjQwDPPeZrSx8SqXL2/RqDU2EnH7I8dPjQ8v7Tqs1RwmSzEs QoQQSBHw1lKVha0AEUb4IiQQIb4I8YUkkCHTQwa5WIjne9xY2mT+VouRfI7N xfVfrK8sfTuRSAavXP3Xd7fjavWPRq1+3TeiQTVcGnh0oHwktlZzmBq0SNsR QgiuXLvNL/+nQU/aBFL1xSW+kAghEb5PEkE5q3Bdl7dv72LGCrTXdzf+9Nb8 N5dXfrG6Wf1jeNDP3nkjigOFWm2xpvx0+tjI8LnMYMnMxQT5eIjruVye36LS TRAqRSD3vZdCIqUgEj5R4CEDj2O5kMZei3rHoLXV6Sy88cp3Fhf/ew6IAAGE 9wOIARmtw9Tu7vKa1yY+Wiqeee+ZYdsi4HdvrjK/HiKUiZQhoZREQhDJAC18 tPSIhEfouwSuQ9cx2VxpNK/PX/n+4uKvXwQdAAHgA/J+AAaQABJRJOydnVsr zZ1O13eMcSuezC61LJzQRgY+KvCJhI+WPpH0IAywIkEhaVIupAhdHS0t3F66 Nv/iD9bW/nAFtAM4QA9wAXX3RnEvQBoYODSL+fzEmalTsx+emjl3YWjsaMlM pcwg0ggZEimFoSNsI8JSCtF1wtpmdWt1aeGVSuW133leYwNoA01gr297BzVw v/8CA0gBBaDYtzkw87ns6PhI+czM0JHjp/PFUjmZSmUM07RCKUPP6XVae/Vq fbdys1ZbvOX5ja2+ULcP0Opbt18H/G8Ah+shDWQPzVQ/RSnLTGRsO5U0TMuM VKjC0PUjLd1+fgPAOxTybl9YcvdC9VcBDobV3x0JINm3MfYbmdX/hu57FfZF Dgot6Fe8eqfw3wLwzvVmX9jsvx8AHEAcnn91/BlySEFKTpuCtgAAABN0RVh0 QXV0aG9yAHdhcnN6YXdpYW5rYQy+S5cAAABYdEVYdENvcHlyaWdodABDQzAg UHVibGljIERvbWFpbiBEZWRpY2F0aW9uIGh0dHA6Ly9jcmVhdGl2ZWNvbW1v bnMub3JnL3B1YmxpY2RvbWFpbi96ZXJvLzEuMC/G4735AAAAIXRFWHRDcmVh dGlvbiBUaW1lADIwMTAtMDMtMjlUMDg6MDg6MzD47LxwAAAAJXRFWHRkYXRl OmNyZWF0ZQAyMDIxLTA4LTE1VDIwOjU0OjM5LTA0OjAwNBT3DQAAACV0RVh0 ZGF0ZTptb2RpZnkAMjAyMS0wOC0xNVQyMDo1NDoxMS0wNDowMDSDBqsAAADI elRYdERlc2NyaXB0aW9uAAAY042OwQqCQBCGn6B3GOy+Cl0qTAjEc1HRJVhW HXUrd2pmLXr7tDrVpcMP838w/F+wxxxyprsgB2ALclAxtRAbaBirRdB4f5mH oTeuJlUxYoly8nRRxHW4HahO30SvmI5Y+CCBF4dPhzg0CYwOLs45GdKfG+sK hBuy2H4xUlM1i76+BhcBwwirLj/bAlJqjXXzP9UyxmuHzp8feiknLPW6Q/H9 moy3yK1oqvROUE2yH99suX45PwEyf2MTOoCNrQAAABl0RVh0U29mdHdhcmUA d3d3Lmlua3NjYXBlLm9yZ5vuPBoAAABWdEVYdFNvdXJjZQBodHRwczovL29w ZW5jbGlwYXJ0Lm9yZy9kZXRhaWwvMzUyMzMvdGFuZ28taW5ldHJuZXQtd2Vi LWJyb3dzZXItYnktd2Fyc3phd2lhbmth5nAuRgAAACB0RVh0VGl0bGUAdGF uZ28gaW5ldHJuZXQgd2ViIGJyb3dzZXLyr62TAAAAAElFTkSuQmCC } set ::tk::icons::base_icon(.) icon pack [button $w.i -text "Set Window Icon to Globe" -image $::tk::icons::base_icon(.) \ -compound top -command {wm iconphoto . $::tk::icons::base_icon(.) }] pack [button $w.b -text "Set Badge to 3" -command {wm iconbadge . 3}] pack [button $w.e -text "Set Badge to 11" -command {wm iconbadge . 11}] pack [button $w.f -text "Reset Badge" -command {wm iconbadge . ""}] ## See Code / Dismiss buttons pack [addSeeDismiss $w.buttons $w] -side bottom -fill x |
Changes to library/entry.tcl.
︙ | ︙ | |||
115 116 117 118 119 120 121 | tk::CancelRepeat } bind Entry <Control-Button-1> { %W icursor @%x } bind Entry <<PrevChar>> { | | | | | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | tk::CancelRepeat } bind Entry <Control-Button-1> { %W icursor @%x } bind Entry <<PrevChar>> { tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert] } bind Entry <<NextChar>> { tk::EntrySetCursor %W [tk::EntryNextChar %W insert] } bind Entry <<SelectPrevChar>> { tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert] tk::EntrySeeInsert %W } bind Entry <<SelectNextChar>> { tk::EntryKeySelect %W [tk::EntryNextChar %W insert] tk::EntrySeeInsert %W } bind Entry <<PrevWord>> { tk::EntrySetCursor %W [tk::EntryPreviousWord %W insert] } bind Entry <<NextWord>> { tk::EntrySetCursor %W [tk::EntryNextWord %W insert] |
︙ | ︙ | |||
161 162 163 164 165 166 167 | tk::EntrySeeInsert %W } bind Entry <Delete> { if {[%W selection present]} { %W delete sel.first sel.last } else { | | > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | tk::EntrySeeInsert %W } bind Entry <Delete> { if {[%W selection present]} { %W delete sel.first sel.last } else { %W delete [tk::startOfCluster [%W get] [%W index insert]] \ [tk::endOfCluster [%W get] [%W index insert]] } } bind Entry <BackSpace> { tk::EntryBackspace %W } bind Entry <Control-space> { |
︙ | ︙ | |||
191 192 193 194 195 196 197 | %W selection clear } bind Entry <Key> { tk::CancelRepeat tk::EntryInsert %W %A } | | < | < > | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | %W selection clear } bind Entry <Key> { tk::CancelRepeat tk::EntryInsert %W %A } # Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the # <Key> class binding will also fire and insert the character, # which is wrong. Ditto for Escape, Return, and Tab. bind Entry <Alt-Key> {# nothing} bind Entry <Meta-Key> {# nothing} bind Entry <Control-Key> {# nothing} bind Entry <Escape> {# nothing} bind Entry <Return> {# nothing} bind Entry <KP_Enter> {# nothing} bind Entry <Tab> {# nothing} bind Entry <Prior> {# nothing} bind Entry <Next> {# nothing} bind Entry <Command-Key> {# nothing} bind Entry <Fn-Key> {# nothing} # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind Entry <<NextLine>> {# nothing} bind Entry <<PrevLine>> {# nothing} # On Windows, paste is done using Shift-Insert. Shift-Insert already # generates the <<Paste>> event, so we don't need to do anything here. if {[tk windowingsystem] ne "win32"} { |
︙ | ︙ | |||
274 275 276 277 278 279 280 | # Bindings for IME text input and accents. bind Entry <<TkStartIMEMarkedText>> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <<TkEndIMEMarkedText>> { | | < < < < > > > > > > > > > > > > > > > > > | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | # Bindings for IME text input and accents. bind Entry <<TkStartIMEMarkedText>> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <<TkEndIMEMarkedText>> { ::tk::EntryEndIMEMarkedText %W } bind Entry <<TkClearIMEMarkedText>> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] } bind Entry <<TkAccentBackspace>> { tk::EntryBackspace %W } # ::tk::EntryEndIMEMarkedText -- # Handles input method text marking in an entry # # Arguments: # w - The entry window. proc ::tk::EntryEndIMEMarkedText {w} { variable Priv if {[catch { set mark [dict get $Priv(IMETextMark) $w] }]} { bell return } $w selection range $mark insert } # A few additional bindings of my own. bind Entry <Button-2> { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } |
︙ | ︙ | |||
373 374 375 376 377 378 379 | } else { $w selection clear } } } word { if {$cur < $anchor} { | | | | | | | | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | } else { $w selection clear } } } word { if {$cur < $anchor} { set before [tk::wordBreakBefore [$w get] $cur] set after [tk::wordBreakAfter [$w get] $anchor-1] } elseif {$cur > $anchor} { set before [tk::wordBreakBefore [$w get] $anchor] set after [tk::wordBreakAfter [$w get] $cur-1] } else { if {[$w index @$Priv(pressX)] < $anchor} { incr anchor -1 } set before [tk::wordBreakBefore [$w get] $anchor] set after [tk::wordBreakAfter [$w get] $anchor] } if {$before < 0} { set before 0 } if {$after < 0} { set after end } |
︙ | ︙ | |||
501 502 503 504 505 506 507 | # Arguments: # w - The entry window in which to backspace. proc ::tk::EntryBackspace w { if {[$w selection present]} { $w delete sel.first sel.last } else { | | | | > | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | # Arguments: # w - The entry window in which to backspace. 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 [tk::startOfCluster [$w get] $x] \ [tk::endOfCluster [$w get] $x] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] set left [lindex $range 0] set right [lindex $range 1] $w xview moveto [expr {$left - ($right - $left)/2.0}] } |
︙ | ︙ | |||
561 562 563 564 565 566 567 | set i [$w index insert] if {$i < [$w index end]} { incr i } if {$i < 2} { return } | | | | | | > > > > > > > > > > > > > > > > > | 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | set i [$w index insert] if {$i < [$w index end]} { incr i } if {$i < 2} { return } set first $i-2 set data [$w get] set new [string index $data $i-1][string index $data $first] $w delete $first $i $w insert insert $new EntrySeeInsert $w } # ::tk::EntryNextWord -- # Returns the index of the next word position after a given position in the # entry. The next word is platform dependent and may be either the next # end-of-word position or the next start-of-word position after the next # end-of-word position. # # Arguments: # w - The entry window in which the cursor is to move. # start - Position at which to start search. if {[tk windowingsystem] eq "win32"} { proc ::tk::EntryNextWord {w start} { set pos [tk::endOfWord [$w get] [$w index $start]] if {$pos >= 0} { set pos [tk::startOfNextWord [$w get] $pos] } if {$pos < 0} { return end } return $pos } } else { proc ::tk::EntryNextWord {w start} { set pos [tk::endOfWord [$w get] [$w index $start]] if {$pos < 0} { return end } return $pos } } # ::tk::EntryPreviousWord -- # # Returns the index of the previous word position before a given # position in the entry. # # Arguments: # w - The entry window in which the cursor is to move. # start - Position at which to start search. proc ::tk::EntryPreviousWord {w start} { set pos [tk::startOfPreviousWord [$w get] [$w index $start]] if {$pos < 0} { return 0 } return $pos } proc ::tk::EntryNextChar {w start} { set pos [tk::endOfCluster [$w get] [$w index $start]] if {$pos < 0} { return end } return $pos } proc ::tk::EntryPreviousChar {w start} { set pos [tk::startOfCluster [$w get] [expr {[$w index $start]-1}]] if {$pos < 0} { return 0 } return $pos } # ::tk::EntryScanMark -- # # Marks the start of a possible scan drag operation # # Arguments: # w - The entry window from which the text to get |
︙ | ︙ |
Changes to library/fontchooser.tcl.
1 2 3 4 | # fontchooser.tcl - # # A themeable Tk font selection dialog. See TIP #324. # | | | | | | | | < < | > > > > > > > > > > > > > > > > > > > > > | < < < < < | | > > > > > > > | > | > | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | # fontchooser.tcl - # # A themeable Tk font selection dialog. See TIP #324. # # Copyright © 2008 Keith Vetter # Copyright © 2008 Pat Thoyts <[email protected]> # # 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 { variable S set S(W) .__tk__fontchooser set S(fonts) [lsort -dictionary -unique [font families]] set S(styles) [list \ [::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 set S(-parent) . set S(-title) {} set S(-command) "" set S(-font) TkDefaultFont set S(bad) [list ] } proc ::tk::fontchooser::Canonical {} { variable S foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style] } set S(sizes,lcase) $S(sizes) set S(sampletext) [::msgcat::mc "AaBbYyZz01"] # 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] } set S(styles,lcase) {} foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style] } } proc ::tk::fontchooser::Setup {} { variable S Canonical ::ttk::style layout FontchooserFrame { Entry.field -sticky news -border true -children { FontchooserFrame.padding -sticky news } } bind [winfo class .] <<ThemeChanged>> \ [list +ttk::style layout FontchooserFrame \ [ttk::style layout FontchooserFrame]] namespace ensemble create -map { show ::tk::fontchooser::Show hide ::tk::fontchooser::Hide configure ::tk::fontchooser::Configure } } ::tk::fontchooser::Setup proc ::tk::fontchooser::Show {} { variable S Canonical if {![winfo exists $S(W)]} { Create wm transient $S(W) [winfo toplevel $S(-parent)] tk::PlaceWindow $S(W) widget $S(-parent) if {[string trim $S(-title)] eq ""} { wm title $S(W) [::msgcat::mc "Font"] } else { wm title $S(W) $S(-title) } } set S(fonts) [lsort -dictionary -unique [font families]] set S(fonts,lcase) {} foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font] } wm deiconify $S(W) } proc ::tk::fontchooser::Hide {} { variable S wm withdraw $S(W) } |
︙ | ︙ | |||
87 88 89 90 91 92 93 | } if {[llength $args] == 0} { set result {} foreach spec $specs { foreach {name xx yy default} $spec break lappend result $name \ | | | | | < | | | < < | | > | | > > > > > > > > > | > > | | | | | | | | | | | | | | | | | | | | | | > > | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | } if {[llength $args] == 0} { set result {} foreach spec $specs { foreach {name xx yy default} $spec break lappend result $name \ [expr {[info exists S($name)] ? $S($name) : $default}] } lappend result -visible \ [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}] return $result } if {[llength $args] == 1} { set option [lindex $args 0] if {[string equal $option "-visible"]} { return [expr {[winfo exists $S(W)] && [winfo ismapped $S(W)]}] } elseif {[info exists S($option)]} { return $S($option) } return -code error -errorcode [list TK LOOKUP OPTION $option] \ "bad option \"$option\": must be\ -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 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 {[winfo exists $S(W)]} { if {{-font} in $args} { Init $S(-font) event generate $S(-parent) <<TkFontchooserFontChanged>> } if {[string trim $S(-title)] eq {}} { wm title $S(W) [::msgcat::mc Font] } else { wm title $S(W) $S(-title) } $S(W).ok configure -state $S(nstate) $S(W).apply configure -state $S(nstate) } return $r } proc ::tk::fontchooser::Create {} { variable S set windowName __tk__fontchooser if {$S(-parent) eq "."} { set S(W) .$windowName } else { set S(W) $S(-parent).$windowName } # Now build the dialog if {![winfo exists $S(W)]} { toplevel $S(W) -class TkFontDialog 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:"] -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) \ -width 3 -validate key -validatecommand {regexp -- {^-*[0-9]*$} %P} ttk_slistbox $S(W).lfonts -height 7 -exportselection 0 \ -selectmode browse -activestyle none \ -listvariable [namespace which -variable S](fonts) ttk_slistbox $S(W).lstyles -width 5 -height 7 -exportselection 0 \ -selectmode browse -activestyle none \ -listvariable [namespace which -variable S](styles) ttk_slistbox $S(W).lsizes -width 4 -height 7 -exportselection 0 \ -selectmode browse -activestyle none \ -listvariable [namespace which -variable S](sizes) set WE $S(W).effects ::ttk::labelframe $WE -text [::msgcat::mc "Effects"] ::tk::AmpWidget ::ttk::checkbutton $WE.strike \ -variable [namespace which -variable S](strike) \ -text [::msgcat::mc "Stri&keout"] \ -command [namespace code [list Click strike]] ::tk::AmpWidget ::ttk::checkbutton $WE.under \ -variable [namespace which -variable S](under) \ -text [::msgcat::mc "&Underline"] \ -command [namespace code [list Click under]] set bbox [::ttk::frame $S(W).bbox] ::ttk::button $S(W).ok -text [::msgcat::mc OK] -default active\ -command [namespace code [list Done 1]] ::ttk::button $S(W).cancel -text [::msgcat::mc Cancel] \ -command [namespace code [list Done 0]] ::tk::AmpWidget ::ttk::button $S(W).apply -text [::msgcat::mc "&Apply"] \ -command [namespace code [list Apply]] wm protocol $S(W) WM_DELETE_WINDOW [namespace code [list Done 0]] # Calculate minimum sizes ttk::scrollbar $S(W).tmpvs set scroll_width [winfo reqwidth $S(W).tmpvs] destroy $S(W).tmpvs set minsize(gap) 10 set minsize(bbox) [winfo reqwidth $S(W).ok] set minsize(fonts) \ [expr {[font measure TkDefaultFont "Helvetica"] + $scroll_width}] 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 } wm minsize $S(W) $min 260 bind $S(W) <Return> [namespace code [list Done 1]] bind $S(W) <Escape> [namespace code [list Done 0]] bind $S(W) <Map> [namespace code [list Visibility %W 1]] bind $S(W) <Unmap> [namespace code [list Visibility %W 0]] bind $S(W) <Destroy> [namespace code [list Visibility %W 0]] |
︙ | ︙ | |||
220 221 222 223 224 225 226 | bind $S(W).apply <<AltUnderlined>> [namespace code [list Apply]] bind $WE.strike <<AltUnderlined>> [list $WE.strike invoke] bind $WE.under <<AltUnderlined>> [list $WE.under invoke] set WS $S(W).sample ::ttk::labelframe $WS -text [::msgcat::mc "Sample"] ::ttk::label $WS.sample -relief sunken -anchor center \ | | < | < > | | | > > > > > | | < > > > | | > > | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 | bind $S(W).apply <<AltUnderlined>> [namespace code [list Apply]] bind $WE.strike <<AltUnderlined>> [list $WE.strike invoke] bind $WE.under <<AltUnderlined>> [list $WE.under invoke] set WS $S(W).sample ::ttk::labelframe $WS -text [::msgcat::mc "Sample"] ::ttk::label $WS.sample -relief sunken -anchor center \ -textvariable [namespace which -variable S](sampletext) set S(sample) $WS.sample grid $WS.sample -sticky news -padx 6 -pady 4 grid rowconfigure $WS 0 -weight 1 grid columnconfigure $WS 0 -weight 1 grid propagate $WS 0 grid $S(W).ok -in $bbox -sticky new -pady {0 2} grid $S(W).cancel -in $bbox -sticky new -pady 2 grid $S(W).apply -in $bbox -sticky new -pady 2 grid columnconfigure $bbox 0 -weight 1 grid $WE.strike -sticky w -padx 10 grid $WE.under -sticky w -padx 10 -pady {0 30} grid columnconfigure $WE 1 -weight 1 grid $S(W).font x $S(W).style x $S(W).size x -in $outer -sticky w grid $S(W).efont x $S(W).estyle x $S(W).esize x $bbox -in $outer -sticky ew grid $S(W).lfonts x $S(W).lstyles x $S(W).lsizes x ^ -in $outer -sticky news grid $WE x $WS - - x ^ -in $outer -sticky news -pady {15 30} grid configure $bbox -sticky n grid rowconfigure $outer 2 -weight 1 grid columnconfigure $outer {1 3 5} -minsize $minsize(gap) grid columnconfigure $outer {0 2 4} -weight 1 grid columnconfigure $outer 0 -minsize $minsize(fonts) grid columnconfigure $outer 2 -minsize $minsize(styles) grid columnconfigure $outer 4 -minsize $minsize(sizes) grid columnconfigure $outer 6 -minsize $minsize(bbox) grid $outer -sticky news grid rowconfigure $S(W) 0 -weight 1 grid columnconfigure $S(W) 0 -weight 1 Init $S(-font) trace add variable [namespace which -variable S](size) \ write [namespace code [list Tracer]] trace add variable [namespace which -variable S](style) \ write [namespace code [list Tracer]] trace add variable [namespace which -variable S](font) \ write [namespace code [list Tracer]] trace add variable [namespace which -variable S](strike) \ write [namespace code [list Tracer]] trace add variable [namespace which -variable S](under) \ write [namespace code [list Tracer]] } Init $S(-font) return } # ::tk::fontchooser::Done -- # # Handles teardown of the dialog, calling -command if needed # # Arguments: # ok true if user pressed OK # proc ::tk::fontchooser::Done {ok} { variable S if {! $ok} { set S(result) "" } trace vdelete S(size) w [namespace code [list Tracer]] trace vdelete S(style) w [namespace code [list Tracer]] trace vdelete S(font) w [namespace code [list Tracer]] trace vdelete S(strike) w [namespace code [list Tracer]] trace vdelete S(under) w [namespace code [list Tracer]] destroy $S(W) if {$ok} { if {$S(-command) ne ""} { uplevel #0 $S(-command) [list $S(result)] } event generate $S(-parent) <<TkFontchooserFontChanged>> } } # ::tk::fontchooser::Apply -- # # Call the -command procedure appending the current font # Errors are reported via the background error mechanism |
︙ | ︙ | |||
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | # Arguments: # defaultFont font to use as the default # proc ::tk::fontchooser::Init {{defaultFont ""}} { variable S if {$S(first) || $defaultFont ne ""} { if {$defaultFont eq ""} { set defaultFont [[entry .___e] cget -font] destroy .___e } 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) | > > < < < < < < < | | < | < | | | | | | | > > > > | < < | > | | > | > > | | > | > > | > > > | > | > > | > > | > > | > > | > | > > | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | # Arguments: # defaultFont font to use as the default # proc ::tk::fontchooser::Init {{defaultFont ""}} { variable S if {$S(first) || $defaultFont ne ""} { Canonical if {$defaultFont eq ""} { set defaultFont [[entry .___e] cget -font] destroy .___e } array set F [font actual $defaultFont] set S(font) $F(-family) set S(style) [::msgcat::mc "Regular"] set S(size) $F(-size) set S(strike) $F(-overstrike) set S(under) $F(-underline) if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} { set S(style) [::msgcat::mc "Bold Italic"] } elseif {$F(-weight) eq "bold"} { set S(style) [::msgcat::mc "Bold"] } elseif {$F(-slant) eq "italic"} { set S(style) [::msgcat::mc "Italic"] } set S(first) 0 } } # ::tk::fontchooser::Click -- # # Handles all button clicks, updating the appropriate widgets # # Arguments: # who which widget got pressed # proc ::tk::fontchooser::Click {who} { variable S if {$who eq "font"} { set S(font) [$S(W).lfonts get [$S(W).lfonts curselection]] } elseif {$who eq "style"} { set S(style) [$S(W).lstyles get [$S(W).lstyles curselection]] } elseif {$who eq "size"} { set S(size) [$S(W).lsizes get [$S(W).lsizes curselection]] } } # ::tk::fontchooser::Tracer -- # # Handles traces on key variables, updating the appropriate widgets # # Arguments: # standard trace arguments (not used) # proc ::tk::fontchooser::Tracer {var1 var2 op} { variable S # We don't need to process strike and under if {$var2 ni [list strike under]} { # Make selection in listbox set value [string tolower $S($var2)] $S(W).l${var2}s selection clear 0 end set n [lsearch -exact $S(${var2}s,lcase) $value] $S(W).l${var2}s selection set $n if {$n >= 0} { set S($var2) [lindex $S(${var2}s) $n] $S(W).e$var2 icursor end $S(W).e$var2 selection clear if {[set i [lsearch $S(bad) $var2]] >= 0} { set S(bad) [lreplace $S(bad) $i $i] } } else { # No match, try prefix set n [lsearch -glob $S(${var2}s,lcase) "$value*"] if {$var2 ne "size" || !([regexp -- {^(-[0-9]+|[0-9]+)$} $value] && $value >= -4096 && $value <= 4096)} { if {[lsearch $S(bad) $var2] < 0} { lappend S(bad) $var2 } } else { if {[set i [lsearch $S(bad) $var2]] >= 0} { set S(bad) [lreplace $S(bad) $i $i] } } } $S(W).l${var2}s see $n } if {[llength $S(bad)] == 0} { set S(nstate) normal Update } else { set S(nstate) disabled } $S(W).ok configure -state $S(nstate) $S(W).apply configure -state $S(nstate) } # ::tk::fontchooser::Update -- # # Shows a sample of the currently selected font # proc ::tk::fontchooser::Update {} { variable S set S(result) [list $S(font) $S(size)] 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) set S(-font) $S(result) } # ::tk::fontchooser::Visibility -- # # Notify the parent when the dialog visibility changes # proc ::tk::fontchooser::Visibility {w visible} { variable S if {$w eq $S(W)} { event generate $S(-parent) <<TkFontchooserVisibility>> } } # ::tk::fontchooser::ttk_slistbox -- # # Create a properly themed scrolled listbox. # This is exactly right on XP but may need adjusting on other platforms. # proc ::tk::fontchooser::ttk_slistbox {w args} { set f [ttk::frame $w -style FontchooserFrame -padding 2] if {[catch { |
︙ | ︙ |
Added library/iconbadges.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | # iconbadges.tcl -- # # Notification badges for Tk applications. # # # Copyright © 2021 Kevin Walzer/WordTech Communications LLC namespace eval ::tk::icons {} image create photo ::tk::icons::1-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA kFBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/HBz/V1f/Rkb/BQX/Dw//oKD/////y8v/Bgb/Pz//ra3/+/v/ zMz/Li7/5ub/+vr/8fH/Ly//uLj/Zmb/n5//Bwf/Dg7/kpL/YWH/rq7/h4f/Cgr/ AQH/AgLXmjE+AAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRBib aYUeAAAAnElEQVQY022Q5w6DMBCD78hi03RQuvegg77/25ULCakq/MenT4piGwAQ A8aFlIKzABGAiAojbRSFihhinOheSdwyVKn+UaoQsry7x5PpjDzPgBWGlPNqUdJR MODky9V6U20N0hwE2W5/ODokQJKdzperQ7JDt7uuPRL299o/5P+IuxA9akO4qI/n 622jukLNp3GFBmoPjOMnHNkJv3kDExXHctm+AAAAJXRFWHRkYXRlOmNyZWF0ZQAy MDIxLTA4LTEwVDA4OjM1OjE0LTA0OjAw0aX6GwAAACV0RVh0ZGF0ZTptb2RpZnkA MjAyMS0wOC0xMFQwODozNToxNC0wNDowMKD4QqcAAAAASUVORK5CYII= } image create photo ::tk::icons::2-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA 21BMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/Cwv/ODj/UlL/UFD/MjL/CAj/ExP/oKD/8fH//v7//f3/7u7/ kJD/DAz/ZWX/9fX/jIz/lpb/+vr/9/f/TEz/TU3/m5v/iYn/Ly//6+v/////YmL/ nJz/5OT/MDD/KSn/srL/7Oz/ZGT/AQH/Nzf/zs7/zc3/SUn/AgL/ICD/ysr/7e3/ gYH/VVX/WVn/Kir/fX3/eXn/AwP/dnb/rKz/qan/q6vjChO4AAAAEXRSTlMAAA5V q9/4NK/0St3cDa7z4Pnet34AAAABYktHRCy63XGrAAAAwElEQVQY021Q1xLCMAxz uktpS9hQoOwZ9t57/P8XUSesB/RinXz2SQIAQiRZUTVNVWSJEABUdMOkHKaho0ZI yKIfWKFAI3qY/iCsE7AdZNFYPJFMIXNskN1gpjNZL5cv+AF1ZVBwVfRK5Uq1Vkeu gIqj0Wz57Q7rIldBe/1N91h/gER7S8ORN55MhcQP6WzOFssVFYf8/XrDtrv94Sje cxMnxnEWJtDq5Xq7B3gkhFUeaCUwFYH+xP5TzrfCyKvCJ3EzGUFH/1QDAAAAJXRF WHRkYXRlOmNyZWF0ZQAyMDIxLTA4LTEwVDA4OjM1OjE0LTA0OjAw0aX6GwAAACV0 RVh0ZGF0ZTptb2RpZnkAMjAyMS0wOC0xMFQwODozNToxNC0wNDowMKD4QqcAAAAA SUVORK5CYII= } image create photo ::tk::icons::3-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA +VBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/CQn/NTX/UlL/Tk7/Kir/BAT/ERH/mZn/8PD/+Pj/+vr/5ub/ cHD/AgL/Vlb/9PT/5eX/X1//nZ3/////29v/HR3/Fhb/QED/RET/Cwv/f3//1dX/ Ghr/Bwf/mpr/9vb/+fn/b2//lZX/2tr//Pz/wsL/Jyf/Dg7/Bgb/MzP/c3P/XV3/ wMD/qqr/ExP/KSn/4+P/bm7/Q0P/6ur/vb3/x8f/19f/KCj/SEj/qan/zc3/y8v/ oKD/ODj/BQX/DQ3/AwON+4wDAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34A AAABYktHRCXDAckPAAAAx0lEQVQY021Q1RLCQBDbo4qW4l7ssOLu7g7//zH07oo8 kJfNZGczyQIAQhaOF0RR4DkLQgBEkWSrSmGVJaIhZLOrH9hthoYkh/oDh4TA6SLM 4/X5A0HCXE7gFGOGwpFoLJ7QDKpwwJNVMpXOZHEuTzgPAhmFYkkv40qVcAFEZlur N5otysS3pLc73V6fSfRQ8wyGozges0NqP5nO5oslXjF7GmK96W53eH9gIWhU7Xg6 X643M6pZ6D54PN+F/tT+85zvC93mC1+z9hl5VNGhJwAAACV0RVh0ZGF0ZTpjcmVh dGUAMjAyMS0wOC0xMFQwODozNToxNC0wNDowMNGl+hsAAAAldEVYdGRhdGU6bW9k aWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTQtMDQ6MDCg+EKnAAAAAElFTkSuQmCC } image create photo ::tk::icons::4-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA 1VBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/AgL/OTn/W1v/ODj/QED/4uL/////oaH/AQH/KSn/zs7/oqL/ Fhb/tbX/9PT/1NT/Cgr/l5f//Pz/h4f/fHz/dXX/+/v/trb/HBz/fX3/qKj/DAz/ EBD/ysr/4eH/zc3/5eX/8fH/lJT/BAT/Dw//uLj/5+f/5ub/8vL/+vr/paX/BQX/ HR3/JCT/ISH/iYn/sLD/Ghr/Tk7/rq7/a2vT0ZXAAAAAEXRSTlMAAA5Vq9/4NK/0 St3cDa7z4Pnet34AAAABYktHRBibaYUeAAAAvklEQVQY022QVRPCMBCEL1RSg5Ji Ibi7W9Hi//8n0aRBHtiXvflm7mZvAQChmKJquq6pSgwhAE6wYRIh08CcIWTZ5CPb ChnCDvmRgxHEE9HspdIZ7ok4KG6EsjmaZ6G7CqgRKRQpLXFEVNAEKVeqNYk00LnV G81WWyJdINbp9voDOhxFiC+OJ3Q6m9PFciUW+fn1xt/6O7o/HMV5HsI7BcH5Qq83 JkK8o5L74ymjfh5iHpMP/Xn7TznfCpOywhdM6Ra8aC+AYwAAACV0RVh0ZGF0ZTpj cmVhdGUAMjAyMS0wOC0xMFQwODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6 bW9kaWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC } image create photo ::tk::icons::5-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA 7VBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/ICD/MjL/Li7/CQn/Bgb/q6v/8/P/8vL/9PT/4uL/FRX/0tL/ ////wsL/xcX/uLj/Jib/Kyv/6ur/8fH/aGj/XV3/SUn/Fhb/AQH/+Pj//Pz/7Oz/ +fn/l5f/Dg7/ODj/qan/sLD/W1v/fn7/9/f/+vr/WVn/EBD/Ghr/2dn/gID/X1// oKD/EhL/5OT/Y2P/S0v/7e3/vb3/ycn/yMj/HR3/AwP/Skr/zc3/LCz/BQX/DAz/ AgKLBoLHAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRB5yCiAr AAAAyUlEQVQY021Q1RLDMAxzVhp1XcbYMXXMzIz//zmLk9HD9GKdzvZJAgBCbJKs qKoiSzZCAFDR7A7K4bBrqBHidNEPXE6mEc1Nf+DWCOgeZD4/QyDImEcHyWAzFI5E I7F4gFFDAhmXEkkzmUpnsshlUHDk8oViqVyxkCug4ihXa/VGtNlCrgqp3en2+oPh SEj80AqO6WRqzsQhfz/PLJa5lbkW77mJzba225uHozDBrZ7Oncu+eaXC6ivQrXV/ vAP9if2nnG+F3leFT2jDGOnV8F/uAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTA4 LTEwVDA4OjM1OjE1LTA0OjAwd9LxrwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0w OC0xMFQwODozNToxNS0wNDowMAaPSRMAAAAASUVORK5CYII= } image create photo ::tk::icons::6-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA 9lBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/AQH/ICD/S0v/UlL/NDT/CAj/WVn/2dn/+Pj/+fn/8PD/jY3/ Cgr/LCz/4OD//f3/hob/cHD/5eX/1NT/NTX/bGz/////39//T0//Bwf/j4//5ub/ wcH/7+//4uL/f3//CQn/lpb/+/v/n5//iIj/8vL/9/f/UVH/hYX/3t7/Hx//vb3/ VVX/6Oj/MzP/ExP/x8f/e3v/EhL/t7f/0tL/wMD/MTH/IiL/xsb/zc3/qKj/QkL/ AgL/Cwv/Dg7/BQWiS7IgAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAAB YktHRCi9sLWyAAAAyklEQVQY021Q1RLCQBDbowalBYq7y+FWirs7/P/PwPawB/Ky mezsThIAIMTC8YIoCjxnIQQAFclq00zYrBJqhMh27QO7/NSIpGg/UCQCqgOZ2+P1 +QPIHCpwTlSCoXAkGos/qZMDHleJZCqdyebyyHkQcBRoMeEvecrIBRBxVGi1Vm80 W8hFJrWp3jG6vT6TzMMBHY4CY2qwQ/P9RJ/O5gu6ZO9NE6s13Wz14o6ZYFb3scPx dHYzq69Al+vt/g70J/afcr4Vul4VPgDLCRmO3FuJegAAACV0RVh0ZGF0ZTpjcmVh dGUAMjAyMS0wOC0xMFQwODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6bW9k aWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC } image create photo ::tk::icons::7-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA xlBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/Hh7/Njb/NTX/Ghr/i4v/9/f/8/P/8vL/8fH/9PT/eHj/fHz/ 3Nz/2Nj/19f/6Oj/////+Pj/YGD/DQ3/Fxf/FRX/IiL/trb/j4//CQn/Zmb/+/v/ xsb/GBj/HR3/0tL//f3/Xl7/ZGT/1dX/BAT/p6f/n5//AQH/Fhb/09P/c3P/GRn/ mZn/qqr/PT3/AgKXVg1iAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAAB YktHRCJdZVysAAAAu0lEQVQY022Q1xKCMBBFN5LQixFR7Bp77wU7//9TJgTFB+7L njmTydxdAECooGCiqgQrBYQAhNF0gyYxdE04hEyL/mKZ3CHNpn+xNQSOy6Hkl3n8 gKPrgOLxWamGYa3eaHL0FMDieavd6fZYfyAYAxFjOBpPpmw2F0xATf9dLFfrBNSv 2mx3e5oqIuHAjoEkIr+npzO7RFJhWYJeb+wuDS+RVKWP5+stFa8qF4riOFsoZ+2c 42QnLKYn/ADYChWCRPB9rQAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0xMFQw ODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDgtMTBU MDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC } image create photo ::tk::icons::8-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA 6lBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/Bwf/MjL/UVH/TU3/Kir/BAT/DAz/j4//7e3/+Pj/5+f/eXn/ BQX/Skr/9/f/7+//Z2f/fn7/+/v/6ur/MDD/UFD/4uL/Jib/QUH/9PT/NTX/EhL/ srL/////09P/2tr/m5v/CAj/ycn//f3/y8v/1dX/s7P/GBj/hYX/HR3/Zmb/0dH/ LCz/5eX/dHT/S0v/wsL/NDT/V1f/sLD/zc3/ysr/paX/RUX/AQH/Bgb/Dg7/DQ3m iTf5AAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRC8j1CARAAAA yklEQVQY021Q1RLCQBDbowZFSpEWh+J+xd3d/v936N5hD+QlmezsTrIAQIhLECVZ lkTBRQgAOorbozN43Ap6hKhe/QOv6nhE8ek/8CkE/AFUoXAkapioAn4QNIdj8UQy mUpnHKkJIOIom7PyhWKpjFoECalSrNbqDauJWgIZqdWmdod2e6hlbhn9wXBExxNu scUptWfhFJ3zRXY+TheT5Yqu+XkWYmMNtkNa3fEQLGpmfziezpcrj/oqdLs/zHeh P7X/POf7wuDrhU+46hlBGTVCQgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0x MFQwODozNToxNS0wNDowMHfS8a8AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDgt MTBUMDg6MzU6MTUtMDQ6MDAGj0kTAAAAAElFTkSuQmCC } image create photo ::tk::icons::9-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA 8FBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/DAz/OTn/U1P/R0f/HBz/AQH/Fhb/oqL/8/P/+fn/+Pj/1NT/ S0v/cXH/////29v/W1v/mJj/0ND/AgL/paX/np7/Ly//7e3//Pz/lZX/vr7/GBj/ VVX/9fX/c3P/QED/5ub//f3/19f/4OD/+/v/eXn/Pz//mZn/oaH/dXX/6Oj/Z2f/ Kir/cHD/enr/FRX/TU3/8PD/Ojr/Ozv/2tr/nJz/CAj/Tk7/sbH/z8//wcH/Bgb/ Dw//CgoJOUsyAAAAEXRSTlMAAA5Vq9/4NK/0St3cDa7z4Pnet34AAAABYktHRCCz az2AAAAAy0lEQVQY022Q1RLCQAxFs9QovlAozuLu7u72/39D0y3yQB6SO2cmmXsD AITYBFGSZUkUbIQAIFHsKjVLtSvICHE46aecDoMRxUV/yqUQcHtQ+QNaMKSj8rhB 8BozHInG4okkIq8AIs4US2eyLBdCLYJk9HyBFWmpXNEQSSDjqLJavdFkLdQyR+1O t9cfsCFHuEj10XgynbE5XzTPL5ar9Sa+3fHzpon9rFI7sOOJmzCt5s+X6221tqxa ge6Pp/4O9Cf2n+d8X+izXvgCm5cZM7QQ1AwAAAAldEVYdGRhdGU6Y3JlYXRlADIw MjEtMDgtMTBUMDg6MzU6MTUtMDQ6MDB30vGvAAAAJXRFWHRkYXRlOm1vZGlmeQAy MDIxLTA4LTEwVDA4OjM1OjE1LTA0OjAwBo9JEwAAAABJRU5ErkJggg== } image create photo ::tk::icons::9plus-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAB OFBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/ERH/AAD/NDT/AQH/AAD/AAD/Cgr/Nzf/U1P/SUn/Hx//AQH/mJj/8fH/+fn/ 2dn/VFT/BAT/YmL//f3/4uL/YGD/j4//IyP/GBj/xsb/xcX/Fxf/lZX/////rKz/ JSX/5eX/3t7/3Nz/AgL/hob/yMj/Hh7/Skr/fn7/MTH/srL/vr7/9fX/NDT/NTX/ 39///v7/3d3/+vr/g4P/RET/9PT/+/v/8/P/R0f/OTn/lpb/pKT/c3P/4eH/dHT/ Dw//Pz//VVX/5ub/ExP/JCT/bW3/fX3/Ghr/QUH/Rkb/Gxv/wsL/1dX/p6f/DAz/ e3v/enr/Dg7/ra3/zs7/w8P/gYH/GRn/Bgb/CwuphzIHAAAAFHRSTlMAAA5Vq9/4 NK/0St3cDa7z8/Ou4A5hHfoAAAABYktHRCy63XGrAAAA+ElEQVQY02NgYGBkZGJm YWVjY2VhZmJkZGAAibBzcIqAAScHO0iMkZGLWwQOuLmAYozsPCJIgIedkYGXT1RM XEJSCibGx8vAzC8tIysrJw/kKUhKKogIMDOwKCopq6gqyamJiKhraGqJiLAwsGrr 6Erp6euoABUZGEoqGLEysBnrmJiayeiYW1haWVtbWdqwMbDZ2tnLOTjqODm7uNrb u7q5szGwinh4enn76Pj6+QcE6gf4B7EysASHhIaFu1lHiIhEGhiGgYxnFvSxj4rW iYkVEfGLi08AOYJXKCIxKTklFcmpQA+lJaRLIXsIi7exBA4iCIWhQQgAiNMk9J5+ e/MAAAAldEVYdGRhdGU6Y3JlYXRlADIwMjEtMDgtMTBUMDg6MzU6MTYtMDQ6MDBG OusyAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIxLTA4LTEwVDA4OjM1OjE2LTA0OjAw N2dTjgAAAABJRU5ErkJggg== } image create photo ::tk::icons::!-badge -data { iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAMAAABhEH5lAAAABGdBTUEAALGPC/xh BQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAA olBMVEUAAAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/ AAD/AAD/AAD/AAD/Fhb/QED/Pj7/ExP/VVX/9PT/8PD/SUn/WFj//v7/+fn/S0v/ SEj/PDz/MjL/6Oj/Jyf/ICD/4+P/2Nj/Fxf/Dw//qKj/nZ3/Cgr/IyP/hIT/gYH/ Hh7/PT3/Ly//paX/oqL/KCj/AgL///8V6AjgAAAAEXRSTlMAAA5Vq9/4NK/0St3c Da7z4Pnet34AAAABYktHRDXettlrAAAAoElEQVQY022QxxKCQBBEZ9hERkygophz lv//NmF3Bz0wp1dd1V3dAwCIDuNCSsGZgwjQKMr1Un2eqxoN0Q/S9gK/1lCF6d+F CiGKNfYHw5GGOAKWaBpn+URDwoAbw3RWzA1xEAYWRVYaEiANLPPV2pAkabPd7Umy xsPxdCajjb9cb3eKtyXq+AeVsFWfr/eHqtKgqmoHdczueM7vhT37wi9PRRMHXNeq aAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wOC0xMFQwODozNToxNi0wNDowMEY6 6zIAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDgtMTBUMDg6MzU6MTYtMDQ6MDA3 Z1OOAAAAAElFTkSuQmCC } if {[tk windowingsystem] eq "x11"} { # ::tk::icons::IconBadge -- # This procedure creates an icon with an overlay badge on systems that # do not have a native icon/badge API. # # Arguments: # win - window name # badgenumber - badge number to draw over the window icon proc ::tk::icons::IconBadge {win badgenumber} { variable ::tk::icons::base_icon if {![info exists ::tk::icons::base_icon]} { return -code error "::tk::icons::base_icon($win) must be set on X11" } if {![info exists ::tk::icons::base_icon($win)]} { return -code error "::tk::icons::base_icon($win) must be set on X11" } if {[lsearch -exact [image names] $::tk::icons::base_icon($win)] <= 0} { return -code error "can't use \"$::tk::icons::base_icon($win)\" as iconphoto: not a photo image" } if {!([string is integer $badgenumber] && $badgenumber > 0) && [string match $badgenumber "!"] == 0 && $badgenumber ne ""} { return -code error "can't use \"$badgenumber\" as icon badge" } wm iconphoto $win $::tk::icons::base_icon($win) if {$badgenumber eq ""} { return } image create photo overlay switch -glob -- $badgenumber { ! { set badge ::tk::icons::!-badge } [1-9] { set badge ::tk::icons::$badgenumber-badge } default { set badge ::tk::icons::9plus-badge } } overlay copy $::tk::icons::base_icon($win) overlay copy $badge -from 0 0 18 18 -to 18 0 wm iconphoto $win overlay } } |
Changes to library/iconlist.tcl.
︙ | ︙ | |||
22 23 24 25 26 27 28 | # <path> see <index> # <path> selection anchor ?<int>? # <path> selection clear <first> ?<last>? # <path> selection get # <path> selection includes <item> # <path> selection set <first> ?<last>? | | | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | # <path> see <index> # <path> selection anchor ?<int>? # <path> selection clear <first> ?<last>? # <path> selection get # <path> selection includes <item> # <path> selection set <first> ?<last>? 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 constructor args { next {*}$args |
︙ | ︙ | |||
334 335 336 337 338 339 340 | foreach sublist $list { set usedColumn 1 lassign $sublist iTag tTag rTag iW iH tW tH set i_dy [expr {($dy - $iH)/2}] set t_dy [expr {($dy - $tH)/2}] | | | | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | foreach sublist $list { set usedColumn 1 lassign $sublist iTag tTag rTag iW iH tW tH set i_dy [expr {($dy - $iH)/2}] set t_dy [expr {($dy - $tH)/2}] $canvas coords $iTag $x [expr {$y + $i_dy}] $canvas coords $tTag [expr {$x + $shift}] [expr {$y + $t_dy}] $canvas coords $rTag $x $y [expr {$x+$dx}] [expr {$y+$dy}] incr y $dy if {($y + $dy) > $H} { set y [expr {$pad * 1}] ; # *1 ? incr x $dx set usedColumn 0 |
︙ | ︙ | |||
452 453 454 455 456 457 458 | bind $canvas <<PrevLine>> [namespace code {my UpDown -1}] bind $canvas <<NextLine>> [namespace code {my UpDown 1}] bind $canvas <<PrevChar>> [namespace code {my LeftRight -1}] bind $canvas <<NextChar>> [namespace code {my LeftRight 1}] bind $canvas <Return> [namespace code {my ReturnKey}] bind $canvas <Key> [namespace code {my KeyPress %A}] | > > | > | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | bind $canvas <<PrevLine>> [namespace code {my UpDown -1}] bind $canvas <<NextLine>> [namespace code {my UpDown 1}] bind $canvas <<PrevChar>> [namespace code {my LeftRight -1}] bind $canvas <<NextChar>> [namespace code {my LeftRight 1}] bind $canvas <Return> [namespace code {my ReturnKey}] bind $canvas <Key> [namespace code {my KeyPress %A}] bind $canvas <Alt-Key> {# nothing} bind $canvas <Meta-Key> {# nothing} bind $canvas <Control-Key> {# nothing} bind $canvas <Command-Key> {# nothing} bind $canvas <Fn-Key> {# nothing} bind $canvas <FocusIn> [namespace code {my FocusIn}] bind $canvas <FocusOut> [namespace code {my FocusOut}] return $w } |
︙ | ︙ |
Changes to library/icons.tcl.
1 2 3 4 5 6 | # icons.tcl -- # # A set of stock icons for use in Tk dialogs. The icons used here # were provided by the Tango Desktop project which provides a # unified set of high quality icons licensed under the # Creative Commons Attribution Share-Alike license | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # icons.tcl -- # # A set of stock icons for use in Tk dialogs. The icons used here # were provided by the Tango Desktop project which provides a # unified set of high quality icons licensed under the # Creative Commons Attribution Share-Alike license # (https://creativecommons.org/licenses/by-sa/3.0/) # # See http://tango.freedesktop.org/Tango_Desktop_Project # # Copyright © 2009 Pat Thoyts <[email protected]> namespace eval ::tk::icons {} |
︙ | ︙ |
Changes to library/listbox.tcl.
1 2 3 4 5 6 7 | # listbox.tcl -- # # This file defines the default bindings for Tk listbox widgets # and provides procedures that help in implementing those bindings. # # Copyright © 1994 The Regents of the University of California. # Copyright © 1994-1995 Sun Microsystems, Inc. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # listbox.tcl -- # # This file defines the default bindings for Tk listbox widgets # and provides procedures that help in implementing those bindings. # # 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. #-------------------------------------------------------------------------- # tk::Priv elements used in this file: # |
︙ | ︙ | |||
173 174 175 176 177 178 179 | %W scan mark %x %y } bind Listbox <B2-Motion> { %W scan dragto %x %y } bind Listbox <MouseWheel> { | | | | | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | %W scan mark %x %y } bind Listbox <B2-Motion> { %W scan dragto %x %y } bind Listbox <MouseWheel> { tk::MouseWheel %W y %D -40.0 } bind Listbox <Option-MouseWheel> { tk::MouseWheel %W y %D -12.0 } bind Listbox <Shift-MouseWheel> { tk::MouseWheel %W x %D -40.0 } bind Listbox <Shift-Option-MouseWheel> { tk::MouseWheel %W x %D -12.0 } # ::tk::ListboxBeginSelect -- # # This procedure is typically invoked on button-1 presses. It begins # the process of making a selection in the listbox. Its exact behavior # depends on the selection mode currently in effect for the listbox; |
︙ | ︙ | |||
244 245 246 247 248 249 250 | $w selection clear 0 end $w selection set $el set Priv(listboxPrev) $el tk::FireListboxSelectEvent $w } extended { set i $Priv(listboxPrev) | | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | $w selection clear 0 end $w selection set $el set Priv(listboxPrev) $el tk::FireListboxSelectEvent $w } extended { set i $Priv(listboxPrev) if {$i < 0} { set i $el $w selection set $el } if {[$w selection includes anchor]} { $w selection clear $i $el $w selection set anchor $el } else { |
︙ | ︙ | |||
454 455 456 457 458 459 460 | proc ::tk::ListboxCancel w { variable ::tk::Priv if {[$w cget -selectmode] ne "extended"} { return } set first [$w index anchor] set last $Priv(listboxPrev) | | | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | proc ::tk::ListboxCancel w { variable ::tk::Priv if {[$w cget -selectmode] ne "extended"} { return } set first [$w index anchor] set last $Priv(listboxPrev) if {$last < 0} { # Not actually doing any selection right now return } if {$first > $last} { set tmp $first set first $last set last $tmp |
︙ | ︙ |
Changes to library/megawidget.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 | # megawidget.tcl # # 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 © 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. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # megawidget.tcl # # 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 © 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 ::oo::class create ::tk::Megawidget { superclass ::oo::class method unknown {w args} { if {[string match .* $w]} { [self] create $w {*}$args return $w |
︙ | ︙ |
Changes to library/menu.tcl.
1 2 3 4 5 6 7 8 | # menu.tcl -- # # 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 © 1992-1994 The Regents of the University of California. # Copyright © 1994-1997 Sun Microsystems, Inc. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # menu.tcl -- # # 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 © 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 <[email protected]> # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # #------------------------------------------------------------------------- |
︙ | ︙ | |||
265 266 267 268 269 270 271 | "can't post $menu: it isn't a descendant of $w" } set cur $Priv(postedMb) if {$cur ne ""} { MenuUnpost {} } if {$::tk_strictMotif} { | | | | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | "can't post $menu: it isn't a descendant of $w" } set cur $Priv(postedMb) if {$cur ne ""} { MenuUnpost {} } if {$::tk_strictMotif} { set Priv(cursor) [$w cget -cursor] $w configure -cursor arrow } if {[tk windowingsystem] ne "aqua"} { set Priv(relief) [$w cget -relief] $w configure -relief raised } else { $w configure -state active } set Priv(postedMb) $w set Priv(focus) [focus] $menu activate {} GenerateMenuSelect $menu update idletasks if {[catch {PostMenubuttonMenu $w $menu $x $y} msg opt]} { # Error posting menu (e.g. bogus -postcommand). Unpost it and # reflect the error. MenuUnpost {} return -options $opt $msg } set Priv(tearoff) $tearoff |
︙ | ︙ | |||
339 340 341 342 343 344 345 | catch { if {$mb ne ""} { set menu [$mb cget -menu] $menu unpost set Priv(postedMb) {} if {$::tk_strictMotif} { | | | | | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | catch { if {$mb ne ""} { set menu [$mb cget -menu] $menu unpost set Priv(postedMb) {} if {$::tk_strictMotif} { $mb configure -cursor $Priv(cursor) } if {[tk windowingsystem] ne "aqua"} { $mb configure -relief $Priv(relief) } else { $mb configure -state normal } } elseif {$Priv(popup) ne ""} { $Priv(popup) unpost set Priv(popup) {} } elseif {[$menu cget -type] ne "menubar" && [$menu cget -type] ne "tearoff"} { # We're in a cascaded sub-menu from a torn-off menu or popup. # Unpost all the menus up to the toplevel one (but not # including the top-level torn-off one) and deactivate the # top-level torn off menu if there is one. while {1} { set parent [winfo parent $menu] if {[winfo class $parent] ne "Menu" || ![winfo ismapped $parent]} { break } $parent activate {} $parent postcascade {} GenerateMenuSelect $parent set type [$parent cget -type] if {$type eq "menubar" || $type eq "tearoff"} { break } set menu $parent } |
︙ | ︙ | |||
471 472 473 474 475 476 477 | # x - The x position of the mouse. # y - The y position of the mouse. # state - Modifier state (tells whether buttons are down). proc ::tk::MenuMotion {menu x y state} { variable ::tk::Priv if {$menu eq $Priv(window)} { | | | | | | | | | | | | | > | | | > | | | | | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | # x - The x position of the mouse. # y - The y position of the mouse. # state - Modifier state (tells whether buttons are down). proc ::tk::MenuMotion {menu x y state} { variable ::tk::Priv if {$menu eq $Priv(window)} { set activeindex [$menu index active] if {[$menu cget -type] eq "menubar"} { if {[info exists Priv(focus)] && $menu ne $Priv(focus)} { $menu activate @$x,$y GenerateMenuSelect $menu } } else { $menu activate @$x,$y GenerateMenuSelect $menu } set index [$menu index @$x,$y] if {[info exists Priv(menuActivated)] \ && $index >= 0 \ && $index ne $activeindex} { set mode [option get $menu clickToFocus ClickToFocus] if {[string is false $mode]} { set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] if {[$menu type $index] eq "cascade"} { # Catch these postcascade commands since the menu could be # destroyed before they run. set Priv(menuActivatedTimer) \ [after $delay [list catch [list \ $menu postcascade active]]] } else { set Priv(menuDeactivatedTimer) \ [after $delay [list catch [list $menu postcascade {}]]] } } } } } # ::tk::MenuButtonDown -- # Handles button presses in menus. There are a couple of tricky things # here: # 1. Change the posted cascade entry (if any) to match the mouse position. |
︙ | ︙ | |||
521 522 523 524 525 526 527 | # Arguments: # menu - The menu window. proc ::tk::MenuButtonDown menu { variable ::tk::Priv if {![winfo viewable $menu]} { | | | | | | | | | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 | # Arguments: # menu - The menu window. proc ::tk::MenuButtonDown menu { variable ::tk::Priv if {![winfo viewable $menu]} { return } if {[$menu index active] < 0} { if {[$menu cget -type] ne "menubar" } { set Priv(window) {} } return } $menu postcascade active if {$Priv(postedMb) ne "" && [winfo viewable $Priv(postedMb)]} { grab -global $Priv(postedMb) } else { while {[$menu cget -type] eq "normal" \ && [winfo class [winfo parent $menu]] eq "Menu" \ && [winfo ismapped [winfo parent $menu]]} { set menu [winfo parent $menu] } if {$Priv(menuBar) eq {}} { set Priv(menuBar) $menu if {$::tk_strictMotif} { set Priv(cursor) [$menu cget -cursor] $menu configure -cursor arrow } if {[$menu type active] eq "cascade"} { set Priv(menuActivated) 1 } } # Don't update grab information if the grab window isn't changing. # Otherwise, we'll get an error when we unpost the menus and # restore the grab, since the old grab window will not be viewable # anymore. if {$menu ne [grab current $menu]} { |
︙ | ︙ | |||
581 582 583 584 585 586 587 | # menu - The menu window. # rootx, rooty - Root coordinates of mouse. # state - Modifier state. proc ::tk::MenuLeave {menu rootx rooty state} { variable ::tk::Priv set Priv(window) {} | | | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | # menu - The menu window. # rootx, rooty - Root coordinates of mouse. # state - Modifier state. proc ::tk::MenuLeave {menu rootx rooty state} { variable ::tk::Priv set Priv(window) {} if {[$menu index active] < 0} { return } if {[$menu type active] eq "cascade" \ && [winfo containing $rootx $rooty] eq \ [$menu entrycget active -menu]} { return } $menu activate {} GenerateMenuSelect $menu } # ::tk::MenuInvoke -- # This procedure is invoked when button 1 is released over a menu. # It invokes the appropriate menu action and unposts the menu if # it came from a menubutton. |
︙ | ︙ | |||
611 612 613 614 615 616 617 | variable ::tk::Priv if {$buttonRelease && $Priv(window) eq ""} { # Mouse was pressed over a menu without a menu button, then # dragged off the menu (possibly with a cascade posted) and # released. Unpost everything and quit. | | | | | | | 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 | variable ::tk::Priv if {$buttonRelease && $Priv(window) eq ""} { # Mouse was pressed over a menu without a menu button, then # dragged off the menu (possibly with a cascade posted) and # released. Unpost everything and quit. $w postcascade {} $w activate {} event generate $w <<MenuSelect>> MenuUnpost $w return } if {[$w type active] eq "cascade"} { $w postcascade active set menu [$w entrycget active -menu] MenuFirstEntry $menu } elseif {[$w type active] eq "tearoff"} { ::tk::TearOffMenu $w MenuUnpost $w } elseif {[$w cget -type] eq "menubar"} { $w postcascade {} set active [$w index active] set isCascade [string equal [$w type $active] "cascade"] # Only de-activate the active item if it's a cascade; this prevents # the annoying "activation flicker" you otherwise get with # checkbuttons/commands/etc. on menubars if { $isCascade } { $w activate {} event generate $w <<MenuSelect>> } MenuUnpost $w # If the active item is not a cascade, invoke it. This enables # the use of checkbuttons/commands/etc. on menubars (which is legal, # but not recommended) if { !$isCascade } { uplevel #0 [list $w invoke $active] } } else { set active [$w index active] if {$Priv(popup) eq "" || $active >= 0} { MenuUnpost $w } uplevel #0 [list $w invoke active] } } # ::tk::MenuEscape -- |
︙ | ︙ | |||
753 754 755 756 757 758 759 | set parent [winfo parent $parent] } } } else { set count -1 set m2 [winfo parent $menu] if {[winfo class $m2] eq "Menu"} { | | | | 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 | set parent [winfo parent $parent] } } } else { set count -1 set m2 [winfo parent $menu] if {[winfo class $m2] eq "Menu"} { $menu activate {} GenerateMenuSelect $menu tk_menuSetFocus $m2 $m2 postcascade {} if {[$m2 cget -type] ne "menubar"} { return } } } |
︙ | ︙ | |||
793 794 795 796 797 798 799 | while {$i >= $length} { incr i -$length } set mb [lindex $buttons $i] if {[winfo class $mb] eq "Menubutton" \ && [$mb cget -state] ne "disabled" \ && [$mb cget -menu] ne "" \ | | | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | while {$i >= $length} { incr i -$length } set mb [lindex $buttons $i] if {[winfo class $mb] eq "Menubutton" \ && [$mb cget -state] ne "disabled" \ && [$mb cget -menu] ne "" \ && [[$mb cget -menu] index last] >= 0} { break } if {$mb eq $w} { return } incr i $count } |
︙ | ︙ | |||
815 816 817 818 819 820 821 | # # Arguments: # menu - Menu window that received the keystroke. # count - 1 means go to the next lower entry, # -1 means go to the next higher entry. proc ::tk::MenuNextEntry {menu count} { | | > | | 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | # # Arguments: # menu - Menu window that received the keystroke. # count - 1 means go to the next lower entry, # -1 means go to the next higher entry. proc ::tk::MenuNextEntry {menu count} { set last [$menu index last] if {$last < 0} { return } set length [expr {[$menu index last]+1}] set quitAfter $length set active [$menu index active] if {$active < 0} { set i 0 } else { set i [expr {$active + $count}] } while {1} { if {$quitAfter <= 0} { # We've tried every entry in the menu. Either there are |
︙ | ︙ | |||
889 890 891 892 893 894 895 | proc ::tk::MenuFind {w char} { set char [string tolower $char] set windowlist [winfo child $w] foreach child $windowlist { # Don't descend into other toplevels. | | | 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | proc ::tk::MenuFind {w char} { set char [string tolower $char] set windowlist [winfo child $w] foreach child $windowlist { # Don't descend into other toplevels. if {[winfo toplevel $w] ne [winfo toplevel $child]} { continue } if {[winfo class $child] eq "Menu" && \ [$child cget -type] eq "menubar"} { if {$char eq ""} { return $child } |
︙ | ︙ | |||
915 916 917 918 919 920 921 | } } } } foreach child $windowlist { # Don't descend into other toplevels. | | | 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 | } } } } foreach child $windowlist { # Don't descend into other toplevels. if {[winfo toplevel $w] ne [winfo toplevel $child]} { continue } switch -- [winfo class $child] { Menubutton { set char2 [string index [$child cget -text] \ [$child cget -underline]] if {$char eq [string tolower $char2] || $char eq ""} { |
︙ | ︙ | |||
1022 1023 1024 1025 1026 1027 1028 | proc ::tk::TraverseWithinMenu {w char} { if {$char eq ""} { return } set char [string tolower $char] set last [$w index last] | < < < | 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | proc ::tk::TraverseWithinMenu {w char} { if {$char eq ""} { return } set char [string tolower $char] set last [$w index last] for {set i 0} {$i <= $last} {incr i} { if {[catch {set char2 [string index \ [$w entrycget $i -label] [$w entrycget $i -underline]]}]} { continue } if {$char eq [string tolower $char2]} { if {[$w type $i] eq "cascade"} { |
︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | # menu - Name of the menu window (possibly empty). proc ::tk::MenuFirstEntry menu { if {$menu eq ""} { return } tk_menuSetFocus $menu | | < < < | 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | # menu - Name of the menu window (possibly empty). proc ::tk::MenuFirstEntry menu { if {$menu eq ""} { return } tk_menuSetFocus $menu if {[$menu index active] >= 0} { return } set last [$menu index last] for {set i 0} {$i <= $last} {incr i} { if {([catch {set state [$menu entrycget $i -state]}] == 0) \ && $state ne "disabled" && [$menu type $i] ne "tearoff"} { $menu activate $i GenerateMenuSelect $menu # Only post the cascade if the current menu is a menubar; # otherwise, if the first entry of the cascade is a cascade, |
︙ | ︙ | |||
1110 1111 1112 1113 1114 1115 1116 | proc ::tk::MenuFindName {menu s} { set i "" if {![regexp {^active$|^last$|^none$|^[0-9]|^@} $s]} { catch {set i [$menu index $s]} return $i } set last [$menu index last] | < < < | 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | proc ::tk::MenuFindName {menu s} { set i "" if {![regexp {^active$|^last$|^none$|^[0-9]|^@} $s]} { catch {set i [$menu index $s]} return $i } set last [$menu index last] for {set i 0} {$i <= $last} {incr i} { if {![catch {$menu entrycget $i -label} label]} { if {$label eq $s} { return $i } } } |
︙ | ︙ | |||
1134 1135 1136 1137 1138 1139 1140 | # menubutton, meaning that the indicator is on and the direction is # neither above nor below, then the menu is posted so that the current # entry is vertically aligned with the menubutton. On the Mac this # will expose a small amount of the blue indicator on the right hand # side. On other platforms the entry is centered over the button. if {[tk windowingsystem] eq "aqua"} { | | | 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 | # menubutton, meaning that the indicator is on and the direction is # neither above nor below, then the menu is posted so that the current # entry is vertically aligned with the menubutton. On the Mac this # will expose a small amount of the blue indicator on the right hand # side. On other platforms the entry is centered over the button. if {[tk windowingsystem] eq "aqua"} { proc ::tk::PostMenubuttonMenu {button menu cx cy} { set entry "" if {[$button cget -indicatoron]} { set entry [MenuFindName $menu [$button cget -text]] if {$entry eq ""} { set entry 0 } } |
︙ | ︙ | |||
1159 1160 1161 1162 1163 1164 1165 | } left { incr x [expr {-[winfo reqwidth $menu]}] } right { incr x [winfo width $button] } | | | | < < < < | | > > > > > | | > | | | | 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 | } left { incr x [expr {-[winfo reqwidth $menu]}] } right { incr x [winfo width $button] } default { # flush incr x [expr {[winfo width $button] - [winfo reqwidth $menu] - 5}] } } PostOverPoint $menu $x $y $entry } } else { proc ::tk::PostMenubuttonMenu {button menu cx cy} { set entry "" if {[$button cget -indicatoron]} { set entry [MenuFindName $menu [$button cget -text]] if {$entry eq ""} { set entry 0 } } set x [winfo rootx $button] set y [winfo rooty $button] switch [$button cget -direction] { above { incr y [expr {-[winfo reqheight $menu]}] # if we go offscreen to the top, show as 'below' if {$y < [winfo vrooty $button]} { set y [expr {[winfo vrooty $button] + [winfo rooty $button]\ + [winfo reqheight $button]}] } set entry {} } below { incr y [winfo height $button] # if we go offscreen to the bottom, show as 'above' set mh [winfo reqheight $menu] if {($y + $mh) > ([winfo vrooty $button] + [winfo vrootheight $button])} { set y [expr {[winfo vrooty $button] + [winfo vrootheight $button] \ + [winfo rooty $button] - $mh}] } set entry {} } left { incr x [expr {- [winfo reqwidth $menu]}] } right { incr x [expr {[winfo width $button]}] } default { # flush if {[$button cget -indicatoron]} { if {$cx ne ""} { set x [expr {$cx - [winfo reqwidth $menu] / 2}] set l [font metrics [$menu cget -font] -linespace] set y [expr {$cy - $l/2 - 2}] } else { incr x [expr {([winfo width $button] - \ [winfo reqwidth $menu])/ 2}] } } else { incr y [winfo height $button] } } } PostOverPoint $menu $x $y $entry } } # ::tk::PostOverPoint -- |
︙ | ︙ | |||
1238 1239 1240 1241 1242 1243 1244 | # If omitted or specified as {}, then the menu's # upper-left corner goes at (x,y). if {[tk windowingsystem] ne "win32"} { proc ::tk::PostOverPoint {menu x y {entry {}}} { if {$entry ne ""} { $menu post $x $y $entry | > | | 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 | # If omitted or specified as {}, then the menu's # upper-left corner goes at (x,y). if {[tk windowingsystem] ne "win32"} { proc ::tk::PostOverPoint {menu x y {entry {}}} { if {$entry ne ""} { $menu post $x $y $entry if {[$menu type $entry] ni {separator tearoff} && [$menu entrycget $entry -state] ne "disabled"} { $menu activate $entry GenerateMenuSelect $menu } } else { $menu post $x $y } return |
︙ | ︙ | |||
1365 1366 1367 1368 1369 1370 1371 | proc ::tk_popup {menu x y {entry {}}} { variable ::tk::Priv if {$Priv(popup) ne "" || $Priv(postedMb) ne ""} { tk::MenuUnpost {} } tk::PostOverPoint $menu $x $y $entry if {[tk windowingsystem] eq "x11" && [winfo viewable $menu]} { | | | 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 | proc ::tk_popup {menu x y {entry {}}} { variable ::tk::Priv if {$Priv(popup) ne "" || $Priv(postedMb) ne ""} { tk::MenuUnpost {} } tk::PostOverPoint $menu $x $y $entry if {[tk windowingsystem] eq "x11" && [winfo viewable $menu]} { tk::SaveGrabInfo $menu grab -global $menu set Priv(popup) $menu set Priv(window) $menu set Priv(menuActivated) 1 tk_menuSetFocus $menu } } |
Changes to library/msgs/cs.msg.
︙ | ︙ | |||
70 71 72 73 74 75 76 77 | ::msgcat::mcset cs "extensions" "pípony" ::msgcat::mcset cs "green" "zeleá" ::msgcat::mcset cs "ignore" "ignorovat" ::msgcat::mcset cs "ok" ::msgcat::mcset cs "red" "červeá" ::msgcat::mcset cs "retry" "znovu" ::msgcat::mcset cs "yes" "ano" } | > > > > > > > > > > > > > > > > > > | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | ::msgcat::mcset cs "extensions" "pípony" ::msgcat::mcset cs "green" "zeleá" ::msgcat::mcset cs "ignore" "ignorovat" ::msgcat::mcset cs "ok" ::msgcat::mcset cs "red" "červeá" ::msgcat::mcset cs "retry" "znovu" ::msgcat::mcset cs "yes" "ano" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset cs "Print" "Tisknout" ::msgcat::mcset cs "Printer" "Tiskárna" ::msgcat::mcset cs "Letter " "Dopis " ::msgcat::mcset cs "Legal " "Legální " ::msgcat::mcset cs "A4" "A4" ::msgcat::mcset cs "Grayscale" "Stupně Šedi" ::msgcat::mcset cs "RGB" "RGB" ::msgcat::mcset cs "Options" "Možnosti" ::msgcat::mcset cs "Copies" "Kopie" ::msgcat::mcset cs "Paper" "Papír" ::msgcat::mcset cs "Scale" "Škála" ::msgcat::mcset cs "Orientation" "Orientace" ::msgcat::mcset cs "Portrait" "Portrét" ::msgcat::mcset cs "Landscape" "Krajina" ::msgcat::mcset cs "Output" "Výstup" } |
Changes to library/msgs/da.msg.
︙ | ︙ | |||
71 72 73 74 75 76 77 78 | ::msgcat::mcset da "extensions" ::msgcat::mcset da "green" "grøn" ::msgcat::mcset da "ignore" "ignorer" ::msgcat::mcset da "ok" ::msgcat::mcset da "red" "rød" ::msgcat::mcset da "retry" "gentag" ::msgcat::mcset da "yes" "ja" } | > > > > > > > > > > > > > > > > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | ::msgcat::mcset da "extensions" ::msgcat::mcset da "green" "grøn" ::msgcat::mcset da "ignore" "ignorer" ::msgcat::mcset da "ok" ::msgcat::mcset da "red" "rød" ::msgcat::mcset da "retry" "gentag" ::msgcat::mcset da "yes" "ja" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset da "Print" "Trykke" ::msgcat::mcset da "Printer" "Printer" ::msgcat::mcset da "Letter " "Brev" ::msgcat::mcset da "Legal " "Juridisk" ::msgcat::mcset da "A4" "A4" ::msgcat::mcset da "Grayscale" "Gråtoneskala" ::msgcat::mcset da "RGB" "Rgb" ::msgcat::mcset da "Options" "Indstillinger" ::msgcat::mcset da "Copies" "Kopier" ::msgcat::mcset da "Paper" "Papir" ::msgcat::mcset da "Scale" "Skalere" ::msgcat::mcset da "Orientation" "Orientering" ::msgcat::mcset da "Portrait" "Portræt" ::msgcat::mcset da "Landscape" "Landskab" ::msgcat::mcset da "Output" "Udskriv Publikation" } |
Changes to library/msgs/de.msg.
︙ | ︙ | |||
84 85 86 87 88 89 90 91 | ::msgcat::mcset de "extensions" "Erweiterungen" ::msgcat::mcset de "green" "grün" ::msgcat::mcset de "ignore" "ignorieren" ::msgcat::mcset de "ok" ::msgcat::mcset de "red" "rot" ::msgcat::mcset de "retry" "wiederholen" ::msgcat::mcset de "yes" "ja" } | > > > > > > > > > > > > > > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ::msgcat::mcset de "extensions" "Erweiterungen" ::msgcat::mcset de "green" "grün" ::msgcat::mcset de "ignore" "ignorieren" ::msgcat::mcset de "ok" ::msgcat::mcset de "red" "rot" ::msgcat::mcset de "retry" "wiederholen" ::msgcat::mcset de "yes" "ja" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset de "Print" "Drucken" ::msgcat::mcset de "Printer" "Drucker" ::msgcat::mcset de "Letter " "Brief" ::msgcat::mcset de "Legal " "Rechtlich" ::msgcat::mcset de "A4" "A4" ::msgcat::mcset de "Grayscale" "Graustufen" ::msgcat::mcset de "RGB" "Rgb" ::msgcat::mcset de "Options" "Optionen" ::msgcat::mcset de "Copies" "Kopien" ::msgcat::mcset de "Paper" "Papier" ::msgcat::mcset de "Scale" "Skala" ::msgcat::mcset de "Orientation" "Ausrichtung" ::msgcat::mcset de "Portrait" "Porträt" ::msgcat::mcset de "Landscape" "Landschaft" ::msgcat::mcset de "Output" "Ausgabe" } |
Changes to library/msgs/el.msg.
︙ | ︙ | |||
79 80 81 82 83 84 85 86 | ::msgcat::mcset el "extensions" "επεκτάσεις" ::msgcat::mcset el "green" "πράσινο" ::msgcat::mcset el "ignore" "αγνόηση" ::msgcat::mcset el "ok" "εντάξει" ::msgcat::mcset el "red" "κόκκινο" ::msgcat::mcset el "retry" "προσπάθησε ξανά" ::msgcat::mcset el "yes" "ναι" } | > > > > > > > > > > > > > > > > > > | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | ::msgcat::mcset el "extensions" "επεκτάσεις" ::msgcat::mcset el "green" "πράσινο" ::msgcat::mcset el "ignore" "αγνόηση" ::msgcat::mcset el "ok" "εντάξει" ::msgcat::mcset el "red" "κόκκινο" ::msgcat::mcset el "retry" "προσπάθησε ξανά" ::msgcat::mcset el "yes" "ναι" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset el "Print" "Τυπώνω" ::msgcat::mcset el "Printer" "Εκτυπωτής" ::msgcat::mcset el "Letter " "Γράμμα" ::msgcat::mcset el "Legal " "Νομικός" ::msgcat::mcset el "A4" "Α4" ::msgcat::mcset el "Grayscale" "Κλίμακα Του Γκρι" ::msgcat::mcset el "RGB" "Rgb" ::msgcat::mcset el "Options" "Επιλογές" ::msgcat::mcset el "Copies" "Αντίγραφα" ::msgcat::mcset el "Paper" "Χαρτί" ::msgcat::mcset el "Scale" "Κλίμακα" ::msgcat::mcset el "Orientation" "Προσανατολισμός" ::msgcat::mcset el "Portrait" "Προσωπογραφία" ::msgcat::mcset el "Landscape" "Τοπίο" ::msgcat::mcset el "Output" "Έξοδος" } |
Changes to library/msgs/en.msg.
︙ | ︙ | |||
85 86 87 88 89 90 91 | ::msgcat::mcset en "green" ::msgcat::mcset en "ignore" ::msgcat::mcset en "ok" ::msgcat::mcset en "red" ::msgcat::mcset en "retry" ::msgcat::mcset en "yes" } | > > > > > > > > > > > > > > > > > > > | 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ::msgcat::mcset en "green" ::msgcat::mcset en "ignore" ::msgcat::mcset en "ok" ::msgcat::mcset en "red" ::msgcat::mcset en "retry" ::msgcat::mcset en "yes" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset en "Print" ::msgcat::mcset en "Printer" ::msgcat::mcset en "Letter " ::msgcat::mcset en "Legal " ::msgcat::mcset en "A4" ::msgcat::mcset en "Grayscale" ::msgcat::mcset en "RGB" ::msgcat::mcset en "Options" ::msgcat::mcset en "Copies" ::msgcat::mcset en "Paper" ::msgcat::mcset en "Scale" ::msgcat::mcset en "Orientation" ::msgcat::mcset en "Portrait" ::msgcat::mcset en "Landscape" ::msgcat::mcset en "Output" } |
Changes to library/msgs/eo.msg.
1 | namespace eval ::tk { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | namespace eval ::tk { ::msgcat::mcset eo "&Abort" "&Ĉesigu" ::msgcat::mcset eo "&About..." "Pri..." ::msgcat::mcset eo "All Files" "Ĉiuj dosieroj" ::msgcat::mcset eo "Application Error" "Aplikoeraro" ::msgcat::mcset eo "&Blue" "&Blua" ::msgcat::mcset eo "Cancel" "Rezignu" ::msgcat::mcset eo "&Cancel" "&Rezignu" ::msgcat::mcset eo "Cannot change to the directory \"%1\$s\".\nPermission denied." "Neeble ŝanĝi al dosierujo \"%1\$s\".\nVi ne rajtas tion." ::msgcat::mcset eo "Choose Directory" "Elektu Dosierujon" ::msgcat::mcset eo "Cl&ear" "&Vakigu" ::msgcat::mcset eo "&Clear Console" "&Vakigu konzolon" ::msgcat::mcset eo "Color" "Koloro" ::msgcat::mcset eo "Console" "Konzolo" ::msgcat::mcset eo "&Copy" "&Kopiu" ::msgcat::mcset eo "Cu&t" "&Eltondu" ::msgcat::mcset eo "&Delete" "&Forigu" ::msgcat::mcset eo "Details >>" "Detaloj >>" ::msgcat::mcset eo "Directory \"%1\$s\" does not exist." "La dosierujo \"%1\$s\" ne ekzistas." ::msgcat::mcset eo "&Directory:" "&Dosierujo:" ::msgcat::mcset eo "&Edit" "&Redaktu" ::msgcat::mcset eo "Error: %1\$s" "Eraro: %1\$s" ::msgcat::mcset eo "E&xit" "&Eliru" ::msgcat::mcset eo "&File" "&Dosiero" ::msgcat::mcset eo "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "La dosiero \"%1\$s\" jam ekzistas.\nĈu vi volas anstataŭigi la dosieron?" ::msgcat::mcset eo "File \"%1\$s\" already exists.\n\n" "La dosiero \"%1\$s\" jam ekzistas. \n\n" ::msgcat::mcset eo "File \"%1\$s\" does not exist." "La dosiero \"%1\$s\" ne ekzistas." ::msgcat::mcset eo "File &name:" "Dosiero&nomo:" ::msgcat::mcset eo "File &names:" "Dosiero&nomoj:" ::msgcat::mcset eo "Files of &type:" "Dosieroj de &Tipo:" ::msgcat::mcset eo "Fi&les:" "Do&sieroj:" ::msgcat::mcset eo "&Filter" "&Filtrilo" ::msgcat::mcset eo "Fil&ter:" "&Filtrilo:" ::msgcat::mcset eo "&Green" "&Verda" ::msgcat::mcset eo "&Help" "&Helpu" ::msgcat::mcset eo "Hi" "Saluton" ::msgcat::mcset eo "&Hide Console" "&Kaŝu konzolon" ::msgcat::mcset eo "&Ignore" "&Ignoru" ::msgcat::mcset eo "Invalid file name \"%1\$s\"." "Malvalida dosieronomo \"%1\$s\"." ::msgcat::mcset eo "Log Files" "Protokolaj dosieroj" ::msgcat::mcset eo "&No" "&Ne" ::msgcat::mcset eo "&OK" "&Bone" ::msgcat::mcset eo "OK" "Bone" ::msgcat::mcset eo "Ok" "Bone" ::msgcat::mcset eo "Open" "Malfermu" ::msgcat::mcset eo "&Open" "&Malfermu" ::msgcat::mcset eo "Open Multiple Files" "Malfermu plurajn dosierojn" ::msgcat::mcset eo "P&aste" "&Algluu" ::msgcat::mcset eo "&Quit" "&Forlasu" ::msgcat::mcset eo "&Red" "&Ruĝa" ::msgcat::mcset eo "Replace existing file?" "Ĉu anstataŭigi ekzistantan dosieron?" ::msgcat::mcset eo "&Retry" "&Reprovu" ::msgcat::mcset eo "&Save" "&Konservu" ::msgcat::mcset eo "Save As" "Konservu kiel" ::msgcat::mcset eo "Save To Log" "Konservu en protokolon" ::msgcat::mcset eo "Select Log File" "Elektu prokolodosieron" ::msgcat::mcset eo "Select a file to source" "Elektu dosieron por interpreti" ::msgcat::mcset eo "&Selection:" "&Elekto:" ::msgcat::mcset eo "Skip Messages" "transsaltu mesaĝojn" ::msgcat::mcset eo "&Source..." "&Fontoprogramo..." ::msgcat::mcset eo "Tcl Scripts" "Tcl-skriptoj" ::msgcat::mcset eo "Tcl for Windows" "Tcl por Vindozo" ::msgcat::mcset eo "Text Files" "Tekstodosieroj" ::msgcat::mcset eo "&Yes" "&Jes" ::msgcat::mcset eo "abort" "ĉesigu" ::msgcat::mcset eo "blue" "blua" ::msgcat::mcset eo "cancel" "rezignu" ::msgcat::mcset eo "extension" "kromprogramo" ::msgcat::mcset eo "extensions" "kromprogramoj" ::msgcat::mcset eo "green" "verda" ::msgcat::mcset eo "ignore" "ignoru" ::msgcat::mcset eo "red" "ruĝa" ::msgcat::mcset eo "retry" "reprovu" ::msgcat::mcset eo "yes" "jes" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset eo "Print" "Presi" ::msgcat::mcset eo "Printer" "Presilo" ::msgcat::mcset eo "Letter " "Letero" ::msgcat::mcset eo "Legal " "Laŭleĝa" ::msgcat::mcset eo "A4" "A4" ::msgcat::mcset eo "Grayscale" "Grizskalo" ::msgcat::mcset eo "RGB" "RGB" ::msgcat::mcset eo "Options" "Opcioj" ::msgcat::mcset eo "Copies" "Kopioj" ::msgcat::mcset eo "Paper" "Papero" ::msgcat::mcset eo "Scale" "Skalo" ::msgcat::mcset eo "Orientation" "Orientiĝo" ::msgcat::mcset eo "Portrait" "Portreto" ::msgcat::mcset eo "Landscape" "Pejzaĝo" ::msgcat::mcset eo "Output" "Eligo" } |
Changes to library/msgs/es.msg.
︙ | ︙ | |||
69 70 71 72 73 74 75 76 | ::msgcat::mcset es "extensions" "extensiones" ::msgcat::mcset es "green" "verde" ::msgcat::mcset es "ignore" "ignorar" ::msgcat::mcset es "ok" ::msgcat::mcset es "red" "rojo" ::msgcat::mcset es "retry" "reintentar" ::msgcat::mcset es "yes" "sí" } | > > > > > > > > > > > > > > > > > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | ::msgcat::mcset es "extensions" "extensiones" ::msgcat::mcset es "green" "verde" ::msgcat::mcset es "ignore" "ignorar" ::msgcat::mcset es "ok" ::msgcat::mcset es "red" "rojo" ::msgcat::mcset es "retry" "reintentar" ::msgcat::mcset es "yes" "sí" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset es "Print" "Imprimir" ::msgcat::mcset es "Printer" "Impresora" ::msgcat::mcset es "Letter" "Carta" ::msgcat::mcset es "Legal" "Legal" ::msgcat::mcset es "A4" "A4" ::msgcat::mcset es "Grayscale" "Escala De Grises" ::msgcat::mcset es "RGB" "Color" ::msgcat::mcset es "Options" "Opciones" ::msgcat::mcset es "Copies" "Copias" ::msgcat::mcset es "Paper" "Papel" ::msgcat::mcset es "Scale" "Escala" ::msgcat::mcset es "Orientation" "Orientación" ::msgcat::mcset es "Portrait" "Retrato" ::msgcat::mcset es "Landscape" "Paisaje" ::msgcat::mcset es "Output" "Salida" } |
Added library/msgs/fi.msg.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | namespace eval ::tk { ::msgcat::mcset fi "AaBbYyZz01" "AaBbÄäÖö01" ::msgcat::mcset fi "&Abort" "&Keskeytä" ::msgcat::mcset fi "&About..." "&Tietoja..." ::msgcat::mcset fi "All Files" "Kaikki tiedostot" ::msgcat::mcset fi "&Apply" "Kä&ytä" ::msgcat::mcset fi "Application Error" "Ohjelmavirhe" ::msgcat::mcset fi "&Blue" "&Sininen" ::msgcat::mcset fi "Bold" "Lihavoitu" ::msgcat::mcset fi "Bold Italic" "Lihavoitu, kursivoitu" ::msgcat::mcset fi "Cancel" "Peruuta" ::msgcat::mcset fi "&Cancel" "&Peruuta" ::msgcat::mcset fi "Cannot change to the directory \"%1\$s\".\nPermission denied." "Ei voitu vaihtaa hakemistoon \"%1\$s\".\nLupa evätty." ::msgcat::mcset fi "Choose Directory" "Valitse hakemisto" ::msgcat::mcset fi "Cl&ear" "&Tyhjennä" ::msgcat::mcset fi "&Clear Console" "&Tyhjennä konsoli" ::msgcat::mcset fi "Color" "Väri" ::msgcat::mcset fi "Console" "Konsoli" ::msgcat::mcset fi "&Copy" "K&opioi" ::msgcat::mcset fi "Cu&t" "&Leikkaa" ::msgcat::mcset fi "&Decrease Font Size" "&Pienennä kirjasinkokoa" ::msgcat::mcset fi "&Delete" "&Poista" ::msgcat::mcset fi "Details >>" "Lisätiedot >>" ::msgcat::mcset fi "Directory \"%1\$s\" does not exist." "Hakemistoa \"%1\$s\" ei ole olemassa." ::msgcat::mcset fi "&Directory:" "&Hakemisto:" ::msgcat::mcset fi "&Edit" "&Muokkaa" ::msgcat::mcset fi "Effects" "Tehosteet" ::msgcat::mcset fi "Error: %1\$s" "Virhe: %1\$s" ::msgcat::mcset fi "E&xit" "&Lopeta" ::msgcat::mcset fi "&File" "&Tiedosto" ::msgcat::mcset fi "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "Tiedosto \"%1\$s\" on jo olemassa.\nHaluatko korvata sen?" ::msgcat::mcset fi "File \"%1\$s\" already exists.\n\n" "Tiedosto \"%1\$s\" on jo olemassa.\n\n" ::msgcat::mcset fi "File \"%1\$s\" does not exist." "Tiedostoa \"%1\$s\" ei ole olemassa." ::msgcat::mcset fi "File &name:" "Tiedosto&nimi:" ::msgcat::mcset fi "File &names:" "Tiedosto&nimet:" ::msgcat::mcset fi "Files of &type:" "T&yyppi:" ::msgcat::mcset fi "Fi&les:" "Ti&edostot:" ::msgcat::mcset fi "&Filter" "&Suodata" ::msgcat::mcset fi "Fil&ter:" "Suo&data:" ::msgcat::mcset fi "Fit To Screen Width" "Sovita ruudun kokoon" ::msgcat::mcset fi "Font" "Kirjasin" ::msgcat::mcset fi "&Font..." "Kir&jasin..." ::msgcat::mcset fi "&Font:" "&Kirjasin:" ::msgcat::mcset fi "Font st&yle:" "Kirjasint&yyli:" ::msgcat::mcset fi "&Green" "&Vihreä" ::msgcat::mcset fi "Help" "Ohje" ::msgcat::mcset fi "&Help" "&Ohje" ::msgcat::mcset fi "Hi" "Hei" ::msgcat::mcset fi "&Hide Console" "P&iilota konsoli" ::msgcat::mcset fi "Hide Fonts" "Piilota kirjasimet" ::msgcat::mcset fi "&Ignore" "&Ohita" ::msgcat::mcset fi "&Increase Font Size" "&Suurenna kirjasinkokoa" ::msgcat::mcset fi "Invalid file name \"%1\$s\"." "Virheellinen tiedostonimi \"%1\$s\"." ::msgcat::mcset fi "Italic" "Kursivoitu" ::msgcat::mcset fi "Log Files" "Lokitiedostot" ::msgcat::mcset fi "&No" "&Ei" ::msgcat::mcset fi "&OK" ::msgcat::mcset fi "OK" ::msgcat::mcset fi "Ok" "OK" ::msgcat::mcset fi "Open" "Avaa" ::msgcat::mcset fi "&Open" "&Avaa" ::msgcat::mcset fi "Open Multiple Files" "Avaa monta tiedostoa" ::msgcat::mcset fi "P&aste" "L&iitä" ::msgcat::mcset fi "&Quit" "&Lopeta" ::msgcat::mcset fi "&Red" "&Punainen" ::msgcat::mcset fi "Regular" "Tavallinen" ::msgcat::mcset fi "Replace existing file?" "Korvataanko olemassaoleva tiedosto?" ::msgcat::mcset fi "&Retry" "&Yritä uudelleen" ::msgcat::mcset fi "Sample" "Malli" ::msgcat::mcset fi "&Save" "&Tallenna" ::msgcat::mcset fi "Save As" "Tallenna nimellä" ::msgcat::mcset fi "Save To Log" "Tallenna lokiin" ::msgcat::mcset fi "Select Log File" "Valitse lokitiedosto" ::msgcat::mcset fi "Select a file to source" "Valitse lähdetiedosto" ::msgcat::mcset fi "&Selection:" "&Valinta:" ::msgcat::mcset fi "Show Fonts" "Näytä kirjasimet" ::msgcat::mcset fi "Skip Messages" "Jätä viestit huomiotta" ::msgcat::mcset fi "&Size:" "K&oko:" ::msgcat::mcset fi "&Source..." "L&ähde..." ::msgcat::mcset fi "Stri&keout" "&Yliviivaa" ::msgcat::mcset fi "Tcl Scripts" "Tcl-skriptit" ::msgcat::mcset fi "Tcl for Windows" "Tcl Windowsille" ::msgcat::mcset fi "Text Files" "Tekstitiedostot" ::msgcat::mcset fi "&Underline" "&Alleviivaa" ::msgcat::mcset fi "Window" "Ikkuna" ::msgcat::mcset fi "&Yes" "&Kyllä" ::msgcat::mcset fi "abort" "keskeytä" ::msgcat::mcset fi "blue" "sininen" ::msgcat::mcset fi "cancel" "peruuta" ::msgcat::mcset fi "extension" "lisäosa" ::msgcat::mcset fi "extensions" "lisäosat" ::msgcat::mcset fi "green" "vihreä" ::msgcat::mcset fi "ignore" "ohita" ::msgcat::mcset fi "ok" ::msgcat::mcset fi "red" "punainen" ::msgcat::mcset fi "retry" "yritä uudelleen" ::msgcat::mcset fi "yes" "kyllä" ::msgcat::mcset fi "Print" "Tulosta" ::msgcat::mcset fi "Printer" "Tulostin" ::msgcat::mcset fi "Letter " "Letter" ::msgcat::mcset fi "Legal " "Legal" ::msgcat::mcset fi "A4" "A4" ::msgcat::mcset fi "Grayscale" "Harmaasävy" ::msgcat::mcset fi "RGB" "RGB" ::msgcat::mcset fi "Options" "Asetukset" ::msgcat::mcset fi "Copies" "Tulosteita" ::msgcat::mcset fi "Paper" "Paperikoko" ::msgcat::mcset fi "Scale" "Skaalaus" ::msgcat::mcset fi "Orientation" "Suunta" ::msgcat::mcset fi "Portrait" "Pysty" ::msgcat::mcset fi "Landscape" "Vaaka" ::msgcat::mcset fi "Output" "Tulos" } |
Changes to library/msgs/fr.msg.
︙ | ︙ | |||
65 66 67 68 69 70 71 72 | ::msgcat::mcset fr "extensions" ::msgcat::mcset fr "green" "vert" ::msgcat::mcset fr "ignore" "ignorer" ::msgcat::mcset fr "ok" ::msgcat::mcset fr "red" "rouge" ::msgcat::mcset fr "retry" "réessayer" ::msgcat::mcset fr "yes" "oui" } | > > > > > > > > > > > > > > > > > > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | ::msgcat::mcset fr "extensions" ::msgcat::mcset fr "green" "vert" ::msgcat::mcset fr "ignore" "ignorer" ::msgcat::mcset fr "ok" ::msgcat::mcset fr "red" "rouge" ::msgcat::mcset fr "retry" "réessayer" ::msgcat::mcset fr "yes" "oui" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset fr "Print" "Imprimer" ::msgcat::mcset fr "Printer" "Imprimante" ::msgcat::mcset fr "Letter " "Lettre" ::msgcat::mcset fr "Legal " "Légal" ::msgcat::mcset fr "A4" "A4" ::msgcat::mcset fr "Grayscale" "Niveaux de Gris" ::msgcat::mcset fr "RGB" "RVB" ::msgcat::mcset fr "Options" "Options" ::msgcat::mcset fr "Copies" "Nombre d'exemplaires" ::msgcat::mcset fr "Paper" "Papier" ::msgcat::mcset fr "Scale" "Échelle" ::msgcat::mcset fr "Orientation" "Orientation" ::msgcat::mcset fr "Portrait" "Portrait" ::msgcat::mcset fr "Landscape" "Paysage" ::msgcat::mcset fr "Output" "Sortie" } |
Changes to library/msgs/hu.msg.
︙ | ︙ | |||
71 72 73 74 75 76 77 78 | ::msgcat::mcset hu "extensions" "kiterjesztések" ::msgcat::mcset hu "green" "zöld" ::msgcat::mcset hu "ignore" "ignorer" ::msgcat::mcset hu "ok" ::msgcat::mcset hu "red" "vörös" ::msgcat::mcset hu "retry" "újra" ::msgcat::mcset hu "yes" "igen" } | > > > > > > > > > > > > > > > > > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | ::msgcat::mcset hu "extensions" "kiterjesztések" ::msgcat::mcset hu "green" "zöld" ::msgcat::mcset hu "ignore" "ignorer" ::msgcat::mcset hu "ok" ::msgcat::mcset hu "red" "vörös" ::msgcat::mcset hu "retry" "újra" ::msgcat::mcset hu "yes" "igen" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset hu "Print" "Nyomtat" ::msgcat::mcset hu "Printer" "Nyomtató" ::msgcat::mcset hu "Letter " "Levél" ::msgcat::mcset hu "Legal " "Törvényes" ::msgcat::mcset hu "A4" "A4" ::msgcat::mcset hu "Grayscale" "Szürkeárnyalatos" ::msgcat::mcset hu "RGB" "Rgb" ::msgcat::mcset hu "Options" "Beállítások" ::msgcat::mcset hu "Copies" "Másolatok" ::msgcat::mcset hu "Paper" "Papír" ::msgcat::mcset hu "Scale" "Hangsor" ::msgcat::mcset hu "Orientation" "Tájékozódás" ::msgcat::mcset hu "Portrait" "Portré" ::msgcat::mcset hu "Landscape" "Táj" ::msgcat::mcset hu "Output" "Hozam" } |
Changes to library/msgs/it.msg.
︙ | ︙ | |||
66 67 68 69 70 71 72 73 | ::msgcat::mcset it "extensions" "estensioni" ::msgcat::mcset it "green" "verde" ::msgcat::mcset it "ignore" "ignora" ::msgcat::mcset it "ok" ::msgcat::mcset it "red" "rosso" ::msgcat::mcset it "retry" "riprova" ::msgcat::mcset it "yes" "sì" } | > > > > > > > > > > > > > > > > > > | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | ::msgcat::mcset it "extensions" "estensioni" ::msgcat::mcset it "green" "verde" ::msgcat::mcset it "ignore" "ignora" ::msgcat::mcset it "ok" ::msgcat::mcset it "red" "rosso" ::msgcat::mcset it "retry" "riprova" ::msgcat::mcset it "yes" "sì" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset it "Print" "Stampare" ::msgcat::mcset it "Printer" "Stampante" ::msgcat::mcset it "Letter " "Lettera" ::msgcat::mcset it "Legal " "Legale" ::msgcat::mcset it "A4" "A4" ::msgcat::mcset it "Grayscale" "Scala Di Grigi" ::msgcat::mcset it "RGB" "Rgb" ::msgcat::mcset it "Options" "Opzioni" ::msgcat::mcset it "Copies" "Copie" ::msgcat::mcset it "Paper" "Carta" ::msgcat::mcset it "Scale" "Scala" ::msgcat::mcset it "Orientation" "Orientamento" ::msgcat::mcset it "Portrait" "Ritratto" ::msgcat::mcset it "Landscape" "Paesaggio" ::msgcat::mcset it "Output" "Prodotto" } |
Changes to library/msgs/nl.msg.
︙ | ︙ | |||
84 85 86 87 88 89 90 91 | ::msgcat::mcset nl "extensions" ::msgcat::mcset nl "green" "groen" ::msgcat::mcset nl "ignore" "negeren" ::msgcat::mcset nl "ok" ::msgcat::mcset nl "red" "rood" ::msgcat::mcset nl "retry" "opnieuw" ::msgcat::mcset nl "yes" "ja" } | > > > > > > > > > > > > > > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ::msgcat::mcset nl "extensions" ::msgcat::mcset nl "green" "groen" ::msgcat::mcset nl "ignore" "negeren" ::msgcat::mcset nl "ok" ::msgcat::mcset nl "red" "rood" ::msgcat::mcset nl "retry" "opnieuw" ::msgcat::mcset nl "yes" "ja" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset nl "Print" "Afdrukken" ::msgcat::mcset nl "Printer" "Printer" ::msgcat::mcset nl "Letter " "Brief" ::msgcat::mcset nl "Legal " "Legaal" ::msgcat::mcset nl "A4" "A4" ::msgcat::mcset nl "Grayscale" "Grijswaarden" ::msgcat::mcset nl "RGB" "Rgb" ::msgcat::mcset nl "Options" "Opties" ::msgcat::mcset nl "Copies" "Kopieën" ::msgcat::mcset nl "Paper" "Papier" ::msgcat::mcset nl "Scale" "Schub" ::msgcat::mcset nl "Orientation" "Oriëntatie" ::msgcat::mcset nl "Portrait" "Portret" ::msgcat::mcset nl "Landscape" "Landschap" ::msgcat::mcset nl "Output" "Uitvoer" } |
Changes to library/msgs/pl.msg.
︙ | ︙ | |||
84 85 86 87 88 89 90 91 | ::msgcat::mcset pl "extensions" "rozszerzenia" ::msgcat::mcset pl "green" "zielony" ::msgcat::mcset pl "ignore" "ignoruj" ::msgcat::mcset pl "ok" ::msgcat::mcset pl "red" "czerwony" ::msgcat::mcset pl "retry" "ponów" ::msgcat::mcset pl "yes" "tak" } | > > > > > > > > > > > > > > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ::msgcat::mcset pl "extensions" "rozszerzenia" ::msgcat::mcset pl "green" "zielony" ::msgcat::mcset pl "ignore" "ignoruj" ::msgcat::mcset pl "ok" ::msgcat::mcset pl "red" "czerwony" ::msgcat::mcset pl "retry" "ponów" ::msgcat::mcset pl "yes" "tak" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset pl "Print" "Drukować" ::msgcat::mcset pl "Printer" "Drukarka" ::msgcat::mcset pl "Letter " "Litera" ::msgcat::mcset pl "Legal " "Legalny" ::msgcat::mcset pl "A4" "A4" ::msgcat::mcset pl "Grayscale" "Skala Szarości" ::msgcat::mcset pl "RGB" "Rgb" ::msgcat::mcset pl "Options" "Opcje" ::msgcat::mcset pl "Copies" "Kopie" ::msgcat::mcset pl "Paper" "Papier" ::msgcat::mcset pl "Scale" "Skala" ::msgcat::mcset pl "Orientation" "Orientacja" ::msgcat::mcset pl "Portrait" "Portret" ::msgcat::mcset pl "Landscape" "Krajobraz" ::msgcat::mcset pl "Output" "Produkt Wyjściowy" } |
Changes to library/msgs/pt.msg.
︙ | ︙ | |||
67 68 69 70 71 72 73 74 | ::msgcat::mcset pt "extensions" "extensões" ::msgcat::mcset pt "green" "verde" ::msgcat::mcset pt "ignore" "ignorar" ::msgcat::mcset pt "ok" ::msgcat::mcset pt "red" "vermelho" ::msgcat::mcset pt "retry" "tentar novamente" ::msgcat::mcset pt "yes" "sim" } | > > > > > > > > > > > > > > > > > > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | ::msgcat::mcset pt "extensions" "extensões" ::msgcat::mcset pt "green" "verde" ::msgcat::mcset pt "ignore" "ignorar" ::msgcat::mcset pt "ok" ::msgcat::mcset pt "red" "vermelho" ::msgcat::mcset pt "retry" "tentar novamente" ::msgcat::mcset pt "yes" "sim" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset pt "Print" "Imprimir" ::msgcat::mcset pt "Printer" "Impressora" ::msgcat::mcset pt "Letter " "Letra" ::msgcat::mcset pt "Legal " "Legal" ::msgcat::mcset pt "A4" "A4" ::msgcat::mcset pt "Grayscale" "Escala De Cinza" ::msgcat::mcset pt "RGB" "Rgb" ::msgcat::mcset pt "Options" "Opções" ::msgcat::mcset pt "Copies" "Exemplares" ::msgcat::mcset pt "Paper" "Papel" ::msgcat::mcset pt "Scale" "Escala" ::msgcat::mcset pt "Orientation" "Orientação" ::msgcat::mcset pt "Portrait" "Retrato" ::msgcat::mcset pt "Landscape" "Paisagem" ::msgcat::mcset pt "Output" "Saída" } |
Changes to library/msgs/ru.msg.
1 2 3 4 5 6 | namespace eval ::tk { ::msgcat::mcset ru "&Abort" "&Отменить" ::msgcat::mcset ru "&About..." "Про..." ::msgcat::mcset ru "All Files" "Все файлы" ::msgcat::mcset ru "Application Error" "Ошибка в программе" ::msgcat::mcset ru "&Blue" " &Голубой" | > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | namespace eval ::tk { ::msgcat::mcset ru "&Abort" "&Отменить" ::msgcat::mcset ru "&About..." "Про..." ::msgcat::mcset ru "All Files" "Все файлы" ::msgcat::mcset ru "Application Error" "Ошибка в программе" ::msgcat::mcset ru "&Apply" "&Применить" ::msgcat::mcset ru "Bold" "Bold" ::msgcat::mcset ru "Bold Italic" "Bold Italic" ::msgcat::mcset ru "&Blue" " &Голубой" ::msgcat::mcset ru "Cancel" "Отмена" ::msgcat::mcset ru "&Cancel" "От&мена" ::msgcat::mcset ru "Cannot change to the directory \"%1\$s\".\nPermission denied." \ "Не могу перейти в каталог \"%1\$s\".\nНедостаточно прав доступа" ::msgcat::mcset ru "Choose Directory" "Выберите каталог" ::msgcat::mcset ru "Cl&ear" "Очистить" ::msgcat::mcset ru "&Clear Console" "&Clear Console" ::msgcat::mcset ru "Color" "Цвет" ::msgcat::mcset ru "Console" "Консоль" ::msgcat::mcset ru "&Copy" "Копировать" ::msgcat::mcset ru "Cu&t" "Вырезать" ::msgcat::mcset ru "&Delete" "Удалить" ::msgcat::mcset ru "Details >>" "Подробнее >>" ::msgcat::mcset ru "Directory \"%1\$s\" does not exist." "Каталога \"%1\$s\" не существует." ::msgcat::mcset ru "&Directory:" "&Каталог:" ::msgcat::mcset ru "&Edit" "&Edit" ::msgcat::mcset ru "Effects" "Эффекты" ::msgcat::mcset ru "Error: %1\$s" "Ошибка: %1\$s" ::msgcat::mcset ru "E&xit" "Выход" ::msgcat::mcset ru "&File" "&File" ::msgcat::mcset ru "File \"%1\$s\" already exists.\nDo you want to overwrite it?" \ "Файл \"%1\$s\" уже существует.\nЗаменить его?" ::msgcat::mcset ru "File \"%1\$s\" already exists.\n\n" "Файл \"%1\$s\" уже существует.\n\n" ::msgcat::mcset ru "File \"%1\$s\" does not exist." "Файл \"%1\$s\" не найден." ::msgcat::mcset ru "File &name:" "&Имя файла:" ::msgcat::mcset ru "File &names:" "&Имена файлов:" ::msgcat::mcset ru "Files of &type:" "&Тип файлов:" ::msgcat::mcset ru "Fi&les:" "Фай&лы:" ::msgcat::mcset ru "&Filter" "&Фильтр" ::msgcat::mcset ru "Fil&ter:" "Филь&тр:" ::msgcat::mcset ru "Font" "Шрифт" ::msgcat::mcset ru "&Font:" "&Шрифт" ::msgcat::mcset ru "Font st&yle:" "&Стиль шрифта:" ::msgcat::mcset ru "&Green" " &Зеленый" ::msgcat::mcset ru "&Help" "&Help" ::msgcat::mcset ru "Hi" "Привет" ::msgcat::mcset ru "&Hide Console" "Спрятать консоль" ::msgcat::mcset ru "&Ignore" "&Игнорировать" ::msgcat::mcset ru "Invalid file name \"%1\$s\"." "Неверное имя файла \"%1\$s\"." ::msgcat::mcset ru "Italic" "Italic" ::msgcat::mcset ru "Log Files" "Файлы журнала" ::msgcat::mcset ru "&No" "&Нет" ::msgcat::mcset ru "&OK" "&ОК" ::msgcat::mcset ru "OK" "ОК" ::msgcat::mcset ru "Ok" "Да" ::msgcat::mcset ru "Open" "Открыть" ::msgcat::mcset ru "&Open" "&Открыть" ::msgcat::mcset ru "Open Multiple Files" "Открыть несколько файлов" ::msgcat::mcset ru "P&aste" "Вставить" ::msgcat::mcset ru "&Quit" "Выход" ::msgcat::mcset ru "&Red" " &Красный" ::msgcat::mcset ru "Replace existing file?" "Заменить существующий файл?" ::msgcat::mcset ru "Regular" "Regular" ::msgcat::mcset ru "&Retry" "&Повторить" ::msgcat::mcset ru "Sample" "Пример" ::msgcat::mcset ru "&Save" "&Сохранить" ::msgcat::mcset ru "Save As" "Сохранить как" ::msgcat::mcset ru "Save To Log" "Сохранить в журнал" ::msgcat::mcset ru "Select Log File" "Выбрать журнал" ::msgcat::mcset ru "Select a file to source" "Выберите файл для интерпретации" ::msgcat::mcset ru "&Selection:" ::msgcat::mcset ru "&Size:" "&Размер:" ::msgcat::mcset ru "Show &Hidden Directories" "Show &Hidden Directories" ::msgcat::mcset ru "Show &Hidden Files and Directories" "Show &Hidden Files and Directories" ::msgcat::mcset ru "Skip Messages" "Пропустить сообщения" ::msgcat::mcset ru "&Source..." "Интерпретировать файл..." ::msgcat::mcset ru "Stri&keout" "П&еречёркнутый" ::msgcat::mcset ru "Tcl Scripts" "Программа на языке TCL" ::msgcat::mcset ru "Tcl for Windows" "TCL для Windows" ::msgcat::mcset ru "Text Files" "Текстовые файлы" ::msgcat::mcset ru "&Underline" "По&дчеркнутый" ::msgcat::mcset ru "&Yes" "&Да" ::msgcat::mcset ru "abort" "отмена" ::msgcat::mcset ru "blue" " голубой" ::msgcat::mcset ru "cancel" "отмена" ::msgcat::mcset ru "extension" "расширение" ::msgcat::mcset ru "extensions" "расширения" ::msgcat::mcset ru "green" " зеленый" ::msgcat::mcset ru "ignore" "пропустить" ::msgcat::mcset ru "ok" "ок" ::msgcat::mcset ru "red" " красный" ::msgcat::mcset ru "retry" "повторить" ::msgcat::mcset ru "yes" "да" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset ru "Print" "Печатать" ::msgcat::mcset ru "Printer" "Принтер" ::msgcat::mcset ru "Letter " "Письмо" ::msgcat::mcset ru "Legal " "Законный" ::msgcat::mcset ru "A4" "A4" ::msgcat::mcset ru "Grayscale" "Серый Масштаб" ::msgcat::mcset ru "RGB" "Ргб" ::msgcat::mcset ru "Options" "Параметры" ::msgcat::mcset ru "Copies" "Копии" ::msgcat::mcset ru "Paper" "Бумага" ::msgcat::mcset ru "Scale" "Шкала" ::msgcat::mcset ru "Orientation" "Ориентация" ::msgcat::mcset ru "Portrait" "Портрет" ::msgcat::mcset ru "Landscape" "Ландшафт" ::msgcat::mcset ru "Output" "Выпуск" } |
Changes to library/msgs/sv.msg.
︙ | ︙ | |||
69 70 71 72 73 74 75 76 | ::msgcat::mcset sv "extensions" "utvidgningar" ::msgcat::mcset sv "green" "grön" ::msgcat::mcset sv "ignore" "ignorera" ::msgcat::mcset sv "ok" ::msgcat::mcset sv "red" "röd" ::msgcat::mcset sv "retry" "försök igen" ::msgcat::mcset sv "yes" "ja" } | > > > > > > > > > > > > > > > > > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | ::msgcat::mcset sv "extensions" "utvidgningar" ::msgcat::mcset sv "green" "grön" ::msgcat::mcset sv "ignore" "ignorera" ::msgcat::mcset sv "ok" ::msgcat::mcset sv "red" "röd" ::msgcat::mcset sv "retry" "försök igen" ::msgcat::mcset sv "yes" "ja" } #localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset sv "Print" "Trycka" ::msgcat::mcset sv "Printer" "Skrivare" ::msgcat::mcset sv "Letter " "Brev" ::msgcat::mcset sv "Legal " "Laglig" ::msgcat::mcset sv "A4" "A4 (På 199" ::msgcat::mcset sv "Grayscale" "Gråskala" ::msgcat::mcset sv "RGB" "Rgb" ::msgcat::mcset sv "Options" "Alternativ" ::msgcat::mcset sv "Copies" "Kopior" ::msgcat::mcset sv "Paper" "Papper" ::msgcat::mcset sv "Scale" "Skala" ::msgcat::mcset sv "Orientation" "Orientering" ::msgcat::mcset sv "Portrait" "Porträtt" ::msgcat::mcset sv "Landscape" "Landskap" ::msgcat::mcset sv "Output" "Utdata" } |
Added library/msgs/zh_cn.msg.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | namespace eval ::tk { ::msgcat::mcset zh_cn "&Abort" "&中止" ::msgcat::mcset zh_cn "&About..." "&关于……" ::msgcat::mcset zh_cn "All Files" "所有文件" ::msgcat::mcset zh_cn "Application Error" "应用程序错误" ::msgcat::mcset zh_cn "&Apply" "&添加" ::msgcat::mcset zh_cn "Bold" "粗体" ::msgcat::mcset zh_cn "Bold Italic" "加粗斜体" ::msgcat::mcset zh_cn "&Blue" "&蓝色" ::msgcat::mcset zh_cn "Cancel" "取消" ::msgcat::mcset zh_cn "&Cancel" "&取消" ::msgcat::mcset zh_cn "Cannot change to the directory \"%1\$s\".\nPermission denied." "无法更改目录 \"%1\$s\"。\n访问被拒绝。" ::msgcat::mcset zh_cn "Choose Directory" "选择文件夹" ::msgcat::mcset zh_cn "Cl&ear" "清&除" ::msgcat::mcset zh_cn "&Clear Console" "&清除终端" ::msgcat::mcset zh_cn "Color" "颜色" ::msgcat::mcset zh_cn "Console" "终端" ::msgcat::mcset zh_cn "&Copy" "&复制" ::msgcat::mcset zh_cn "Cu&t" "剪&切" ::msgcat::mcset zh_cn "&Delete" "&删除" ::msgcat::mcset zh_cn "Details >>" "详细信息 >>" ::msgcat::mcset zh_cn "Directory \"%1\$s\" does not exist." "目录 \"%1\$s\" 不存在。" ::msgcat::mcset zh_cn "&Directory:" "&目录:" ::msgcat::mcset zh_cn "&Edit" "&编辑" ::msgcat::mcset zh_cn "Effects" "效果" ::msgcat::mcset zh_cn "Error: %1\$s" "错误: %1\$s" ::msgcat::mcset zh_cn "E&xit" "退&出" ::msgcat::mcset zh_cn "&File" "&文件" ::msgcat::mcset zh_cn "File \"%1\$s\" already exists.\nDo you want to overwrite it?" "文件 \"%1\$s\" 已经存在。\n您想要覆盖它吗?" ::msgcat::mcset zh_cn "File \"%1\$s\" already exists.\n\n" "文件 \"%1\$s\" 已经存在。\n\n" ::msgcat::mcset zh_cn "File \"%1\$s\" does not exist." "文件 \"%1\$s\" 不存在。" ::msgcat::mcset zh_cn "File &name:" "文件&名:" ::msgcat::mcset zh_cn "File &names:" "文件&名:" ::msgcat::mcset zh_cn "Files of &type:" "文件&类型:" ::msgcat::mcset zh_cn "Fi&les:" "文&件:" ::msgcat::mcset zh_cn "&Filter" "&过滤" ::msgcat::mcset zh_cn "Fil&ter:" "过&滤:" ::msgcat::mcset zh_cn "Font" "字体" ::msgcat::mcset zh_cn "&Font:" "&字体:" ::msgcat::mcset zh_cn "Font st&yle:" "字体&样式:" ::msgcat::mcset zh_cn "&Green" "&绿色" ::msgcat::mcset zh_cn "&Help" "&帮助" ::msgcat::mcset zh_cn "Hi" "你好" ::msgcat::mcset zh_cn "&Hide Console" "&隐藏终端" ::msgcat::mcset zh_cn "&Ignore" "&忽略" ::msgcat::mcset zh_cn "Invalid file name \"%1\$s\"." "无效的文件名 \"%1\$s\"。" ::msgcat::mcset zh_cn "Italic" "斜体" ::msgcat::mcset zh_cn "Log Files" "日志文件" ::msgcat::mcset zh_cn "&No" "&取消" ::msgcat::mcset zh_cn "&OK" "&确定" ::msgcat::mcset zh_cn "OK" "确定" ::msgcat::mcset zh_cn "Ok" "确定" ::msgcat::mcset zh_cn "Open" "打开" ::msgcat::mcset zh_cn "&Open" "&打开" ::msgcat::mcset zh_cn "Open Multiple Files" "打开多个文件" ::msgcat::mcset zh_cn "P&aste" "粘&贴" ::msgcat::mcset zh_cn "&Quit" "&退出" ::msgcat::mcset zh_cn "&Red" "红色" ::msgcat::mcset zh_cn "Regular" "规则" ::msgcat::mcset zh_cn "Replace existing file?" "替换已有文件?" ::msgcat::mcset zh_cn "&Retry" "&重试" ::msgcat::mcset zh_cn "Sample" "样式" ::msgcat::mcset zh_cn "&Save" "&保存" ::msgcat::mcset zh_cn "Save As" "另存为" ::msgcat::mcset zh_cn "Save To Log" "保存到日志" ::msgcat::mcset zh_cn "Select Log File" "选择日志文件" ::msgcat::mcset zh_cn "Select a file to source" "选择一个源文件" ::msgcat::mcset zh_cn "&Selection:" "&选择:" ::msgcat::mcset zh_cn "&Size:" "&大小:" ::msgcat::mcset zh_cn "Show &Hidden Directories" "显示&隐藏目录" ::msgcat::mcset zh_cn "Show &Hidden Files and Directories" "显示&隐藏文件和目录" ::msgcat::mcset zh_cn "Skip Messages" "跳过信息" ::msgcat::mcset zh_cn "&Source..." "&来源……" ::msgcat::mcset zh_cn "Stri&keout" "删&除线" ::msgcat::mcset zh_cn "Tcl Scripts" "Tcl脚本" ::msgcat::mcset zh_cn "Tcl for Windows" "适用于Windows的Tcl" ::msgcat::mcset zh_cn "Text Files" "文本文档" ::msgcat::mcset zh_cn "&Underline" "&下划线" ::msgcat::mcset zh_cn "&Yes" "&确定" ::msgcat::mcset zh_cn "abort" "中止" ::msgcat::mcset zh_cn "blue" "蓝色" ::msgcat::mcset zh_cn "cancel" "取消" ::msgcat::mcset zh_cn "extension" "拓展" ::msgcat::mcset zh_cn "extensions" "拓展" ::msgcat::mcset zh_cn "green" "绿色" ::msgcat::mcset zh_cn "ignore" "忽略" ::msgcat::mcset zh_cn "ok" "确定" ::msgcat::mcset zh_cn "red" "红色" ::msgcat::mcset zh_cn "retry" "重试" ::msgcat::mcset zh_cn "yes" "确认" } #Kevin Walzer通过微软翻译对打印内容进行本地化 localization of print terms by Kevin Walzer via Microsoft Translator namespace eval ::tk { ::msgcat::mcset zh_cn "Print" "输出" ::msgcat::mcset zh_cn "Printer" "输出器" ::msgcat::mcset zh_cn "Letter " "信 " ::msgcat::mcset zh_cn "Legal " "合法的 " ::msgcat::mcset zh_cn "A4" "A4" ::msgcat::mcset zh_cn "Grayscale" "灰度" ::msgcat::mcset zh_cn "RGB" "RGB" ::msgcat::mcset zh_cn "Options" "设置" ::msgcat::mcset zh_cn "Copies" "复制" ::msgcat::mcset zh_cn "Paper" "纸" ::msgcat::mcset zh_cn "Scale" "规模" ::msgcat::mcset zh_cn "Orientation" "方向" ::msgcat::mcset zh_cn "Portrait" "竖向" ::msgcat::mcset zh_cn "Landscape" "横向" ::msgcat::mcset zh_cn "Output" "输出" } |
Changes to library/optMenu.tcl.
︙ | ︙ | |||
33 34 35 36 37 38 39 | } menubutton $w -textvariable $varName -indicatoron 1 -menu $w.menu \ -relief raised -highlightthickness 1 -anchor c \ -direction flush menu $w.menu -tearoff 0 $w.menu add radiobutton -label $firstValue -variable $varName foreach i $args { | | | 33 34 35 36 37 38 39 40 41 42 43 | } menubutton $w -textvariable $varName -indicatoron 1 -menu $w.menu \ -relief raised -highlightthickness 1 -anchor c \ -direction flush menu $w.menu -tearoff 0 $w.menu add radiobutton -label $firstValue -variable $varName foreach i $args { $w.menu add radiobutton -label $i -variable $varName } return $w.menu } |
Added library/print.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 | # print.tcl -- # This file defines the 'tk print' command for printing of the canvas # widget and text on X11, Windows, and macOS. It implements an abstraction # layer that presents a consistent API across the three platforms. # Copyright © 2009 Michael I. Schwartz. # Copyright © 2021 Kevin Walzer/WordTech Communications LLC. # Copyright © 2021 Harald Oehlmann, Elmicron GmbH # Copyright © 2022 Emiliano Gavilan # # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. namespace eval ::tk::print { namespace import -force ::tk::msgcat::* # makeTempFile: # Create a temporary file and populate its contents # Arguments: # filename - base of the name of the file to create # contents - what to put in the file; defaults to empty # Returns: # Full filename for created file # proc makeTempFile {filename {contents ""}} { set f [file tempfile filename $filename] try { puts -nonewline $f $contents return $filename } finally { close $f } } if {[tk windowingsystem] eq "win32"} { variable printer_name variable copies variable dpi_x variable dpi_y variable paper_width variable paper_height variable margin_left variable margin_top variable printargs array set printargs {} # Multiple utility procedures for printing text based on the # C printer primitives. # _set_dc: # Select printer and set device context and other parameters # for print job. # proc _set_dc {} { variable printargs variable printer_name variable paper_width variable paper_height variable dpi_x variable dpi_y variable copies #First, we select the printer. _selectprinter #Next, set values. Some are taken from the printer, #some are sane defaults. if {[info exists printer_name] && $printer_name ne ""} { set printargs(hDC) $printer_name set printargs(pw) $paper_width set printargs(pl) $paper_height set printargs(lm) 1000 set printargs(tm) 1000 set printargs(rm) 1000 set printargs(bm) 1000 set printargs(resx) $dpi_x set printargs(resy) $dpi_y set printargs(copies) $copies set printargs(resolution) [list $dpi_x $dpi_y] } } # _print_data # This function prints multiple-page files, using a line-oriented # function, taking advantage of knowing the character widths. # Arguments: # data - Text data for printing # breaklines - If non-zero, keep newlines in the string as # newlines in the output. # font - Font for printing proc _print_data {data {breaklines 1} {font ""}} { variable printargs variable printer_name _set_dc if {![info exists printer_name]} { return } if {$font eq ""} { _gdi characters $printargs(hDC) -array printcharwid } else { _gdi characters $printargs(hDC) -font $font -array printcharwid } set pagewid [expr {($printargs(pw) - $printargs(rm) ) / 1000 * $printargs(resx)}] set pagehgt [expr {($printargs(pl) - $printargs(bm) ) / 1000 * $printargs(resy)}] set totallen [string length $data] set curlen 0 set curhgt [expr {$printargs(tm) * $printargs(resy) / 1000}] _opendoc _openpage while {$curlen < $totallen} { set linestring [string range $data $curlen end] if {$breaklines} { set endind [string first "\n" $linestring] if {$endind >= 0} { set linestring [string range $linestring 0 $endind] # handle blank lines.... if {$linestring eq ""} { set linestring " " } } } set result [_print_page_nextline $linestring \ printcharwid printargs $curhgt $font] incr curlen [lindex $result 0] incr curhgt [lindex $result 1] if {$curhgt + [lindex $result 1] > $pagehgt} { _closepage _openpage set curhgt [expr {$printargs(tm) * $printargs(resy) / 1000}] } } _closepage _closedoc } # _print_file # This function prints multiple-page files # It will either break lines or just let them run over the # margins (and thus truncate). # The font argument is JUST the font name, not any additional # arguments. # Arguments: # filename - File to open for printing # breaklines - 1 to break lines as done on input, 0 to ignore newlines # font - Optional arguments to supply to the text command proc _print_file {filename {breaklines 1} {font ""}} { set fn [open $filename r] set data [read $fn] close $fn _print_data $data $breaklines $font } # _print_page_nextline # Returns the pair "chars y" # where chars is the number of characters printed on the line # and y is the height of the line printed # Arguments: # string - Data to print # pdata - Array of values for printer characteristics # cdata - Array of values for character widths # y - Y value to begin printing at # font - if non-empty specifies a font to draw the line in proc _print_page_nextline {string carray parray y font} { upvar #0 $carray charwidths upvar #0 $parray printargs variable printargs set endindex 0 set totwidth 0 set maxwidth [expr { (($printargs(pw) - $printargs(rm)) / 1000) * $printargs(resx) }] set maxstring [string length $string] set lm [expr {$printargs(lm) * $printargs(resx) / 1000}] for {set i 0} {($i < $maxstring) && ($totwidth < $maxwidth)} {incr i} { incr totwidth $charwidths([string index $string $i]) # set width($i) $totwidth } set endindex $i set startindex $endindex if {$i < $maxstring} { # In this case, the whole data string is not used up, and we # wish to break on a word. Since we have all the partial # widths calculated, this should be easy. set endindex [expr {[string wordstart $string $endindex] - 1}] set startindex [expr {$endindex + 1}] # If the line is just too long (no word breaks), print as much # as you can.... if {$endindex <= 1} { set endindex $i set startindex $i } } set txt [string trim [string range $string 0 $endindex] "\r\n"] if {$font ne ""} { set result [_gdi text $printargs(hDC) $lm $y \ -anchor nw -justify left \ -text $txt -font $font] } else { set result [_gdi text $printargs(hDC) $lm $y \ -anchor nw -justify left -text $txt] } return "$startindex $result" } # These procedures read in the canvas widget, and write all of # its contents out to the Windows printer. variable option variable vtgPrint proc _init_print_canvas {} { variable option variable vtgPrint variable printargs set vtgPrint(printer.bg) white } proc _is_win {} { variable printargs return [info exist tk_patchLevel] } # _print_widget # Main procedure for printing a widget. Currently supports # canvas widgets. Handles opening and closing of printer. # Arguments: # wid - The widget to be printed. # printer - Flag whether to use the default printer. # name - App name to pass to printer. proc _print_widget {wid {printer default} {name "Tk Print Output"}} { variable printargs variable printer_name _set_dc if {![info exists printer_name]} { return } _opendoc _openpage # Here is where any scaling/gdi mapping should take place # For now, scale so the dimensions of the window are sized to the # width of the page. Scale evenly. # For normal windows, this may be fine--but for a canvas, one # wants the canvas dimensions, and not the WINDOW dimensions. if {[winfo class $wid] eq "Canvas"} { set sc [$wid cget -scrollregion] # if there is no scrollregion, use width and height. if {$sc eq ""} { set window_x [$wid cget -width] set window_y [$wid cget -height] } else { set window_x [lindex $sc 2] set window_y [lindex $sc 3] } } else { set window_x [winfo width $wid] set window_y [winfo height $wid] } set printer_x [expr { ( $printargs(pw) - $printargs(lm) - $printargs(rm) ) * $printargs(resx) / 1000.0 }] set printer_y [expr { ( $printargs(pl) - $printargs(tm) - $printargs(bm) ) * $printargs(resy) / 1000.0 }] set factor_x [expr {$window_x / $printer_x}] set factor_y [expr {$window_y / $printer_y}] if {$factor_x < $factor_y} { set lo $window_y set ph $printer_y } else { set lo $window_x set ph $printer_x } _gdi map $printargs(hDC) -logical $lo -physical $ph \ -offset $printargs(resolution) # Handling of canvas widgets. switch [winfo class $wid] { Canvas { _print_canvas $printargs(hDC) $wid } default { puts "Can't print items of type [winfo class $wid]. No handler registered" } } # End printing process. _closepage _closedoc } # _print_canvas # Main procedure for writing canvas widget items to printer. # Arguments: # hdc - The printer handle. # cw - The canvas widget. proc _print_canvas {hdc cw} { variable vtgPrint variable printargs # Get information about page being printed to # print_canvas.CalcSizing $cw set vtgPrint(canvas.bg) [string tolower [$cw cget -background]] # Re-write each widget from cw to printer foreach id [$cw find all] { set type [$cw type $id] if {[info commands _print_canvas.$type] eq "_print_canvas.$type"} { _print_canvas.[$cw type $id] $printargs(hDC) $cw $id } else { puts "Omitting canvas item of type $type since there is no handler registered for it" } } } # These procedures support the various canvas item types, reading the # information about the item on the real canvas and then writing a # similar item to the printer. # _print_canvas.line # Description: # Prints a line item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.line {hdc cw id} { variable vtgPrint variable printargs set color [_print_canvas.TransColor [$cw itemcget $id -fill]] if {[string match $vtgPrint(printer.bg) $color]} { return } set coords [$cw coords $id] set wdth [$cw itemcget $id -width] set arrow [$cw itemcget $id -arrow] set arwshp [$cw itemcget $id -arrowshape] set dash [$cw itemcget $id -dash] set smooth [$cw itemcget $id -smooth] set splinesteps [$cw itemcget $id -splinesteps] set cmdargs {} if {$wdth > 1} { lappend cmdargs -width $wdth } if {$dash ne ""} { lappend cmdargs -dash $dash } if {$smooth ne ""} { lappend cmdargs -smooth $smooth } if {$splinesteps ne ""} { lappend cmdargs -splinesteps $splinesteps } set result [_gdi line $hdc {*}$coords \ -fill $color -arrow $arrow -arrowshape $arwshp \ {*}$cmdargs] if {$result ne ""} { puts $result } } # _print_canvas.arc # Prints a arc item. # Args: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.arc {hdc cw id} { variable vtgPrint variable printargs set color [_print_canvas.TransColor [$cw itemcget $id -outline]] if {[string match $vtgPrint(printer.bg) $color]} { return } set coords [$cw coords $id] set wdth [$cw itemcget $id -width] set style [$cw itemcget $id -style] set start [$cw itemcget $id -start] set extent [$cw itemcget $id -extent] set fill [$cw itemcget $id -fill] set cmdargs {} if {$wdth > 1} { lappend cmdargs -width $wdth } if {$fill ne ""} { lappend cmdargs -fill $fill } _gdi arc $hdc {*}$coords \ -outline $color -style $style -start $start -extent $extent \ {*}$cmdargs } # _print_canvas.polygon # Prints a polygon item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.polygon {hdc cw id} { variable vtgPrint variable printargs set fcolor [_print_canvas.TransColor [$cw itemcget $id -fill]] if {$fcolor eq ""} { set fcolor $vtgPrint(printer.bg) } set ocolor [_print_canvas.TransColor [$cw itemcget $id -outline]] if {$ocolor eq ""} { set ocolor $vtgPrint(printer.bg) } set coords [$cw coords $id] set wdth [$cw itemcget $id -width] set smooth [$cw itemcget $id -smooth] set splinesteps [$cw itemcget $id -splinesteps] set cmdargs {} if {$smooth ne ""} { lappend cmdargs -smooth $smooth } if {$splinesteps ne ""} { lappend cmdargs -splinesteps $splinesteps } _gdi polygon $hdc {*}$coords \ -width $wdth -fill $fcolor -outline $ocolor {*}$cmdargs } # _print_canvas.oval # Prints an oval item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.oval {hdc cw id} { variable vtgPrint set fcolor [_print_canvas.TransColor [$cw itemcget $id -fill]] if {$fcolor eq ""} { set fcolor $vtgPrint(printer.bg) } set ocolor [_print_canvas.TransColor [$cw itemcget $id -outline]] if {$ocolor eq ""} { set ocolor $vtgPrint(printer.bg) } set coords [$cw coords $id] set wdth [$cw itemcget $id -width] _gdi oval $hdc {*}$coords \ -width $wdth -fill $fcolor -outline $ocolor } # _print_canvas.rectangle # Prints a rectangle item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.rectangle {hdc cw id} { variable vtgPrint set fcolor [_print_canvas.TransColor [$cw itemcget $id -fill]] if {$fcolor eq ""} { set fcolor $vtgPrint(printer.bg) } set ocolor [_print_canvas.TransColor [$cw itemcget $id -outline]] if {$ocolor eq ""} { set ocolor $vtgPrint(printer.bg) } set coords [$cw coords $id] set wdth [$cw itemcget $id -width] _gdi rectangle $hdc {*}$coords \ -width $wdth -fill $fcolor -outline $ocolor } # _print_canvas.text # Prints a text item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.text {hdc cw id} { variable vtgPrint variable printargs set color [_print_canvas.TransColor [$cw itemcget $id -fill]] # if {"white" eq [string tolower $color]} {return} # set color black set txt [$cw itemcget $id -text] if {$txt eq ""} { return } set coords [$cw coords $id] set anchr [$cw itemcget $id -anchor] set bbox [$cw bbox $id] set wdth [expr {[lindex $bbox 2] - [lindex $bbox 0]}] set just [$cw itemcget $id -justify] # Get the real canvas font info and create a compatible font, # suitable for printer name extraction. set font [font create {*}[font actual [$cw itemcget $id -font]]] # Just get the name and family, or some of the _gdi commands will # fail. set font [list [font configure $font -family] \ -[font configure $font -size]] _gdi text $hdc {*}$coords \ -fill $color -text $txt -font $font \ -anchor $anchr -width $wdth -justify $just } # _print_canvas.image # Prints an image item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.image {hdc cw id} { # First, we have to get the image name. set imagename [$cw itemcget $id -image] # Now we get the size. set wid [image width $imagename] set hgt [image height $imagename] # Next, we get the location and anchor set anchor [$cw itemcget $id -anchor] set coords [$cw coords $id] _gdi photo $hdc -destination $coords -photo $imagename } # _print_canvas.bitmap # Prints a bitmap item. # Arguments: # hdc - The printer handle. # cw - The canvas widget. # id - The id of the canvas item. proc _print_canvas.bitmap {hdc cw id} { variable option variable vtgPrint # First, we have to get the bitmap name. set imagename [$cw itemcget $id -image] # Now we get the size. set wid [image width $imagename] set hgt [image height $imagename] #Next, we get the location and anchor. set anchor [$cw itemcget $id -anchor] set coords [$cw coords $id] # Since the GDI commands don't yet support images and bitmaps, # and since this represents a rendered bitmap, we CAN use # copybits IF we create a new temporary toplevel to hold the beast. # If this is too ugly, change the option! if {[info exist option(use_copybits)]} { set firstcase $option(use_copybits) } else { set firstcase 0 } if {$firstcase > 0} { set tl [toplevel .tmptop[expr {int( rand() * 65535 )}] \ -height $hgt -width $wid \ -background $vtgPrint(canvas.bg)] canvas $tl.canvas -width $wid -height $hgt $tl.canvas create image 0 0 -image $imagename -anchor nw pack $tl.canvas -side left -expand false -fill none tkwait visibility $tl.canvas update set srccoords [list 0 0 [expr {$wid - 1}] [expr {$hgt - 1}]] set dstcoords [list [lindex $coords 0] [lindex $coords 1] [expr {$wid - 1}] [expr {$hgt - 1}]] _gdi copybits $hdc -window $tl -client \ -source $srccoords -destination $dstcoords destroy $tl } else { _gdi bitmap $hdc {*}$coords \ -anchor $anchor -bitmap $imagename } } # These procedures transform attribute setting from the real # canvas to the appropriate setting for printing to paper. # _print_canvas.TransColor # Does the actual transformation of colors from the # canvas widget to paper. # Arguments: # color - The color value to be transformed. proc _print_canvas.TransColor {color} { variable vtgPrint variable printargs switch [string toupper $color] { $vtgPrint(canvas.bg) {return $vtgPrint(printer.bg)} } return $color } # Initialize all the variables once. _init_print_canvas } #end win32 procedures #begin X11 procedures # X11 procedures wrap standard Unix shell commands such as lp/lpr and # lpstat for printing. Some output configuration that on other platforms # is managed through the printer driver/dialog is configured through the # canvas postscript command. if {[tk windowingsystem] eq "x11"} { variable printcmd {} # print options variable optlist set optlist(printer) {} set optlist(paper) [list [mc "Letter"] [mc "Legal"] [mc "A4"]] set optlist(orient) [list [mc "Portrait"] [mc "Landscape"]] set optlist(color) [list [mc "Grayscale"] [mc "RGB"]] set optlist(zoom) {100 90 80 70 60 50 40 30 20 10} # selected options variable sel array set sel { printer {} copies {} paper {} orient {} color {} zoom {} } # default values for dialog widgets option add *Printdialog*TLabel.anchor e option add *Printdialog*TMenubutton.Menu.tearOff 0 option add *Printdialog*TMenubutton.width 12 option add *Printdialog*TSpinbox.width 12 # this is tempting to add, but it's better to leave it to user's taste # option add *Printdialog*Menu.background snow # returns the full qualified var name proc myvar {varname} { set fqvar [uplevel 1 [list namespace which -variable $varname]] # assert var existence if {$fqvar eq ""} { return -code error "Wrong varname \"$varname\"" } return $fqvar } # ttk version of [tk_optionMenu] # var should be a full qualified varname proc ttk_optionMenu {w var args} { ttk::menubutton $w \ -textvariable $var \ -menu $w.menu menu $w.menu foreach option $args { $w.menu add command \ -label $option \ -command [list set $var $option] } # return the same value as tk_optionMenu return $w.menu } # _setprintenv # Set the print environtment - print command, and list of printers. # Arguments: # none. proc _setprintenv {} { variable printcmd variable optlist #Test for existence of lpstat command to obtain list of printers. Return error #if not found. catch {exec lpstat -a} msg set notfound "command not found" if {[string first $notfound $msg] >= 0} { error "Unable to obtain list of printers. Please install the CUPS package \ for your system." return } set notfound "No destinations added" if {[string first $notfound $msg] != -1} { error "Please check or update your CUPS installation." return } # Select print command. We prefer lpr, but will fall back to lp if # necessary. if {[auto_execok lpr] ne ""} { set printcmd lpr } else { set printcmd lp } #Build list of printers set printers {} set printdata [exec lpstat -a] foreach item [split $printdata \n] { lappend printers [lindex [split $item] 0] } # filter out duplicates set optlist(printer) [lsort -unique $printers] } # _print # Main printer dialog. Select printer, set options, and # fire print command. # Arguments: # w - widget with contents to print. # proc _print {w} { # TODO: revise padding variable optlist variable sel # should this be called with every invocaton? _setprintenv if {$sel(printer) eq "" && [llength $optlist(printer)] > 0} { set sel(printer) [lindex $optlist(printer) 0] } set p ._print catch {destroy $p} # copy the current values to a dialog's temorary variable # this allow us to cancel the dialog discarding any changes # made to the options namespace eval dlg {variable sel} array set dlg::sel [array get sel] # The toplevel of our dialog toplevel $p -class Printdialog place [ttk::frame $p.background] -x 0 -y 0 -relwidth 1.0 -relheight 1.0 wm title $p [mc "Print"] wm resizable $p 0 0 wm attributes $p -type dialog # The printer to use set pf [ttk::frame $p.printerf] pack $pf -side top -fill x -expand no -padx 12 -pady 12 ttk::label $pf.printerl -text "[mc "Printer"] :" ttk::combobox $pf.printer \ -textvariable [myvar dlg::sel](printer) \ -state readonly \ -values $optlist(printer) pack $pf.printerl -side left -padx {0 6} pack $pf.printer -side left # Start of printing options set of [ttk::labelframe $p.optionsframe -text [mc "Options"]] pack $of -fill x -padx 12 -pady {0 12} -ipadx 3 -ipady 3 # COPIES ttk::label $of.copiesl -text "[mc "Copies"] :" ttk::spinbox $of.copies -from 1 -to 1000 \ -textvariable [myvar dlg::sel](copies) \ -width 5 grid $of.copiesl $of.copies -sticky ew -padx 3 -pady 3 # PAPER SIZE ttk::label $of.paperl -text "[mc "Paper"] :" ttk_optionMenu $of.paper [myvar dlg::sel](paper) {*}$optlist(paper) grid $of.paperl $of.paper -sticky ew -padx 3 -pady 3 # additional options for canvas output if {[winfo class $w] eq "Canvas"} { # SCALE ttk::label $of.percentl -text "[mc "Scale"] :" ttk_optionMenu $of.percent [myvar dlg::sel](zoom) {*}$optlist(zoom) grid $of.percentl $of.percent -sticky ew -padx 3 -pady 3 # ORIENT ttk::label $of.orientl -text "[mc "Orientation"] :" ttk_optionMenu $of.orient [myvar dlg::sel](orient) {*}$optlist(orient) grid $of.orientl $of.orient -sticky ew -padx 3 -pady 3 # COLOR ttk::label $of.colorl -text "[mc "Output"] :" ttk_optionMenu $of.color [myvar dlg::sel](color) {*}$optlist(color) grid $of.colorl $of.color -sticky ew -padx 3 -pady 3 } # The buttons frame. set bf [ttk::frame $p.buttonf] pack $bf -fill x -expand no -side bottom -padx 12 -pady {0 12} ttk::button $bf.print -text [mc "Print"] \ -command [namespace code [list _runprint $w $p]] ttk::button $bf.cancel -text [mc "Cancel"] \ -command [namespace code [list _cancel $p]] pack $bf.print -side right pack $bf.cancel -side right -padx {0 6} #Center the window as a dialog. ::tk::PlaceWindow $p } proc _cancel {p} { namespace delete dlg destroy $p } # _runprint - # Execute the print command--print the file. # Arguments: # w - widget with contents to print. # proc _runprint {w p} { variable printcmd variable sel # copy the values back from the dialog array set sel [array get dlg::sel] namespace delete dlg #First, generate print file. if {[winfo class $w] eq "Text"} { set file [makeTempFile tk_text.txt [$w get 1.0 end]] } if {[winfo class $w] eq "Canvas"} { if {$sel(color) eq [mc "RGB"]} { set colormode color } else { set colormode gray } if {$sel(orient) eq [mc "Landscape"]} { set willrotate "1" } else { set willrotate "0" } #Scale based on size of widget, not size of paper. set printwidth [expr {$sel(zoom) / 100.00 * [winfo width $w]}] set file [makeTempFile tk_canvas.ps] $w postscript -file $file -colormode $colormode \ -rotate $willrotate -pagewidth $printwidth } #Build list of args to pass to print command. set printargs {} if {$printcmd eq "lpr"} { lappend printargs -P $sel(printer) -# $sel(copies) } else { lappend printargs -d $sel(printer) -n $sel(copies) } # launch the job in the background after 0 [list exec $printcmd {*}$printargs -o PageSize=$sel(paper) $file] destroy $p } # Initialize with sane defaults. set sel(copies) 1 set sel(paper) [mc "A4"] set sel(orient) [mc "Portrait"] set sel(color) [mc "RGB"] set sel(zoom) 100 } #end X11 procedures #begin macOS Aqua procedures if {[tk windowingsystem] eq "aqua"} { # makePDF - # Convert a file to PDF # Arguments: # inFilename - file containing the data to convert; format is # autodetected. # outFilename - base for filename to write to; conventionally should # have .pdf as suffix # Returns: # The full pathname of the generated PDF. # proc makePDF {inFilename outFilename} { set out [::tk::print::makeTempFile $outFilename] try { exec /usr/sbin/cupsfilter $inFilename > $out } trap NONE {msg} { # cupsfilter produces a lot of debugging output, which we # don't want. regsub -all -line {^(?:DEBUG|INFO):.*$} $msg "" msg set msg [string trimleft [regsub -all {\n+} $msg "\n"] "\n"] if {$msg ne ""} { # Lines should be prefixed with WARN or ERROR now puts $msg } } return $out } } #end macOS Aqua procedures namespace export canvas text namespace ensemble create } # tk print -- # This procedure prints the canvas and text widgets using platform- # native API's. # Arguments: # w: Widget to print. proc ::tk::print {w} { switch [winfo class $w],[tk windowingsystem] { "Canvas,win32" { tailcall ::tk::print::_print_widget $w 0 "Tk Print Output" } "Canvas,x11" { tailcall ::tk::print::_print $w } "Canvas,aqua" { set psfile [::tk::print::makeTempFile tk_canvas.ps] try { $w postscript -file $psfile set printfile [::tk::print::makePDF $psfile tk_canvas.pdf] ::tk::print::_print $printfile } finally { file delete $psfile } } "Text,win32" { tailcall ::tk::print::_print_data [$w get 1.0 end] 1 {Arial 12} } "Text,x11" { tailcall ::tk::print::_print $w } "Text,aqua" { set txtfile [::tk::print::makeTempFile tk_text.txt [$w get 1.0 end]] try { set printfile [::tk::print::makePDF $txtfile tk_text.pdf] ::tk::print::_print $printfile } finally { file delete $txtfile } } default { return -code error -errorcode {TK PRINT CLASS_UNSUPPORTED} \ "widgets of class [winfo class $w] are not supported on\ this platform" } } } #Add this command to the tk command ensemble: tk print #Thanks to Christian Gollwitzer for the guidance here namespace ensemble configure tk -map \ [dict merge [namespace ensemble configure tk -map] \ {print ::tk::print}] return # Local Variables: # mode: tcl # fill-column: 78 # End: |
Changes to library/scale.tcl.
︙ | ︙ | |||
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | # repeat - Whether and how to auto-repeat the action: "noRepeat" # means don't auto-repeat, "initial" means this is the # first action in an auto-repeat sequence, and "again" # means this is the second repetition or later. proc ::tk::ScaleIncrement {w dir big repeat} { variable ::tk::Priv if {![winfo exists $w]} return if {$big eq "big"} { set inc [$w cget -bigincrement] if {$inc == 0} { set inc [expr {abs([$w cget -to] - [$w cget -from])/10.0}] } if {$inc < [$w cget -resolution]} { set inc [$w cget -resolution] } } else { set inc [$w cget -resolution] } if {([$w cget -from] > [$w cget -to]) ^ ($dir eq "up")} { if {$inc > 0} { set inc [expr {-$inc}] } } else { if {$inc < 0} { set inc [expr {-$inc}] } } $w set [expr {[$w get] + $inc}] if {$repeat eq "again"} { set Priv(afterId) [after [$w cget -repeatinterval] \ [list tk::ScaleIncrement $w $dir $big again]] } elseif {$repeat eq "initial"} { set delay [$w cget -repeatdelay] if {$delay > 0} { set Priv(afterId) [after $delay \ [list tk::ScaleIncrement $w $dir $big again]] } } } # ::tk::ScaleControlPress -- | > > > > > > > > > > > > > > > > > | 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | # repeat - Whether and how to auto-repeat the action: "noRepeat" # means don't auto-repeat, "initial" means this is the # first action in an auto-repeat sequence, and "again" # means this is the second repetition or later. proc ::tk::ScaleIncrement {w dir big repeat} { variable ::tk::Priv if {![winfo exists $w]} return # give the cancel callback a chance to be serviced if the execution time of # the -command script lasts longer than -repeatdelay set clockms [clock milliseconds] if {$repeat eq "again" && [expr {$clockms - $Priv(clockms)}] > [expr {[$w cget -repeatinterval] * 1.1}]} { set Priv(clockms) $clockms set Priv(afterId) [after [$w cget -repeatinterval] \ [list tk::ScaleIncrement $w $dir $big again]] return } if {$big eq "big"} { set inc [$w cget -bigincrement] if {$inc == 0} { set inc [expr {abs([$w cget -to] - [$w cget -from])/10.0}] } if {$inc < [$w cget -resolution]} { set inc [$w cget -resolution] } } else { set inc [$w cget -resolution] } if {([$w cget -from] > [$w cget -to]) ^ ($dir eq "up")} { if {$inc > 0} { set inc [expr {-$inc}] } } else { if {$inc < 0} { set inc [expr {-$inc}] } } # this will run the -command script (if any) during the redrawing # of the scale at idle time $w set [expr {[$w get] + $inc}] if {$repeat eq "again"} { set Priv(clockms) $clockms set Priv(afterId) [after [$w cget -repeatinterval] \ [list tk::ScaleIncrement $w $dir $big again]] } elseif {$repeat eq "initial"} { set delay [$w cget -repeatdelay] if {$delay > 0} { set Priv(clockms) $clockms set Priv(afterId) [after $delay \ [list tk::ScaleIncrement $w $dir $big again]] } } } # ::tk::ScaleControlPress -- |
︙ | ︙ |
Changes to library/scrlbar.tcl.
︙ | ︙ | |||
126 127 128 129 130 131 132 | } bind Scrollbar <<LineEnd>> { tk::ScrollToPos %W 1 } } bind Scrollbar <MouseWheel> { | | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | } bind Scrollbar <<LineEnd>> { tk::ScrollToPos %W 1 } } bind Scrollbar <MouseWheel> { tk::ScrollByUnits %W hv %D -40.0 } bind Scrollbar <Option-MouseWheel> { 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 # depending on where the mouse is. # |
︙ | ︙ |
Changes to library/spinbox.tcl.
︙ | ︙ | |||
125 126 127 128 129 130 131 | %W invoke buttonup } bind Spinbox <<NextLine>> { %W invoke buttondown } bind Spinbox <<PrevChar>> { | | | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | %W invoke buttonup } bind Spinbox <<NextLine>> { %W invoke buttondown } bind Spinbox <<PrevChar>> { ::tk::EntrySetCursor %W [tk::EntryPreviousChar %W insert] } bind Spinbox <<NextChar>> { ::tk::EntrySetCursor %W [tk::EntryNextChar %W insert] } bind Spinbox <<SelectPrevChar>> { ::tk::EntryKeySelect %W [tk::EntryPreviousChar %W insert] ::tk::EntrySeeInsert %W } bind Spinbox <<SelectNextChar>> { ::tk::EntryKeySelect %W [tk::EntryNextChar %W insert] ::tk::EntrySeeInsert %W } bind Spinbox <<PrevWord>> { ::tk::EntrySetCursor %W [::tk::EntryPreviousWord %W insert] } bind Spinbox <<NextWord>> { ::tk::EntrySetCursor %W [::tk::EntryNextWord %W insert] |
︙ | ︙ | |||
171 172 173 174 175 176 177 | ::tk::EntrySeeInsert %W } bind Spinbox <Delete> { if {[%W selection present]} { %W delete sel.first sel.last } else { | | > | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | ::tk::EntrySeeInsert %W } bind Spinbox <Delete> { if {[%W selection present]} { %W delete sel.first sel.last } else { %W delete [tk::startOfCluster [%W get] [%W index insert]] \ [tk::endOfGlyphCluster [%W get] [%W index insert]] } } bind Spinbox <BackSpace> { ::tk::EntryBackspace %W } bind Spinbox <Control-space> { |
︙ | ︙ | |||
200 201 202 203 204 205 206 | bind Spinbox <<SelectNone>> { %W selection clear } bind Spinbox <Key> { ::tk::EntryInsert %W %A } | | < | < > | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 | bind Spinbox <<SelectNone>> { %W selection clear } bind Spinbox <Key> { ::tk::EntryInsert %W %A } # Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the # <Key> class binding will also fire and insert the character, # which is wrong. Ditto for Escape, Return, and Tab. bind Spinbox <Alt-Key> {# nothing} bind Spinbox <Meta-Key> {# nothing} bind Spinbox <Control-Key> {# nothing} bind Spinbox <Escape> {# nothing} bind Spinbox <Return> {# nothing} bind Spinbox <KP_Enter> {# nothing} bind Spinbox <Tab> {# nothing} bind Spinbox <Prior> {# nothing} bind Spinbox <Next> {# nothing} bind Spinbox <Command-Key> {# nothing} bind Spinbox <Fn-Key> {# nothing} # On Windows, paste is done using Shift-Insert. Shift-Insert already # generates the <<Paste>> event, so we don't need to do anything here. if {[tk windowingsystem] ne "win32"} { bind Spinbox <Insert> { catch {::tk::EntryInsert %W [::tk::GetSelection %W PRIMARY]} } |
︙ | ︙ | |||
465 466 467 468 469 470 471 | } else { $w selection clear } } } word { if {$cur < [$w index anchor]} { | | | | | | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | } else { $w selection clear } } } word { if {$cur < [$w index anchor]} { set before [tk::wordBreakBefore [$w get] $cur] set after [tk::wordBreakAfter [$w get] $anchor-1] } else { set before [tk::wordBreakBefore [$w get] $anchor] set after [tk::wordBreakAfter [$w get] $cur-1] } if {$before < 0} { set before 0 } if {$after < 0} { set after end } |
︙ | ︙ |
Added library/systray.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | # 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 <Any-Enter> "after 100 [list [namespace current]::_balloon_show %W [list $help] cursor]" bind $w <Any-Leave> "destroy %W._balloon" } proc _balloon_show {w msg i} { if {![winfo exists $w]} { return } # Use string match to allow that the help will be shown when # the pointer is in any child of the desired widget if {([winfo class $w] ne "Menu") && ![string match $w* [eval [list winfo containing] \ [winfo pointerxy $w]]]} { return } set top $w._balloon catch {destroy $top} toplevel $top -bg black -bd 1 wm overrideredirect $top 1 if {[tk windowingsystem] eq "aqua"} { ::tk::unsupported::MacWindowStyle style $top help none } pack [message $top._txt -aspect 10000 -text $msg] update idletasks set screenw [winfo screenwidth $w] set screenh [winfo screenheight $w] set reqw [winfo reqwidth $top] set reqh [winfo reqheight $top] # When adjusting for being on the screen boundary, check that we are # near the "edge" already, as Tk handles multiple monitors oddly if {$i eq "cursor"} { set y [expr {[winfo pointery $w]+20}] if {($y < $screenh) && ($y+$reqh) > $screenh} { set y [expr {[winfo pointery $w]-$reqh-5}] } } elseif {$i ne ""} { set y [expr {[winfo rooty $w]+[winfo vrooty $w]+[$w yposition $i]+25}] if {($y < $screenh) && ($y+$reqh) > $screenh} { # show above if we would be offscreen set y [expr {[winfo rooty $w]+[$w yposition $i]-$reqh-5}] } } else { set y [expr {[winfo rooty $w]+[winfo vrooty $w]+[winfo height $w]+5}] if {($y < $screenh) && ($y+$reqh) > $screenh} { # show above if we would be offscreen set y [expr {[winfo rooty $w]-$reqh-5}] } } if {$i eq "cursor"} { set x [winfo pointerx $w] } else { set x [expr {[winfo rootx $w]+[winfo vrootx $w]+ ([winfo width $w]-$reqw)/2}] } # only readjust when we would appear right on the screen edge if {$x<0 && ($x+$reqw)>0} { set x 0 } elseif {($x < $screenw) && ($x+$reqw) > $screenw} { set x [expr {$screenw-$reqw}] } if {[tk windowingsystem] eq "aqua"} { set focus [focus] } wm geometry $top +$x+$y wm deiconify $top raise $top if {[tk windowingsystem] eq "aqua" && $focus ne ""} { # Aqua's help window steals focus on display after idle [list focus -force $focus] } } 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 <Button-1> event. # -button3 - Tcl proc to invoke on <Button-3> 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 <Button-1> event. # -button3 - Tcl proc to change for <Button-3> 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 <Button-1> [dict get $values -button1] bind ._tray <Button-3> [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 <Button-1> [dict get $args -button1] } if {[dict exists $args -button3]} { bind ._tray <Button-3> [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 namespace ensemble configure tk -map \ [dict merge [namespace ensemble configure tk -map] \ {systray ::tk::systray sysnotify ::tk::sysnotify::sysnotify}] |
Changes to library/tearoff.tcl.
︙ | ︙ | |||
27 28 29 30 31 32 33 | # the parent of the new menu. This guarantees that the torn off # menu will be on the same screen as the original menu. By making # it a child of the ancestor, rather than a child of the menu, it # can continue to live even if the menu is deleted; it will go # away when the toplevel goes away. if {$x == 0} { | | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # the parent of the new menu. This guarantees that the torn off # menu will be on the same screen as the original menu. By making # it a child of the ancestor, rather than a child of the menu, it # can continue to live even if the menu is deleted; it will go # away when the toplevel goes away. if {$x == 0} { set x [winfo rootx $w] } if {$y == 0} { 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} } } |
︙ | ︙ | |||
62 63 64 65 66 67 68 | # Pick a title for the new menu by looking at the parent of the # original: if the parent is a menu, then use the text of the active # entry. If it's a menubutton then use its text. set parent [winfo parent $w] if {[$menu cget -title] ne ""} { | | | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # Pick a title for the new menu by looking at the parent of the # original: if the parent is a menu, then use the text of the active # entry. If it's a menubutton then use its text. set parent [winfo parent $w] if {[$menu cget -title] ne ""} { wm title $menu [$menu cget -title] } else { switch -- [winfo class $parent] { Menubutton { wm title $menu [$parent cget -text] } Menu { wm title $menu [$parent entrycget active -label] } } } if {[tk windowingsystem] eq "win32"} { # [Bug 3181181]: Find the toplevel window for the menu set parent [winfo toplevel $parent] |
︙ | ︙ | |||
131 132 133 134 135 136 137 | if {[lindex $option 0] eq "-type"} { continue } lappend cmd [lindex $option 0] [lindex $option 4] } eval $cmd set last [$src index last] | | | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | if {[lindex $option 0] eq "-type"} { continue } lappend cmd [lindex $option 0] [lindex $option 4] } eval $cmd set last [$src index last] if {$last < 0} { return } for {set i [$src cget -tearoff]} {$i <= $last} {incr i} { set cmd [list $dst add [$src type $i]] foreach option [$src entryconfigure $i] { lappend cmd [lindex $option 0] [lindex $option 4] } |
︙ | ︙ |
Changes to library/text.tcl.
1 2 3 4 5 6 7 | # text.tcl -- # # This file defines the default bindings for Tk text widgets and provides # procedures that help in implementing the bindings. # # Copyright © 1992-1994 The Regents of the University of California. # Copyright © 1994-1997 Sun Microsystems, Inc. | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # text.tcl -- # # This file defines the default bindings for Tk text widgets and provides # procedures that help in implementing the bindings. # # 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. # #------------------------------------------------------------------------- # Elements of ::tk::Priv that are used in this file: |
︙ | ︙ | |||
95 96 97 98 99 100 101 | } } # stop an accidental double click triggering <Double-Button-1> bind Text <Double-Control-Button-1> { # nothing } # stop an accidental movement triggering <B1-Motion> bind Text <Control-B1-Motion> { # nothing } bind Text <<PrevChar>> { | | | | | | | | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | } } # stop an accidental double click triggering <Double-Button-1> bind Text <Double-Control-Button-1> { # nothing } # stop an accidental movement triggering <B1-Motion> bind Text <Control-B1-Motion> { # nothing } bind Text <<PrevChar>> { tk::TextSetCursor %W [tk::TextPrevPos %W insert tk::startOfCluster] } bind Text <<NextChar>> { tk::TextSetCursor %W [tk::TextNextPos %W insert tk::endOfCluster] } bind Text <<PrevLine>> { tk::TextSetCursor %W [tk::TextUpDownLine %W -1] } bind Text <<NextLine>> { tk::TextSetCursor %W [tk::TextUpDownLine %W 1] } bind Text <<SelectPrevChar>> { tk::TextKeySelect %W [tk::TextPrevPos %W insert tk::startOfCluster] } bind Text <<SelectNextChar>> { tk::TextKeySelect %W [tk::TextNextPos %W insert tk::endOfCluster] } bind Text <<SelectPrevLine>> { tk::TextKeySelect %W [tk::TextUpDownLine %W -1] } bind Text <<SelectNextLine>> { tk::TextKeySelect %W [tk::TextUpDownLine %W 1] } bind Text <<PrevWord>> { tk::TextSetCursor %W [tk::TextPrevPos %W insert tk::startOfPreviousWord] } bind Text <<NextWord>> { tk::TextSetCursor %W [tk::TextNextWord %W insert] } bind Text <<PrevPara>> { tk::TextSetCursor %W [tk::TextPrevPara %W insert] } bind Text <<NextPara>> { tk::TextSetCursor %W [tk::TextNextPara %W insert] } bind Text <<SelectPrevWord>> { tk::TextKeySelect %W [tk::TextPrevPos %W insert tk::startOfPreviousWord] } bind Text <<SelectNextWord>> { tk::TextKeySelect %W [tk::TextNextWord %W insert] } bind Text <<SelectPrevPara>> { tk::TextKeySelect %W [tk::TextPrevPara %W insert] } |
︙ | ︙ | |||
218 219 220 221 222 223 224 | } } bind Text <Delete> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last } else { if {[%W compare end != insert+1c]} { | | > | > | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | } } bind Text <Delete> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last } else { if {[%W compare end != insert+1c]} { %W delete [tk::TextPrevPos %W insert+1c tk::startOfCluster] \ [tk::TextNextPos %W insert tk::endOfCluster] } %W see insert } } bind Text <BackSpace> { if {[tk::TextCursorInSelection %W]} { %W delete sel.first sel.last } else { if {[%W compare insert != 1.0]} { %W delete [tk::TextPrevPos %W insert tk::startOfCluster] \ [tk::TextNextPos %W insert-1c tk::endOfCluster] } %W see insert } } bind Text <Control-space> { %W mark set [tk::TextAnchor %W] insert |
︙ | ︙ | |||
292 293 294 295 296 297 298 | bind Text <Insert> { catch {tk::TextInsert %W [::tk::GetSelection %W PRIMARY]} } bind Text <Key> { tk::TextInsert %W %A } | | < | < > | 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | bind Text <Insert> { catch {tk::TextInsert %W [::tk::GetSelection %W PRIMARY]} } bind Text <Key> { tk::TextInsert %W %A } # Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound. # Otherwise, if a widget binding for one of these is defined, the # <Key> class binding will also fire and insert the character, # which is wrong. Ditto for <Escape>. bind Text <Alt-Key> {# nothing } bind Text <Meta-Key> {# nothing} bind Text <Control-Key> {# nothing} bind Text <Escape> {# nothing} bind Text <KP_Enter> {# nothing} bind Text <Command-Key> {# nothing} bind Text <Fn-Key> {# nothing} # Additional emacs-like bindings: bind Text <Control-d> { if {!$tk_strictMotif && [%W compare end != insert+1c]} { %W delete insert } |
︙ | ︙ | |||
353 354 355 356 357 358 359 | bind Text <<Redo>> { catch { %W edit redo } } bind Text <Meta-b> { if {!$tk_strictMotif} { | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | bind Text <<Redo>> { catch { %W edit redo } } bind Text <Meta-b> { if {!$tk_strictMotif} { tk::TextSetCursor %W [tk::TextPrevPos %W insert tk::startOfPreviousWord] } } bind Text <Meta-d> { if {!$tk_strictMotif && [%W compare end != insert+1c]} { %W delete insert [tk::TextNextWord %W insert] } } |
︙ | ︙ | |||
378 379 380 381 382 383 384 | bind Text <Meta-greater> { if {!$tk_strictMotif} { tk::TextSetCursor %W end-1c } } bind Text <Meta-BackSpace> { if {!$tk_strictMotif} { | | | < < < | < < > > > > > > > > > > > > > > > > > > > | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | bind Text <Meta-greater> { if {!$tk_strictMotif} { tk::TextSetCursor %W end-1c } } bind Text <Meta-BackSpace> { if {!$tk_strictMotif} { %W delete [tk::TextPrevPos %W insert tk::startOfPreviousWord] insert } } bind Text <Meta-Delete> { if {!$tk_strictMotif} { %W delete [tk::TextPrevPos %W insert tk::startOfPreviousWord] insert } } # Bindings for IME text input. bind Text <<TkStartIMEMarkedText>> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Text <<TkEndIMEMarkedText>> { ::tk::TextEndIMEMarkedText %W } bind Text <<TkClearIMEMarkedText>> { %W delete IMEmarkedtext.first IMEmarkedtext.last } bind Text <<TkAccentBackspace>> { %W delete insert-1c } # ::tk::TextEndIMEMarkedText -- # # Handles input method text marking in a text widget. # # Arguments: # w - The text widget proc ::tk::TextEndIMEMarkedText {w} { variable Priv if {[catch { set mark [dict get $Priv(IMETextMark) $w] }]} { bell return } $w tag add IMEmarkedtext $mark insert $w tag configure IMEmarkedtext -underline on } # Macintosh only bindings: if {[tk windowingsystem] eq "aqua"} { bind Text <Control-v> { tk::TextScrollPages %W 1 } |
︙ | ︙ | |||
438 439 440 441 442 443 444 | if {!$tk_strictMotif} { tk::TextScanDrag %W %x %y } } set ::tk::Priv(prevPos) {} bind Text <MouseWheel> { | | | | | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | if {!$tk_strictMotif} { tk::TextScanDrag %W %x %y } } set ::tk::Priv(prevPos) {} bind Text <MouseWheel> { tk::MouseWheel %W y %D -4.0 pixels } bind Text <Option-MouseWheel> { tk::MouseWheel %W y %D -1.2 pixels } bind Text <Shift-MouseWheel> { tk::MouseWheel %W x %D -4.0 pixels } bind Text <Shift-Option-MouseWheel> { 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 # of the character just after the boundary. # |
︙ | ︙ | |||
571 572 573 574 575 576 577 | if {[$w compare $cur < $first]} { set first $cur } elseif {[$w compare $cur > $last]} { set last $cur } # Now find word boundaries | | | | 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | if {[$w compare $cur < $first]} { set first $cur } elseif {[$w compare $cur > $last]} { set last $cur } # Now find word boundaries set first [TextPrevPos $w "$first + 1c" tk::wordBreakBefore] set last [TextNextPos $w "$last - 1c" tk::wordBreakAfter] } line { # Set initial range based only on the anchor set first "$anchorname linestart" set last "$anchorname lineend" # Extend range (if necessary) based on the current point |
︙ | ︙ | |||
1065 1066 1067 1068 1069 1070 1071 | # # Arguments: # w - The text window in which the cursor is to move. # start - Position at which to start search. if {[tk windowingsystem] eq "win32"} { proc ::tk::TextNextWord {w start} { | | | | | 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 | # # Arguments: # w - The text window in which the cursor is to move. # start - Position at which to start search. if {[tk windowingsystem] eq "win32"} { proc ::tk::TextNextWord {w start} { TextNextPos $w [TextNextPos $w $start tk::endOfWord] \ tk::startOfNextWord } } else { proc ::tk::TextNextWord {w start} { TextNextPos $w $start tk::endOfWord } } # ::tk::TextNextPos -- # Returns the index of the next position after the given starting # position in the text as computed by a specified function. # |
︙ | ︙ |
Changes to library/tk.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # tk.tcl -- # # Initialization script normally executed in the interpreter for each Tk-based # application. Arranges class bindings for widgets. # # 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 | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # tk.tcl -- # # Initialization script normally executed in the interpreter for each Tk-based # application. Arranges class bindings for widgets. # # 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.7a6 # Create a ::tk namespace namespace eval ::tk { # Set up the msgcat commands namespace eval msgcat { namespace export mc mcmax if {[interp issafe] || [catch {package require msgcat}]} { |
︙ | ︙ | |||
375 376 377 378 379 380 381 | event add <<Copy>> <Control-c> <F16> <Control-Lock-C> event add <<Paste>> <Control-v> <F18> <Control-Lock-V> event add <<Undo>> <Control-z> <Control-Lock-Z> event add <<Redo>> <Control-Z> <Control-Lock-z> # 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. | | | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | event add <<Copy>> <Control-c> <F16> <Control-Lock-C> event add <<Paste>> <Control-v> <F18> <Control-Lock-V> event add <<Undo>> <Control-z> <Control-Lock-Z> event add <<Redo>> <Control-Z> <Control-Lock-z> # 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 <<SelectAll>> <Control-/> event add <<SelectNone>> <Control-backslash> event add <<NextChar>> <Right> event add <<SelectNextChar>> <Shift-Right> event add <<PrevChar>> <Left> event add <<SelectPrevChar>> <Shift-Left> event add <<NextWord>> <Control-Right> event add <<SelectNextWord>> <Control-Shift-Right> |
︙ | ︙ | |||
422 423 424 425 426 427 428 | "win32" { event add <<Cut>> <Control-x> <Shift-Delete> <Control-Lock-X> event add <<Copy>> <Control-c> <Control-Insert> <Control-Lock-C> event add <<Paste>> <Control-v> <Shift-Insert> <Control-Lock-V> event add <<Undo>> <Control-z> <Control-Lock-Z> event add <<Redo>> <Control-y> <Control-Lock-Y> | | | 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | "win32" { event add <<Cut>> <Control-x> <Shift-Delete> <Control-Lock-X> event add <<Copy>> <Control-c> <Control-Insert> <Control-Lock-C> event add <<Paste>> <Control-v> <Shift-Insert> <Control-Lock-V> event add <<Undo>> <Control-z> <Control-Lock-Z> event add <<Redo>> <Control-y> <Control-Lock-Y> event add <<SelectAll>> <Control-/> <Control-a> <Control-Lock-A> event add <<SelectNone>> <Control-backslash> event add <<NextChar>> <Right> event add <<SelectNextChar>> <Shift-Right> event add <<PrevChar>> <Left> event add <<SelectPrevChar>> <Shift-Left> event add <<NextWord>> <Control-Right> event add <<SelectNextWord>> <Control-Shift-Right> |
︙ | ︙ | |||
453 454 455 456 457 458 459 | "aqua" { event add <<Cut>> <Command-x> <F2> <Command-Lock-X> event add <<Copy>> <Command-c> <F3> <Command-Lock-C> event add <<Paste>> <Command-v> <F4> <Command-Lock-V> event add <<Clear>> <Clear> # Official bindings | | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | "aqua" { event add <<Cut>> <Command-x> <F2> <Command-Lock-X> event add <<Copy>> <Command-c> <F3> <Command-Lock-C> event add <<Paste>> <Command-v> <F4> <Command-Lock-V> event add <<Clear>> <Clear> # Official bindings # See https://support.apple.com/en-us/HT201236 event add <<SelectAll>> <Command-a> event add <<Undo>> <Command-Key-z> <Command-Lock-Key-Z> event add <<Redo>> <Shift-Command-Key-z> <Shift-Command-Lock-Key-z> event add <<NextChar>> <Right> <Control-Key-f> <Control-Lock-Key-F> event add <<SelectNextChar>> <Shift-Right> <Shift-Control-Key-F> <Shift-Control-Lock-Key-F> event add <<PrevChar>> <Left> <Control-Key-b> <Control-Lock-Key-B> event add <<SelectPrevChar>> <Shift-Left> <Shift-Control-Key-B> <Shift-Control-Lock-Key-B> |
︙ | ︙ | |||
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | if {$::tk_library ne ""} { proc ::tk::SourceLibFile {file} { namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]] } namespace eval ::tk { SourceLibFile icons SourceLibFile button SourceLibFile entry SourceLibFile listbox SourceLibFile menu SourceLibFile panedwindow SourceLibFile scale SourceLibFile scrlbar SourceLibFile spinbox SourceLibFile text } } # ---------------------------------------------------------------------- # Default bindings for keyboard traversal. # ---------------------------------------------------------------------- | > > > > > | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 | if {$::tk_library ne ""} { proc ::tk::SourceLibFile {file} { namespace eval :: [list source -encoding utf-8 [file join $::tk_library $file.tcl]] } namespace eval ::tk { SourceLibFile icons SourceLibFile iconbadges SourceLibFile button SourceLibFile entry SourceLibFile listbox SourceLibFile menu SourceLibFile panedwindow SourceLibFile print SourceLibFile scale SourceLibFile scrlbar SourceLibFile spinbox if {![interp issafe]} { SourceLibFile systray } SourceLibFile text } } # ---------------------------------------------------------------------- # Default bindings for keyboard traversal. # ---------------------------------------------------------------------- |
︙ | ︙ | |||
675 676 677 678 679 680 681 | if {$length > $maxlen} { set maxlen $length } } return $maxlen } | < < < < < < < < < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | if {$length > $maxlen} { set maxlen $length } } return $maxlen } if {[tk windowingsystem] eq "aqua"} { #stub procedures to respond to "do script" Apple Events proc ::tk::mac::DoScriptFile {file} { uplevel #0 $file source -encoding utf-8 $file } proc ::tk::mac::DoScriptText {script} { uplevel #0 $script eval $script } #This procedure is required to silence warnings generated #by inline AppleScript execution. proc ::tk::mac::GetDynamicSdef {} { puts "" } } if {[info commands ::tk::endOfWord] eq ""} { proc ::tk::endOfWord {str start {locale {}}} { if {$start < 0} { set start -1 } set start [tcl_endOfWord $str $start] if {$start < 0} { set start "" } return $start } } if {[info commands ::tk::startOfNextWord] eq ""} { proc ::tk::startOfNextWord {str start {locale {}}} { if {$start < 0} { set start -1 } elseif {[string match end-* $start]} { set start [expr {[string length $str]-1-[string range $start 4 end]}] } set start [tcl_startOfNextWord $str $start] if {$start < 0} { set start "" } return $start } } if {[info commands ::tk::startOfPreviousWord] eq ""} { proc ::tk::startOfPreviousWord {str start {locale {}}} { if {$start < 0} { set start -1 } elseif {[string match end-* $start]} { set start [expr {[string length $str]-1-[string range $start 4 end]}] } set start [tcl_startOfPreviousWord $str $start] if {$start < 0} { set start "" } return $start } } if {[info commands ::tk::wordBreakBefore] eq ""} { proc ::tk::wordBreakBefore {str start {locale {}}} { if {$start < 0} { set start -1 } elseif {[string match end-* $start]} { set start [expr {[string length $str]-1-[string range $start 4 end]}] } set start [tcl_wordBreakBefore $str $start] if {$start < 0} { set start "" } return $start } } if {[info commands ::tk::wordBreakAfter] eq ""} { proc ::tk::wordBreakAfter {str start {locale {}}} { if {$start < 0} { set start -1 } elseif {[string match end-* $start]} { set start [expr {[string length $str]-1-[string range $start 4 end]}] } set start [tcl_wordBreakAfter $str $start] if {$start < 0} { set start "" } return $start } } if {[info commands ::tk::endOfCluster] eq ""} { proc ::tk::endOfCluster {str start {locale {}}} { if {$start < 0} { set start -1 } elseif {$start eq "end"} { set start [expr {[string length $str]-1}] } elseif {[string match end-* $start]} { set start [expr {[string length $str]-1-[string range $start 4 end]}] } elseif {$start >= [string length $str]} { return "" } if {[string length [string index $str $start]] > 1} { incr start } incr start return $start } } if {[info commands ::tk::startOfCluster] eq ""} { proc ::tk::startOfCluster {str start {locale {}}} { if {$start < 0} { set start -1 } elseif {$start eq "end"} { set start [expr {[string length $str]-1}] } elseif {[string match end-* $start]} { set start [expr {[string length $str]-1-[string range $start 4 end]}] } elseif {$start >= [string length $str]} { return [string length $str] } if {[string length [string index $str $start]] < 1} { incr start -1 } if {$start < 0} { return "" } return $start } } # Create a dictionary to store the starting index of the IME marked # text in an Entry or Text widget. set ::tk::Priv(IMETextMark) [dict create] |
︙ | ︙ |
Changes to library/tkfbox.tcl.
︙ | ︙ | |||
577 578 579 580 581 582 583 | return } # Turn on the busy cursor. BUG?? We haven't disabled X events, though, # so the user may still click and cause havoc ... # set entCursor [$data(ent) cget -cursor] | | | | 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | return } # Turn on the busy cursor. BUG?? We haven't disabled X events, though, # so the user may still click and cause havoc ... # set entCursor [$data(ent) cget -cursor] set dlgCursor [$w cget -cursor] $data(ent) configure -cursor watch $w configure -cursor watch update idletasks $data(icons) deleteall set showHidden $showHiddenVar # Make the dir list. Note that using an explicit [pwd] (instead of '.') is |
︙ | ︙ | |||
629 630 631 632 633 634 635 | ::tk::SetAmpText $data(okBtn) [mc "&Save"] } } # turn off the busy cursor. # $data(ent) configure -cursor $entCursor | | | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | ::tk::SetAmpText $data(okBtn) [mc "&Save"] } } # turn off the busy cursor. # $data(ent) configure -cursor $entCursor $w configure -cursor $dlgCursor } # ::tk::dialog::file::SetPathSilently -- # # Sets data(selectPath) without invoking the trace procedure # proc ::tk::dialog::file::SetPathSilently {w path} { |
︙ | ︙ | |||
905 906 907 908 909 910 911 | } else { set data(selectFile) $file } Done $w } } PATH { | | | | | | 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 | } else { set data(selectFile) $file } Done $w } } PATH { tk_messageBox -icon warning -type ok -parent $w -message \ [mc "Directory \"%1\$s\" does not exist." $path] $data(ent) selection range 0 end $data(ent) icursor end } CHDIR { tk_messageBox -type ok -parent $w -icon warning -message \ [mc "Cannot change to the directory\ \"%1\$s\".\nPermission denied." $path] $data(ent) selection range 0 end $data(ent) icursor end } ERROR { tk_messageBox -type ok -parent $w -icon warning -message \ [mc "Invalid file name \"%1\$s\"." $path] $data(ent) selection range 0 end |
︙ | ︙ | |||
1117 1118 1119 1120 1121 1122 1123 | if { [info exists data(-typevariable)] && $data(-typevariable) ne "" && [info exists data(-filetypes)] && [llength $data(-filetypes)] && [info exists data(filterType)] && $data(filterType) ne "" } then { upvar #0 $data(-typevariable) typeVariable set typeVariable [lindex $data(origfiletypes) \ | | < | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 | if { [info exists data(-typevariable)] && $data(-typevariable) ne "" && [info exists data(-filetypes)] && [llength $data(-filetypes)] && [info exists data(filterType)] && $data(filterType) ne "" } then { upvar #0 $data(-typevariable) typeVariable set typeVariable [lindex $data(origfiletypes) \ [lsearch -exact $data(-filetypes) $data(filterType)] 0] } } bind $data(okBtn) <Destroy> {} set Priv(selectFilePath) $selectFilePath } # ::tk::dialog::file::GlobFiltered -- |
︙ | ︙ |
Changes to library/ttk/altTheme.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # # Ttk widget set: Alternate theme # namespace eval ttk::theme::alt { variable colors array set colors { -frame "#d9d9d9" -window "#ffffff" -darker "#c3c3c3" -border "#414141" -activebg "#ececec" -disabledfg "#a3a3a3" -selectbg "#4a6984" -selectfg "#ffffff" -altindicator "#aaaaaa" | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # # Ttk widget set: Alternate theme # namespace eval ttk::theme::alt { variable colors array set colors { -frame "#d9d9d9" -window "#ffffff" -alternate "#f0f0f0" -darker "#c3c3c3" -border "#414141" -activebg "#ececec" -disabledfg "#a3a3a3" -selectbg "#4a6984" -selectfg "#ffffff" -altindicator "#aaaaaa" |
︙ | ︙ | |||
89 90 91 92 93 94 95 | ttk::style map TNotebook.Tab \ -background [list selected $colors(-frame)] \ -expand [list selected {2 2 1 0}] \ ; # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised | | > > > | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | ttk::style map TNotebook.Tab \ -background [list selected $colors(-frame)] \ -expand [list selected {2 2 1 0}] \ ; # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Treeview -background $colors(-window) \ -stripedbackground $colors(-alternate) ttk::style configure Treeview.Separator \ -background $colors(-alternate) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ selected $colors(-selectfg)] ttk::style configure TScale \ -groovewidth 4 -troughrelief sunken \ -sliderwidth raised -borderwidth 2 ttk::style configure TProgressbar \ -background $colors(-selectbg) -borderwidth 0 } } |
Changes to library/ttk/aquaTheme.tcl.
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | ttk::style map TButton \ -foreground { pressed white {alternate !pressed !background} white} ttk::style configure TMenubutton -anchor center -padding {2 0 0 2} ttk::style configure Toolbutton -anchor center # Entry ttk::style configure TEntry \ -foreground systemTextColor \ -background systemTextBackgroundColor ttk::style map TEntry \ -foreground { disabled systemDisabledControlTextColor } \ | > > > > > > > > > > > > | | > > > > > > | > > > | > > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | ttk::style map TButton \ -foreground { 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 } \ -selectbackground { !focus systemUnemphasizedSelectedTextBackgroundColor } # Combobox: ttk::style map TCombobox \ -foreground { disabled systemDisabledControlTextColor } \ -selectbackground { !focus systemUnemphasizedSelectedTextBackgroundColor } # Spinbox ttk::style configure TSpinbox \ -foreground systemTextColor \ -background systemTextBackgroundColor 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 {} # Notebook ttk::style configure TNotebook -tabmargins {10 0} -tabposition n ttk::style configure TNotebook -padding {18 8 18 17} ttk::style configure TNotebook.Tab -padding {12 3 12 2} ttk::style configure TNotebook.Tab -foreground systemControlTextColor ttk::style map TNotebook.Tab \ -foreground { background systemControlTextColor disabled systemDisabledControlTextColor selected systemSelectedTabTextColor} # Treeview: ttk::style configure Heading \ -font TkHeadingFont \ -foreground systemTextColor \ -background systemWindowBackgroundColor ttk::style configure Treeview -rowheight 18 \ -background systemTextBackgroundColor \ -stripedbackground systemDisabledControlTextColor \ -foreground systemTextColor \ -fieldbackground systemTextBackgroundColor ttk::style map Treeview \ -background { selected systemSelectedTextBackgroundColor } # Enable animation for ttk::progressbar widget: 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) # ttk::style configure TLabelframe \ -labeloutside true -labelmargins {14 0 14 4} # TODO: panedwindow sashes should be 9 pixels (HIG:Controls:Split Views) } } |
Changes to library/ttk/button.tcl.
︙ | ︙ | |||
38 39 40 41 42 43 44 | ttk::copyBindings TButton TRadiobutton # ...plus a few more: bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 } bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 } | | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | ttk::copyBindings TButton TRadiobutton # ...plus a few more: bind TRadiobutton <Up> { ttk::button::RadioTraverse %W -1 } bind TRadiobutton <Down> { ttk::button::RadioTraverse %W +1 } # bind TCheckbutton <+> { %W select } # bind TCheckbutton <minus> { %W deselect } # activate -- # Simulate a button press: temporarily set the state to 'pressed', # then invoke the button. # proc ttk::button::activate {w} { |
︙ | ︙ | |||
62 63 64 65 66 67 68 | # A radiobutton group consists of all the radiobuttons with # the same parent and -variable; this is a pretty good heuristic # that works most of the time. # proc ttk::button::RadioTraverse {w dir} { set group [list] foreach sibling [winfo children [winfo parent $w]] { | | | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # A radiobutton group consists of all the radiobuttons with # the same parent and -variable; this is a pretty good heuristic # that works most of the time. # proc ttk::button::RadioTraverse {w dir} { set group [list] foreach sibling [winfo children [winfo parent $w]] { if { [winfo class $sibling] eq "TRadiobutton" && [$sibling cget -variable] eq [$w cget -variable] && ![$sibling instate disabled] } { lappend group $sibling } } if {![llength $group]} { # Shouldn't happen, but can. return } set pos [expr {([lsearch -exact $group $w] + $dir) % [llength $group]}] tk::TabToWindow [lindex $group $pos] } |
Changes to library/ttk/clamTheme.tcl.
︙ | ︙ | |||
125 126 127 128 129 130 131 | -background [list selected $colors(-frame) {} $colors(-darker)] \ -lightcolor [list selected $colors(-lighter) {} $colors(-dark)] \ ; # Treeview: ttk::style configure Heading \ -font TkHeadingFont -relief raised -padding {3} | | > > > | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | -background [list selected $colors(-frame) {} $colors(-darker)] \ -lightcolor [list selected $colors(-lighter) {} $colors(-dark)] \ ; # Treeview: ttk::style configure Heading \ -font TkHeadingFont -relief raised -padding {3} ttk::style configure Treeview -background $colors(-window) \ -stripedbackground $colors(-lighter) ttk::style configure Treeview.Separator \ -background $colors(-lighter) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ selected $colors(-selectfg)] ttk::style configure TLabelframe \ -labeloutside true -labelmargins {0 0 0 4} \ -borderwidth 2 -relief raised ttk::style configure TProgressbar -background $colors(-frame) ttk::style configure Sash -sashthickness 6 -gripcount 10 } |
︙ | ︙ |
Changes to library/ttk/classicTheme.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # # "classic" Tk theme. # # Implements Tk's traditional Motif-like look and feel. # namespace eval ttk::theme::classic { variable colors; array set colors { -frame "#d9d9d9" -window "#ffffff" -activebg "#ececec" -troughbg "#c3c3c3" -selectbg "#c3c3c3" -selectfg "#000000" -disabledfg "#a3a3a3" -indicator "#b03060" -altindicator "#b05e5e" | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # # "classic" Tk theme. # # Implements Tk's traditional Motif-like look and feel. # namespace eval ttk::theme::classic { variable colors; array set colors { -frame "#d9d9d9" -window "#ffffff" -alternate "#f0f0f0" -activebg "#ececec" -troughbg "#c3c3c3" -selectbg "#c3c3c3" -selectfg "#000000" -disabledfg "#a3a3a3" -indicator "#b03060" -altindicator "#b05e5e" |
︙ | ︙ | |||
92 93 94 95 96 97 98 | ttk::style configure TNotebook.Tab \ -padding {3m 1m} \ -background $colors(-troughbg) ttk::style map TNotebook.Tab -background [list selected $colors(-frame)] # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised | | > > > | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ttk::style configure TNotebook.Tab \ -padding {3m 1m} \ -background $colors(-troughbg) ttk::style map TNotebook.Tab -background [list selected $colors(-frame)] # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Treeview -background $colors(-window) \ -stripedbackground $colors(-alternate) ttk::style configure Treeview.Separator \ -background $colors(-alternate) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ selected $colors(-selectfg)] # |
︙ | ︙ |
Changes to library/ttk/combobox.tcl.
︙ | ︙ | |||
182 183 184 185 186 187 188 | ## Scroll -- Mousewheel binding # proc ttk::combobox::Scroll {cb dir {factor 1.0}} { $cb instate disabled { return } set max [llength [$cb cget -values]] set current [$cb current] | > > > | > | | < | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | ## Scroll -- Mousewheel binding # proc ttk::combobox::Scroll {cb dir {factor 1.0}} { $cb instate disabled { return } set max [llength [$cb cget -values]] set current [$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. # |
︙ | ︙ | |||
309 310 311 312 313 314 315 | $w configure -relief flat -borderwidth 0 wm overrideredirect $w true wm attributes $w -topmost 1 } aqua { $w configure -relief solid -borderwidth 0 tk::unsupported::MacWindowStyle style $w \ | | | 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | $w configure -relief flat -borderwidth 0 wm overrideredirect $w true wm attributes $w -topmost 1 } aqua { $w configure -relief solid -borderwidth 0 tk::unsupported::MacWindowStyle style $w \ help {noActivates hideOnSuspend} wm resizable $w 0 0 } } return $w } ## ConfigureListbox -- |
︙ | ︙ | |||
337 338 339 340 341 342 343 | $popdown.l selection clear 0 end $popdown.l selection set $current $popdown.l activate $current $popdown.l see $current set height [llength $values] if {$height > [$cb cget -height]} { set height [$cb cget -height] | | | 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | $popdown.l selection clear 0 end $popdown.l selection set $current $popdown.l activate $current $popdown.l see $current set height [llength $values] if {$height > [$cb cget -height]} { set height [$cb cget -height] grid $popdown.sb grid configure $popdown.l -padx {1 0} } else { grid remove $popdown.sb grid configure $popdown.l -padx 1 } $popdown.l configure -height $height } |
︙ | ︙ | |||
362 363 364 365 366 367 368 | 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 { | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | 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 } set H [winfo reqheight $popdown] if {$y + $h + $H > [winfo screenheight $popdown]} { set Y [expr {$y - $H}] } else { set Y [expr {$y + $h}] |
︙ | ︙ |
Changes to library/ttk/defaults.tcl.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # # Settings for default theme. # namespace eval ttk::theme::default { variable colors array set colors { -frame "#d9d9d9" -foreground "#000000" -window "#ffffff" -text "#000000" -activebg "#ececec" -selectbg "#4a6984" -selectfg "#ffffff" -darker "#c3c3c3" -disabledfg "#a3a3a3" -indicator "#4a6984" | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # # Settings for default theme. # namespace eval ttk::theme::default { variable colors array set colors { -frame "#d9d9d9" -foreground "#000000" -window "#ffffff" -alternate "#e8e8e8" -text "#000000" -activebg "#ececec" -selectbg "#4a6984" -selectfg "#ffffff" -darker "#c3c3c3" -disabledfg "#a3a3a3" -indicator "#4a6984" |
︙ | ︙ | |||
103 104 105 106 107 108 109 | ttk::style map TNotebook.Tab \ -background [list selected $colors(-frame)] # Treeview. # ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Treeview \ | | > > > | | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | ttk::style map TNotebook.Tab \ -background [list selected $colors(-frame)] # Treeview. # ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Treeview \ -background $colors(-window) \ -stripedbackground $colors(-alternate) \ -foreground $colors(-text) ; ttk::style configure Treeview.Separator \ -background $colors(-alternate) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ selected $colors(-selectfg)] # Combobox popdown frame ttk::style layout ComboboxPopdownFrame { ComboboxPopdownFrame.border -sticky nswe } |
︙ | ︙ |
Changes to library/ttk/entry.tcl.
︙ | ︙ | |||
115 116 117 118 119 120 121 | ## Edit bindings: # bind TEntry <Key> { ttk::entry::Insert %W %A } bind TEntry <Delete> { ttk::entry::Delete %W } bind TEntry <BackSpace> { ttk::entry::Backspace %W } | | < < < < | > | | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | ## Edit bindings: # bind TEntry <Key> { ttk::entry::Insert %W %A } bind TEntry <Delete> { ttk::entry::Delete %W } bind TEntry <BackSpace> { ttk::entry::Backspace %W } # Ignore all Alt, Meta, Control, Command, and Fn keypresses unless explicitly bound. # Otherwise, the <Key> class binding will fire and insert the character. # Ditto for Escape, Return, and Tab. # bind TEntry <Alt-Key> {# nothing} bind TEntry <Meta-Key> {# nothing} bind TEntry <Control-Key> {# nothing} bind TEntry <Escape> {# nothing} bind TEntry <Return> {# nothing} bind TEntry <KP_Enter> {# nothing} bind TEntry <Tab> {# nothing} bind TEntry <Command-Key> {# nothing} bind TEntry <Fn-Key> {# nothing} # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind TEntry <<PrevLine>> {# nothing} bind TEntry <<NextLine>> {# nothing} ## Additional emacs-like bindings: # bind TEntry <Control-d> { ttk::entry::Delete %W } |
︙ | ︙ | |||
160 161 162 163 164 165 166 167 168 169 170 171 172 173 | } bind TEntry <<TkClearIMEMarkedText>> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] } bind TEntry <<TkAccentBackspace>> { ttk::entry::Backspace %W } ### Clipboard procedures. # ## EntrySelection -- Return the selected text of the entry. # Raises an error if there is no selection. # | > > > > > > > > > > > > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | } bind TEntry <<TkClearIMEMarkedText>> { %W delete [dict get $::tk::Priv(IMETextMark) "%W"] [%W index insert] } bind TEntry <<TkAccentBackspace>> { ttk::entry::Backspace %W } ## EndIMEMarkedText -- Handle the end of input method selection. # proc ::ttk::entry::EndIMEMarkedText {w} { variable ::tk::Priv if {[catch { set mark [dict get $Priv(IMETextMark) $w] }]} { bell return } $w selection range $mark insert } ### Clipboard procedures. # ## EntrySelection -- Return the selected text of the entry. # Raises an error if there is no selection. # |
︙ | ︙ | |||
244 245 246 247 248 249 250 | # position following the next end-of-word position. # set ::ttk::entry::State(startNext) \ [string equal [tk windowingsystem] "win32"] proc ttk::entry::NextWord {w start} { variable State | | | | > > > > > > > > > > > > > > > > > > > > > | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | # position following the next end-of-word position. # set ::ttk::entry::State(startNext) \ [string equal [tk windowingsystem] "win32"] proc ttk::entry::NextWord {w start} { variable State set pos [tk::endOfWord [$w get] [$w index $start]] if {$pos >= 0 && $State(startNext)} { set pos [tk::startOfNextWord [$w get] $pos] } if {$pos < 0} { return end } return $pos } ## PrevWord -- Find the previous word position. # proc ttk::entry::PrevWord {w start} { set pos [tk::startOfPreviousWord [$w get] [$w index $start]] if {$pos < 0} { return 0 } return $pos } ## NextChar -- Find the next char position. # proc ttk::entry::NextChar {w start} { variable State set pos [tk::endOfCluster [$w get] [$w index $start]] if {$pos < 0} { return end } return $pos } ## PrevChar -- Find the previous char position. # proc ttk::entry::PrevChar {w start} { set pos [tk::startOfCluster [$w get] [expr {[$w index $start]-1}]] if {$pos < 0} { return 0 } return $pos } ## RelIndex -- Compute character/word/line-relative index. # proc ttk::entry::RelIndex {w where {index insert}} { switch -- $where { prevchar { PrevChar $w $index } nextchar { NextChar $w $index } prevword { PrevWord $w $index } nextword { NextWord $w $index } home { return 0 } end { $w index end } default { error "Bad relative index $index" } } } |
︙ | ︙ | |||
310 311 312 313 314 315 316 | # proc ttk::entry::ExtendTo {w index} { set index [$w index $index] set insert [$w index insert] # Figure out selection anchor: if {![$w selection present]} { | | | | | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | # proc ttk::entry::ExtendTo {w index} { set index [$w index $index] set insert [$w index insert] # Figure out selection anchor: if {![$w selection present]} { set anchor $insert } else { set selfirst [$w index sel.first] set sellast [$w index sel.last] if { ($index < $selfirst) || ($insert == $selfirst && $index <= $sellast) } { set anchor $sellast } else { set anchor $selfirst } } # Extend selection: if {$anchor < $index} { $w selection range $anchor $index } else { $w selection range $index $anchor } $w icursor $index return $anchor } ## Extend -- Extend the selection to a relative position, show insert cursor |
︙ | ︙ | |||
388 389 390 391 392 393 394 | # and sets the selection mode for subsequent drag operations. # proc ttk::entry::Select {w x mode} { variable State set cur [ClosestGap $w $x] switch -- $mode { | | | | 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | # and sets the selection mode for subsequent drag operations. # proc ttk::entry::Select {w x mode} { variable State set cur [ClosestGap $w $x] switch -- $mode { word { WordSelect $w $cur $cur } line { LineSelect $w $cur $cur } char { # no-op } } set State(anchor) $cur set State(selectMode) $mode } |
︙ | ︙ | |||
495 496 497 498 499 500 501 | } $w selection range $first $last } ## WordBack, WordForward -- helper routines for WordSelect. # proc ttk::entry::WordBack {text index} { | | | | 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | } $w selection range $first $last } ## WordBack, WordForward -- helper routines for WordSelect. # proc ttk::entry::WordBack {text index} { if {[set pos [tk::wordBreakBefore $text $index]] < 0} { return 0 } return $pos } proc ttk::entry::WordForward {text index} { if {[set pos [tk::wordBreakAfter $text $index]] < 0} { return end } return $pos } ## LineSelect -- Select the entire line. # proc ttk::entry::LineSelect {w _ _} { variable State |
︙ | ︙ | |||
537 538 539 540 541 542 543 | if {abs($dx) > $State(deadband)} { set State(scanMoved) 1 } set left [expr {$State(scanIndex) + ($dx*$State(scanNum))/$State(scanDen)}] $w xview $left if {$left != [set newLeft [$w index @0]]} { | | | 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | if {abs($dx) > $State(deadband)} { set State(scanMoved) 1 } set left [expr {$State(scanIndex) + ($dx*$State(scanNum))/$State(scanDen)}] $w xview $left if {$left != [set newLeft [$w index @0]]} { # We've scanned past one end of the entry; # reset the mark so that the text will start dragging again # as soon as the mouse reverses direction. # set State(scanX) $x set State(scanIndex) $newLeft } } |
︙ | ︙ | |||
594 595 596 597 598 599 600 | ## Backspace -- Backspace over the character just before the insert cursor. # If there is a selection, delete that instead. # If the new insert position is offscreen to the left, # scroll to place the cursor at about the middle of the window. # proc ttk::entry::Backspace {w} { if {[PendingDelete $w]} { | | | | > | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | ## Backspace -- Backspace over the character just before the insert cursor. # If there is a selection, delete that instead. # If the new insert position is offscreen to the left, # scroll to place the cursor at about the middle of the window. # proc ttk::entry::Backspace {w} { if {[PendingDelete $w]} { See $w return } set x [expr {[$w index insert] - 1}] if {$x < 0} { return } $w delete [tk::startOfCluster [$w get] $x] [tk::endOfCluster [$w get] $x] if {[$w index @0] >= [$w index insert]} { set range [$w xview] set left [lindex $range 0] set right [lindex $range 1] $w xview moveto [expr {$left - ($right - $left)/2.0}] } } ## Delete -- Delete the character after the insert cursor. # If there is a selection, delete that instead. # proc ttk::entry::Delete {w} { if {![PendingDelete $w]} { $w delete [tk::startOfCluster [$w get] [$w index insert]] \ [tk::endOfCluster [$w get] [$w index insert]] } } #*EOF* |
Changes to library/ttk/fonts.tcl.
︙ | ︙ | |||
62 63 64 65 66 67 68 | catch {font create TkCaptionFont} catch {font create TkTooltipFont} catch {font create TkFixedFont} catch {font create TkIconFont} catch {font create TkMenuFont} catch {font create TkSmallCaptionFont} | | | | | | | | | | | | < | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | < | < | | | | | < | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | catch {font create TkCaptionFont} catch {font create TkTooltipFont} catch {font create TkFixedFont} catch {font create TkIconFont} catch {font create TkMenuFont} catch {font create TkSmallCaptionFont} if {!$tip145} {apply {{} { global tcl_platform switch -- [tk windowingsystem] { win32 { # In safe interps there is no osVersion element. if {[info exists tcl_platform(osVersion)]} { if {$tcl_platform(osVersion) >= 5.0} { set family "Tahoma" } else { set family "MS Sans Serif" } } else { if {[lsearch -exact [font families] Tahoma] >= 0} { set family "Tahoma" } else { set family "MS Sans Serif" } } set size 8 font configure TkDefaultFont -family $family -size $size font configure TkTextFont -family $family -size $size font configure TkHeadingFont -family $family -size $size font configure TkCaptionFont -family $family -size $size -weight bold font configure TkTooltipFont -family $family -size $size font configure TkFixedFont -family Courier -size 10 font configure TkIconFont -family $family -size $size font configure TkMenuFont -family $family -size $size font configure TkSmallCaptionFont -family $family -size $size } aqua { set family "Lucida Grande" set fixed "Monaco" set menusize 14 set size 13 set viewsize 12 set smallsize 11 set labelsize 10 set fixedsize 11 font configure TkDefaultFont -family $family -size $size font configure TkTextFont -family $family -size $size font configure TkHeadingFont -family $family -size $smallsize font configure TkCaptionFont -family $family -size $size -weight bold font configure TkTooltipFont -family $family -size $smallsize font configure TkFixedFont -family $fixed -size $fixedsize font configure TkIconFont -family $family -size $size font configure TkMenuFont -family $family -size $menusize font configure TkSmallCaptionFont -family $family -size $labelsize } default - x11 { if {![catch {tk::pkgconfig get fontsystem} fs] && $fs eq "xft"} { set family "sans-serif" set fixed "monospace" } else { set family "Helvetica" set fixed "courier" } set size 10 set ttsize 9 set capsize 12 set fixedsize 10 font configure TkDefaultFont -family $family -size $size font configure TkTextFont -family $family -size $size font configure TkHeadingFont -family $family -size $size -weight bold font configure TkCaptionFont -family $family -size $capsize -weight bold font configure TkTooltipFont -family $family -size $ttsize font configure TkFixedFont -family $fixed -size $fixedsize font configure TkIconFont -family $family -size $size font configure TkMenuFont -family $family -size $size font configure TkSmallCaptionFont -family $family -size $ttsize } } } ::ttk}} } #*EOF* |
Changes to library/ttk/menubutton.tcl.
︙ | ︙ | |||
78 79 80 81 82 83 84 | set buttonPad 1 set bevelPad 4 set mh [winfo reqheight $menu] set bh [expr {[winfo height $mb]} + $buttonPad] set bbh [expr {[winfo height $mb]} + $bevelPad] set mw [winfo reqwidth $menu] set bw [winfo width $mb] | < < | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | set buttonPad 1 set bevelPad 4 set mh [winfo reqheight $menu] set bh [expr {[winfo height $mb]} + $buttonPad] set bbh [expr {[winfo height $mb]} + $bevelPad] set mw [winfo reqwidth $menu] set bw [winfo width $mb] set entry [::tk::MenuFindName $menu [$mb cget -text]] if {$entry < 0} { set entry 0 } set x [winfo rootx $mb] set y [winfo rooty $mb] switch [$mb cget -direction] { above { set entry "" |
︙ | ︙ | |||
103 104 105 106 107 108 109 | incr y $menuPad incr x -$mw } right { incr y $menuPad incr x $bw } | | < < | | | | < | < < < < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | incr y $menuPad incr x -$mw } right { incr y $menuPad incr x $bw } default { # flush incr y $bbh } } return [list $x $y $entry] } } else { proc ::ttk::menubutton::PostPosition {mb menu} { set mh [expr {[winfo reqheight $menu]}] set bh [expr {[winfo height $mb]}] set mw [expr {[winfo reqwidth $menu]}] set bw [expr {[winfo width $mb]}] if {[tk windowingsystem] eq "win32"} { incr mh 6 incr mw 16 } set entry [::tk::MenuFindName $menu [$mb cget -text]] if {$entry < 0} { set entry 0 } set x [winfo rootx $mb] set y [winfo rooty $mb] switch [$mb cget -direction] { above { set entry "" incr y -$mh # if we go offscreen to the top, show as 'below' if {$y < [winfo vrooty $mb]} { set y [expr {[winfo vrooty $mb] + [winfo rooty $mb]\ + [winfo reqheight $mb]}] } } below { set entry "" incr y $bh # if we go offscreen to the bottom, show as 'above' if {($y + $mh) > ([winfo vrooty $mb] + [winfo vrootheight $mb])} { set y [expr {[winfo vrooty $mb] + [winfo vrootheight $mb] \ + [winfo rooty $mb] - $mh}] } } left { incr x -$mw } right { incr x $bw } default { # flush incr x [expr {([winfo width $mb] - [winfo reqwidth $menu])/ 2}] } } return [list $x $y $entry] } } # Popdown -- |
︙ | ︙ | |||
192 193 194 195 196 197 198 | } set State(pulldown) 1 set State(oldcursor) [$mb cget -cursor] $mb state pressed $mb configure -cursor [$menu cget -cursor] foreach {x y entry} [PostPosition $mb $menu] { break } | | | | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | } set State(pulldown) 1 set State(oldcursor) [$mb cget -cursor] $mb state pressed $mb configure -cursor [$menu cget -cursor] foreach {x y entry} [PostPosition $mb $menu] { break } if {$entry >= 0} { $menu post $x $y $entry } else { $menu post $x $y } tk_menuSetFocus $menu } # TransferGrab (X11 only) -- # Switch from pulldown mode (menubutton has an implicit grab) # to popdown mode (menu has an explicit grab). # proc ttk::menubutton::TransferGrab {mb} { variable State if {$State(pulldown)} { $mb configure -cursor $State(oldcursor) $mb state {!pressed !active} set State(pulldown) 0 set menu [$mb cget -menu] foreach {x y entry} [PostPosition $mb $menu] { break } tk_popup $menu [winfo rootx $menu] [winfo rooty $menu] } } # FindMenuEntry -- # Hack to support tk_optionMenus. # Returns the index of the menu entry with a matching -label, # "" if not found. # proc ttk::menubutton::FindMenuEntry {menu s} { set last [$menu index last] if {$last < 0} { return "" } for {set i 0} {$i <= $last} {incr i} { if {![catch {$menu entrycget $i -label} label] && ($label eq $s)} { return $i } } return "" } #*EOF* |
Changes to library/ttk/notebook.tcl.
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | bind TNotebook <Control-Tab> { ttk::notebook::CycleTab %W 1; break } bind TNotebook <Control-Shift-Tab> { ttk::notebook::CycleTab %W -1; break } catch { bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break } } bind TNotebook <Destroy> { ttk::notebook::Cleanup %W } # ActivateTab $nb $tab -- # Select the specified tab and set focus. # # Desired behavior: # + take focus when reselecting the currently-selected tab; # + keep focus if the notebook already has it; # + otherwise set focus to the first traversable widget | > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | bind TNotebook <Control-Tab> { ttk::notebook::CycleTab %W 1; break } bind TNotebook <Control-Shift-Tab> { ttk::notebook::CycleTab %W -1; break } catch { bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break } } bind TNotebook <Destroy> { 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; # + keep focus if the notebook already has it; # + otherwise set focus to the first traversable widget |
︙ | ︙ | |||
52 53 54 55 56 57 58 | ActivateTab $w $index } } # CycleTab -- # Select the next/previous tab in the list. # | | < | > > > > | > | | | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | ActivateTab $w $index } } # CycleTab -- # Select the next/previous tab in the list. # proc ttk::notebook::CycleTab {w dir {factor 1.0}} { set current [$w index current] if {$current >= 0} { set tabCount [$w index end] set d [expr {$dir/$factor}] set d [expr {int($d > 0 ? ceil($d) : floor($d))}] set select [expr {($current + $d) % $tabCount}] set step [expr {$d > 0 ? 1 : -1}] while {[$w tab $select -state] ne "normal" && ($select != $current)} { set select [expr {($select + $step) % $tabCount}] } if {$select != $current} { ActivateTab $w $select } } } |
︙ | ︙ | |||
108 109 110 111 112 113 114 | bind $top <Control-Next> {+ttk::notebook::TLCycleTab %W 1} bind $top <Control-Prior> {+ttk::notebook::TLCycleTab %W -1} bind $top <Control-Tab> {+ttk::notebook::TLCycleTab %W 1} bind $top <Control-Shift-Tab> {+ttk::notebook::TLCycleTab %W -1} catch { bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1} } | < | | < < < < | 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | bind $top <Control-Next> {+ttk::notebook::TLCycleTab %W 1} bind $top <Control-Prior> {+ttk::notebook::TLCycleTab %W -1} bind $top <Control-Tab> {+ttk::notebook::TLCycleTab %W 1} bind $top <Control-Shift-Tab> {+ttk::notebook::TLCycleTab %W -1} catch { bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1} } bind $top <Option-Key> \ +[list ttk::notebook::MnemonicActivation $top %K] bind $top <Destroy> {+ttk::notebook::TLCleanup %W} } lappend TLNotebooks($top) $nb } # TLCleanup -- <Destroy> binding for traversal-enabled toplevels |
︙ | ︙ |
Changes to library/ttk/panedwindow.tcl.
1 2 3 4 5 6 7 8 | # # Bindings for ttk::panedwindow widget. # namespace eval ttk::panedwindow { variable State array set State { pressed 0 | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # # Bindings for ttk::panedwindow widget. # namespace eval ttk::panedwindow { variable State array set State { pressed 0 pressX - pressY - sash - sashPos - } } ## Bindings: |
︙ | ︙ | |||
28 29 30 31 32 33 34 | ## Sash movement: # proc ttk::panedwindow::Press {w x y} { variable State set sash [$w identify $x $y] if {$sash eq ""} { | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ## Sash movement: # proc ttk::panedwindow::Press {w x y} { variable State set sash [$w identify $x $y] if {$sash eq ""} { set State(pressed) 0 return } set State(pressed) 1 set State(pressX) $x set State(pressY) $y set State(sash) $sash set State(sashPos) [$w sashpos $sash] } proc ttk::panedwindow::Drag {w x y} { variable State if {!$State(pressed)} { return } switch -- [$w cget -orient] { horizontal { set delta [expr {$x - $State(pressX)}] } vertical { set delta [expr {$y - $State(pressY)}] } } $w sashpos $State(sash) [expr {$State(sashPos) + $delta}] } proc ttk::panedwindow::Release {w x y} { variable State set State(pressed) 0 |
︙ | ︙ | |||
75 76 77 78 79 80 81 | variable State ttk::saveCursor $w State(userConfCursor) \ [list [ttk::cursor hresize] [ttk::cursor vresize]] set cursor $State(userConfCursor) if {[llength [$w identify $x $y]]} { | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | variable State ttk::saveCursor $w State(userConfCursor) \ [list [ttk::cursor hresize] [ttk::cursor vresize]] set cursor $State(userConfCursor) if {[llength [$w identify $x $y]]} { # Assume we're over a sash. switch -- [$w cget -orient] { horizontal { set cursor hresize } vertical { set cursor vresize } } } ttk::setCursor $w $cursor } #*EOF* |
Changes to library/ttk/progress.tcl.
︙ | ︙ | |||
9 10 11 12 13 14 15 | # Autoincrement -- # Periodic callback procedure for autoincrement mode # proc ttk::progressbar::Autoincrement {pb steptime stepsize} { variable Timers if {![winfo exists $pb]} { | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # Autoincrement -- # Periodic callback procedure for autoincrement mode # proc ttk::progressbar::Autoincrement {pb steptime stepsize} { variable Timers if {![winfo exists $pb]} { # widget has been destroyed -- cancel timer unset -nocomplain Timers($pb) return } set Timers($pb) [after $steptime \ [list ttk::progressbar::Autoincrement $pb $steptime $stepsize] ] $pb step $stepsize } # ttk::progressbar::start -- # Start autoincrement mode. Invoked by [$pb start] widget code. # |
︙ | ︙ |
Changes to library/ttk/scale.tcl.
|
| | | 1 2 3 4 5 6 7 8 | # scale.tcl - Copyright © 2004 Pat Thoyts <[email protected]> # # Bindings for the TScale widget namespace eval ttk::scale { variable State array set State { dragging 0 |
︙ | ︙ |
Changes to library/ttk/scrollbar.tcl.
︙ | ︙ | |||
70 71 72 73 74 75 76 | } } } proc ttk::scrollbar::Drag {w x y} { variable State if {![info exists State(first)]} { | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | } } } proc ttk::scrollbar::Drag {w x y} { variable State if {![info exists State(first)]} { # Initial buttonpress was not on the thumb, # or something screwy has happened. In either case, ignore: return; } set xDelta [expr {$x - $State(xPress)}] set yDelta [expr {$y - $State(yPress)}] Moveto $w [expr {$State(first) + [$w delta $xDelta $yDelta]}] } |
︙ | ︙ |
Changes to library/ttk/sizegrip.tcl.
︙ | ︙ | |||
8 9 10 11 12 13 14 | switch -- [tk windowingsystem] { x11 - win32 { option add *TSizegrip.cursor [ttk::cursor seresize] widgetDefault } aqua { | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | switch -- [tk windowingsystem] { x11 - win32 { option add *TSizegrip.cursor [ttk::cursor seresize] widgetDefault } aqua { # Aqua sizegrips use default Arrow cursor. } } namespace eval ttk::sizegrip { variable State array set State { pressed 0 |
︙ | ︙ |
Changes to library/ttk/spinbox.tcl.
︙ | ︙ | |||
19 20 21 22 23 24 25 | bind TSpinbox <Up> { event generate %W <<Increment>> } bind TSpinbox <Down> { event generate %W <<Decrement>> } bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 } bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 } | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | bind TSpinbox <Up> { event generate %W <<Increment>> } bind TSpinbox <Down> { event generate %W <<Decrement>> } bind TSpinbox <<Increment>> { ttk::spinbox::Spin %W +1 } bind TSpinbox <<Decrement>> { ttk::spinbox::Spin %W -1 } 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] |
︙ | ︙ | |||
76 77 78 79 80 81 82 | proc ttk::spinbox::Release {w} { ttk::CancelRepeat } ## MouseWheel -- # Mousewheel callback. Turn these into <<Increment>> (-1, up) | | | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | proc ttk::spinbox::Release {w} { ttk::CancelRepeat } ## MouseWheel -- # Mousewheel callback. Turn these into <<Increment>> (-1, up) # or <<Decrement> (+1, down) events. Not used any more. # proc ttk::spinbox::MouseWheel {w dir {factor 1.0}} { if {[$w instate disabled]} { return } if {($dir < 0) ^ ($factor < 0)} { event generate $w <<Increment>> } elseif {$dir != 0} { event generate $w <<Decrement>> } } ## SelectAll -- # Select widget contents. # |
︙ | ︙ | |||
130 131 132 133 134 135 136 | ## Spin -- # Handle <<Increment>> and <<Decrement>> events. # If -values is specified, cycle through the list. # Otherwise cycle through numeric range based on # -from, -to, and -increment. # | | > > | | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | ## Spin -- # Handle <<Increment>> and <<Decrement>> 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 {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) [$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] 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] + $d * [$w cget -increment]}] }]} { set v [$w cget -from] } $w set [FormatValue $w [Adjust $w $v [$w cget -from] [$w cget -to]]] } SelectAll $w uplevel #0 [$w cget -command] |
︙ | ︙ |
Changes to library/ttk/treeview.tcl.
︙ | ︙ | |||
16 17 18 19 20 21 22 23 24 25 26 27 28 29 | set State(pressX) 0 # For pressMode == "resize" set State(resizeColumn) #0 # For pressmode == "heading" set State(heading) {} } ### Widget bindings. # bind Treeview <Motion> { ttk::treeview::Motion %W %x %y } bind Treeview <B1-Leave> { #nothing } | > > > | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | set State(pressX) 0 # For pressMode == "resize" set State(resizeColumn) #0 # For pressmode == "heading" set State(heading) {} set State(cellAnchor) {} set State(cellAnchorOp) "set" } ### Widget bindings. # bind Treeview <Motion> { ttk::treeview::Motion %W %x %y } bind Treeview <B1-Leave> { #nothing } |
︙ | ︙ | |||
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | # ## Keynav -- Keyboard navigation # # @@@ TODO: verify/rewrite up and down code. # proc ttk::treeview::Keynav {w dir} { set focus [$w focus] if {$focus eq ""} { return } switch -- $dir { up { if {[set up [$w prev $focus]] eq ""} { set focus [$w parent $focus] } else { while {[$w item $up -open] && [llength [$w children $up]]} { | > > > > > > > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | # ## Keynav -- Keyboard navigation # # @@@ TODO: verify/rewrite up and down code. # proc ttk::treeview::Keynav {w dir} { variable State set focus [$w focus] if {$focus eq ""} { return } set cells [expr {[$w cget -selecttype] eq "cell"}] if {$cells} { lassign $State(cellAnchor) _ colAnchor # Just in case, give it a valid value if {$colAnchor eq ""} { set colAnchor "#1" } } switch -- $dir { up { if {[set up [$w prev $focus]] eq ""} { set focus [$w parent $focus] } else { while {[$w item $up -open] && [llength [$w children $up]]} { |
︙ | ︙ | |||
78 79 80 81 82 83 84 | while {$up ne "" && [set down [$w next $up]] eq ""} { set up [$w parent $up] } set focus $down } } left { | > > > > > > > > | | | > > > > > > > > > > > > > | > > > | > > > | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | while {$up ne "" && [set down [$w next $up]] eq ""} { set up [$w parent $up] } set focus $down } } left { if {$cells} { # This assumes that colAnchor is of the "#N" format. set colNo [string range $colAnchor 1 end] set firstCol [expr {"tree" ni [$w cget -show]}] if {$colNo > $firstCol} { incr colNo -1 set colAnchor "#$colNo" } } elseif {[$w item $focus -open] && [llength [$w children $focus]]} { CloseItem $w $focus } else { set focus [$w parent $focus] } } right { if {$cells} { set colNo [string range $colAnchor 1 end] set dispCol [$w cget -displaycolumns] if {$dispCol eq "#all"} { set lastCol [llength [$w cget -columns]] } else { set lastCol [llength $dispCol] } if {$colNo < ($lastCol - 1)} { incr colNo set colAnchor "#$colNo" } } else { OpenItem $w $focus } } } if {$focus != {}} { if {$cells} { set cell [list $focus $colAnchor] SelectOp $w $focus $cell choose } else { SelectOp $w $focus "" choose } } } ## Motion -- pointer motion binding. # Sets cursor, active element ... # proc ttk::treeview::Motion {w x y} { |
︙ | ︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 152 153 | if {$heading != {}} { $w heading $heading state active } set State(activeHeading) $heading set State(activeWidget) $w } } ## Select $w $x $y $selectop # Binding procedure for selection operations. # See "Selection modes", below. # proc ttk::treeview::Select {w x y op} { if {[set item [$w identify row $x $y]] ne "" } { | > > > > > > > > > > > > > > | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | if {$heading != {}} { $w heading $heading state active } set State(activeHeading) $heading set State(activeWidget) $w } } ## IndentifyCell -- Locate the cell at coordinate # Only active when -selecttype is "cell", and leaves cell empty otherwise. # Down the call chain it is enough to check cell to know the selecttype. proc ttk::treeview::IdentifyCell {w x y} { set cell {} if {[$w cget -selecttype] eq "cell"} { # Later handling assumes that the column in the cell ID is of the # format #N, which is always the case from "identify cell" set cell [$w identify cell $x $y] } return $cell } ## Select $w $x $y $selectop # Binding procedure for selection operations. # See "Selection modes", below. # proc ttk::treeview::Select {w x y op} { if {[set item [$w identify row $x $y]] ne "" } { set cell [IdentifyCell $w $x $y] SelectOp $w $item $cell $op } } ## DoubleClick -- Double-Button-1 binding. # proc ttk::treeview::DoubleClick {w x y} { if {[set row [$w identify row $x $y]] ne ""} { |
︙ | ︙ | |||
172 173 174 175 176 177 178 | switch -- [$w identify region $x $y] { nothing { } heading { heading.press $w $x $y } separator { resize.press $w $x $y } tree - cell { set item [$w identify item $x $y] | > > | | 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | switch -- [$w identify region $x $y] { nothing { } heading { heading.press $w $x $y } separator { resize.press $w $x $y } tree - cell { set item [$w identify item $x $y] set cell [IdentifyCell $w $x $y] SelectOp $w $item $cell choose switch -glob -- [$w identify element $x $y] { *indicator - *disclosure { Toggle $w $item } } } } } |
︙ | ︙ | |||
234 235 236 237 238 239 240 | } proc ttk::treeview::heading.drag {w x y} { variable State if { [$w identify region $x $y] eq "heading" && [$w identify column $x $y] eq $State(heading) } { | | | | | | | | | | | | | | > > > > > > | | > | > > > > > > > > | | | | > | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | } proc ttk::treeview::heading.drag {w x y} { variable State if { [$w identify region $x $y] eq "heading" && [$w identify column $x $y] eq $State(heading) } { $w heading $State(heading) state pressed } else { $w heading $State(heading) state !pressed } } proc ttk::treeview::heading.release {w} { variable State if {[lsearch -exact [$w heading $State(heading) state] pressed] >= 0} { after 0 [$w heading $State(heading) -command] } $w heading $State(heading) state !pressed } ### Selection modes. # ## SelectOp $w $item [ choose | extend | toggle ] -- # Dispatch to appropriate selection operation # depending on current value of -selectmode. # proc ttk::treeview::SelectOp {w item cell op} { select.$op.[$w cget -selectmode] $w $item $cell } ## -selectmode none: # proc ttk::treeview::select.choose.none {w item cell} { $w focus $item; $w see $item } proc ttk::treeview::select.toggle.none {w item cell} { $w focus $item; $w see $item } proc ttk::treeview::select.extend.none {w item cell} { $w focus $item; $w see $item } ## -selectmode browse: # proc ttk::treeview::select.choose.browse {w item cell} { BrowseTo $w $item $cell } proc ttk::treeview::select.toggle.browse {w item cell} { BrowseTo $w $item $cell } proc ttk::treeview::select.extend.browse {w item cell} { BrowseTo $w $item $cell } ## -selectmode multiple: # proc ttk::treeview::select.choose.extended {w item cell} { BrowseTo $w $item $cell } proc ttk::treeview::select.toggle.extended {w item cell} { variable State if {$cell ne ""} { $w cellselection toggle [list $cell] set State(cellAnchor) $cell set State(cellAnchorOp) add } else { $w selection toggle [list $item] } } proc ttk::treeview::select.extend.extended {w item cell} { variable State if {$cell ne ""} { if {$State(cellAnchor) ne ""} { $w cellselection $State(cellAnchorOp) $State(cellAnchor) $cell } else { BrowseTo $w $item $cell } } else { if {[set anchor [$w focus]] ne ""} { $w selection set [between $w $anchor $item] } else { BrowseTo $w $item $cell } } } ### Tree structure utilities. # ## between $tv $item1 $item2 -- |
︙ | ︙ | |||
315 316 317 318 319 320 321 | # Recursive worker routine for ttk::treeview::between # proc ttk::treeview::ScanBetween {tv item1 item2 item} { variable between variable selectingBetween if {$item eq $item1 || $item eq $item2} { | | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | # Recursive worker routine for ttk::treeview::between # proc ttk::treeview::ScanBetween {tv item1 item2 item} { variable between variable selectingBetween if {$item eq $item1 || $item eq $item2} { lappend between $item set selectingBetween [expr {!$selectingBetween}] } elseif {$selectingBetween} { lappend between $item } foreach child [$tv children $item] { ScanBetween $tv $item1 $item2 $child } } ### User interaction utilities. |
︙ | ︙ | |||
364 365 366 367 368 369 370 | } ## ToggleFocus -- toggle opened/closed state of focus item # proc ttk::treeview::ToggleFocus {w} { set item [$w focus] if {$item ne ""} { | | | > > > > > > > | > | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 | } ## ToggleFocus -- toggle opened/closed state of focus item # proc ttk::treeview::ToggleFocus {w} { set item [$w focus] if {$item ne ""} { Toggle $w $item } } ## BrowseTo -- navigate to specified item; set focus and selection # proc ttk::treeview::BrowseTo {w item cell} { variable State $w see $item $w focus $item set State(cellAnchor) $cell set State(cellAnchorOp) set if {$cell ne ""} { $w cellselection set [list $cell] } else { $w selection set [list $item] } } #*EOF* |
Changes to library/ttk/utils.tcl.
︙ | ︙ | |||
69 70 71 72 73 74 75 | # Test if the widget can take keyboard focus. # # See the description of the -takefocus option in options(n) # for details. # proc ttk::takesFocus {w} { if {![winfo viewable $w]} { | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # Test if the widget can take keyboard focus. # # See the description of the -takefocus option in options(n) # for details. # proc ttk::takesFocus {w} { if {![winfo viewable $w]} { return 0 } elseif {[catch {$w cget -takefocus} takefocus]} { return [GuessTakeFocus $w] } else { switch -- $takefocus { "" { return [GuessTakeFocus $w] } 0 { return 0 } 1 { return 1 } |
︙ | ︙ | |||
140 141 142 143 144 145 146 | return } set restoreGrab [set restoreFocus ""] set grabbed [grab current $w] if {[winfo exists $grabbed]} { | | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | return } set restoreGrab [set restoreFocus ""] set grabbed [grab current $w] if {[winfo exists $grabbed]} { switch [grab status $grabbed] { global { set restoreGrab [list grab -global $grabbed] } local { set restoreGrab [list grab $grabbed] } none { ;# grab window is really in a different interp } } } set focus [focus] if {$focus ne ""} { set restoreFocus [list focus -force $focus] } set Grab($w) [list $restoreGrab $restoreFocus] } ## RestoreGrab -- # Restore previous grab and focus windows. |
︙ | ︙ | |||
232 233 234 235 236 237 238 | # Begin auto-repeat. # proc ttk::Repeatedly {args} { variable Repeat after cancel $Repeat(timer) set script [uplevel 1 [list namespace code $args]] set Repeat(script) $script | < > < > | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | # Begin auto-repeat. # proc ttk::Repeatedly {args} { variable Repeat after cancel $Repeat(timer) set script [uplevel 1 [list namespace code $args]] set Repeat(script) $script set Repeat(timer) [after $Repeat(delay) ttk::Repeat] uplevel #0 $script } ## Repeat -- # Continue auto-repeat # proc ttk::Repeat {} { variable Repeat set Repeat(timer) [after $Repeat(interval) ttk::Repeat] uplevel #0 $Repeat(script) } ## ttk::CancelRepeat -- # Halt auto-repeat. # proc ttk::CancelRepeat {} { variable Repeat |
︙ | ︙ | |||
276 277 278 279 280 281 282 | # 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. | | | | | < | < < < < | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | # 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 two additional arguments # specifying the mousewheel change and a factor. # proc ttk::bindMouseWheel {bindtag callback} { bind $bindtag <MouseWheel> "$callback %D -120.0" bind $bindtag <Option-MouseWheel> "$callback %D -12.0" } ## Mousewheel bindings for standard scrollable widgets. # bind TtkScrollable <MouseWheel> \ { tk::MouseWheel %W y %D -40.0 } bind TtkScrollable <Option-MouseWheel> \ { tk::MouseWheel %W y %D -12.0 } bind TtkScrollable <Shift-MouseWheel> \ { tk::MouseWheel %W x %D -40.0 } bind TtkScrollable <Shift-Option-MouseWheel> \ { tk::MouseWheel %W x %D -12.0 } #*EOF* |
Changes to library/ttk/vistaTheme.tcl.
︙ | ︙ | |||
41 42 43 44 45 46 47 | ttk::style configure TNotebook -tabmargins {2 2 2 0} ttk::style map TNotebook.Tab \ -expand [list selected {2 2 2 2}] # Treeview: ttk::style configure Heading -font TkHeadingFont | | > > > | | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | ttk::style configure TNotebook -tabmargins {2 2 2 0} ttk::style map TNotebook.Tab \ -expand [list selected {2 2 2 2}] # Treeview: ttk::style configure Heading -font TkHeadingFont ttk::style configure Treeview -background SystemWindow \ -stripedbackground System3dLight ttk::style configure Treeview.Separator \ -background System3dLight ttk::style map Treeview \ -background [list disabled SystemButtonFace \ selected SystemHighlight] \ -foreground [list disabled SystemGrayText \ selected SystemHighlightText] # Label and Toolbutton ttk::style configure TLabelframe.Label -foreground SystemButtonText ttk::style configure Toolbutton -padding {4 4} |
︙ | ︙ | |||
87 88 89 90 91 92 93 | } } ttk::style map TCombobox \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ -foreground [list \ disabled SystemGrayText \ | | | 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | } } ttk::style map TCombobox \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ -foreground [list \ disabled SystemGrayText \ {readonly focus} SystemHighlightText \ ] \ -focusfill [list {readonly focus} SystemHighlight] \ ; # Entry ttk::style configure TEntry -padding {1 1 1 1} ;# Needs lookup ttk::style element create Entry.field vsapi \ |
︙ | ︙ |
Changes to library/ttk/winTheme.tcl.
︙ | ︙ | |||
28 29 30 31 32 33 34 | ttk::style map TButton -relief {{!disabled pressed} sunken} ttk::style configure TEntry \ -padding 2 -selectborderwidth 0 -insertwidth 1 ttk::style map TEntry \ -fieldbackground \ | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | ttk::style map TButton -relief {{!disabled pressed} sunken} ttk::style configure TEntry \ -padding 2 -selectborderwidth 0 -insertwidth 1 ttk::style map TEntry \ -fieldbackground \ [list readonly SystemButtonFace disabled SystemButtonFace] \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ ; ttk::style configure TCombobox -padding 2 ttk::style map TCombobox \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ -fieldbackground [list \ readonly SystemButtonFace \ disabled SystemButtonFace] \ -foreground [list \ disabled SystemGrayText \ {readonly focus} SystemHighlightText \ ] \ -focusfill [list {readonly focus} SystemHighlight] \ ; ttk::style element create ComboboxPopdownFrame.border from default ttk::style configure ComboboxPopdownFrame \ -borderwidth 1 -relief solid |
︙ | ︙ | |||
67 68 69 70 71 72 73 | ttk::style configure TNotebook -tabmargins {2 2 2 0} ttk::style configure TNotebook.Tab -padding {3 1} -borderwidth 1 ttk::style map TNotebook.Tab -expand [list selected {2 2 2 0}] # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised | | > | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | ttk::style configure TNotebook -tabmargins {2 2 2 0} ttk::style configure TNotebook.Tab -padding {3 1} -borderwidth 1 ttk::style map TNotebook.Tab -expand [list selected {2 2 2 0}] # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Treeview -background SystemWindow \ -stripedbackground System3dLight ttk::style map Treeview \ -background [list disabled SystemButtonFace \ selected SystemHighlight] \ -foreground [list disabled SystemGrayText \ selected SystemHighlightText] ttk::style configure TProgressbar \ -background SystemHighlight -borderwidth 0 ; } } |
Changes to library/ttk/xpTheme.tcl.
︙ | ︙ | |||
38 39 40 41 42 43 44 | ; ttk::style configure TCombobox -padding 2 ttk::style map TCombobox \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ -foreground [list \ disabled SystemGrayText \ | | | > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | ; ttk::style configure TCombobox -padding 2 ttk::style map TCombobox \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ -foreground [list \ disabled SystemGrayText \ {readonly focus} SystemHighlightText \ ] \ -focusfill [list {readonly focus} SystemHighlight] \ ; ttk::style configure TSpinbox -padding {2 0 14 0} ttk::style map TSpinbox \ -selectbackground [list !focus SystemWindow] \ -selectforeground [list !focus SystemWindowText] \ ; ttk::style configure Toolbutton -padding {4 4} # Treeview: ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Treeview -background SystemWindow \ -stripedbackground System3dLight ttk::style map Treeview \ -background [list disabled SystemButtonFace \ selected SystemHighlight] \ -foreground [list disabled SystemGrayText \ selected SystemHighlightText]; } } |
Changes to library/xmfbox.tcl.
︙ | ︙ | |||
79 80 81 82 83 84 85 | proc ::tk::MotifFDialog_Create {dataName type argList} { upvar ::tk::dialog::file::$dataName data MotifFDialog_Config $dataName $type $argList if {$data(-parent) eq "."} { | | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | proc ::tk::MotifFDialog_Create {dataName type argList} { upvar ::tk::dialog::file::$dataName data MotifFDialog_Config $dataName $type $argList if {$data(-parent) eq "."} { set w .$dataName } else { set w $data(-parent).$dataName } # (re)create the dialog box if necessary # if {![winfo exists $w]} { MotifFDialog_BuildUI $w } elseif {[winfo class $w] ne "TkMotifFDialog"} { |
︙ | ︙ | |||
544 545 546 547 548 549 550 | # None. proc ::tk::MotifFDialog_Update {w} { upvar ::tk::dialog::file::[winfo name $w] data $data(fEnt) delete 0 end $data(fEnt) insert 0 \ | | | 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | # None. proc ::tk::MotifFDialog_Update {w} { upvar ::tk::dialog::file::[winfo name $w] data $data(fEnt) delete 0 end $data(fEnt) insert 0 \ [::tk::dialog::file::JoinFile $data(selectPath) $data(filter)] $data(sEnt) delete 0 end $data(sEnt) insert 0 [::tk::dialog::file::JoinFile $data(selectPath) \ $data(selectFile)] MotifFDialog_LoadFiles $w } |
︙ | ︙ | |||
592 593 594 595 596 597 598 | set top 0 set dlist "" set flist "" foreach f [glob -nocomplain .* *] { if {[file isdir ./$f]} { lappend dlist $f } else { | | | | | | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | set top 0 set dlist "" set flist "" foreach f [glob -nocomplain .* *] { if {[file isdir ./$f]} { lappend dlist $f } else { foreach pat $data(filter) { if {[string match $pat $f]} { if {[string match .* $f]} { incr top } lappend flist $f break } } } } eval [list $data(dList) insert end] [lsort -dictionary $dlist] eval [list $data(fList) insert end] [lsort -dictionary $flist] # The user probably doesn't want to see the . files. We adjust the view # so that the listbox displays all the non-dot files |
︙ | ︙ |
Added macosx/Credits.html.in.
> > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <!doctype htmL> <html> <head> </head> <body style="font-size:120%;font-family:Arial,sans-serif;"> <p> Tcl and Tk are distributed under a modified BSD license:<br> <a href="https://www.tcl-lang.org/software/tcltk/license.html"> https://www.tcl-lang.org/software/tcltk/license.html </a> </p> <ul style="list-style-type:none;"> <li>© 1987-@TK_YEAR@ Tcl Core Team and Contributers.</li> <li>© 2011-@TK_YEAR@ Kevin Walzer/WordTech Communications LLC.</li> <li>© 2014-@TK_YEAR@ Marc Culler.</li> <li>© 2002-2012 Daniel A. Steffen.</li> <li>© 2001-2009 Apple Inc.</li> <li>© 2001-2002 Jim Ingham & Ian Reid.</li> <li>© 1998-2000 Jim Ingham & Ray Johnson.</li> <li>© 1998-2000 Scriptics Inc.</li> <li>© 1996-1997 Sun Microsystems Inc.</li> </ul> </body> </html> |
Changes to macosx/GNUmakefile.
︙ | ︙ | |||
42 43 44 45 46 47 48 | 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_) | < < < < < < | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 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_) override BUILD_DIR = ${DESTDIR}/build override INSTALL_PATH = /Frameworks endif #------------------------------------------------------------------------------------------------------- # meta targets |
︙ | ︙ | |||
141 142 143 144 145 146 147 | else override CONFIGURE_ARGS := ${CONFIGURE_ARGS} --enable-xft VERSION := ${VERSION}-X11 wish := ${wish}-X11 override EMBEDDED_BUILD := endif | | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | else override CONFIGURE_ARGS := ${CONFIGURE_ARGS} --enable-xft VERSION := ${VERSION}-X11 wish := ${wish}-X11 override EMBEDDED_BUILD := endif INSTALL_TARGETS = install-binaries install-libraries install-headers ifeq (${EMBEDDED_BUILD},) INSTALL_TARGETS += install-private-headers install-demos endif ifeq (${INSTALL_BUILD}_${EMBEDDED_BUILD}_${BUILD_STYLE},1__Deployment) INSTALL_TARGETS += html-tk ifneq (${INSTALL_MANPAGES},) INSTALL_TARGETS += install-doc endif endif |
︙ | ︙ | |||
189 190 191 192 193 194 195 | ${MAKE} install-${PROJECT} INSTALL_ROOT="${OBJ_DIR}/" ${objdir}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure \ ${UNIX_DIR}/tkConfig.sh.in Tk-Info.plist.in Wish-Info.plist.in mkdir -p "${OBJ_DIR}" && cd "${OBJ_DIR}" && \ if [ ${UNIX_DIR}/configure -nt config.status ]; then ${UNIX_DIR}/configure -C \ --prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \ | | | 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | ${MAKE} install-${PROJECT} INSTALL_ROOT="${OBJ_DIR}/" ${objdir}/Makefile: ${UNIX_DIR}/Makefile.in ${UNIX_DIR}/configure \ ${UNIX_DIR}/tkConfig.sh.in Tk-Info.plist.in Wish-Info.plist.in mkdir -p "${OBJ_DIR}" && cd "${OBJ_DIR}" && \ if [ ${UNIX_DIR}/configure -nt config.status ]; then ${UNIX_DIR}/configure -C \ --prefix="${PREFIX}" --bindir="${BINDIR}" --libdir="${LIBDIR}" \ --mandir="${MANDIR}" --enable-framework --disable-zipfs \ --with-tcl="${TCL_DIR}" \ ${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}; else ./config.status; fi ifneq (${VERSION},${TCL_VERSION}) @cd "${OBJ_DIR}" && sed -e 's#/Versions/${TCL_VERSION}#/Versions/${VERSION}#' \ tkConfig.sh > tkConfig.sh.1 && mv -f tkConfig.sh.1 tkConfig.sh endif |
︙ | ︙ |
Changes to macosx/README.
︙ | ︙ | |||
323 324 325 326 327 328 329 | other unix platform (indeed, the GNUmakefiles are just wrappers around the unix buildsystem). The macOS specific configure flags are --enable-aqua, --enable-framework and --disable-corefoundation (which disables CF and notably reverts to the standard select based notifier). Note that --enable-aqua is incompatible with --disable-corefoundation (for both Tcl and Tk configure). | | < < < < < | | | 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | other unix platform (indeed, the GNUmakefiles are just wrappers around the unix buildsystem). The macOS specific configure flags are --enable-aqua, --enable-framework and --disable-corefoundation (which disables CF and notably reverts to the standard select based notifier). Note that --enable-aqua is incompatible with --disable-corefoundation (for both Tcl and Tk configure). - It was once possible to build with the Xcode IDE via the project in tk/macosx, but this has not been tested recently. Take care to use the project matching your DevTools and OS version: Tk.xcodeproj: for Xcode 3.2 on 10.6 These have the following targets: Tk: calls through to tk/macosx/GNUMakefile, requires a corresponding build of the Tcl target of tcl/macosx/Tcl.xcode. tktest: static build of TkAqua tktest for debugging. tktest-X11: static build of TkX11 tktest for debugging. The following build configurations are available: Debug: debug build for the active architecture, with Fix & Continue enabled. Debug clang: use clang compiler. Debug llvm-gcc: use llvm-gcc compiler. Debug gcc40: use gcc 4.0 compiler. DebugNoGC: disable Objective-C garbage collection. DebugNoFixAndContinue: disable Fix & Continue. DebugNoCF: disable corefoundation (X11 only). DebugMemCompile: enable memory and bytecode debugging. DebugLeaks: define PURIFY. DebugGCov: enable generation of gcov data files. Release: release build for the active architecture. ReleaseUniversal: 32/64-bit universal build. ReleaseUniversal clang: use clang compiler. ReleaseUniversal llvm-gcc: use llvm-gcc compiler. ReleaseUniversal gcc40: use gcc 4.0 compiler. ReleaseUniversal10.5SDK: build against the 10.5 SDK (with 10.5 deployment target). Note that the non-SDK configurations have their deployment target set to 10.6 (Tk.xcodeproj). The Xcode projects refer to the toplevel tcl and tk source directories via the the TCL_SRCROOT and TK_SRCROOT user build settings, by default these are set to the project-relative paths '../../tcl' and '../../tk', if your source directories are named differently, e.g. '../../tcl8.7' and '../../tk8.7', you need to manually change the TCL_SRCROOT and TK_SRCROOT settings by editing your ${USER}.pbxuser file (located inside the Tk.xcodeproj bundle directory) with a text editor. - To enable weak-linking, set the MACOSX_DEPLOYMENT_TARGET environment variable to the minimal OS version the binaries should be able to run on, e.g: export MACOSX_DEPLOYMENT_TARGET=10.6 |
︙ | ︙ | |||
387 388 389 390 391 392 393 | [ create the following symbolic link for the build to work as setup by default ] [ ln -fs /path_to_tcl/build /path_to_tk/build ] [ (where /path_to_{tcl,tk} is the directory containing the tcl resp. tk tree) ] [ or you can pass an argument of BUILD_DIR=/somewhere to the tcl and tk make. ] - The following instructions assume the Tcl and Tk source trees are named "tcl${ver}" and "tk${ver}" (where ${ver} is a shell variable containing the | | | < < | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | [ create the following symbolic link for the build to work as setup by default ] [ ln -fs /path_to_tcl/build /path_to_tk/build ] [ (where /path_to_{tcl,tk} is the directory containing the tcl resp. tk tree) ] [ or you can pass an argument of BUILD_DIR=/somewhere to the tcl and tk make. ] - The following instructions assume the Tcl and Tk source trees are named "tcl${ver}" and "tk${ver}" (where ${ver} is a shell variable containing the Tcl/Tk version number, e.g. '8.7'). Setup this shell variable as follows: ver="8.7" - Setup environment variables as desired, e.g. for a universal build on 10.5: CFLAGS="-arch x86_64 -arch arm64e -mmacosx-version-min=10.5" export CFLAGS - Change to the directory containing the Tcl and Tk source trees and build: make -C tcl${ver}/macosx make -C tk${ver}/macosx - Install Tcl and Tk onto the root volume (admin password required): |
︙ | ︙ | |||
462 463 464 465 466 467 468 | - 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: | | | 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | - 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.7/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. |
︙ | ︙ | |||
548 549 550 551 552 553 554 | starting the event loop. Since the CheckProc function gets called for every Tk event, it is an appropriate place to drain the main NSAutoreleasePool and replace it with a new pool. This is done by calling the method [NSApp _resetAutoreleasePool], where _resetAutoreleasePool is a method which we define for the subclass. Unfortunately, by itself this is not | | | 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | starting the event loop. Since the CheckProc function gets called for every Tk event, it is an appropriate place to drain the main NSAutoreleasePool and replace it with a new pool. This is done by calling the method [NSApp _resetAutoreleasePool], where _resetAutoreleasePool is a method which we define for the subclass. Unfortunately, by itself this is not sufficient for safe memory management because, as was made painfully evident with the release of OS X 10.13, it is possible for calls to TclDoOneEvent, and hence to CheckProc, to be nested. Draining the autorelease pool in a nested call leads to crashes as objects in use by the outer call can get freed by the inner call and then reused later. One particular situation where this happens is when a modal dialogue gets posted by a Tk Application. To address this, the NSApp object also implements a semaphore to prevent draining the autorelease pool |
︙ | ︙ | |||
681 682 683 684 685 686 687 | conditional code which is only used for macOS. 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 | | | 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | conditional code which is only used for macOS. 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.7 provides three virtual events <<LightAqua>>, <<DarkAqua>> and <<AppearanceChanged>>, 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. |
︙ | ︙ |
Changes to macosx/Tk-Common.xcconfig.
︙ | ︙ | |||
29 30 31 32 33 34 35 | BINDIR = $(PREFIX)/bin CFLAGS = $(CFLAGS) CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS) FRAMEWORK_INSTALL_PATH = /Library/Frameworks INCLUDEDIR = $(PREFIX)/include LIBDIR = $(PREFIX)/lib MANDIR = $(PREFIX)/man | < | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | BINDIR = $(PREFIX)/bin CFLAGS = $(CFLAGS) CPPFLAGS = -mmacosx-version-min=$(MACOSX_DEPLOYMENT_TARGET) $(CPPFLAGS) FRAMEWORK_INSTALL_PATH = /Library/Frameworks INCLUDEDIR = $(PREFIX)/include LIBDIR = $(PREFIX)/lib MANDIR = $(PREFIX)/man PREFIX = /usr/local TCL_BUILD_DIR = $(OBJROOT)/../tcl/Tcl.build/$(CONFIGURATION)/Tcl.build/Objects TCL_CONFIGURE_ARGS = --enable-dtrace TCL_FRAMEWORK_DIR = $(SYMROOT)/../tcl/$(CONFIGURATION) TCL_LIBRARY = $(LIBDIR)/tcl$(VERSION) TCL_PACKAGE_PATH = "$(LIBDIR)" TCL_DEFS = HAVE_TCL_CONFIG_H TK_LIBRARY = $(LIBDIR)/tk$(VERSION) TK_DEFS = HAVE_TK_CONFIG_H VERSION = 8.7 |
Changes to macosx/Tk-Release.xcconfig.
︙ | ︙ | |||
9 10 11 12 13 14 15 | // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. #include "Tk-Common.xcconfig" DEBUG_INFORMATION_FORMAT = dwarf-with-dsym // DEPLOYMENT_POSTPROCESSING = YES | | | 9 10 11 12 13 14 15 16 17 18 19 | // See the file "license.terms" for information on usage and redistribution // of this file, and for a DISCLAIMER OF ALL WARRANTIES. #include "Tk-Common.xcconfig" DEBUG_INFORMATION_FORMAT = dwarf-with-dsym // DEPLOYMENT_POSTPROCESSING = YES GCC_OPTIMIZATION_LEVEL = 2 GCC_PREPROCESSOR_DEFINITIONS = NDEBUG $(TCL_DEFS) $(TK_DEFS) $(GCC_PREPROCESSOR_DEFINITIONS) CONFIGURE_ARGS = --disable-symbols $(TCL_CONFIGURE_ARGS) $(CONFIGURE_ARGS) MAKE_TARGET = deploy |
Deleted macosx/Tk.xcode/default.pbxuser.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Deleted macosx/Tk.xcode/project.pbxproj.
|
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < |
Changes to macosx/Tk.xcodeproj/project.pbxproj.
︙ | ︙ | |||
4745 4746 4747 4748 4749 4750 4751 | }; name = ReleaseUniversal; }; F91BCC51093152310042A6BF /* ReleaseUniversal */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { | | | | 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 | }; name = ReleaseUniversal; }; F91BCC51093152310042A6BF /* ReleaseUniversal */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INPUT_FILETYPE = sourcecode.c.objc; MACOSX_DEPLOYMENT_TARGET = 10.6; PREBINDING = NO; }; |
︙ | ︙ | |||
5057 5058 5059 5060 5061 5062 5063 | PRODUCT_NAME = "tktest-X11"; }; name = DebugNoFixAndContinue; }; F97258AC0A86873D00096C78 /* ReleaseUniversal */ = { isa = XCBuildConfiguration; buildSettings = { | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 | PRODUCT_NAME = "tktest-X11"; }; name = DebugNoFixAndContinue; }; F97258AC0A86873D00096C78 /* ReleaseUniversal */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; GCC_INPUT_FILETYPE = sourcecode.c.c; HEADER_SEARCH_PATHS = ( /usr/X11R6/include, /usr/X11R6/include/freetype2, "$(HEADER_SEARCH_PATHS)", ); LIBRARY_SEARCH_PATHS = ( /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = ReleaseUniversal; }; F987512F0DE7B57E00B1C9EC /* DebugNoCF */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */; buildSettings = { ARCHS = ( "$(NATIVE_ARCH_64_BIT)", "$(NATIVE_ARCH_32_BIT)", |
︙ | ︙ | |||
5183 5184 5185 5186 5187 5188 5189 | /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = DebugNoCF; }; | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 | /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = DebugNoCF; }; F9988AB10D814C6500B6B03B /* Debug gcc40 */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */; buildSettings = { ARCHS = ( "$(NATIVE_ARCH_64_BIT)", "$(NATIVE_ARCH_32_BIT)", |
︙ | ︙ | |||
5390 5391 5392 5393 5394 5395 5396 | }; name = "Debug llvm-gcc"; }; F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { | | | | 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 | }; name = "Debug llvm-gcc"; }; F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INPUT_FILETYPE = sourcecode.c.objc; GCC_VERSION = 4.0; MACOSX_DEPLOYMENT_TARGET = 10.6; PREBINDING = NO; |
︙ | ︙ | |||
5424 5425 5426 5427 5428 5429 5430 | PRODUCT_NAME = tktest; }; name = "ReleaseUniversal gcc40"; }; F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */ = { isa = XCBuildConfiguration; buildSettings = { | | | | | | 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 | PRODUCT_NAME = tktest; }; name = "ReleaseUniversal gcc40"; }; F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; GCC_INPUT_FILETYPE = sourcecode.c.c; HEADER_SEARCH_PATHS = ( /usr/X11R6/include, /usr/X11R6/include/freetype2, "$(HEADER_SEARCH_PATHS)", ); LIBRARY_SEARCH_PATHS = ( /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = "ReleaseUniversal gcc40"; }; F9988BB50D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; DEBUG_INFORMATION_FORMAT = dwarf; GCC = "llvm-gcc"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INPUT_FILETYPE = sourcecode.c.objc; GCC_OPTIMIZATION_LEVEL = 4; |
︙ | ︙ | |||
5482 5483 5484 5485 5486 5487 5488 | PRODUCT_NAME = tktest; }; name = "ReleaseUniversal llvm-gcc"; }; F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = { isa = XCBuildConfiguration; buildSettings = { | | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 | PRODUCT_NAME = tktest; }; name = "ReleaseUniversal llvm-gcc"; }; F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; GCC_INPUT_FILETYPE = sourcecode.c.c; HEADER_SEARCH_PATHS = ( /usr/X11R6/include, /usr/X11R6/include/freetype2, "$(HEADER_SEARCH_PATHS)", ); LIBRARY_SEARCH_PATHS = ( /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = "ReleaseUniversal llvm-gcc"; }; F99EE73C0BE835310060D4AF /* DebugLeaks */ = { isa = XCBuildConfiguration; buildSettings = { PRODUCT_NAME = Wish; SKIP_INSTALL = NO; }; name = DebugLeaks; }; F99EE73E0BE835310060D4AF /* DebugLeaks */ = { isa = XCBuildConfiguration; buildSettings = { OTHER_LDFLAGS = ( "$(OTHER_LDFLAGS_AQUA)", "$(OTHER_LDFLAGS)", ); PRODUCT_NAME = tktest; }; name = DebugLeaks; }; F99EE7400BE835310060D4AF /* DebugLeaks */ = { isa = XCBuildConfiguration; buildSettings = { GCC_INPUT_FILETYPE = sourcecode.c.c; HEADER_SEARCH_PATHS = ( /usr/X11R6/include, /usr/X11R6/include/freetype2, "$(HEADER_SEARCH_PATHS)", ); LIBRARY_SEARCH_PATHS = ( /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = DebugLeaks; }; F99EE7420BE835310060D4AF /* DebugLeaks */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE8330B65C87F00310EA2 /* Tk-Debug.xcconfig */; buildSettings = { ARCHS = ( "$(NATIVE_ARCH_64_BIT)", ); CPPFLAGS = "-arch $(CURRENT_ARCH) $(CPPFLAGS)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = unsupported; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INPUT_FILETYPE = sourcecode.c.objc; GCC_PREPROCESSOR_DEFINITIONS = ( |
︙ | ︙ | |||
5692 5693 5694 5695 5696 5697 5698 | }; F9A9D1F30FC77799002A2BE3 /* ReleaseUniversal clang */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { ARCHS = ( "$(NATIVE_ARCH_64_BIT)", | < | | 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 | }; F9A9D1F30FC77799002A2BE3 /* ReleaseUniversal clang */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { ARCHS = ( "$(NATIVE_ARCH_64_BIT)", ); CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; DEBUG_INFORMATION_FORMAT = dwarf; GCC = clang; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INPUT_FILETYPE = sourcecode.c.objc; GCC_OPTIMIZATION_LEVEL = 4; |
︙ | ︙ | |||
5730 5731 5732 5733 5734 5735 5736 | PRODUCT_NAME = tktest; }; name = "ReleaseUniversal clang"; }; F9A9D1F60FC77799002A2BE3 /* ReleaseUniversal clang */ = { isa = XCBuildConfiguration; buildSettings = { | | | | 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 | PRODUCT_NAME = tktest; }; name = "ReleaseUniversal clang"; }; F9A9D1F60FC77799002A2BE3 /* ReleaseUniversal clang */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; HEADER_SEARCH_PATHS = ( /usr/X11R6/include, /usr/X11R6/include/freetype2, "$(HEADER_SEARCH_PATHS)", ); LIBRARY_SEARCH_PATHS = ( /usr/X11R6/lib, |
︙ | ︙ | |||
5767 5768 5769 5770 5771 5772 5773 | PRODUCT_NAME = tktest; }; name = ReleaseUniversal10.5SDK; }; F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = { isa = XCBuildConfiguration; buildSettings = { | | | | | | 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 | PRODUCT_NAME = tktest; }; name = ReleaseUniversal10.5SDK; }; F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = { isa = XCBuildConfiguration; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; GCC_INPUT_FILETYPE = sourcecode.c.c; HEADER_SEARCH_PATHS = ( /usr/X11R6/include, /usr/X11R6/include/freetype2, "$(HEADER_SEARCH_PATHS)", ); LIBRARY_SEARCH_PATHS = ( /usr/X11R6/lib, "$(LIBRARY_SEARCH_PATHS)", ); PRODUCT_NAME = "tktest-X11"; }; name = ReleaseUniversal10.5SDK; }; F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */ = { isa = XCBuildConfiguration; baseConfigurationReference = F97AE82B0B65C69B00310EA2 /* Tk-Release.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CFLAGS = "-arch x86_64 -arch arm64e $(CFLAGS)"; CPPFLAGS = "-isysroot $(SDKROOT) $(CPPFLAGS)"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_GC = supported; GCC_ENABLE_PASCAL_STRINGS = NO; GCC_INPUT_FILETYPE = sourcecode.c.objc; MACOSX_DEPLOYMENT_TARGET = 10.5; PREBINDING = NO; |
︙ | ︙ | |||
5812 5813 5814 5815 5816 5817 5818 | buildConfigurations = ( F95CC8AC09158F3100EA5ACE /* Debug */, F9A9D1F00FC77787002A2BE3 /* Debug clang */, F9988AB60D814C7500B6B03B /* Debug llvm-gcc */, F9988AB20D814C6500B6B03B /* Debug gcc40 */, F90E36D60F3B5C8400810A10 /* DebugNoGC */, F95CC8AE09158F3100EA5ACE /* DebugNoFixAndContinue */, | < < < < < < < < < < < < | 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 | buildConfigurations = ( F95CC8AC09158F3100EA5ACE /* Debug */, F9A9D1F00FC77787002A2BE3 /* Debug clang */, F9988AB60D814C7500B6B03B /* Debug llvm-gcc */, F9988AB20D814C6500B6B03B /* Debug gcc40 */, F90E36D60F3B5C8400810A10 /* DebugNoGC */, F95CC8AE09158F3100EA5ACE /* DebugNoFixAndContinue */, F98751300DE7B57E00B1C9EC /* DebugNoCF */, F93084370BB93D2800CD0B9E /* DebugMemCompile */, F99EE73C0BE835310060D4AF /* DebugLeaks */, F9359B260DF212DA00E04F67 /* DebugGCov */, F95CC8AD09158F3100EA5ACE /* Release */, F91BCC4F093152310042A6BF /* ReleaseUniversal */, F9A9D1F40FC77799002A2BE3 /* ReleaseUniversal clang */, F9988BB60D81587400B6B03B /* ReleaseUniversal llvm-gcc */, F9988BB20D81586D00B6B03B /* ReleaseUniversal gcc40 */, F9EEED960C2FEFD300396116 /* ReleaseUniversal10.5SDK */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; F95CC8B009158F3100EA5ACE /* Build configuration list for PBXNativeTarget "tktest" */ = { isa = XCConfigurationList; buildConfigurations = ( F95CC8B109158F3100EA5ACE /* Debug */, F9A9D1F10FC77787002A2BE3 /* Debug clang */, F9988AB70D814C7500B6B03B /* Debug llvm-gcc */, F9988AB30D814C6500B6B03B /* Debug gcc40 */, F90E36D70F3B5C8400810A10 /* DebugNoGC */, F95CC8B309158F3100EA5ACE /* DebugNoFixAndContinue */, F98751310DE7B57E00B1C9EC /* DebugNoCF */, F93084380BB93D2800CD0B9E /* DebugMemCompile */, F99EE73E0BE835310060D4AF /* DebugLeaks */, F9359B270DF212DA00E04F67 /* DebugGCov */, F95CC8B209158F3100EA5ACE /* Release */, F91BCC50093152310042A6BF /* ReleaseUniversal */, F9A9D1F50FC77799002A2BE3 /* ReleaseUniversal clang */, F9988BB70D81587400B6B03B /* ReleaseUniversal llvm-gcc */, F9988BB30D81586D00B6B03B /* ReleaseUniversal gcc40 */, F9EEED970C2FEFD300396116 /* ReleaseUniversal10.5SDK */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; F95CC8B509158F3100EA5ACE /* Build configuration list for PBXProject "Tk" */ = { isa = XCConfigurationList; buildConfigurations = ( F95CC8B609158F3100EA5ACE /* Debug */, F9A9D1EF0FC77787002A2BE3 /* Debug clang */, F9988AB50D814C7500B6B03B /* Debug llvm-gcc */, F9988AB10D814C6500B6B03B /* Debug gcc40 */, F90E36D50F3B5C8400810A10 /* DebugNoGC */, F95CC8B809158F3100EA5ACE /* DebugNoFixAndContinue */, F987512F0DE7B57E00B1C9EC /* DebugNoCF */, F930843A0BB93D2800CD0B9E /* DebugMemCompile */, F99EE7420BE835310060D4AF /* DebugLeaks */, F9359B250DF212DA00E04F67 /* DebugGCov */, F95CC8B709158F3100EA5ACE /* Release */, F91BCC51093152310042A6BF /* ReleaseUniversal */, F9A9D1F30FC77799002A2BE3 /* ReleaseUniversal clang */, F9988BB50D81587400B6B03B /* ReleaseUniversal llvm-gcc */, F9988BB10D81586D00B6B03B /* ReleaseUniversal gcc40 */, F9EEED990C2FEFD300396116 /* ReleaseUniversal10.5SDK */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; F97258A80A86873D00096C78 /* Build configuration list for PBXNativeTarget "tktest-X11" */ = { isa = XCConfigurationList; buildConfigurations = ( F97258A90A86873D00096C78 /* Debug */, F9A9D1F20FC77787002A2BE3 /* Debug clang */, F9988AB80D814C7500B6B03B /* Debug llvm-gcc */, F9988AB40D814C6500B6B03B /* Debug gcc40 */, F90E36D80F3B5C8400810A10 /* DebugNoGC */, F97258AB0A86873D00096C78 /* DebugNoFixAndContinue */, F98751320DE7B57E00B1C9EC /* DebugNoCF */, F93084390BB93D2800CD0B9E /* DebugMemCompile */, F99EE7400BE835310060D4AF /* DebugLeaks */, F9359B280DF212DA00E04F67 /* DebugGCov */, F97258AA0A86873D00096C78 /* Release */, F97258AC0A86873D00096C78 /* ReleaseUniversal */, F9A9D1F60FC77799002A2BE3 /* ReleaseUniversal clang */, F9988BB80D81587400B6B03B /* ReleaseUniversal llvm-gcc */, F9988BB40D81586D00B6B03B /* ReleaseUniversal gcc40 */, F9EEED980C2FEFD300396116 /* ReleaseUniversal10.5SDK */, ); |
︙ | ︙ |
Changes to macosx/tkMacOSXBitmap.c.
1 2 3 4 5 | /* * tkMacOSXBitmap.c -- * * This file handles the implementation of native bitmaps. * | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /* * tkMacOSXBitmap.c -- * * This file handles the implementation of native bitmaps. * * Copyright © 1996-1997 Sun Microsystems, Inc. * Copyright © 2001-2009 Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * * 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 "tkMacOSXConstants.h" /* * This structure holds information about native bitmaps. */ typedef struct { const char *name; /* Name of icon. */ OSType iconType; /* OSType of icon. */ |
︙ | ︙ | |||
45 46 47 48 49 50 51 | {"note", kAlertNoteIcon}, {"caution", kAlertCautionIcon}, {NULL, 0} }; #define builtInIconSize 32 | | | | | | | | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | {"note", kAlertNoteIcon}, {"caution", kAlertCautionIcon}, {NULL, 0} }; #define builtInIconSize 32 #define OSTYPE_TO_UTI(x) ((NSString *)UTTypeCreatePreferredIdentifierForTag( \ kUTTagClassOSType, UTCreateStringForOSType(x), nil)) static Tcl_HashTable iconBitmapTable = {}; typedef struct { int kind, width, height; char *value; } IconBitmap; static const char *const iconBitmapOptionStrings[] = { "-file", "-fileType", "-imageFile", "-namedImage", "-osType", "-systemType", NULL }; enum iconBitmapOptions { ICON_FILE, ICON_FILETYPE, ICON_IMAGEFILE, ICON_NAMEDIMAGE, ICON_OSTYPE, ICON_SYSTEMTYPE }; /* *---------------------------------------------------------------------- * * TkpDefineNativeBitmaps -- |
︙ | ︙ | |||
170 171 172 173 174 175 176 | */ Pixmap TkpCreateNativeBitmap( Display *display, const void *source) /* Info about the icon to build. */ { | | | < | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | */ Pixmap TkpCreateNativeBitmap( Display *display, const void *source) /* Info about the icon to build. */ { NSString *filetype = [NSString stringWithUTF8String:(char *)source]; NSImage *iconImage = TkMacOSXIconForFileType(filetype); CGSize size = CGSizeMake(builtInIconSize, builtInIconSize); Pixmap pixmap = PixmapFromImage(display, iconImage, size); return pixmap; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
201 202 203 204 205 206 207 | static int OSTypeFromString(const char *s, OSType *t) { int result = TCL_ERROR; Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); | | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | static int OSTypeFromString(const char *s, OSType *t) { int result = TCL_ERROR; Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); (void)Tcl_UtfToExternalDStringEx(encoding, s, -1, TCL_ENCODING_NOCOMPLAIN, &ds); if (Tcl_DStringLength(&ds) <= 4) { char string[4] = {}; memcpy(string, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); *t = (OSType) string[0] << 24 | (OSType) string[1] << 16 | (OSType) string[2] << 8 | (OSType) string[3]; result = TCL_OK; } |
︙ | ︙ | |||
249 250 251 252 253 254 255 | int *height) { Tcl_HashEntry *hPtr; Pixmap pixmap = None; NSString *string; NSImage *image = nil; NSSize size = { .width = builtInIconSize, .height = builtInIconSize }; | < | | | | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | int *height) { Tcl_HashEntry *hPtr; Pixmap pixmap = None; NSString *string; NSImage *image = nil; NSSize size = { .width = builtInIconSize, .height = builtInIconSize }; if (iconBitmapTable.buckets && (hPtr = Tcl_FindHashEntry(&iconBitmapTable, name))) { OSType type; IconBitmap *iconBitmap = (IconBitmap *)Tcl_GetHashValue(hPtr); name = NULL; size = NSMakeSize(iconBitmap->width, iconBitmap->height); switch (iconBitmap->kind) { case ICON_FILE: string = [[NSString stringWithUTF8String:iconBitmap->value] stringByExpandingTildeInPath]; image = [[NSWorkspace sharedWorkspace] iconForFile:string]; break; case ICON_FILETYPE: string = [NSString stringWithUTF8String:iconBitmap->value]; image = TkMacOSXIconForFileType(string); break; case ICON_OSTYPE: if (OSTypeFromString(iconBitmap->value, &type) == TCL_OK) { string = [NSString stringWithUTF8String:iconBitmap->value]; image = TkMacOSXIconForFileType(string); } break; case ICON_SYSTEMTYPE: name = iconBitmap->value; break; case ICON_NAMEDIMAGE: string = [NSString stringWithUTF8String:iconBitmap->value]; |
︙ | ︙ | |||
308 309 310 311 312 313 314 315 316 | } } if (image) { *width = size.width; *height = size.height; pixmap = PixmapFromImage(display, image, NSSizeToCGSize(size)); } else if (name) { OSType iconType; if (OSTypeFromString(name, &iconType) == TCL_OK) { | > > > > > | | < | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | } } if (image) { *width = size.width; *height = size.height; pixmap = PixmapFromImage(display, image, NSSizeToCGSize(size)); } else if (name) { /* * As a last resort, try to interpret the name as an OSType. * It would probably be better to just return None at this * point. */ OSType iconType; if (OSTypeFromString(name, &iconType) == TCL_OK) { NSString *iconUTI = TkMacOSXOSTypeToUTI(iconType); NSImage *iconImage = TkMacOSXIconForFileType(iconUTI); pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size)); } } return pixmap; } /* |
︙ | ︙ | |||
380 381 382 383 384 385 386 | goto end; } #if 0 if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) { Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); | | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | goto end; } #if 0 if ((kind == ICON_TYPE || kind == ICON_SYSTEM)) { Tcl_DString ds; Tcl_Encoding encoding = Tcl_GetEncoding(NULL, "macRoman"); (void)Tcl_UtfToExternalDStringEx(encoding, value, -1, TCL_ENCODING_NOCOMPLAIN, &ds); len = Tcl_DStringLength(&ds); Tcl_DStringFree(&ds); Tcl_FreeEncoding(encoding); if (len > 4) { Tcl_SetObjResult(interp, Tcl_NewStringObj( "invalid bitmap value", -1)); Tcl_SetErrorCode(interp, "TK", "MACBITMAP", "INVALID", NULL); goto end; } } #endif ib.value = (char *)ckalloc(len + 1); strcpy(ib.value, value); if (!iconBitmapTable.buckets) { Tcl_InitHashTable(&iconBitmapTable, TCL_STRING_KEYS); } hPtr = Tcl_CreateHashEntry(&iconBitmapTable, name, &isNew); if (!isNew) { iconBitmap = (IconBitmap *)Tcl_GetHashValue(hPtr); ckfree(iconBitmap->value); } else { iconBitmap = (IconBitmap *)ckalloc(sizeof(IconBitmap)); Tcl_SetHashValue(hPtr, iconBitmap); } *iconBitmap = ib; result = TCL_OK; |
︙ | ︙ |
Changes to macosx/tkMacOSXButton.c.
1 2 3 4 5 6 | /* * tkMacOSXButton.c -- * * This file implements the Macintosh specific portion of the button * widgets. * | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tkMacOSXButton.c -- * * This file implements the Macintosh specific portion of the button * widgets. * * Copyright © 1996-1997 Sun Microsystems, Inc. * Copyright © 2001 Apple Computer, Inc. * Copyright © 2006-2007 Daniel A. Steffen <[email protected]> * 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. * */ #include "tkMacOSXPrivate.h" |
︙ | ︙ | |||
177 178 179 180 181 182 183 | *---------------------------------------------------------------------- */ void TkpDisplayButton( ClientData clientData) /* Information about widget. */ { | | | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | *---------------------------------------------------------------------- */ void TkpDisplayButton( ClientData clientData) /* Information about widget. */ { MacButton *macButtonPtr = (MacButton *)clientData; TkButton *butPtr = (TkButton *)clientData; Tk_Window tkwin = butPtr->tkwin; Pixmap pixmap; DrawParams* dpPtr = &macButtonPtr->drawParams; int needhighlight = 0; butPtr->flags &= ~REDRAW_PENDING; if ((butPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) { |
︙ | ︙ | |||
761 762 763 764 765 766 767 | /* * To avoid buttons with white text on a white background, we set the * state to inactive in Dark Mode unless the button is pressed or is a * -default active button. This isn't perfect but it is mostly usable. * Using a ttk::button would be a much better choice, however. */ | > | | | | > | 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 | /* * To avoid buttons with white text on a white background, we set the * state to inactive in Dark Mode unless the button is pressed or is a * -default active button. This isn't perfect but it is mostly usable. * Using a ttk::button would be a much better choice, however. */ if ([NSApp macOSVersion] < 101500) { if (TkMacOSXInDarkMode(butPtr->tkwin) && mbPtr->drawinfo.state != kThemeStatePressed && !(mbPtr->drawinfo.adornment & kThemeAdornmentDefault)) { hiinfo.state = kThemeStateInactive; } } HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, kHIThemeOrientationNormal, &contHIRec); TkMacOSXRestoreDrawingContext(&dc); ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo, (MacButton *) mbPtr, 32, true); |
︙ | ︙ | |||
897 898 899 900 901 902 903 | */ static void ButtonEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { | | | | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 | */ static void ButtonEventProc( ClientData clientData, /* Information about window. */ XEvent *eventPtr) /* Information about event. */ { TkButton *buttonPtr = (TkButton *)clientData; MacButton *mbPtr = (MacButton *)clientData; if (eventPtr->type == ActivateNotify || eventPtr->type == DeactivateNotify) { if ((buttonPtr->tkwin == NULL) || (!Tk_IsMapped(buttonPtr->tkwin))) { return; } if (eventPtr->type == ActivateNotify) { |
︙ | ︙ | |||
953 954 955 956 957 958 959 | *btnkind = kThemeBevelButton; } else if (butPtr->borderWidth == 4) { *btnkind = kThemeRoundedBevelButton; } else { *btnkind = kThemePushButton; } | | | 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | *btnkind = kThemeBevelButton; } else if (butPtr->borderWidth == 4) { *btnkind = kThemeRoundedBevelButton; } else { *btnkind = kThemePushButton; } if ((butPtr->image == NULL) && (butPtr->bitmap == None)) { switch (butPtr->type) { case TYPE_BUTTON: *btnkind = kThemePushButton; break; case TYPE_RADIO_BUTTON: if (butPtr->borderWidth <= 1) { *btnkind = kThemeSmallRadioButton; |
︙ | ︙ | |||
1170 1171 1172 1173 1174 1175 1176 | * *-------------------------------------------------------------- */ static void PulseDefaultButtonProc(ClientData clientData) { | | | 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | * *-------------------------------------------------------------- */ static void PulseDefaultButtonProc(ClientData clientData) { MacButton *mbPtr = (MacButton *)clientData; TkpDisplayButton(clientData); /* * Fix 40ada90762: any idle calls to TkpDisplayButton need to be canceled * in case the button is destroyed and has its data freed before the idle * event is handled (DestroyButton only cancels calls when REDRAW_PENDING * is set, which is not the case after calling TkpDisplayButton directly). |
︙ | ︙ |
Changes to macosx/tkMacOSXClipboard.c.
1 2 3 4 5 | /* * tkMacOSXClipboard.c -- * * This file manages the clipboard for the Tk toolkit. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXClipboard.c -- * * This file manages the clipboard for the Tk toolkit. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 2001-2009 Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * * 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 "tkMacOSXConstants.h" |
︙ | ︙ | |||
133 134 135 136 137 138 139 | NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: NSStringPboardType]]; if (type) { string = [pb stringForType:type]; } if (string) { | < | < < < < < | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: NSStringPboardType]]; if (type) { string = [pb stringForType:type]; } if (string) { result = proc(clientData, interp, string.UTF8String); } } else { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s selection doesn't exist or form \"%s\" not defined", Tk_GetAtomName(tkwin, selection), Tk_GetAtomName(tkwin, target))); Tcl_SetErrorCode(interp, "TK", "SELECTION", "EXISTS", NULL); |
︙ | ︙ |
Changes to macosx/tkMacOSXColor.c.
1 2 3 4 5 6 7 | /* * 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. * | | | | | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* * 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 © 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 <[email protected]> * 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" #include "tkMacOSXColor.h" static Tcl_HashTable systemColors; static int numSystemColors; static int rgbColorIndex; static int controlAccentIndex; static int selectedTabTextIndex; static int pressedButtonTextIndex; 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]; |
︙ | ︙ | |||
63 64 65 66 67 68 69 | NSString *colorName = [[NSString alloc] initWithCString:entry->macName encoding:NSUTF8StringEncoding]; SEL colorSelector = NSSelectorFromString(colorName); if (![NSColor respondsToSelector:colorSelector]) { if ([colorName isEqualToString:@"controlAccentColor"]) { useFakeAccentColor = YES; | | > | 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | 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"] && ![colorName isEqualToString:@"pressedButtonTextColor"]) { /* Uncomment to print all unsupported colors: */ /* printf("Unsupported color %s\n", colorName.UTF8String); */ continue; } } entry->selector = [colorName retain]; } |
︙ | ︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | 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 -- | > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | 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; hPtr = Tcl_FindHashEntry(&systemColors, "PressedButtonTextColor"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); pressedButtonTextIndex = entry->index; [pool drain]; } /* *---------------------------------------------------------------------- * * TkMacOSXRGBPixel -- |
︙ | ︙ | |||
173 174 175 176 177 178 179 | MODULE_SCOPE unsigned long TkMacOSXRGBPixel( unsigned long red, unsigned long green, unsigned long blue) { | | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | 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; } |
︙ | ︙ | |||
203 204 205 206 207 208 209 | * None. *---------------------------------------------------------------------- */ MODULE_SCOPE unsigned long TkMacOSXClearPixel( void) { | | | 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | * None. *---------------------------------------------------------------------- */ MODULE_SCOPE unsigned long TkMacOSXClearPixel( void) { MacPixel p = {0}; p.pixel.value = 0; p.pixel.colortype = clearColor; return p.ulong; } /* |
︙ | ︙ | |||
232 233 234 235 236 237 238 | *---------------------------------------------------------------------- */ SystemColorDatum* GetEntryFromPixel( unsigned long pixel) { | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | *---------------------------------------------------------------------- */ 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) { |
︙ | ︙ | |||
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | static void GetRGBA( SystemColorDatum *entry, unsigned long pixel, CGFloat *rgba) { NSColor *bgColor, *color = nil; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } 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; case ttkBackground: /* * Prior to OSX 10.14, getComponents returns black when applied to | > > | > > > > < > > > > > > > > < < | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | static void GetRGBA( SystemColorDatum *entry, unsigned long pixel, CGFloat *rgba) { NSColor *bgColor, *color = nil; int OSVersion = [NSApp macOSVersion]; if (!sRGB) { sRGB = [NSColorSpace sRGBColorSpace]; } 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; case ttkBackground: /* * 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]; } } 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 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) { if (OSVersion > 100600 && OSVersion < 110000) { color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; } else { color = [[NSColor textColor] colorUsingColorSpace:sRGB]; } } else if (entry->index == pressedButtonTextIndex) { if (OSVersion < 120000) { color = [[NSColor whiteColor] colorUsingColorSpace:sRGB]; } else { color = [[NSColor blackColor] colorUsingColorSpace:sRGB]; } } else { color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; } [color getComponents: rgba]; break; default: break; } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
369 370 371 372 373 374 375 376 377 378 379 380 381 382 | * 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; } | > | 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | * so it needs its own pool. */ NSAutoreleasePool *pool = [NSAutoreleasePool new]; if (entry->type == HIBrush) { OSStatus err = ChkErr(HIThemeBrushCreateCGColor, entry->value, c); [pool drain]; return err == noErr; } GetRGBA(entry, pixel, rgba); *c = CGColorCreate(sRGB.CGColorSpace, rgba); [pool drain]; return true; } |
︙ | ︙ | |||
408 409 410 411 412 413 414 | NSView *view = nil; if (winPtr && winPtr->privatePtr) { view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr); } if (view) { name = [[view effectiveAppearance] name]; } else { | | > > | | < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | > < < < | | | < | | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | NSView *view = nil; if (winPtr && winPtr->privatePtr) { view = TkMacOSXGetNSViewForDrawable((Drawable)winPtr->privatePtr); } if (view) { name = [[view effectiveAppearance] name]; } else { name = [[NSApp effectiveAppearance] name]; } return (name == NSAppearanceNameDarkAqua); } #else (void) tkwin; #endif return false; } /* *---------------------------------------------------------------------- * * TkSetMacColor -- * * 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 color is not found, true otherwise. * * Side effects: * The CGColorRef referenced by the variable macColor may be modified. * *---------------------------------------------------------------------- */ int TkSetMacColor( unsigned long pixel, /* Pixel value to convert. */ void *macColor) /* CGColorRef to modify. */ { CGColorRef *color = (CGColorRef*)macColor; 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: * A possibly nil pointer to an NSColor. * * Side effects: * None * *---------------------------------------------------------------------- */ NSColor* TkMacOSXGetNSColor( TCL_UNUSED(GC), unsigned long pixel) /* Pixel value to convert. */ { CGColorRef cgColor = NULL; NSColor *nsColor = nil; TkSetMacColor(pixel, &cgColor); if (cgColor) { nsColor = [NSColor colorWithColorSpace:sRGB components:CGColorGetComponents(cgColor) count:CGColorGetNumberOfComponents(cgColor)]; CGColorRelease(cgColor); } return nsColor; } /* *---------------------------------------------------------------------- * |
︙ | ︙ | |||
621 622 623 624 625 626 627 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXSetColorInContext( | | | | < < | 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | * None. * *---------------------------------------------------------------------- */ void TkMacOSXSetColorInContext( TCL_UNUSED(GC), unsigned long pixel, CGContextRef context) { OSStatus err = noErr; CGColorRef cgColor = NULL; 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); CGContextSetStrokeColorWithColor(context, cgColor); CGColorRelease(cgColor); |
︙ | ︙ | |||
691 692 693 694 695 696 697 | { Display *display = NULL; TkColor *tkColPtr; XColor color; Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap; NSView *view = nil; static Bool initialized = NO; | < < | | < | > > > > > > > > > > | | | > > | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | { Display *display = NULL; TkColor *tkColPtr; XColor color; Colormap colormap = tkwin ? Tk_Colormap(tkwin) : noColormap; NSView *view = nil; static Bool initialized = NO; if (!initialized) { initialized = YES; initColorTable(); } if (tkwin) { display = Tk_Display(tkwin); Drawable d = Tk_WindowId(tkwin); view = TkMacOSXGetNSViewForDrawable(d); } /* * Check to see if this is a system color. If not, just call XParseColor. */ if (strncasecmp(name, "system", 6) == 0) { Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&systemColors, name + 6); MacPixel p = {0}; if (hPtr != NULL) { SystemColorDatum *entry = (SystemColorDatum *)Tcl_GetHashValue(hPtr); CGColorRef c = NULL; 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 *windowAppearance; if (view) { windowAppearance = [view effectiveAppearance]; } else { windowAppearance = [NSApp effectiveAppearance]; } if ([windowAppearance name] == NSAppearanceNameDarkAqua) { colormap = darkColormap; } else { colormap = lightColormap; } if (@available(macOS 11.0, *)) { CGFloat *rgbaPtr = rgba; [windowAppearance performAsCurrentDrawingAppearance:^{ GetRGBA(entry, p.ulong, rgbaPtr); }]; } else { #if MAC_OS_X_VERSION_MIN_REQUIRED < 110000 NSAppearance *savedAppearance = [NSAppearance currentAppearance]; [NSAppearance setCurrentAppearance:windowAppearance]; GetRGBA(entry, p.ulong, rgba); [NSAppearance setCurrentAppearance:savedAppearance]; #endif } } else { GetRGBA(entry, p.ulong, rgba); } #else GetRGBA(entry, p.ulong, rgba); #endif color.red = rgba[0] * 65535.0; |
︙ | ︙ |
Changes to macosx/tkMacOSXColor.h.
︙ | ︙ | |||
83 84 85 86 87 88 89 | * 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 }, | | | 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | * 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 }, |
︙ | ︙ | |||
171 172 173 174 175 176 177 | {"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 }, | | > > > | | 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | {"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 label text -- depends on OS version. */ {"SelectedTabTextColor", semantic, 0, "textColor", 0, NULL }, /* Color to use for selected button labels -- depends on OS version. */ {"PressedButtonTextColor", 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, rgbColor, 0, NULL, 0, NULL } }; #endif /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Changes to macosx/tkMacOSXConfig.c.
1 2 3 4 5 6 | /* * tkMacOSXConfig.c -- * * This module implements the Macintosh system defaults for * the configuration package. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* * tkMacOSXConfig.c -- * * This module implements the Macintosh system defaults for * the configuration package. * * 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. */ #include "tkInt.h" /* *---------------------------------------------------------------------- * * Tk_GetSystemDefault -- * * Given a dbName and className for a configuration option, * return a string representation of the option. * * Results: * Returns a Tk_Uid that is the string identifier that identifies * this option. Returns NULL if there are no system defaults * that match this pair. * * Side effects: * None, once the package is initialized. * *---------------------------------------------------------------------- */ Tcl_Obj * Tk_GetSystemDefault( Tk_Window tkwin, /* A window to use. */ const char *dbName, /* The option database name. */ const char *className) /* The name of the option class. */ { (void)tkwin; (void)dbName; (void)className; |
︙ | ︙ |
Changes to macosx/tkMacOSXConstants.h.
1 2 3 4 5 6 7 8 | /* * tkMacOSXConstants.h -- * * 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.) * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkMacOSXConstants.h -- * * 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 © 2017 Marc Culler * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACCONSTANTS #define _TKMACCONSTANTS |
︙ | ︙ | |||
79 80 81 82 83 84 85 | #define NSCursorUpdate NSEventTypeCursorUpdate #define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground #define NSCompositeCopy NSCompositingOperationCopy #define NSWarningAlertStyle NSAlertStyleWarning #define NSInformationalAlertStyle NSAlertStyleInformational #define NSCriticalAlertStyle NSAlertStyleCritical #define NSCenterTextAlignment NSTextAlignmentCenter | < > > > > > | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #define NSCursorUpdate NSEventTypeCursorUpdate #define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground #define NSCompositeCopy NSCompositingOperationCopy #define NSWarningAlertStyle NSAlertStyleWarning #define NSInformationalAlertStyle NSAlertStyleInformational #define NSCriticalAlertStyle NSAlertStyleCritical #define NSCenterTextAlignment NSTextAlignmentCenter #define NSApplicationDefinedMask NSEventMaskApplicationDefined #define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow #define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel #define NSDocModalWindowMask NSWindowStyleMaskDocModalWindow #define NSHUDWindowMask NSWindowStyleMaskHUDWindow #define NSTitledWindowMask NSWindowStyleMaskTitled #define NSClosableWindowMask NSWindowStyleMaskClosable #define NSResizableWindowMask NSWindowStyleMaskResizable #define NSUnifiedTitleAndToolbarWindowMask NSWindowStyleMaskUnifiedTitleAndToolbar #define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable #define NSBorderlessWindowMask NSWindowStyleMaskBorderless #define NSFullScreenWindowMask NSWindowStyleMaskFullScreen #define NSAlphaFirstBitmapFormat NSBitmapFormatAlphaFirst #define NSAnyEventMask NSEventMaskAny #define NSLeftMouseDownMask NSEventMaskLeftMouseDown #define NSMouseMovedMask NSEventMaskMouseMoved #define NSLeftMouseDraggedMask NSEventMaskLeftMouseDragged #endif #if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 #define NSStringPboardType NSPasteboardTypeString #define NSOnState NSControlStateValueOn #define NSOffState NSControlStateValueOff #endif |
︙ | ︙ |
Changes to macosx/tkMacOSXCursor.c.
1 2 3 4 5 | /* * tkMacOSXCursor.c -- * * This file contains Macintosh specific cursor related routines. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXCursor.c -- * * This file contains Macintosh specific cursor related routines. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 2001-2009 Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * * 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 "tkMacOSXCursors.h" |
︙ | ︙ | |||
258 259 260 261 262 263 264 | haveHotSpot = 1; break; case IMAGEPATH: path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1]; break; case IMAGEBITMAP: { unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1); | | | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | haveHotSpot = 1; break; case IMAGEPATH: path = [NSApp tkFrameworkImagePath:cursorNames[idx].id1]; break; case IMAGEBITMAP: { unsigned char *bitmap = (unsigned char *)(cursorNames[idx].id1); NSBitmapImageRep *bitmapImageRep = nil; CGImageRef img = NULL, mask = NULL, maskedImg = NULL; static const CGFloat decodeWB[] = {1, 0}; CGColorSpaceRef colorspace = CGColorSpaceCreateWithName( kCGColorSpaceGenericGray); CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, bitmap, pix*pix/8, NULL); |
︙ | ︙ | |||
368 369 370 371 372 373 374 | Tcl_Interp *interp, /* Interpreter to use for error reporting. */ 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; | | | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | Tcl_Interp *interp, /* Interpreter to use for error reporting. */ 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; TkSizeT argc; /* * All cursor names are valid lists of one element (for * TkX11-compatibility), even unadorned system cursor names. */ if (Tcl_SplitList(interp, string, &argc, &argv) == TCL_OK) { |
︙ | ︙ | |||
453 454 455 456 457 458 459 | void TkpFreeCursor( TkCursor *cursorPtr) { TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr; [macCursorPtr->macCursor release]; | | | 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | void TkpFreeCursor( TkCursor *cursorPtr) { TkMacOSXCursor *macCursorPtr = (TkMacOSXCursor *) cursorPtr; [macCursorPtr->macCursor release]; macCursorPtr->macCursor = nil; if (macCursorPtr == gCurrentCursor) { gCurrentCursor = NULL; } } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
532 533 534 535 536 537 538 | void TkpSetCursor( TkpCursor cursor) { int cursorChanged = 1; | | | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | void TkpSetCursor( TkpCursor cursor) { int cursorChanged = 1; if (cursor == NULL) { /* * 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 * NULL, we always need to reset it, we can't trust the cursorChanged * logic. */ |
︙ | ︙ |
Changes to macosx/tkMacOSXCursors.h.
1 2 3 4 5 6 | /* * tkMacOSXCursors.h -- * * This file defines a set of Macintosh cursor resources that * are only available on the Macintosh platform. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkMacOSXCursors.h -- * * This file defines a set of Macintosh cursor resources that * are only available on the Macintosh platform. * * Copyright © 1995-1996 Sun Microsystems, Inc. * Copyright © 2008-2009 Apple Inc. * Copyright © 2008-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ static const unsigned char tkMacOSXCursors[][68] = { |
︙ | ︙ |
Changes to macosx/tkMacOSXDebug.c.
1 2 3 4 5 6 | /* * tkMacOSXDebug.c -- * * Implementation of Macintosh specific functions for debugging MacOS * events, regions, etc... * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXDebug.c -- * * Implementation of Macintosh specific functions for debugging MacOS * events, regions, etc... * * Copyright © 2001-2009, Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * * 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" |
︙ | ︙ |
Changes to macosx/tkMacOSXDebug.h.
1 2 3 4 5 6 | /* * tkMacOSXDebug.h -- * * Declarations of Macintosh specific functions for debugging MacOS events, * regions, etc... * | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXDebug.h -- * * Declarations of Macintosh specific functions for debugging MacOS events, * regions, etc... * * Copyright © 2001-2009, Apple Inc. * Copyright © 2005-2009 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef _TKMACDEBUG #define _TKMACDEBUG |
︙ | ︙ |
Changes to macosx/tkMacOSXDefault.h.
︙ | ︙ | |||
38 39 40 41 42 43 44 | #define NORMAL_BG "systemWindowBackgroundColor" #define TEXT_BG "systemTextBackgroundColor" #define NORMAL_FG "systemTextColor" #define ACTIVE_BG "systemWindowBackgroundColor" #define ACTIVE_FG "systemTextColor" #define SELECT_BG "systemSelectedTextBackgroundColor" #define SELECT_FG "systemSelectedTextColor" | | > | | > | | < < < < < < < < < < < | | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #define NORMAL_BG "systemWindowBackgroundColor" #define TEXT_BG "systemTextBackgroundColor" #define NORMAL_FG "systemTextColor" #define ACTIVE_BG "systemWindowBackgroundColor" #define ACTIVE_FG "systemTextColor" #define SELECT_BG "systemSelectedTextBackgroundColor" #define SELECT_FG "systemSelectedTextColor" #define INACTIVE_SELECT_BG "systemUnemphasizedSelectedTextBackgroundColor" #define TROUGH "#c3c3c3" #define INDICATOR "#b03060" #define DISABLED "systemDisabledControlTextColor" #define IGNORED "#abcdef" /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: */ #define DEF_BUTTON_ANCHOR "center" #define DEF_BUTTON_ACTIVE_BG_COLOR ACTIVE_BG #define DEF_BUTTON_ACTIVE_BG_MONO BLACK #define DEF_BUTTON_ACTIVE_FG_COLOR "systemPressedButtonTextColor" #define DEF_CHKRAD_ACTIVE_FG_COLOR ACTIVE_FG #define DEF_BUTTON_ACTIVE_FG_MONO WHITE #define DEF_BUTTON_BG_COLOR NORMAL_BG #define DEF_BUTTON_BG_MONO WHITE #define DEF_BUTTON_BITMAP "" #define DEF_BUTTON_BORDER_WIDTH "2" #define DEF_BUTTON_CURSOR "" #define DEF_BUTTON_COMMAND "" #define DEF_BUTTON_COMPOUND "none" #define DEF_BUTTON_DEFAULT "disabled" #define DEF_BUTTON_DISABLED_FG_COLOR DISABLED #define DEF_BUTTON_DISABLED_FG_MONO "" #define DEF_BUTTON_FG BLACK #define DEF_LABEL_FG NORMAL_FG #define DEF_CHKRAD_FG DEF_LABEL_FG #define DEF_BUTTON_FONT "TkDefaultFont" #define DEF_BUTTON_HEIGHT "0" #define DEF_BUTTON_HIGHLIGHT_BG_COLOR DEF_BUTTON_BG_COLOR #define DEF_BUTTON_HIGHLIGHT_BG_MONO DEF_BUTTON_BG_MONO #define DEF_BUTTON_HIGHLIGHT NORMAL_FG #define DEF_LABEL_HIGHLIGHT_WIDTH "0" //#if TK_MAC_BUTTON_USE_COMPATIBILITY_METRICS //#define DEF_BUTTON_HIGHLIGHT_WIDTH "4" //#define DEF_BUTTON_HIGHLIGHT_WIDTH_NOCM "1" //#else #define DEF_BUTTON_HIGHLIGHT_WIDTH "1" //#endif #define DEF_BUTTON_IMAGE NULL #define DEF_BUTTON_INDICATOR "1" #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 "" #define DEF_BUTTON_PADX "1" #define DEF_LABCHKRAD_PADX "1" #define DEF_BUTTON_PADY "1" #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" #define DEF_BUTTON_SELECT_COLOR INDICATOR #define DEF_BUTTON_SELECT_MONO BLACK #define DEF_BUTTON_SELECT_IMAGE NULL #define DEF_BUTTON_STATE "normal" #define DEF_LABEL_TAKE_FOCUS "0" #define DEF_BUTTON_TAKE_FOCUS NULL #define DEF_BUTTON_TEXT "" #define DEF_BUTTON_TEXT_VARIABLE "" #define DEF_BUTTON_VALUE "" #define DEF_BUTTON_WIDTH "0" #define DEF_BUTTON_WRAP_LENGTH "0" #define DEF_RADIOBUTTON_VARIABLE "selectedButton" #define DEF_CHECKBUTTON_VARIABLE "" /* * Defaults for canvases: */ #define DEF_CANVAS_BG_COLOR NORMAL_BG #define DEF_CANVAS_BG_MONO WHITE #define DEF_CANVAS_BORDER_WIDTH "0" #define DEF_CANVAS_CLOSE_ENOUGH "1" #define DEF_CANVAS_CONFINE "1" #define DEF_CANVAS_CURSOR "" #define DEF_CANVAS_HEIGHT "7c" #define DEF_CANVAS_HIGHLIGHT_BG NORMAL_BG #define DEF_CANVAS_HIGHLIGHT NORMAL_FG #define DEF_CANVAS_HIGHLIGHT_WIDTH "3" #define DEF_CANVAS_INSERT_BG BLACK #define DEF_CANVAS_INSERT_BD_COLOR "0" #define DEF_CANVAS_INSERT_BD_MONO "0" #define DEF_CANVAS_INSERT_OFF_TIME "300" #define DEF_CANVAS_INSERT_ON_TIME "600" #define DEF_CANVAS_INSERT_WIDTH "2" |
︙ | ︙ | |||
179 180 181 182 183 184 185 | #define DEF_ENTRY_DISABLED_BG_COLOR NORMAL_BG #define DEF_ENTRY_DISABLED_BG_MONO WHITE #define DEF_ENTRY_DISABLED_FG DISABLED #define DEF_ENTRY_EXPORT_SELECTION "1" #define DEF_ENTRY_FONT "TkTextFont" #define DEF_ENTRY_FG NORMAL_FG #define DEF_ENTRY_HIGHLIGHT_BG NORMAL_BG | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | #define DEF_ENTRY_DISABLED_BG_COLOR NORMAL_BG #define DEF_ENTRY_DISABLED_BG_MONO WHITE #define DEF_ENTRY_DISABLED_FG DISABLED #define DEF_ENTRY_EXPORT_SELECTION "1" #define DEF_ENTRY_FONT "TkTextFont" #define DEF_ENTRY_FG NORMAL_FG #define DEF_ENTRY_HIGHLIGHT_BG NORMAL_BG #define DEF_ENTRY_HIGHLIGHT NORMAL_FG #define DEF_ENTRY_HIGHLIGHT_WIDTH "3" #define DEF_ENTRY_INSERT_BG NORMAL_FG #define DEF_ENTRY_INSERT_BD_COLOR "0" #define DEF_ENTRY_INSERT_BD_MONO "0" #define DEF_ENTRY_INSERT_OFF_TIME "300" #define DEF_ENTRY_INSERT_ON_TIME "600" #define DEF_ENTRY_INSERT_WIDTH "1" |
︙ | ︙ | |||
221 222 223 224 225 226 227 | #define DEF_FRAME_BORDER_WIDTH "0" #define DEF_FRAME_CLASS "Frame" #define DEF_FRAME_COLORMAP "" #define DEF_FRAME_CONTAINER "0" #define DEF_FRAME_CURSOR "" #define DEF_FRAME_HEIGHT "0" #define DEF_FRAME_HIGHLIGHT_BG NORMAL_BG | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | #define DEF_FRAME_BORDER_WIDTH "0" #define DEF_FRAME_CLASS "Frame" #define DEF_FRAME_COLORMAP "" #define DEF_FRAME_CONTAINER "0" #define DEF_FRAME_CURSOR "" #define DEF_FRAME_HEIGHT "0" #define DEF_FRAME_HIGHLIGHT_BG NORMAL_BG #define DEF_FRAME_HIGHLIGHT NORMAL_FG #define DEF_FRAME_HIGHLIGHT_WIDTH "0" #define DEF_FRAME_PADX "0" #define DEF_FRAME_PADY "0" #define DEF_FRAME_RELIEF "flat" #define DEF_FRAME_TAKE_FOCUS "0" #define DEF_FRAME_VISUAL "" #define DEF_FRAME_WIDTH "0" |
︙ | ︙ | |||
257 258 259 260 261 262 263 | #define DEF_LISTBOX_CURSOR "" #define DEF_LISTBOX_DISABLED_FG DISABLED #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "TkTextFont" #define DEF_LISTBOX_FG NORMAL_FG #define DEF_LISTBOX_HEIGHT "10" #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG | | | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | #define DEF_LISTBOX_CURSOR "" #define DEF_LISTBOX_DISABLED_FG DISABLED #define DEF_LISTBOX_EXPORT_SELECTION "1" #define DEF_LISTBOX_FONT "TkTextFont" #define DEF_LISTBOX_FG NORMAL_FG #define DEF_LISTBOX_HEIGHT "10" #define DEF_LISTBOX_HIGHLIGHT_BG NORMAL_BG #define DEF_LISTBOX_HIGHLIGHT NORMAL_FG #define DEF_LISTBOX_HIGHLIGHT_WIDTH "0" #define DEF_LISTBOX_JUSTIFY "left" #define DEF_LISTBOX_RELIEF "solid" #define DEF_LISTBOX_SCROLL_COMMAND "" #define DEF_LISTBOX_LIST_VARIABLE "" #define DEF_LISTBOX_SELECT_COLOR SELECT_BG #define DEF_LISTBOX_SELECT_MONO BLACK |
︙ | ︙ | |||
301 302 303 304 305 306 307 | #define DEF_MENU_ENTRY_ON_VALUE "1" #define DEF_MENU_ENTRY_SELECT_IMAGE NULL #define DEF_MENU_ENTRY_STATE "normal" #define DEF_MENU_ENTRY_VALUE NULL #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL | < | | | | | | | | | | | | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | #define DEF_MENU_ENTRY_ON_VALUE "1" #define DEF_MENU_ENTRY_SELECT_IMAGE NULL #define DEF_MENU_ENTRY_STATE "normal" #define DEF_MENU_ENTRY_VALUE NULL #define DEF_MENU_ENTRY_CHECK_VARIABLE NULL #define DEF_MENU_ENTRY_RADIO_VARIABLE "selectedButton" #define DEF_MENU_ENTRY_SELECT NULL /* * Defaults for menus overall: */ #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 IGNORED #define DEF_MENU_ACTIVE_FG_MONO IGNORED #define DEF_MENU_ACTIVE_RELIEF "flat" #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 IGNORED #define DEF_MENU_DISABLED_FG_MONO "" #define DEF_MENU_FONT "menu" /* special: see tkMacOSXMenu.c */ #define DEF_MENU_FG "#010000" /* Detects custom fg. */ #define DEF_MENU_POST_COMMAND "" #define DEF_MENU_RELIEF "flat" #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" /* |
︙ | ︙ | |||
353 354 355 356 357 358 359 | #define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED #define DEF_MENUBUTTON_DISABLED_FG_MONO "" #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 | | < | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | #define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED #define DEF_MENUBUTTON_DISABLED_FG_MONO "" #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 NORMAL_FG #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 "" #define DEF_MENUBUTTON_PADX "0" #define DEF_MENUBUTTON_PADY "0" #define DEF_MENUBUTTON_RELIEF "flat" #define DEF_MENUBUTTON_STATE "normal" #define DEF_MENUBUTTON_TAKE_FOCUS "0" #define DEF_MENUBUTTON_TEXT "" #define DEF_MENUBUTTON_TEXT_VARIABLE "" #define DEF_MENUBUTTON_WIDTH "0" #define DEF_MENUBUTTON_WRAP_LENGTH "0" /* * Defaults for messages: */ #define DEF_MESSAGE_ANCHOR "center" #define DEF_MESSAGE_ASPECT "150" #define DEF_MESSAGE_BG_COLOR NORMAL_BG #define DEF_MESSAGE_BG_MONO WHITE #define DEF_MESSAGE_BORDER_WIDTH "1" #define DEF_MESSAGE_CURSOR "" #define DEF_MESSAGE_FG NORMAL_FG #define DEF_MESSAGE_FONT "TkDefaultFont" #define DEF_MESSAGE_HIGHLIGHT_BG NORMAL_BG #define DEF_MESSAGE_HIGHLIGHT NORMAL_FG #define DEF_MESSAGE_HIGHLIGHT_WIDTH "0" #define DEF_MESSAGE_JUSTIFY "left" #define DEF_MESSAGE_PADX "-1" #define DEF_MESSAGE_PADY "-1" #define DEF_MESSAGE_RELIEF "flat" #define DEF_MESSAGE_TAKE_FOCUS "0" #define DEF_MESSAGE_TEXT "" |
︙ | ︙ | |||
449 450 451 452 453 454 455 | #define DEF_SCALE_DIGITS "0" #define DEF_SCALE_FONT "TkDefaultFont" #define DEF_SCALE_FG_COLOR NORMAL_FG #define DEF_SCALE_FG_MONO BLACK #define DEF_SCALE_FROM "0" #define DEF_SCALE_HIGHLIGHT_BG_COLOR DEF_SCALE_BG_COLOR #define DEF_SCALE_HIGHLIGHT_BG_MONO DEF_SCALE_BG_MONO | | | 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | #define DEF_SCALE_DIGITS "0" #define DEF_SCALE_FONT "TkDefaultFont" #define DEF_SCALE_FG_COLOR NORMAL_FG #define DEF_SCALE_FG_MONO BLACK #define DEF_SCALE_FROM "0" #define DEF_SCALE_HIGHLIGHT_BG_COLOR DEF_SCALE_BG_COLOR #define DEF_SCALE_HIGHLIGHT_BG_MONO DEF_SCALE_BG_MONO #define DEF_SCALE_HIGHLIGHT NORMAL_FG #define DEF_SCALE_HIGHLIGHT_WIDTH "0" #define DEF_SCALE_LABEL "" #define DEF_SCALE_LENGTH "100" #define DEF_SCALE_ORIENT "vertical" #define DEF_SCALE_RELIEF "flat" #define DEF_SCALE_REPEAT_DELAY "300" #define DEF_SCALE_REPEAT_INTERVAL "100" |
︙ | ︙ | |||
484 485 486 487 488 489 490 | #define DEF_SCROLLBAR_BG_COLOR NORMAL_BG #define DEF_SCROLLBAR_BG_MONO WHITE #define DEF_SCROLLBAR_BORDER_WIDTH "0" #define DEF_SCROLLBAR_COMMAND "" #define DEF_SCROLLBAR_CURSOR "" #define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1" #define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG | | | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 | #define DEF_SCROLLBAR_BG_COLOR NORMAL_BG #define DEF_SCROLLBAR_BG_MONO WHITE #define DEF_SCROLLBAR_BORDER_WIDTH "0" #define DEF_SCROLLBAR_COMMAND "" #define DEF_SCROLLBAR_CURSOR "" #define DEF_SCROLLBAR_EL_BORDER_WIDTH "-1" #define DEF_SCROLLBAR_HIGHLIGHT_BG NORMAL_BG #define DEF_SCROLLBAR_HIGHLIGHT NORMAL_FG #define DEF_SCROLLBAR_HIGHLIGHT_WIDTH "0" #define DEF_SCROLLBAR_JUMP "0" #define DEF_SCROLLBAR_ORIENT "vertical" #define DEF_SCROLLBAR_RELIEF "flat" #define DEF_SCROLLBAR_REPEAT_DELAY "300" #define DEF_SCROLLBAR_REPEAT_INTERVAL "100" #define DEF_SCROLLBAR_TAKE_FOCUS NULL |
︙ | ︙ | |||
511 512 513 514 515 516 517 | #define DEF_TEXT_BORDER_WIDTH "0" #define DEF_TEXT_CURSOR "xterm" #define DEF_TEXT_FG NORMAL_FG #define DEF_TEXT_EXPORT_SELECTION "1" #define DEF_TEXT_FONT "TkFixedFont" #define DEF_TEXT_HEIGHT "24" #define DEF_TEXT_HIGHLIGHT_BG NORMAL_BG | | | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 | #define DEF_TEXT_BORDER_WIDTH "0" #define DEF_TEXT_CURSOR "xterm" #define DEF_TEXT_FG NORMAL_FG #define DEF_TEXT_EXPORT_SELECTION "1" #define DEF_TEXT_FONT "TkFixedFont" #define DEF_TEXT_HEIGHT "24" #define DEF_TEXT_HIGHLIGHT_BG NORMAL_BG #define DEF_TEXT_HIGHLIGHT NORMAL_FG #define DEF_TEXT_HIGHLIGHT_WIDTH "3" #define DEF_TEXT_INSERT_BG NORMAL_FG #define DEF_TEXT_INSERT_BD_COLOR "0" #define DEF_TEXT_INSERT_BD_MONO "0" #define DEF_TEXT_INSERT_OFF_TIME "300" #define DEF_TEXT_INSERT_ON_TIME "600" #define DEF_TEXT_INSERT_UNFOCUSSED "none" |
︙ | ︙ |
Changes to macosx/tkMacOSXDialog.c.
1 2 3 4 5 6 | /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. | | | > | > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright (c) 2001-2009, Apple Inc. * Copyright (c) 2006-2009 Daniel A. Steffen <[email protected]> * Copyright (c) 2017 Christian Gollwitzer * Copyright (c) 2022 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 "tkFileFilter.h" #include "tkMacOSXConstants.h" #if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 #define modalOK NSOKButton #define modalCancel NSCancelButton #else #define modalOK NSModalResponseOK #define modalCancel NSModalResponseCancel #endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090 #define modalOther -1 // indicates that the -command option was used. #define modalError -2 static void setAllowedFileTypes( NSSavePanel *panel, NSMutableArray *extensions) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 /* UTType exists in the SDK */ if (@available(macOS 11.0, *)) { NSMutableArray<UTType *> *allowedTypes = [NSMutableArray array]; for (NSString *ext in extensions) { UTType *uttype = [UTType typeWithFilenameExtension: ext]; [allowedTypes addObject:uttype]; } [panel setAllowedContentTypes:allowedTypes]; } else { # if MAC_OS_X_VERSION_MIN_REQUIRED < 110000 /* setAllowedFileTypes is not deprecated */ [panel setAllowedFileTypes:extensions]; #endif } #else [panel setAllowedFileTypes:extensions]; #endif } /* * Vars for filtering in "open file" and "save file" dialogs. */ typedef struct { bool doFileTypes; /* Show the accessory view which |
︙ | ︙ | |||
64 65 66 67 68 69 70 | "-initialcolor", "-parent", "-title", NULL }; enum colorOptions { COLOR_INITIAL, COLOR_PARENT, COLOR_TITLE }; static const char *const openOptionStrings[] = { | | | | | | | | | | | | | | | | | | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | "-initialcolor", "-parent", "-title", NULL }; enum colorOptions { COLOR_INITIAL, COLOR_PARENT, COLOR_TITLE }; static const char *const openOptionStrings[] = { "-command", "-defaultextension", "-filetypes", "-initialdir", "-initialfile", "-message", "-multiple", "-parent", "-title", "-typevariable", NULL }; enum openOptions { OPEN_COMMAND, OPEN_DEFAULT, OPEN_FILETYPES, OPEN_INITDIR, OPEN_INITFILE, OPEN_MESSAGE, OPEN_MULTIPLE, OPEN_PARENT, OPEN_TITLE, OPEN_TYPEVARIABLE }; static const char *const saveOptionStrings[] = { "-command", "-confirmoverwrite", "-defaultextension", "-filetypes", "-initialdir", "-initialfile", "-message", "-parent", "-title", "-typevariable", NULL }; enum saveOptions { SAVE_COMMAND, SAVE_CONFIRMOW, SAVE_DEFAULT, SAVE_FILETYPES, SAVE_INITDIR, SAVE_INITFILE, SAVE_MESSAGE, SAVE_PARENT, SAVE_TITLE, SAVE_TYPEVARIABLE }; static const char *const chooseOptionStrings[] = { "-command", "-initialdir", "-message", "-mustexist", "-parent", "-title", NULL }; enum chooseOptions { CHOOSE_COMMAND, CHOOSE_INITDIR, CHOOSE_MESSAGE, CHOOSE_MUSTEXIST, CHOOSE_PARENT, CHOOSE_TITLE }; typedef struct { Tcl_Interp *interp; Tcl_Obj *cmdObj; int multiple; } FilePanelCallbackInfo; static const char *const alertOptionStrings[] = { "-default", "-detail", "-icon", "-message", "-parent", "-title", "-type", "-command", NULL }; enum alertOptions { ALERT_DEFAULT, ALERT_DETAIL, ALERT_ICON, ALERT_MESSAGE, ALERT_PARENT, ALERT_TITLE, ALERT_TYPE, ALERT_COMMAND }; typedef struct { Tcl_Interp *interp; Tcl_Obj *cmdObj; int typeIndex; } AlertCallbackInfo; static const char *const alertTypeStrings[] = { |
︙ | ︙ | |||
215 216 217 218 219 220 221 | (void)sender; (void)url; *outError = nil; return YES; } - (void) tkFilePanelDidEnd: (NSSavePanel *) panel returnCode: (NSModalResponse) returnCode | | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | (void)sender; (void)url; *outError = nil; return YES; } - (void) tkFilePanelDidEnd: (NSSavePanel *) panel returnCode: (NSModalResponse) returnCode contextInfo: (const void *) contextInfo { const FilePanelCallbackInfo *callbackInfo = (const FilePanelCallbackInfo *)contextInfo; if (returnCode == modalOK) { Tcl_Obj *resultObj; if (callbackInfo->multiple) { resultObj = Tcl_NewListObj(0, NULL); for (NSURL *url in [(NSOpenPanel*)panel URLs]) { |
︙ | ︙ | |||
250 251 252 253 254 255 256 | } } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } } else if (returnCode == modalCancel) { Tcl_ResetResult(callbackInfo->interp); } | < < < < < < | | | 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | } } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } } else if (returnCode == modalCancel) { Tcl_ResetResult(callbackInfo->interp); } [NSApp stopModalWithCode:returnCode]; } - (void) tkAlertDidEnd: (NSAlert *) alert returnCode: (NSInteger) returnCode contextInfo: (const void *) contextInfo { AlertCallbackInfo *callbackInfo = (AlertCallbackInfo *)contextInfo; if (returnCode >= NSAlertFirstButtonReturn) { Tcl_Obj *resultObj = Tcl_NewStringObj(alertButtonStrings[ alertNativeButtonIndexAndTypeToButtonIndex[callbackInfo-> typeIndex][returnCode - NSAlertFirstButtonReturn]], -1); if (callbackInfo->cmdObj) { |
︙ | ︙ | |||
289 290 291 292 293 294 295 | } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } } if ([alert window] == [NSApp modalWindow]) { [NSApp stopModalWithCode:returnCode]; } | < < < < < | | | | > | > > > > > > > > | | | | | | | < | | | | | < | < > > | < > > > | | < < < < < < < < < < < < | | | | | < | < | | 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } } if ([alert window] == [NSApp modalWindow]) { [NSApp stopModalWithCode:returnCode]; } } - (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 * the NSSavePanel, where it has the effect that it does not append an * extension. Setting the allowed file types to nil allows selecting * any file. */ setAllowedFileTypes(openpanel, nil); } else { NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]; setAllowedFileTypes(openpanel, allowedtypes); [openpanel setAllowsOtherFileTypes:NO]; } filterInfo.userHasSelectedFilter = true; } - (void)saveFormat:(id)sender { NSPopUpButton *button = (NSPopUpButton *)sender; filterInfo.fileTypeIndex = [button indexOfSelectedItem]; if ([[filterInfo.fileTypeAllowsAll objectAtIndex:filterInfo.fileTypeIndex] boolValue]) { [savepanel setAllowsOtherFileTypes:YES]; setAllowedFileTypes(savepanel, nil); } else { NSMutableArray *allowedtypes = [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]; setAllowedFileTypes(savepanel, allowedtypes); [savepanel setAllowsOtherFileTypes:NO]; } filterInfo.userHasSelectedFilter = true; } @end #pragma mark - static NSInteger showOpenSavePanel( NSSavePanel *panel, NSWindow *parent, Tcl_Interp *interp, Tcl_Obj *cmdObj, int multiple) { NSInteger modalReturnCode; int OSVersion = [NSApp macOSVersion]; const FilePanelCallbackInfo callbackInfo = {interp, cmdObj, multiple}; /* * Use a sheet if -parent is specified (unless there is already a sheet). */ if (parent && ![parent attachedSheet]) { if (OSVersion < 101500) { [panel beginSheetModalForWindow:parent completionHandler:^(NSModalResponse returnCode) { [NSApp tkFilePanelDidEnd:panel returnCode:returnCode contextInfo:&callbackInfo ]; }]; modalReturnCode = [NSApp runModalForWindow:panel]; } else if (OSVersion < 110000) { [panel beginSheetModalForWindow:parent completionHandler:^(NSModalResponse returnCode) { [NSApp tkFilePanelDidEnd:panel returnCode:returnCode contextInfo:&callbackInfo ]; }]; modalReturnCode = [panel runModal]; } else { [parent beginSheet: panel completionHandler:nil]; modalReturnCode = [panel runModal]; [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode contextInfo:&callbackInfo ]; [parent endSheet:panel]; } } else { modalReturnCode = [panel runModal]; [NSApp tkFilePanelDidEnd:panel returnCode:modalReturnCode contextInfo:&callbackInfo ]; } return cmdObj ? modalOther : modalReturnCode; } /* *---------------------------------------------------------------------- * * Tk_ChooseColorObjCmd -- * |
︙ | ︙ | |||
419 420 421 422 423 424 425 | Tk_ChooseColorObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int result = TCL_ERROR; | | | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | Tk_ChooseColorObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { int result = TCL_ERROR; Tk_Window parent, tkwin = (Tk_Window)clientData; const char *title = NULL; int i; NSColor *color = nil, *initialColor = nil; NSColorPanel *colorPanel; NSInteger returnCode, numberOfComponents = 0; for (i = 1; i < objc; i += 2) { |
︙ | ︙ | |||
472 473 474 475 476 477 478 | colorPanel = [NSColorPanel sharedColorPanel]; [colorPanel orderOut:NSApp]; [colorPanel setContinuous:NO]; [colorPanel setBecomesKeyOnlyIfNeeded:NO]; [colorPanel setShowsAlpha: NO]; [colorPanel _setUseModalAppearance:YES]; if (title) { | | | 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | colorPanel = [NSColorPanel sharedColorPanel]; [colorPanel orderOut:NSApp]; [colorPanel setContinuous:NO]; [colorPanel setBecomesKeyOnlyIfNeeded:NO]; [colorPanel setShowsAlpha: NO]; [colorPanel _setUseModalAppearance:YES]; if (title) { NSString *s = [[TKNSString alloc] initWithTclUtfBytes:title length:-1]; [colorPanel setTitle:s]; [s release]; } if (initialColor) { [colorPanel setColor:initialColor]; } |
︙ | ︙ | |||
544 545 546 547 548 549 550 | filterInfo.allowedExtensions = [NSMutableArray array]; filterInfo.allowedExtensionsAllowAll = NO; if (filterInfo.doFileTypes) { for (FileFilter *filterPtr = fl.filters; filterPtr; filterPtr = filterPtr->next) { | | | | 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | filterInfo.allowedExtensions = [NSMutableArray array]; filterInfo.allowedExtensionsAllowAll = NO; if (filterInfo.doFileTypes) { for (FileFilter *filterPtr = fl.filters; filterPtr; filterPtr = filterPtr->next) { NSString *name = [[TKNSString alloc] initWithTclUtfBytes: filterPtr->name length:-1]; [filterInfo.fileTypeNames addObject:name]; [name release]; NSMutableArray *clauseextensions = [NSMutableArray array]; NSMutableArray *displayextensions = [NSMutableArray array]; bool allowsAll = NO; for (FileFilterClause *clausePtr = filterPtr->clauses; clausePtr; clausePtr = clausePtr->next) { for (GlobPattern *globPtr = clausePtr->patterns; globPtr; globPtr = globPtr->next) { const char *str = globPtr->pattern; while (*str && (*str == '*' || *str == '.')) { str++; } if (*str) { NSString *extension = [[TKNSString alloc] initWithTclUtfBytes:str length:-1]; if (![filterInfo.allowedExtensions containsObject:extension]) { [filterInfo.allowedExtensions addObject:extension]; } [clauseextensions addObject:extension]; [displayextensions addObject:[@"." stringByAppendingString:extension]]; |
︙ | ︙ | |||
615 616 617 618 619 620 621 | * Check that the typevariable exists. */ if (selectedFileTypeObj != NULL) { const char *selectedFileType = Tcl_GetString(selectedFileTypeObj); NSString *selectedFileTypeStr = | | | 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | * Check that the typevariable exists. */ if (selectedFileTypeObj != NULL) { const char *selectedFileType = Tcl_GetString(selectedFileTypeObj); NSString *selectedFileTypeStr = [[TKNSString alloc] initWithTclUtfBytes:selectedFileType length:-1]; NSUInteger index = [filterInfo.fileTypeNames indexOfObject:selectedFileTypeStr]; if (index != NSNotFound) { filterInfo.fileTypeIndex = index; filterInfo.preselectFilter = true; } |
︙ | ︙ | |||
674 675 676 677 678 679 680 | int Tk_GetOpenFileObjCmd( ClientData clientData, /* Main window associated with interpreter. */ Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { | | < < | 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | int Tk_GetOpenFileObjCmd( 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 = (Tk_Window)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, multiple = 0; Tcl_Obj *cmdObj = NULL, *typeVariablePtr = NULL, *fileTypesPtr = NULL; NSString *directory = nil, *filename = nil; NSString *message = nil, *title = nil; NSWindow *parent; openpanel = [NSOpenPanel openPanel]; NSInteger modalReturnCode = modalError; BOOL parentIsKey = NO; |
︙ | ︙ | |||
708 709 710 711 712 713 714 | break; case OPEN_FILETYPES: fileTypesPtr = objv[i + 1]; break; case OPEN_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { | | | > | < > > | < > | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | break; case OPEN_FILETYPES: fileTypesPtr = objv[i + 1]; break; case OPEN_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[TKNSString alloc] initWithTclUtfBytes:str length:len] autorelease]; } break; case OPEN_INITFILE: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { filename = [[[TKNSString alloc] initWithTclUtfBytes:str length:len] autorelease]; } break; case OPEN_MESSAGE: str = Tcl_GetStringFromObj(objv[i + 1], &len); message = [[TKNSString alloc] initWithTclUtfBytes: str length:len]; break; case OPEN_MULTIPLE: if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &multiple) != TCL_OK) { goto end; } break; case OPEN_PARENT: str = Tcl_GetStringFromObj(objv[i + 1], &len); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case OPEN_TITLE: str = Tcl_GetStringFromObj(objv[i + 1], &len); title = [[TKNSString alloc] initWithTclUtfBytes: str length:len]; break; case OPEN_TYPEVARIABLE: typeVariablePtr = objv[i + 1]; break; case OPEN_COMMAND: cmdObj = objv[i+1]; break; |
︙ | ︙ | |||
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 | [label setEditable:NO]; [label setStringValue:@"Filter:"]; [label setBordered:NO]; [label setBezeled:NO]; [label setDrawsBackground:NO]; [popupButton addItemsWithTitles:filterInfo.fileTypeLabels]; [popupButton setAction:@selector(selectFormat:)]; [accessoryView addSubview:label]; [accessoryView addSubview:popupButton]; if (filterInfo.preselectFilter) { /* * A specific filter was selected from the typevariable. Select it * and open the accessory view. */ [popupButton selectItemAtIndex:filterInfo.fileTypeIndex]; /* * On OSX > 10.11, the options are not visible by default. Ergo * allow all file types [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]]; */ | > | | < < < < | > > > | 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 | [label setEditable:NO]; [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) { /* * A specific filter was selected from the typevariable. Select it * and open the accessory view. */ [popupButton selectItemAtIndex:filterInfo.fileTypeIndex]; /* * On OSX > 10.11, the options are not visible by default. Ergo * allow all file types [openpanel setAllowedFileTypes:filterInfo.fileTypeExtensions[filterInfo.fileTypeIndex]]; */ setAllowedFileTypes(openpanel, filterInfo.allowedExtensions); } else { setAllowedFileTypes(openpanel, filterInfo.allowedExtensions); } if (filterInfo.allowedExtensionsAllowAll) { [openpanel setAllowsOtherFileTypes:YES]; } else { [openpanel setAllowsOtherFileTypes:NO]; } [openpanel setAccessoryView:accessoryView]; } else { /* * No filters are given. Allow picking all files. */ [openpanel setAllowsOtherFileTypes:YES]; } if (cmdObj) { if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } if (directory || filename) { NSURL *fileURL = getFileURL(directory, filename); [openpanel setDirectoryURL:fileURL]; } if (haveParentOption) { parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } modalReturnCode = showOpenSavePanel(openpanel, parent, interp, cmdObj, multiple); if (cmdObj) { Tcl_DecrRefCount(cmdObj); } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; if (parentIsKey) { [parent makeKeyWindow]; } if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) { /* |
︙ | ︙ | |||
951 952 953 954 955 956 957 | { 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; | < < | 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | { 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; NSString *directory = nil, *filename = nil, *defaultType = nil; NSString *message = nil, *title = nil; NSWindow *parent; savepanel = [NSSavePanel savePanel]; NSInteger modalReturnCode = modalError; BOOL parentIsKey = NO; |
︙ | ︙ | |||
975 976 977 978 979 980 981 | Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } switch (index) { case SAVE_DEFAULT: str = Tcl_GetStringFromObj(objv[i + 1], &len); while (*str && (*str == '*' || *str == '.')) { | | | | | > | < > > | < > | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 | Tcl_SetErrorCode(interp, "TK", "FILEDIALOG", "VALUE", NULL); goto end; } switch (index) { case SAVE_DEFAULT: str = Tcl_GetStringFromObj(objv[i + 1], &len); while (*str && (*str == '*' || *str == '.')) { str++; len--; } if (*str) { defaultType = [[[TKNSString alloc] initWithTclUtfBytes:str length:len] autorelease]; } break; case SAVE_FILETYPES: fileTypesPtr = objv[i + 1]; break; case SAVE_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[TKNSString alloc] initWithTclUtfBytes:str length:len] autorelease]; } break; case SAVE_INITFILE: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { filename = [[[TKNSString alloc] initWithTclUtfBytes:str length:len] autorelease]; [savepanel setNameFieldStringValue:filename]; } break; case SAVE_MESSAGE: str = Tcl_GetStringFromObj(objv[i + 1], &len); message = [[TKNSString alloc] initWithTclUtfBytes: str length:len]; break; case SAVE_PARENT: str = Tcl_GetStringFromObj(objv[i + 1], &len); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case SAVE_TITLE: str = Tcl_GetStringFromObj(objv[i + 1], &len); title = [[TKNSString alloc] initWithTclUtfBytes: str length:len]; break; case SAVE_TYPEVARIABLE: typeVariablePtr = objv[i + 1]; break; case SAVE_COMMAND: cmdObj = objv[i+1]; break; |
︙ | ︙ | |||
1080 1081 1082 1083 1084 1085 1086 1087 | [label setDrawsBackground:NO]; NSPopUpButton *popupButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(50.0, 2, 340, 22.0) pullsDown:NO]; [popupButton addItemsWithTitles:filterInfo.fileTypeLabels]; [popupButton selectItemAtIndex:filterInfo.fileTypeIndex]; [popupButton setAction:@selector(saveFormat:)]; | > < > | | < < < < | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 | [label setDrawsBackground:NO]; 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]; setAllowedFileTypes(savepanel, [filterInfo.fileTypeExtensions objectAtIndex:filterInfo.fileTypeIndex]); [savepanel setAllowsOtherFileTypes:filterInfo.allowedExtensionsAllowAll]; } else if (defaultType) { /* * If no filetypes are given, defaultextension is an alternative way to * specify the attached extension. Just propose this extension, but * don't display an accessory view. */ NSMutableArray *AllowedFileTypes = [NSMutableArray array]; [AllowedFileTypes addObject:defaultType]; setAllowedFileTypes(savepanel, AllowedFileTypes); [savepanel setAllowsOtherFileTypes:YES]; } [savepanel setCanSelectHiddenExtension:YES]; [savepanel setExtensionHidden:NO]; if (cmdObj) { if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } if (directory) { [savepanel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; } /* * Check for file name and set to the empty string if nil. This prevents a crash |
︙ | ︙ | |||
1138 1139 1140 1141 1142 1143 1144 | if (haveParentOption) { parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } | | > > > | 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 | if (haveParentOption) { parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } modalReturnCode = showOpenSavePanel(savepanel, parent, interp, cmdObj, 0); if (cmdObj) { Tcl_DecrRefCount(cmdObj); } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; if (parentIsKey) { [parent makeKeyWindow]; } if (typeVariablePtr && (modalReturnCode == NSOKButton) && filterInfo.doFileTypes) { |
︙ | ︙ | |||
1192 1193 1194 1195 1196 1197 1198 | Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, mustexist = 0; Tcl_Obj *cmdObj = NULL; | < < | 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 | Tcl_Obj *const objv[]) /* Argument objects. */ { Tk_Window tkwin = (Tk_Window)clientData; char *str; int i, result = TCL_ERROR, haveParentOption = 0; int index, len, mustexist = 0; Tcl_Obj *cmdObj = NULL; NSString *directory = nil; NSString *message, *title; NSWindow *parent; NSOpenPanel *panel = [NSOpenPanel openPanel]; NSInteger modalReturnCode = modalError; BOOL parentIsKey = NO; |
︙ | ︙ | |||
1216 1217 1218 1219 1220 1221 1222 | Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "VALUE", NULL); goto end; } switch (index) { case CHOOSE_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { | | > | < > > | < > < < < < | > > > | 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 | Tcl_SetErrorCode(interp, "TK", "DIRDIALOG", "VALUE", NULL); goto end; } switch (index) { case CHOOSE_INITDIR: str = Tcl_GetStringFromObj(objv[i + 1], &len); if (len) { directory = [[[TKNSString alloc] initWithTclUtfBytes:str length:len] autorelease]; } break; case CHOOSE_MESSAGE: str = Tcl_GetStringFromObj(objv[i + 1], &len); message = [[TKNSString alloc] initWithTclUtfBytes: str length:len]; [panel setMessage:message]; [message release]; break; case CHOOSE_MUSTEXIST: if (Tcl_GetBooleanFromObj(interp, objv[i + 1], &mustexist) != TCL_OK) { goto end; } break; case CHOOSE_PARENT: str = Tcl_GetStringFromObj(objv[i + 1], &len); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case CHOOSE_TITLE: str = Tcl_GetStringFromObj(objv[i + 1], &len); title = [[TKNSString alloc] initWithTclUtfBytes: str length:len]; [panel setTitle:title]; [title release]; break; case CHOOSE_COMMAND: cmdObj = objv[i+1]; break; } } [panel setPrompt:@"Choose"]; [panel setCanChooseFiles:NO]; [panel setCanChooseDirectories:YES]; [panel setCanCreateDirectories:!mustexist]; if (cmdObj) { if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } /* * Check for directory value, set to root if not specified; otherwise * crashes with exception because of nil string parameter. */ if (!directory) { directory = @"/"; } parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); [panel setDirectoryURL:[NSURL fileURLWithPath:directory isDirectory:YES]]; if (haveParentOption) { parent = TkMacOSXGetNSWindowForDrawable(((TkWindow *)tkwin)->window); parentIsKey = parent && [parent isKeyWindow]; } else { parent = nil; parentIsKey = False; } modalReturnCode = showOpenSavePanel(panel, parent, interp, cmdObj, 0); if (cmdObj) { Tcl_DecrRefCount(cmdObj); } result = (modalReturnCode != modalError) ? TCL_OK : TCL_ERROR; if (parentIsKey) { [parent makeKeyWindow]; } end: return result; } |
︙ | ︙ | |||
1311 1312 1313 1314 1315 1316 1317 | * *---------------------------------------------------------------------- */ void TkAboutDlg(void) { | < < | < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 | * *---------------------------------------------------------------------- */ void TkAboutDlg(void) { [NSApp orderFrontStandardAboutPanel:nil]; } /* *---------------------------------------------------------------------- * * TkMacOSXStandardAboutPanelObjCmd -- * * Implements the ::tk::mac::standardAboutPanel command. * |
︙ | ︙ | |||
1396 1397 1398 1399 1400 1401 1402 | int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { if (objc > 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } | | | 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 | int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { if (objc > 1) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return TCL_ERROR; } [NSApp orderFrontStandardAboutPanel:nil]; return TCL_OK; } /* *---------------------------------------------------------------------- * * Tk_MessageBoxObjCmd -- |
︙ | ︙ | |||
1429 1430 1431 1432 1433 1434 1435 | { 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; | | | 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 | { 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; AlertCallbackInfo callbackInfo; NSString *message, *title; NSWindow *parent; NSArray *buttons; NSAlert *alert = [NSAlert new]; NSInteger modalReturnCode = 1; BOOL parentIsKey = NO; |
︙ | ︙ | |||
1461 1462 1463 1464 1465 1466 1467 | * know the '-type' as well. */ indexDefaultOption = i; break; case ALERT_DETAIL: | < | > > < | > > < | > > | 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 | * know the '-type' as well. */ indexDefaultOption = i; break; case ALERT_DETAIL: str = Tcl_GetString(objv[i + 1]); message = [[TKNSString alloc] initWithTclUtfBytes: str length:-1]; [alert setInformativeText:message]; [message release]; break; case ALERT_ICON: if (Tcl_GetIndexFromObjStruct(interp, objv[i + 1], alertIconStrings, sizeof(char *), "-icon value", TCL_EXACT, &iconIndex) != TCL_OK) { goto end; } break; case ALERT_MESSAGE: str = Tcl_GetString(objv[i + 1]); message = [[TKNSString alloc] initWithTclUtfBytes: str length:-1]; [alert setMessageText:message]; [message release]; break; case ALERT_PARENT: str = Tcl_GetString(objv[i + 1]); tkwin = Tk_NameToWindow(interp, str, tkwin); if (!tkwin) { goto end; } haveParentOption = 1; break; case ALERT_TITLE: str = Tcl_GetString(objv[i + 1]); title = [[TKNSString alloc] initWithTclUtfBytes: str length:-1]; [[alert window] setTitle:title]; [title release]; break; case ALERT_TYPE: if (Tcl_GetIndexFromObjStruct(interp, objv[i + 1], alertTypeStrings, sizeof(char *), "-type value", TCL_EXACT, &typeIndex) != TCL_OK) { |
︙ | ︙ | |||
1557 1558 1559 1560 1561 1562 1563 | setKeyEquivalent: @"\r"]; if (cmdObj) { if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } | < | | | | | | > > > | 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 | setKeyEquivalent: @"\r"]; if (cmdObj) { if (Tcl_IsShared(cmdObj)) { cmdObj = Tcl_DuplicateObj(cmdObj); } Tcl_IncrRefCount(cmdObj); } callbackInfo.cmdObj = cmdObj; callbackInfo.interp = interp; callbackInfo.typeIndex = typeIndex; 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) { [NSApp tkAlertDidEnd:alert returnCode:returnCode contextInfo:&callbackInfo]; }]; #else [alert beginSheetModalForWindow:parent modalDelegate:NSApp didEndSelector:@selector(tkAlertDidEnd:returnCode:contextInfo:) contextInfo:&callbackInfo]; #endif modalReturnCode = cmdObj ? 0 : [alert runModal]; } else { modalReturnCode = [alert runModal]; [NSApp tkAlertDidEnd:alert returnCode:modalReturnCode contextInfo:&callbackInfo]; } if (cmdObj) { Tcl_DecrRefCount(cmdObj); } result = (modalReturnCode >= NSAlertFirstButtonReturn) ? TCL_OK : TCL_ERROR; end: [alert release]; if (parentIsKey) { [parent makeKeyWindow]; } |
︙ | ︙ | |||
1645 1646 1647 1648 1649 1650 1651 | }; static Tcl_Interp *fontchooserInterp = NULL; static NSFont *fontPanelFont = nil; static NSMutableDictionary *fontPanelFontAttributes = nil; static const char *const fontchooserOptionStrings[] = { | | | | 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 | }; static Tcl_Interp *fontchooserInterp = NULL; static NSFont *fontPanelFont = nil; static NSMutableDictionary *fontPanelFontAttributes = nil; static const char *const fontchooserOptionStrings[] = { "-command", "-font", "-parent", "-title", "-visible", NULL }; enum FontchooserOption { FontchooserCmd, FontchooserFont, FontchooserParent, FontchooserTitle, FontchooserVisible }; @implementation TKApplication(TKFontPanel) - (void) changeFont: (id) sender { |
︙ | ︙ | |||
1730 1731 1732 1733 1734 1735 1736 | { FontchooserData *fcdPtr; Tcl_Obj *fontObj; if (!fontchooserInterp) { return; } | | | | 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 | { FontchooserData *fcdPtr; Tcl_Obj *fontObj; if (!fontchooserInterp) { return; } fcdPtr = (FontchooserData *)Tcl_GetAssocData(fontchooserInterp, "::tk::fontchooser", NULL); switch (kind) { case FontchooserClosed: if (fcdPtr->parent != NULL) { Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserVisibility", NULL); fontchooserInterp = NULL; } break; case FontchooserSelection: fontObj = TkMacOSXFontDescriptionForNSFontAndNSFontAttributes( fontPanelFont, fontPanelFontAttributes); |
︙ | ︙ | |||
1789 1790 1791 1792 1793 1794 1795 | FontchooserData *fcdPtr, int optionIndex) { Tcl_Obj *resObj = NULL; switch(optionIndex) { case FontchooserParent: | | | 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 | FontchooserData *fcdPtr, int optionIndex) { Tcl_Obj *resObj = NULL; switch(optionIndex) { case FontchooserParent: if (fcdPtr->parent != NULL) { resObj = Tcl_NewStringObj( ((TkWindow *)fcdPtr->parent)->pathName, -1); } else { resObj = Tcl_NewStringObj(".", 1); } break; case FontchooserTitle: |
︙ | ︙ | |||
1818 1819 1820 1821 1822 1823 1824 | if (fcdPtr->cmdObj) { resObj = fcdPtr->cmdObj; } else { resObj = Tcl_NewObj(); } break; case FontchooserVisible: | | | | 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 | if (fcdPtr->cmdObj) { resObj = fcdPtr->cmdObj; } else { resObj = Tcl_NewObj(); } break; case FontchooserVisible: resObj = Tcl_NewBooleanObj([[[NSFontManager sharedFontManager] fontPanel:NO] isVisible]); break; default: resObj = Tcl_NewObj(); } return resObj; } |
︙ | ︙ | |||
1852 1853 1854 1855 1856 1857 1858 | FontchooserConfigureCmd( ClientData clientData, /* Main window */ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tk_Window tkwin = (Tk_Window)clientData; | | | 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 | FontchooserConfigureCmd( ClientData clientData, /* Main window */ Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]) { Tk_Window tkwin = (Tk_Window)clientData; FontchooserData *fcdPtr = (FontchooserData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); int i, r = TCL_OK; /* * With no arguments we return all the options in a dict */ |
︙ | ︙ | |||
1909 1910 1911 1912 1913 1914 1915 | Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL); return TCL_ERROR; } case FontchooserParent: { Tk_Window parent = Tk_NameToWindow(interp, Tcl_GetString(objv[i+1]), tkwin); | | | 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 | Tcl_SetErrorCode(interp, "TK", "FONTDIALOG", "READONLY", NULL); return TCL_ERROR; } case FontchooserParent: { Tk_Window parent = Tk_NameToWindow(interp, Tcl_GetString(objv[i+1]), tkwin); if (parent == NULL) { return TCL_ERROR; } if (fcdPtr->parent) { Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); } fcdPtr->parent = parent; |
︙ | ︙ | |||
1936 1937 1938 1939 1940 1941 1942 | fcdPtr->titleObj = Tcl_DuplicateObj(fcdPtr->titleObj); } Tcl_IncrRefCount(fcdPtr->titleObj); } else { fcdPtr->titleObj = NULL; } break; | | | 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 | fcdPtr->titleObj = Tcl_DuplicateObj(fcdPtr->titleObj); } Tcl_IncrRefCount(fcdPtr->titleObj); } else { fcdPtr->titleObj = NULL; } break; case FontchooserFont: { Tcl_GetStringFromObj(objv[i+1], &len); if (len) { Tk_Font f = Tk_AllocFontFromObj(interp, tkwin, objv[i+1]); if (!f) { return TCL_ERROR; } |
︙ | ︙ | |||
1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 | [fm setSelectedAttributes:fontPanelFontAttributes isMultiple:NO]; if ([fp isVisible]) { Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; case FontchooserCmd: if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } Tcl_GetStringFromObj(objv[i+1], &len); if (len) { fcdPtr->cmdObj = objv[i+1]; | > | 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 | [fm setSelectedAttributes:fontPanelFontAttributes isMultiple:NO]; if ([fp isVisible]) { Tk_SendVirtualEvent(fcdPtr->parent, "TkFontchooserFontChanged", NULL); } break; } case FontchooserCmd: if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } Tcl_GetStringFromObj(objv[i+1], &len); if (len) { fcdPtr->cmdObj = objv[i+1]; |
︙ | ︙ | |||
2015 2016 2017 2018 2019 2020 2021 | static int FontchooserShowCmd( ClientData clientData, /* Main window */ Tcl_Interp *interp, TCL_UNUSED(int), TCL_UNUSED(Tcl_Obj *const *)) { | | | | 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 | static int FontchooserShowCmd( ClientData clientData, /* Main window */ Tcl_Interp *interp, TCL_UNUSED(int), TCL_UNUSED(Tcl_Obj *const *)) { FontchooserData *fcdPtr = (FontchooserData *)Tcl_GetAssocData(interp, "::tk::fontchooser", NULL); if (fcdPtr->parent == NULL) { fcdPtr->parent = (Tk_Window)clientData; Tk_CreateEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); } NSFontManager *fm = [NSFontManager sharedFontManager]; NSFontPanel *fp = [fm fontPanel:YES]; |
︙ | ︙ | |||
2093 2094 2095 2096 2097 2098 2099 | */ static void FontchooserParentEventHandler( ClientData clientData, XEvent *eventPtr) { | | | 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 | */ static void FontchooserParentEventHandler( ClientData clientData, XEvent *eventPtr) { FontchooserData *fcdPtr = (FontchooserData *)clientData; if (eventPtr->type == DestroyNotify) { Tk_DeleteEventHandler(fcdPtr->parent, StructureNotifyMask, FontchooserParentEventHandler, fcdPtr); fcdPtr->parent = NULL; FontchooserHideCmd(NULL, NULL, 0, NULL); } |
︙ | ︙ | |||
2125 2126 2127 2128 2129 2130 2131 | */ static void DeleteFontchooserData( ClientData clientData, Tcl_Interp *interp) { | | | 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 | */ static void DeleteFontchooserData( ClientData clientData, Tcl_Interp *interp) { FontchooserData *fcdPtr = (FontchooserData *)clientData; if (fcdPtr->titleObj) { Tcl_DecrRefCount(fcdPtr->titleObj); } if (fcdPtr->cmdObj) { Tcl_DecrRefCount(fcdPtr->cmdObj); } |
︙ | ︙ |
Changes to macosx/tkMacOSXDraw.c.
1 2 3 4 5 6 | /* * tkMacOSXDraw.c -- * * This file contains functions that draw to windows. Many of thees * functions emulate Xlib functions. * | | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | /* * tkMacOSXDraw.c -- * * This file contains functions that draw to windows. Many of thees * functions emulate Xlib functions. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 2001-2009 Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * 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 >= 101000 #define GET_CGCONTEXT [[NSGraphicsContext currentContext] CGContext] #else #define GET_CGCONTEXT [[NSGraphicsContext currentContext] graphicsPort] #endif /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_DRAWING #define TK_MAC_DEBUG_IMAGE_DRAWING #define TK_MAC_DEBUG_CG #endif */ #define radians(d) ((d) * (M_PI/180.0)) /* * Non-antialiased CG drawing looks better and more like X11 drawing when using |
︙ | ︙ | |||
527 528 529 530 531 532 533 | int XFillPolygon( Display *display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XPoint *points, /* Array of points. */ int npoints, /* Number of points. */ | | | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | int XFillPolygon( Display *display, /* Display. */ Drawable d, /* Draw on this. */ GC gc, /* Use this GC. */ XPoint *points, /* Array of points. */ int npoints, /* Number of points. */ TCL_UNUSED(int), /* Shape to draw. */ int mode) /* Drawing mode. */ { MacDrawable *macWin = (MacDrawable *)d; TkMacOSXDrawingContext dc; int i; display->request++; |
︙ | ︙ | |||
557 558 559 560 561 562 563 | macWin->yOff + points[i].y + o); } else { prevx += points[i].x; prevy += points[i].y; CGContextAddLineToPoint(dc.context, prevx, prevy); } } | > | > | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | macWin->yOff + points[i].y + o); } else { prevx += points[i].x; prevy += points[i].y; CGContextAddLineToPoint(dc.context, prevx, prevy); } } (gc->fill_rule == EvenOddRule) ? CGContextEOFillPath(dc.context) : CGContextFillPath(dc.context); } TkMacOSXRestoreDrawingContext(&dc); return Success; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 | 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 *)TkMacOSXGetNSViewForDrawable(macDraw); | | | | > | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | | | | > > > | > > | > > > > > > > > > > | | > > > < | < | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 | 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 *)TkMacOSXGetNSViewForDrawable(macDraw); HIShapeRef srcRgn, dstRgn; HIMutableShapeRef dmgRgn = HIShapeCreateMutable(); NSRect bounds, viewSrcRect, srcRect, dstRect; int result = 0; if (view) { /* * Get the scroll area in NSView coordinates (origin at bottom left). */ bounds = [view bounds]; viewSrcRect = NSMakeRect(macDraw->xOff + x, bounds.size.height - height - (macDraw->yOff + y), width, height); /* * Scroll the rectangle. */ [view scrollRect:viewSrcRect by:NSMakeSize(dx, -dy)]; /* * Compute the damage region, using Tk coordinates (origin at top left). */ srcRect = CGRectMake(x, y, width, height); dstRect = CGRectOffset(srcRect, dx, dy); srcRgn = HIShapeCreateWithRect(&srcRect); dstRgn = HIShapeCreateWithRect(&dstRect); ChkErr(HIShapeDifference, srcRgn, dstRgn, dmgRgn); result = HIShapeIsEmpty(dmgRgn) ? 0 : 1; } /* * Convert the HIShape dmgRgn into a TkRegion and store it. */ TkMacOSXSetWithNativeRegion(damageRgn, dmgRgn); /* * Mutable shapes are not reference counted, and must be released. */ CFRelease(dmgRgn); return result; } /* *---------------------------------------------------------------------- * * TkMacOSXSetUpGraphicsPort -- |
︙ | ︙ | |||
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 | GC gc, TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = (MacDrawable *)d; Bool canDraw = true; TKContentView *view = nil; TkMacOSXDrawingContext dc = {}; /* * If the drawable is not a pixmap, get the associated NSView. */ if (!(macDraw->flags & TK_IS_PIXMAP)) { view = (TKContentView *)TkMacOSXGetNSViewForDrawable(d); | > > > > > > | 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | GC gc, TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = (MacDrawable *)d; Bool canDraw = true; TKContentView *view = nil; TkMacOSXDrawingContext dc = {}; CGFloat drawingHeight; #ifdef TK_MAC_DEBUG_CG fprintf(stderr, "TkMacOSXSetupDrawingContext: %s\n", macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); #endif /* * If the drawable is not a pixmap, get the associated NSView. */ if (!(macDraw->flags & TK_IS_PIXMAP)) { view = (TKContentView *)TkMacOSXGetNSViewForDrawable(d); |
︙ | ︙ | |||
1269 1270 1271 1272 1273 1274 1275 | /* * 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); | | < < < < | 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 | /* * 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) { NSRect drawingBounds, currentBounds; dc.view = view; dc.context = GET_CGCONTEXT; if (dc.clipRgn) { 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); |
︙ | ︙ | |||
1318 1319 1320 1321 1322 1323 1324 | * 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. */ | | > > > > > > > > > > | | | | | | < < < < < | > < < < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < | 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 | * 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. */ #ifdef TK_MAC_DEBUG_CG fprintf(stderr, "TkMacOSXSetupDrawingContext: pushing GState for %s\n", macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); #endif CGContextSaveGState(dc.context); CGContextSetTextDrawingMode(dc.context, kCGTextFill); { /* Restricted scope for t needed for C++ */ drawingHeight = view ? [view bounds].size.height : CGContextGetClipBoundingBox(dc.context).size.height; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = drawingHeight }; 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 */ if (!HIShapeIsRectangular(dc.clipRgn)) { /* * We expect the clipping path dc.clipRgn to consist of the * bounding rectangle of the drawable window, together with * disjoint smaller rectangles inside of it which bound its * geometric children. In that case the even-odd rule will * clip to the region inside the large rectangle and outside * of the smaller rectangles. */ ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); #ifdef TK_MAC_DEBUG_CG fprintf(stderr, "Setting complex clip for %s to:\n", macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None"); TkMacOSXPrintRectsInRegion(dc.clipRgn); #endif CGContextEOClip(dc.context); } else { CGRect r; HIShapeGetBounds(dc.clipRgn, &r); #ifdef TK_MAC_DEBUG_CG fprintf(stderr, "Current clip BBox is %s\n", NSStringFromRect(CGContextGetClipBoundingBox(GET_CGCONTEXT)).UTF8String); fprintf(stderr, "Setting clip for %s to rect %s:\n", macDraw->winPtr ? Tk_PathName(macDraw->winPtr) : "None", NSStringFromRect(r).UTF8String); #endif CGContextClipToRect(dc.context, r); } } 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) { CGSize size = NSSizeToCGSize([view bounds].size); CGContextSetPatternPhase(dc.context, size); } if (gc->function != GXcopy) { TkMacOSXDbgMsg("Logical functions other than GXcopy are " "not supported for CG drawing!"); } if (!shouldAntialias) { |
︙ | ︙ | |||
1417 1418 1419 1420 1421 1422 1423 | CGContextSetLineJoin(dc.context, cgJoin[(unsigned) gc->join_style]); } } end: #ifdef TK_MAC_DEBUG_DRAWING | | < < < | | < | 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 | CGContextSetLineJoin(dc.context, cgJoin[(unsigned) gc->join_style]); } } end: #ifdef TK_MAC_DEBUG_DRAWING if (!canDraw && macDraw->winPtr != NULL) { fprintf(stderr, "Cannot draw in %s - postponing.\n", Tk_PathName(macDraw->winPtr)); } #endif if (!canDraw && dc.clipRgn) { CFRelease(dc.clipRgn); dc.clipRgn = NULL; } |
︙ | ︙ | |||
1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 | void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr) { if (dcPtr->context) { CGContextSynchronize(dcPtr->context); CGContextRestoreGState(dcPtr->context); } if (dcPtr->clipRgn) { CFRelease(dcPtr->clipRgn); } #ifdef TK_MAC_DEBUG bzero(dcPtr, sizeof(TkMacOSXDrawingContext)); | > > > > > > > | > | 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 | void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr) { if (dcPtr->context) { CGContextSynchronize(dcPtr->context); CGContextRestoreGState(dcPtr->context); #ifdef TK_MAC_DEBUG_CG fprintf(stderr, "TkMacOSXRestoreDrawingContext: popped GState\n"); #endif } if (dcPtr->clipRgn) { CFRelease(dcPtr->clipRgn); dcPtr->clipRgn = NULL; } #ifdef TK_MAC_DEBUG bzero(dcPtr, sizeof(TkMacOSXDrawingContext)); #endif } /* *---------------------------------------------------------------------- * * TkMacOSXGetClipRgn -- * |
︙ | ︙ | |||
1520 1521 1522 1523 1524 1525 1526 | } return clipRgn; } /* *---------------------------------------------------------------------- * | | | | 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 | } return clipRgn; } /* *---------------------------------------------------------------------- * * Tk_ClipDrawableToRect -- * * Clip all drawing into the drawable d to the given rectangle. If width * or height are negative, reset to no clipping. * * Results: * None. * * Side effects: * Subsequent drawing into d is offset and clipped as specified. * *---------------------------------------------------------------------- */ void Tk_ClipDrawableToRect( TCL_UNUSED(Display *), Drawable d, int x, int y, int width, int height) { MacDrawable *macDraw = (MacDrawable *)d; |
︙ | ︙ | |||
1636 1637 1638 1639 1640 1641 1642 | { return NULL; } /* *---------------------------------------------------------------------- * | | | 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 | { return NULL; } /* *---------------------------------------------------------------------- * * Tk_DrawHighlightBorder -- * * This procedure draws a rectangular ring around the outside of a widget * to indicate that it has received the input focus. * * On the Macintosh, this puts a 1 pixel border in the bgGC color between * the widget and the focus ring, except in the case where highlightWidth * is 1, in which case the border is left out. |
︙ | ︙ | |||
1658 1659 1660 1661 1662 1663 1664 | * A rectangle "width" pixels wide is drawn in "drawable", corresponding * to the outer area of "tkwin". * *---------------------------------------------------------------------- */ void | | | 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 | * A rectangle "width" pixels wide is drawn in "drawable", corresponding * to the outer area of "tkwin". * *---------------------------------------------------------------------- */ void Tk_DrawHighlightBorder ( Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable) { if (highlightWidth == 1) { |
︙ | ︙ |
Changes to macosx/tkMacOSXEmbed.c.
1 2 3 4 5 6 7 8 9 | /* * tkMacOSXEmbed.c -- * * This file contains platform-specific procedures for theMac to provide * 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. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tkMacOSXEmbed.c -- * * This file contains platform-specific procedures for theMac to provide * 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 © 1996-1997 Sun Microsystems, Inc. * Copyright © 2001-2009 Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * * 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 "tkBusy.h" |
︙ | ︙ | |||
71 72 73 74 75 76 77 | * Side effects: * None. * *---------------------------------------------------------------------- */ Window | | | > | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | * Side effects: * None. * *---------------------------------------------------------------------- */ Window Tk_MakeWindow( Tk_Window tkwin, Window parent) { MacDrawable *macWin; TkWindow *winPtr = (TkWindow *)tkwin; (void)parent; /* * If this window is marked as embedded then the window structure should * have already been created in the Tk_UseWindow function. */ if (Tk_IsEmbedded(winPtr)) { macWin = winPtr->privatePtr; } else { /* * Allocate sub window |
︙ | ︙ | |||
174 175 176 177 178 179 180 | } return code; } /* *---------------------------------------------------------------------- * | | | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | } return code; } /* *---------------------------------------------------------------------- * * Tk_UseWindow -- * * This procedure causes a Tk window to use a given X window as its * parent window, rather than the root window for the screen. It is * invoked by an embedded application to specify the window in which it * is embedded. * * Results: * The return value is normally TCL_OK. If an error occurs (such as * string not being a valid window spec), then the return value is * TCL_ERROR and an error message is left in the interp's result if * interp is non-NULL. * * Side effects: * None. * *---------------------------------------------------------------------- */ int Tk_UseWindow( Tcl_Interp *interp, /* If not NULL, used for error reporting if * string is bogus. */ Tk_Window tkwin, /* Tk window that does not yet have an * associated X window. */ const char *string) /* String identifying an X window to use for * tkwin; must be an integer value. */ { |
︙ | ︙ | |||
318 319 320 321 322 323 324 | return TCL_OK; } /* *---------------------------------------------------------------------- * | | | | 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | return TCL_OK; } /* *---------------------------------------------------------------------- * * Tk_MakeContainer -- * * This procedure is called to indicate that a particular window will be * a container for an embedded application. This changes certain aspects * of the window's behavior, such as whether it will receive events * anymore. * * Results: * None. * * Side effects: * None. * *---------------------------------------------------------------------- */ void Tk_MakeContainer( Tk_Window tkwin) /* Token for a window that is about to become * a container. */ { TkWindow *winPtr = (TkWindow *) tkwin; Container *containerPtr; /* |
︙ | ︙ | |||
436 437 438 439 440 441 442 | { TkWindow *contWinPtr, *topWinPtr; topWinPtr = winPtr->privatePtr->toplevel->winPtr; if (!Tk_IsEmbedded(topWinPtr)) { return winPtr->privatePtr->toplevel; } | | | 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | { TkWindow *contWinPtr, *topWinPtr; topWinPtr = winPtr->privatePtr->toplevel->winPtr; if (!Tk_IsEmbedded(topWinPtr)) { return winPtr->privatePtr->toplevel; } contWinPtr = (TkWindow *)Tk_GetOtherWindow((Tk_Window)topWinPtr); /* * TODO: Here we should handle out of process embedding. */ if (!contWinPtr) { return NULL; |
︙ | ︙ | |||
633 634 635 636 637 638 639 | /* TODO: Implement this or decide it definitely needs no implementation */ } /* *---------------------------------------------------------------------- * | | | | | | | | | | | | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 | /* TODO: Implement this or decide it definitely needs no implementation */ } /* *---------------------------------------------------------------------- * * Tk_GetOtherWindow -- * * If both the container and embedded window are in the same process, * this procedure will return either one, given the other. * * Results: * If tkwin is a container, the return value is the token for the * embedded window, and vice versa. If the "other" window isn't in this * process, NULL is returned. * * Side effects: * None. * *---------------------------------------------------------------------- */ Tk_Window Tk_GetOtherWindow( Tk_Window tkwin) /* Tk's structure for a container or embedded * window. */ { Container *containerPtr; /* * Tk_GetOtherWindow returns NULL if both windows are not in the same * process... */ if (!(((TkWindow *)tkwin)->flags & TK_BOTH_HALVES)) { return NULL; } for (containerPtr = firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { if ((Tk_Window)containerPtr->embeddedPtr == tkwin) { return (Tk_Window)containerPtr->parentPtr; } else if ((Tk_Window)containerPtr->parentPtr == tkwin) { return (Tk_Window)containerPtr->embeddedPtr; } } return NULL; } /* *---------------------------------------------------------------------- |
︙ | ︙ | |||
700 701 702 703 704 705 706 | */ static void EmbeddedEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | */ static void EmbeddedEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { TkWindow *winPtr = (TkWindow *)clientData; if (eventPtr->type == DestroyNotify) { EmbedWindowDeleted(winPtr); } } /* |
︙ | ︙ | |||
735 736 737 738 739 740 741 | */ static void ContainerEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | */ static void ContainerEventProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { TkWindow *winPtr = (TkWindow *)clientData; Container *containerPtr; Tk_ErrorHandler errHandler; if (!firstContainerPtr) { /* * When the interpreter is being dismantled this can be nil. */ |
︙ | ︙ | |||
843 844 845 846 847 848 849 | */ static void EmbedStructureProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | | 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | */ static void EmbedStructureProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { Container *containerPtr = (Container *)clientData; Tk_ErrorHandler errHandler; if (eventPtr->type == ConfigureNotify) { /* * Send a ConfigureNotify to the embedded application. */ if (containerPtr->embeddedPtr != NULL) { TkDoConfigureNotify(containerPtr->embeddedPtr); } if (containerPtr->embedded != None) { /* * Ignore errors, since the embedded application could have * deleted its window. */ |
︙ | ︙ | |||
897 898 899 900 901 902 903 | */ static void EmbedActivateProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 | */ static void EmbedActivateProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { Container *containerPtr = (Container *)clientData; if (containerPtr->embeddedPtr != NULL) { if (eventPtr->type == ActivateNotify) { TkGenerateActivateEvents(containerPtr->embeddedPtr,1); } else if (eventPtr->type == DeactivateNotify) { TkGenerateActivateEvents(containerPtr->embeddedPtr,0); } |
︙ | ︙ | |||
932 933 934 935 936 937 938 | */ static void EmbedFocusProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { | | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | */ static void EmbedFocusProc( ClientData clientData, /* Token for container window. */ XEvent *eventPtr) /* ResizeRequest event. */ { Container *containerPtr = (Container *)clientData; Display *display; XEvent event; if (containerPtr->embeddedPtr != NULL) { display = Tk_Display(containerPtr->parentPtr); event.xfocus.serial = LastKnownRequestProcessed(display); event.xfocus.send_event = false; |
︙ | ︙ | |||
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 | * Find the Container structure for this window. Delete the information * about the embedded application and free the container's record. */ prevPtr = NULL; containerPtr = firstContainerPtr; while (1) { if (containerPtr->embeddedPtr == winPtr) { /* * We also have to destroy our parent, to clean up the container. * Fabricate an event to do this. */ if (containerPtr->parentPtr != NULL && | > > > | 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | * Find the Container structure for this window. Delete the information * about the embedded application and free the container's record. */ prevPtr = NULL; containerPtr = firstContainerPtr; while (1) { if (containerPtr == NULL) { return; } if (containerPtr->embeddedPtr == winPtr) { /* * We also have to destroy our parent, to clean up the container. * Fabricate an event to do this. */ if (containerPtr->parentPtr != NULL && |
︙ | ︙ |
Changes to macosx/tkMacOSXEntry.c.
1 2 3 4 5 | /* * tkMacOSXEntry.c -- * * This file implements the native aqua entry widget. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXEntry.c -- * * This file implements the native aqua entry widget. * * Copyright © 2001 Apple Computer, Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * 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. */ #include "tkMacOSXPrivate.h" #include "tkEntry.h" |
︙ | ︙ |
Changes to macosx/tkMacOSXEvent.c.
1 2 3 4 5 | /* * tkMacOSXEvent.c -- * * This file contains the basic Mac OS X Event handling routines. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* * tkMacOSXEvent.c -- * * This file contains the basic Mac OS X Event handling routines. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 2001-2009, Apple Inc. * Copyright © 2005-2009 Daniel A. Steffen <[email protected]> * * 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" |
︙ | ︙ | |||
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | default: break; /* return theEvent */ } return processedEvent; } @end #pragma mark - int XSync( Display *display, 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 | > | | | | | > > > | < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | default: break; /* return theEvent */ } return processedEvent; } @end #pragma mark - int XSync( Display *display, 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. On X11 the * call to XSync might cause the window manager to generate more events * which would then get processed. Apparently this process stabilizes on * X11, leaving the window manager in a state where all events have been * generated and no additional events can be genereated by updating widgets. * * It is not clear what the Aqua port should do when XSync is called, but * currently the best option seems to be to do nothing. (See ticket * [da5f2266df].) */ display->request++; return 0; } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Added macosx/tkMacOSXFileTypes.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /* There are situations where a graphical user interface needs to know the file type (i.e. data format) of a file. The two main ones are when generating an icon to represent a file, and when filtering the choice of files in a file open or save dialog. Early Macintosh systems used OSTypes as identifiers for file types. An OSType is a FourCC datatype - four bytes which can be packed into a 32 bit integer. In the HFS filesystem they were included in the file metadata. The metadata also included another OSType (the Creator Code) which identified the application which created the file. In OSX 10.4 the Uniform Type Identifier was introduced as an alternative way to describe file types. These are strings (NSStrings, actually) in a reverse DNS format, such as "com.apple.application-bundle". Apple provided a tool for converting OSType codes to Uniform Type Identifiers, which they deprecated in macOS 12.0 after introducing the UTType class in macOS 11.0. An instance of the UTType class has properties which give the Uniform Type Identifier as well as the preferred file name extension for a given file type. This module provides tools for working with file types which are meant to abstract the many variants that Apple has used over the years, and which can be used without generating deprecation warnings. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXFileTypes.h" #if MAC_OS_X_VERSION_MAX_ALLOWED >= 110000 #import <UniformTypeIdentifiers/UniformTypeIdentifiers.h> #endif #define CHARS_TO_OSTYPE(string) (OSType) string[0] << 24 | \ (OSType) string[1] << 16 | \ (OSType) string[2] << 8 | \ (OSType) string[3] static BOOL initialized = false; static Tcl_HashTable ostype2identifier; static void initOSTypeTable(void) { int newPtr; Tcl_HashEntry *hPtr; const IdentifierForOSType *entry; Tcl_InitHashTable(&ostype2identifier, TCL_ONE_WORD_KEYS); for (entry = OSTypeDB; entry->ostype != NULL; entry++) { const char *key = INT2PTR(CHARS_TO_OSTYPE(entry->ostype)); hPtr = Tcl_CreateHashEntry(&ostype2identifier, key, &newPtr); if (newPtr) { Tcl_SetHashValue(hPtr, entry->identifier); } } initialized = true; } MODULE_SCOPE NSString *TkMacOSXOSTypeToUTI(OSType ostype) { if (!initialized) { initOSTypeTable(); } Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&ostype2identifier, INT2PTR(ostype)); if (hPtr) { char *UTI = Tcl_GetHashValue(hPtr); return [[NSString alloc] initWithCString:UTI encoding:NSASCIIStringEncoding]; } return nil; } /* * The NSWorkspace method iconForFileType, which was deprecated in macOS 12.0, would * accept an NSString which could be an encoding of an OSType, or a file extension, * or a Uniform Type Idenfier. This function can serve as a replacement. */ MODULE_SCOPE NSImage *TkMacOSXIconForFileType(NSString *filetype) { if (!initialized) { initOSTypeTable(); } #if MAC_OS_X_VERSION_MAX_ALLOWED < 110000 // We don't have UTType but iconForFileType is not deprecated, so use it. return [[NSWorkspace sharedWorkspace] iconForFileType:filetype]; #else // We might have UTType but iconForFileType might be deprecated. if (@available(macOS 11.0, *)) { /* Yes, we do have UTType */ UTType *uttype = [UTType typeWithIdentifier: filetype]; if (uttype == nil || !uttype.isDeclared) { uttype = [UTType typeWithFilenameExtension: filetype]; } if (uttype == nil || (!uttype.isDeclared && filetype.length == 4)) { OSType ostype = CHARS_TO_OSTYPE(filetype.UTF8String); NSString *UTI = TkMacOSXOSTypeToUTI(ostype); if (UTI) { uttype = [UTType typeWithIdentifier:UTI]; } } if (uttype == nil || !uttype.isDeclared) { return nil; } return [[NSWorkspace sharedWorkspace] iconForContentType:uttype]; } else { /* No, we don't have UTType. */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 110000 /* but iconForFileType is not deprecated, so we can use it. */ return [[NSWorkspace sharedWorkspace] iconForFileType:filetype]; #else /* * Cannot be reached: MIN_REQUIRED >= 110000 yet 11.0 is not available. * But the compiler can't figure that out, so it will warn about an * execution path with no return value unless we put a return here. */ return nil; #endif } #endif } /* * Local Variables: * mode: objc * c-basic-offset: 4 * fill-column: 79 * coding: utf-8 * End: */ |
Added macosx/tkMacOSXFileTypes.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /* Apple never published a database of OSType codes for File Types. However, a database of known OSType codes representing Creators and File Types used on Apple systems prior to 2003 is available at: http://www.lacikam.co.il/tcdb/download/TCDBdata.zip Among the 12034 distinct OSType codes for File Types that are listed in the TCDB database, there are 121 for which the UTTypeCreatePreferredIdentifierForTag function (deprecated in macOS 12.0) was able to generate a Uniform Type Identifier on macOS 12.5.1. The mapping from those OSTypes to Uniform Type identifiers is given by the following array, in which OSTypes are represented as strings of length 4. */ typedef struct { const char *ostype; const char *identifier; } IdentifierForOSType; static const IdentifierForOSType OSTypeDB[] = { {".SGI", "com.sgi.sgi-image"}, {".WAV", "com.microsoft.waveform-audio"}, {"8BPS", "com.adobe.photoshop-image"}, {"ABPR", "com.apple.addressbook.person"}, {"AIFC", "public.aifc-audio"}, {"AIFF", "public.aiff-audio"}, {"APPC", "com.apple.deprecated-application-file"}, {"APPD", "com.apple.deprecated-application-file"}, {"APPL", "com.apple.application-bundle"}, {"ASF_", "com.microsoft.advanced-systems-format"}, {"ASX_", "com.microsoft.advanced-stream-redirector"}, {"BMP ", "com.microsoft.bmp"}, {"BMPf", "com.microsoft.bmp"}, {"BNDL", "com.apple.generic-bundle"}, {"DDim", "com.apple.disk-image-raw"}, {"DICM", "org.nema.dicom"}, {"DOTM", "org.openxmlformats.wordprocessingml.template.macro-enabled"}, {"EM3F", "com.apple.logic-song"}, {"EPSF", "com.adobe.encapsulated-postscript"}, {"FFIL", "com.apple.font-suitcase"}, {"FLI ", "public.flc-animation"}, {"FNDR", "com.apple.legacy.finder-icon"}, {"GIFf", "com.compuserve.gif"}, {"HTML", "public.html"}, {"JPEG", "public.jpeg"}, {"LWFN", "com.adobe.postscript-lwfn-font"}, {"MP3 ", "public.mp3"}, {"MP3!", "public.mp3"}, {"MP3U", "com.apple.tv.m3u-playlist"}, {"MPEG", "public.mpeg"}, {"MPG ", "public.mpeg"}, {"MPG2", "com.apple.music.mp2"}, {"MPG3", "public.mp3"}, {"Midi", "public.midi-audio"}, {"MooV", "com.apple.quicktime-movie"}, {"Mp3 ", "public.mp3"}, {"PAT ", "org.gimp.pat"}, {"PDF ", "com.adobe.pdf"}, {"PICT", "com.apple.pict"}, {"PNGf", "public.png"}, {"PNRA", "com.real.realaudio"}, {"PNRM", "com.real.realmedia"}, {"PNTG", "com.apple.macpaint-image"}, {"PPOT", "com.microsoft.powerpoint.pot"}, {"PPSS", "com.microsoft.powerpoint.pps"}, {"RTF ", "public.rtf"}, {"SDP ", "public.sdp"}, {"SIT5", "com.stuffit.archive.sit"}, {"SLD8", "com.microsoft.powerpoint.ppt"}, {"Sd2f", "com.digidesign.sd2-audio"}, {"TEXT", "com.apple.traditional-mac-plain-text"}, {"TIFF", "public.tiff"}, {"TPIC", "com.truevision.tga-image"}, {"ULAW", "public.ulaw-audio"}, {"VfW ", "public.avi"}, {"W8BN", "com.microsoft.word.doc"}, {"W8TN", "com.microsoft.word.dot"}, {"WAVE", "com.microsoft.waveform-audio"}, {"XLA5", "com.microsoft.excel.xla"}, {"XLS8", "com.microsoft.excel.xls"}, {"XLW8", "com.microsoft.excel.xlw"}, {"alis", "com.apple.alias-record"}, {"appe", "com.apple.deprecated-application-file"}, {"cdev", "com.apple.deprecated-application-file"}, {"clpp", "com.apple.finder.pictclipping"}, {"clps", "com.apple.finder.sound-clipping"}, {"clpt", "com.apple.finder.textclipping"}, {"clpu", "com.apple.finder.clipping"}, {"ctrl", "com.apple.legacy.finder-icon"}, {"dfil", "com.apple.deprecated-application-file"}, {"dict", "com.apple.document-type.dictionary"}, {"disk", "public.volume"}, {"docs", "com.apple.documents-folder"}, {"dvc!", "public.dv-movie"}, {"ffil", "com.apple.font-suitcase"}, {"flpy", "com.apple.storage-removable"}, {"fold", "public.folder"}, {"font", "com.apple.legacy.finder-icon"}, {"grup", "com.apple.user-group"}, {"hdrv", "com.apple.disk-image-raw"}, {"hdsk", "com.apple.storage-internal"}, {"help", "com.apple.help-document"}, {"hkdb", "com.apple.itunes.db"}, {"hvpl", "com.apple.music.visual"}, {"ilaf", "com.apple.afp-internet-location"}, {"ilfi", "com.apple.file-internet-location"}, {"ilft", "com.apple.ftp-internet-location"}, {"ilge", "com.apple.generic-internet-location"}, {"ilht", "com.apple.web-internet-location"}, {"ilma", "com.apple.mail-internet-location"}, {"ilnw", "com.apple.news-internet-location"}, {"macD", "com.apple.legacy.finder-icon"}, {"mp3!", "public.mp3"}, {"mpg3", "public.mp3"}, {"note", "com.apple.alert-note"}, {"osas", "com.apple.applescript.script"}, {"plug", "com.apple.plugin"}, {"pref", "com.apple.legacy.finder-icon"}, {"prfb", "com.apple.icon-overlay.private-folder-badge"}, {"prof", "com.apple.colorsync-profile"}, {"qtif", "com.apple.quicktime-image"}, {"sLS8", "com.microsoft.excel.xlt"}, {"sM3F", "com.apple.logic-song"}, {"sbBF", "com.apple.finder.burn-folder"}, {"scrp", "com.apple.legacy.finder-icon"}, {"sdoc", "com.apple.generic-stationery"}, {"sfnt", "com.apple.font-suitcase"}, {"shlb", "com.apple.legacy.finder-icon"}, {"srvr", "com.apple.file-server"}, {"svg ", "public.svg-image"}, {"svgz", "public.svg-image"}, {"tDoc", "com.apple.documents-folder"}, {"tfil", "com.apple.font-suitcase"}, {"trsh", "com.apple.trash-empty"}, {"ttcf", "public.truetype-collection-font"}, {"ttro", "com.apple.traditional-mac-plain-text"}, {"txtn", "com.apple.txn.text-multimedia-data"}, {"url ", "public.url"}, {"user", "com.apple.user"}, {"utxt", "public.utf16-plain-text"}, {"vCrd", "public.vcard"}, {NULL, NULL} }; |
Changes to macosx/tkMacOSXFont.c.
1 2 3 4 5 6 | /* * tkMacOSXFont.c -- * * Contains the Macintosh implementation of the platform-independent font * package interface. * | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /* * tkMacOSXFont.c -- * * Contains the Macintosh implementation of the platform-independent font * package interface. * * Copyright © 2002-2004 Benjamin Riefenstahl, [email protected] * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * 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. */ #include "tkMacOSXPrivate.h" #include "tkMacOSXFont.h" |
︙ | ︙ | |||
108 109 110 111 112 113 114 | - (instancetype)initWithTclUtfBytes:(const void *)bytes length:(NSUInteger)len { self = [self init]; if (self) { Tcl_DStringInit(&_ds); | | | | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | - (instancetype)initWithTclUtfBytes:(const void *)bytes length:(NSUInteger)len { self = [self init]; if (self) { Tcl_DStringInit(&_ds); Tcl_UtfToChar16DString((const char *)bytes, len, &_ds); _string = [[NSString alloc] initWithCharactersNoCopy:(unichar *)Tcl_DStringValue(&_ds) length:Tcl_DStringLength(&_ds)>>1 freeWhenDone:NO]; self.UTF8String = _string.UTF8String; } return self; } - (instancetype)initWithString:(NSString *)aString { self = [self init]; if (self) { _string = [[NSString alloc] initWithString:aString]; _UTF8String = _string.UTF8String; } return self; } - (void)dealloc { Tcl_DStringFree(&_ds); |
︙ | ︙ | |||
145 146 147 148 149 150 151 | } - (unichar)characterAtIndex:(NSUInteger)index { return [_string characterAtIndex:index]; } | < < < < | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | } - (unichar)characterAtIndex:(NSUInteger)index { return [_string characterAtIndex:index]; } - (Tcl_DString)DString { if ( _ds.string == NULL) { /* * The DString has not been initialized. Construct it from * our string's unicode characters. |
︙ | ︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 185 186 | Tcl_DStringSetLength(&_ds, p - Tcl_DStringValue(&_ds)); } return _ds; } #ifndef __clang__ @synthesize UTF8String = _UTF8String; #endif @end #define GetNSFontTraitsFromTkFontAttributes(faPtr) \ ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \ ((faPtr)->slant == TK_FS_ITALIC ? NSItalicFontMask : NSUnitalicFontMask) | > | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | Tcl_DStringSetLength(&_ds, p - Tcl_DStringValue(&_ds)); } return _ds; } #ifndef __clang__ @synthesize UTF8String = _UTF8String; @synthesize DString = _ds; #endif @end #define GetNSFontTraitsFromTkFontAttributes(faPtr) \ ((faPtr)->weight == TK_FW_BOLD ? NSBoldFontMask : NSUnboldFontMask) | \ ((faPtr)->slant == TK_FS_ITALIC ? NSItalicFontMask : NSUnitalicFontMask) |
︙ | ︙ | |||
243 244 245 246 247 248 249 | { NSFontManager *fm = [NSFontManager sharedFontManager]; NSFont *nsFont, *dflt = nil; #define defaultFont (dflt ? dflt : (dflt = [NSFont systemFontOfSize:0])) NSString *family; if (familyName) { | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 | { NSFontManager *fm = [NSFontManager sharedFontManager]; NSFont *nsFont, *dflt = nil; #define defaultFont (dflt ? dflt : (dflt = [NSFont systemFontOfSize:0])) NSString *family; if (familyName) { family = [[[TKNSString alloc] initWithTclUtfBytes:familyName length:-1] autorelease]; } else { family = [defaultFont familyName]; } if (size == 0.0) { size = [defaultFont pointSize]; } nsFont = [fm fontWithFamily:family traits:traits weight:weight size:size]; |
︙ | ︙ | |||
419 420 421 422 423 424 425 426 427 428 429 430 431 432 | Tk_Window tkwin, const char* name, TkFontAttributes *faPtr) { TkDeleteNamedFont(NULL, tkwin, name); return TkCreateNamedFont(interp, tkwin, name, faPtr); } #pragma mark - #pragma mark Font handling: /* *------------------------------------------------------------------------- * | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | Tk_Window tkwin, const char* name, TkFontAttributes *faPtr) { TkDeleteNamedFont(NULL, tkwin, name); return TkCreateNamedFont(interp, tkwin, name, faPtr); } #pragma mark - #pragma mark Grapheme Cluster indexing /* *---------------------------------------------------------------------- * * startOfClusterObjCmd -- * * This function is invoked to process the startOfCluster command. * * Results: * A standard Tcl result. * * Side effects: * None * *---------------------------------------------------------------------- */ static int startOfClusterObjCmd( TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TKNSString *S; const char *stringArg; int numBytes; TkSizeT index; if ((unsigned)(objc - 3) > 1) { Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?"); return TCL_ERROR; } stringArg = Tcl_GetStringFromObj(objv[1], &numBytes); if (stringArg == NULL) { return TCL_ERROR; } S = [[TKNSString alloc] initWithTclUtfBytes:stringArg length:numBytes]; if (TkGetIntForIndex(objv[2], [S length] - 1, 0, &index) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INDEX", NULL); return TCL_ERROR; } if (index != TCL_INDEX_NONE) { if ((size_t)index >= [S length]) { index = (TkSizeT)[S length]; } else { NSRange range = [S rangeOfComposedCharacterSequenceAtIndex:index]; index = range.location; } Tcl_SetObjResult(interp, TkNewIndexObj(index)); } return TCL_OK; } static int endOfClusterObjCmd( TCL_UNUSED(void *), Tcl_Interp *interp, /* Current interpreter. */ int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { TKNSString *S; char *stringArg; int numBytes; TkSizeT index; if ((unsigned)(objc - 3) > 1) { Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?"); return TCL_ERROR; } stringArg = Tcl_GetStringFromObj(objv[1], &numBytes); if (stringArg == NULL) { return TCL_ERROR; } S = [[TKNSString alloc] initWithTclUtfBytes:stringArg length:numBytes]; if (TkGetIntForIndex(objv[2], [S length] - 1, 0, &index) != TCL_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", Tcl_GetString(objv[2]))); Tcl_SetErrorCode(interp, "TK", "VALUE", "INDEX", NULL); return TCL_ERROR; } if ((size_t)index + 1 <= [S length]) { if (index == TCL_INDEX_NONE) { index = 0; } else { NSRange range = [S rangeOfComposedCharacterSequenceAtIndex:index]; index = range.location + range.length; } Tcl_SetObjResult(interp, TkNewIndexObj(index)); } return TCL_OK; } #pragma mark - #pragma mark Font handling: /* *------------------------------------------------------------------------- * |
︙ | ︙ | |||
516 517 518 519 520 521 522 523 524 525 526 527 528 529 | whitespaceAndNewlineCharacterSet] retain]; cs = [whitespaceCharacterSet mutableCopy]; [cs removeCharactersInString:@" "]; lineendingCharacterSet = [cs copy]; [cs release]; } [pool drain]; } /* *--------------------------------------------------------------------------- * * TkpGetNativeFont -- * | > > | 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 | whitespaceAndNewlineCharacterSet] retain]; cs = [whitespaceCharacterSet mutableCopy]; [cs removeCharactersInString:@" "]; lineendingCharacterSet = [cs copy]; [cs release]; } [pool drain]; Tcl_CreateObjCommand(interp, "::tk::startOfCluster", startOfClusterObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tk::endOfCluster", endOfClusterObjCmd, NULL, NULL); } /* *--------------------------------------------------------------------------- * * TkpGetNativeFont -- * |
︙ | ︙ | |||
1152 1153 1154 1155 1156 1157 1158 | 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 * whole (not just the range) string when * drawing. */ { | < | 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 | 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 * whole (not just the range) string when * drawing. */ { TkpDrawAngledCharsInContext(display, drawable, gc, tkfont, source, numBytes, rangeStart, rangeLength, x, y, 0.0); } void TkpDrawAngledCharsInContext( TCL_UNUSED(Display *), /* Display on which to draw. */ |
︙ | ︙ | |||
1189 1190 1191 1192 1193 1194 1195 | NSAttributedString *attributedString; CTTypesetterRef typesetter; CFIndex start, length; CTLineRef line, full=nil; MacDrawable *macWin = (MacDrawable *)drawable; TkMacOSXDrawingContext drawingContext; CGContextRef context; | | | > | | > > | | 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 | NSAttributedString *attributedString; CTTypesetterRef typesetter; CFIndex start, length; CTLineRef line, full=nil; MacDrawable *macWin = (MacDrawable *)drawable; TkMacOSXDrawingContext drawingContext; CGContextRef context; CGColorRef fg = NULL; NSFont *nsFont; CGAffineTransform t; CGFloat width, height, textX = (CGFloat) x, textY = (CGFloat) y; if (rangeStart < 0 || rangeLength <= 0 || rangeStart + rangeLength > numBytes || !TkMacOSXSetupDrawingContext(drawable, gc, &drawingContext)) { return; } string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes]; if (!string) { return; } context = drawingContext.context; TkSetMacColor(gc->foreground, &fg); attributes = [fontPtr->nsAttributes mutableCopy]; if (fg) { [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName]; CGColorRelease(fg); } nsFont = [attributes objectForKey:NSFontAttributeName]; [nsFont setInContext:GET_NSCONTEXT(context, NO)]; CGContextSetTextMatrix(context, CGAffineTransformIdentity); attributedString = [[NSAttributedString alloc] initWithString:string attributes:attributes]; [string release]; typesetter = CTTypesetterCreateWithAttributedString( (CFAttributedStringRef)attributedString); textX += (CGFloat) macWin->xOff; textY += (CGFloat) macWin->yOff; height = [drawingContext.view bounds].size.height; textY = height - textY; t = CGAffineTransformMake(1.0, 0.0, 0.0, -1.0, 0.0, height); if (angle != 0.0) { t = CGAffineTransformTranslate( CGAffineTransformRotate( CGAffineTransformTranslate(t, textX, textY), angle*PI/180.0), -textX, -textY); |
︙ | ︙ | |||
1250 1251 1252 1253 1254 1255 1256 | textX += (width - CTLineGetTypographicBounds(line, NULL, NULL, NULL)); } CGContextSetTextPosition(context, textX, textY); CTLineDraw(line, context); CFRelease(line); CFRelease(typesetter); [attributedString release]; | < | 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 | textX += (width - CTLineGetTypographicBounds(line, NULL, NULL, NULL)); } CGContextSetTextPosition(context, textX, textY); CTLineDraw(line, context); CFRelease(line); CFRelease(typesetter); [attributedString release]; [attributes release]; TkMacOSXRestoreDrawingContext(&drawingContext); } #pragma mark - #pragma mark Accessors: |
︙ | ︙ |
Changes to macosx/tkMacOSXFont.h.
1 2 3 4 5 6 | /* * tkMacOSXFont.h -- * * Contains the Macintosh implementation of the platform-independent * font package interface. * | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkMacOSXFont.h -- * * Contains the Macintosh implementation of the platform-independent * font package interface. * * 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 <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ #ifndef TKMACOSXFONT_H #define TKMACOSXFONT_H 1 |
︙ | ︙ |
Changes to macosx/tkMacOSXHLEvents.c.
1 2 3 4 5 | /* * tkMacOSXHLEvents.c -- * * Implements high level event support for the Macintosh. * | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* * tkMacOSXHLEvents.c -- * * Implements high level event support for the Macintosh. * * Copyright © 1995-1997 Sun Microsystems, Inc. * Copyright © 2001-2009 Apple Inc. * Copyright © 2006-2009 Daniel A. Steffen <[email protected]> * 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. */ #include "tkMacOSXPrivate.h" #include <sys/param.h> |
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | */ 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 { [super terminate:nil]; } - (void) preferences: (id) sender { (void)sender; [self handleShowPreferencesEvent:Nil withReplyEvent:Nil]; | > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | */ 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 getSdefProc[] = "::tk::mac::GetDynamicSdef"; #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]; |
︙ | ︙ | |||
221 222 223 224 225 226 227 | continue; } URLString[actual] = '\0'; fileURL = [NSURL URLWithString:[NSString stringWithUTF8String:(char*)URLString]]; if (fileURL == nil) { continue; } | | > < < | 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | continue; } URLString[actual] = '\0'; fileURL = [NSURL URLWithString:[NSString stringWithUTF8String:(char*)URLString]]; if (fileURL == nil) { continue; } (void)Tcl_ExternalToUtfDStringEx(utf8, [[fileURL path] UTF8String], -1, TCL_ENCODING_NOCOMPLAIN, &pathName); Tcl_DStringAppendElement(openCommand, Tcl_DStringValue(&pathName)); Tcl_DStringFree(&pathName); } Tcl_FreeEncoding(utf8); AEDisposeDesc(&contents); AEInfo->interp = _eventInterp; AEInfo->procedure = openDocumentProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; if (Tcl_FindCommand(_eventInterp, "::tk::mac::OpenDocuments", NULL, 0)){ ProcessAppleEvent((ClientData)AEInfo); } else { Tcl_CreateTimerHandler(500, ProcessAppleEvent, (ClientData)AEInfo); } } |
︙ | ︙ | |||
257 258 259 260 261 262 263 | Tcl_DStringInit(printCommand); Tcl_DStringAppend(printCommand, printDocProc, -1); Tcl_DStringAppendElement(printCommand, printFile); AEInfo->interp = _eventInterp; AEInfo->procedure = printDocProc; AEInfo->replyEvent = nil; | < | 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | Tcl_DStringInit(printCommand); Tcl_DStringAppend(printCommand, printDocProc, -1); Tcl_DStringAppendElement(printCommand, printFile); AEInfo->interp = _eventInterp; AEInfo->procedure = printDocProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; ProcessAppleEvent((ClientData)AEInfo); } - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent { |
︙ | ︙ | |||
320 321 322 323 324 325 326 | Tcl_DString *scriptFileCommand = &AEInfo->command; Tcl_DStringInit(scriptFileCommand); Tcl_DStringAppend(scriptFileCommand, scriptFileProc, -1); Tcl_DStringAppendElement(scriptFileCommand, [[fileURL path] UTF8String]); AEInfo->interp = _eventInterp; AEInfo->procedure = scriptFileProc; AEInfo->replyEvent = nil; | < | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | Tcl_DString *scriptFileCommand = &AEInfo->command; Tcl_DStringInit(scriptFileCommand); Tcl_DStringAppend(scriptFileCommand, scriptFileProc, -1); Tcl_DStringAppendElement(scriptFileCommand, [[fileURL path] UTF8String]); AEInfo->interp = _eventInterp; AEInfo->procedure = scriptFileProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; ProcessAppleEvent((ClientData)AEInfo); } } } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, NULL, 0, &actual)) { /* |
︙ | ︙ | |||
352 353 354 355 356 357 358 | AEInfo->procedure = scriptTextProc; AEInfo->retryCount = 0; if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { AEInfo->replyEvent = replyEvent; ProcessAppleEvent(AEInfo); } else { AEInfo->replyEvent = nil; | < | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 | AEInfo->procedure = scriptTextProc; AEInfo->retryCount = 0; if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { AEInfo->replyEvent = replyEvent; ProcessAppleEvent(AEInfo); } else { AEInfo->replyEvent = nil; ProcessAppleEvent(AEInfo); } } } } } |
︙ | ︙ | |||
376 377 378 379 380 381 382 | Tcl_DStringInit(launchCommand); Tcl_DStringAppend(launchCommand, launchURLProc, -1); Tcl_DStringAppendElement(launchCommand, cURL); AEInfo->interp = _eventInterp; AEInfo->procedure = launchURLProc; AEInfo->replyEvent = nil; | > | > > > > > > > > > > > > > > | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | Tcl_DStringInit(launchCommand); Tcl_DStringAppend(launchCommand, launchURLProc, -1); Tcl_DStringAppendElement(launchCommand, cURL); AEInfo->interp = _eventInterp; AEInfo->procedure = launchURLProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; ProcessAppleEvent((ClientData)AEInfo); } - (void)handleGetSDEFEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { AppleEventInfo *AEInfo = (AppleEventInfo *)ckalloc(sizeof(AppleEventInfo)); Tcl_DString *sdefCommand = &AEInfo->command; (void)event; (void)replyEvent; Tcl_DStringInit(sdefCommand); Tcl_DStringAppend(sdefCommand, getSdefProc, -1); AEInfo->interp = _eventInterp; AEInfo->procedure = getSdefProc; AEInfo->replyEvent = nil; AEInfo->retryCount = 0; ProcessAppleEvent((ClientData)AEInfo); } @end #pragma mark - /* |
︙ | ︙ | |||
518 519 520 521 522 523 524 525 526 527 528 529 530 531 | andSelector:@selector(handleDoScriptEvent:withReplyEvent:) forEventClass:kAEMiscStandards andEventID:kAEDoScript]; [aeManager setEventHandler:NSApp andSelector:@selector(handleURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; } } /* *---------------------------------------------------------------------- * * TkMacOSXDoHLEvent -- | > > > > > > > > > | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | andSelector:@selector(handleDoScriptEvent:withReplyEvent:) forEventClass:kAEMiscStandards andEventID:kAEDoScript]; [aeManager setEventHandler:NSApp andSelector:@selector(handleURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; /* * We do not load our sdef dynamically but this event handler * is required to silence error messages from inline execution * of AppleScript at the Objective-C level. */ [aeManager setEventHandler:NSApp andSelector:@selector(handleGetSDEFEvent:withReplyEvent:) forEventClass:'ascr' andEventID:'gsdf']; } } /* *---------------------------------------------------------------------- * * TkMacOSXDoHLEvent -- |
︙ | ︙ |
Changes to macosx/tkMacOSXImage.c.
1 2 3 4 5 6 | /* * tkMacOSXImage.c -- * * The code in this file provides an interface for XImages, * * Copyright (c) 1995-1997 Sun Microsystems, Inc. | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | /* * tkMacOSXImage.c -- * * The code in this file provides an interface for XImages, * * Copyright (c) 1995-1997 Sun Microsystems, Inc. * Copyright (c) 2001-2009, Apple Inc. * Copyright (c) 2005-2009 Daniel A. Steffen <[email protected]> * Copyright (c) 2017-2021 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 "tkMacOSXConstants.h" #include "xbytes.h" static CGImageRef CreateCGImageFromPixmap(Drawable pixmap); static CGImageRef CreateCGImageFromDrawableRect( Drawable drawable, int x, int y, unsigned int width, unsigned int height); /* Pixel formats * * Tk uses the XImage structure defined in Xlib.h for storing images. The * image data in an XImage is a 32-bit aligned array of bytes. Interpretation * of that data is not specified, but the structure includes parameters which * provide interpretation hints so that an application can use a family of * different data structures. * * The possible values for the XImage format field are XYBitmap, XYPixmap and * ZPixmap. The macOS port does not support the XYPixmap format. This means * that bitmap images are stored as a single bit plane (XYBitmap) and that * color images are stored as a sequence of pixel values (ZPixmap). * * For a ZPixmap, the number of bits allocated to each pixel is specified by * the bits_per_pixel field of the XImage structure. The functions in this * module which convert between XImage and native CGImage or NSImage structures * only support XImages with 32 bits per pixel. The ImageGetPixel and PutPixel * implementations in this file allow 1, 4, 8, 16 or 32 bits per pixel, however. * * In tkImgPhInstance.c the layout used for pixels is determined by the values * of the red_mask, blue_mask and green_mask fields in the XImage structure. * The Aqua port always sets red_mask = 0xFF0000, green_mask = 0xFF00, and * blue_mask = 0xFF. This means that a 32bpp ZPixmap XImage uses ARGB32 pixels, * with small-endian byte order BGRA. The data array for such an XImage can be * passed directly to construct a CGBitmapImageRep if one specifies the * bitmapInfo as kCGBitmapByteOrder32Big | kCGImageAlphaLast. * * The structures below describe the bitfields in two common 32 bpp pixel * layouts. Note that bit field layouts are compiler dependent. The layouts * shown in the comments are those produced by clang and gcc. Also note * that kCGBitmapByteOrder32Big is consistently set when creating CGImages or * CGImageBitmapReps. */ /* RGBA32 0xRRGGBBAA (Byte order is RGBA on big-endian systems.) * This is used by NSBitmapImageRep when the bitmapFormat property is 0, * the default value. */ typedef struct RGBA32pixel_t { unsigned red: 8; unsigned green: 8; unsigned blue: 8; unsigned alpha: 8; } RGBA32pixel; /* * ARGB32 0xAARRGGBB (Byte order is ARGB on big-endian systems.) * This is used by Aqua Tk for XImages and by NSBitmapImageReps whose * bitmapFormat property is NSAlphaFirstBitmapFormat. */ typedef struct ARGB32pixel_t { unsigned blue: 8; unsigned green: 8; unsigned red: 8; unsigned alpha: 8; } ARGB32pixel; typedef union pixel32_t { unsigned int uint; RGBA32pixel rgba; ARGB32pixel argb; } pixel32; #pragma mark XImage handling int _XInitImageFuncPtrs( TCL_UNUSED(XImage *)) /* image */ { |
︙ | ︙ | |||
51 52 53 54 55 56 57 | TCL_UNUSED(size_t)) /* size */ { ckfree(info); } CGImageRef TkMacOSXCreateCGImageWithXImage( | | > | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | TCL_UNUSED(size_t)) /* size */ { ckfree(info); } CGImageRef TkMacOSXCreateCGImageWithXImage( XImage *image, uint32_t alphaInfo) { CGImageRef img = NULL; size_t bitsPerComponent, bitsPerPixel; size_t len = image->bytes_per_line * image->height; const CGFloat *decode = NULL; CGBitmapInfo bitmapInfo; CGDataProviderRef provider = NULL; |
︙ | ︙ | |||
73 74 75 76 77 78 79 | /* Reverses the sense of the bits */ static const CGFloat decodeWB[2] = {1, 0}; decode = decodeWB; bitsPerComponent = 1; bitsPerPixel = 1; | > > | | | | | | | | | | < > > | < > > | < > < | < | > > > | < | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | /* Reverses the sense of the bits */ static const CGFloat decodeWB[2] = {1, 0}; decode = decodeWB; bitsPerComponent = 1; bitsPerPixel = 1; data = (char *)ckalloc(len); if (data) { if (image->bitmap_bit_order != MSBFirst) { char *srcPtr = image->data + image->xoffset; char *endPtr = srcPtr + len; char *destPtr = data; while (srcPtr < endPtr) { *destPtr++ = xBitReverseTable[(unsigned char)(*(srcPtr++))]; } } else { memcpy(data, image->data + image->xoffset, len); } provider = CGDataProviderCreateWithData(data, data, len, releaseData); if (!provider) { ckfree(data); } img = CGImageMaskCreate(image->width, image->height, bitsPerComponent, bitsPerPixel, image->bytes_per_line, provider, decode, 0); CGDataProviderRelease(provider); } } else if ((image->format == ZPixmap) && (image->bits_per_pixel == 32)) { /* * Color image */ if (image->width == 0 && image->height == 0) { /* * CGCreateImage complains on early macOS releases. */ return NULL; } CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB(); bitsPerComponent = 8; bitsPerPixel = 32; bitmapInfo = kCGBitmapByteOrder32Big | alphaInfo; data = (char *)ckalloc(len); if (data) { memcpy(data, image->data + image->xoffset, len); provider = CGDataProviderCreateWithData(data, data, len, releaseData); if (!provider) { ckfree(data); } img = CGImageCreate(image->width, image->height, bitsPerComponent, bitsPerPixel, image->bytes_per_line, colorspace, bitmapInfo, provider, decode, 0, kCGRenderingIntentDefault); CGDataProviderRelease(provider); } if (colorspace) { CFRelease(colorspace); } } else { TkMacOSXDbgMsg("Unsupported image type"); } |
︙ | ︙ | |||
201 202 203 204 205 206 207 | 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: /* 8 bits per channel */ | > | < < < | | | < > | 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | 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: /* 8 bits per channel */ { ARGB32pixel *pixel = (ARGB32pixel *)srcPtr; r = pixel->red; g = pixel->green; b = pixel->blue; } break; 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: /* 2 bits per channel */ |
︙ | ︙ | |||
245 246 247 248 249 250 251 | } /* *---------------------------------------------------------------------- * * ImagePutPixel -- * | | > > > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | } /* *---------------------------------------------------------------------- * * ImagePutPixel -- * * Set a single pixel in an image. The pixel is provided as an unsigned * 32-bit integer. The value of that integer is interpreted by assuming * that its low-order N bits have the format specified by the XImage, * where N is equal to the bits_per_pixel field of the XImage. * * Results: * None. * * Side effects: * None. * |
︙ | ︙ | |||
271 272 273 274 275 276 277 | unsigned char *dstPtr = ((unsigned char*) image->data) + (y * image->bytes_per_line) + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); if (image->bits_per_pixel == 32) { *((unsigned int*) dstPtr) = pixel; } else { | < < < | < | < < < | | | | 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | unsigned char *dstPtr = ((unsigned char*) image->data) + (y * image->bytes_per_line) + (((image->xoffset + x) * image->bits_per_pixel) / NBBY); if (image->bits_per_pixel == 32) { *((unsigned int*) dstPtr) = pixel; } else { switch (image->bits_per_pixel) { case 16: *((unsigned short*) dstPtr) = pixel & 0xffff; break; case 8: *dstPtr = pixel & 0xff; break; case 4: { *dstPtr = (x % 2) ? ((*dstPtr & 0xf0) | (pixel & 0x0f)) : ((*dstPtr & 0x0f) | ((pixel << 4) & 0xf0)); break; } case 1: *dstPtr = pixel ? (*dstPtr | (0x80 >> (x % 8))) : (*dstPtr & ~(0x80 >> (x % 8))); break; } } } return 0; } |
︙ | ︙ | |||
332 333 334 335 336 337 338 | unsigned int height, int bitmap_pad, int bytes_per_line) { XImage *ximage; display->request++; | | | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | unsigned int height, int bitmap_pad, int bytes_per_line) { XImage *ximage; display->request++; ximage = (XImage *)ckalloc(sizeof(XImage)); ximage->height = height; ximage->width = width; ximage->depth = depth; ximage->xoffset = offset; ximage->format = format; ximage->data = data; |
︙ | ︙ | |||
388 389 390 391 392 393 394 | return ximage; } /* *---------------------------------------------------------------------- * |