Tk Library Source Code

Check-in [a5d49dd445]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tsw: Minor improvements.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a5d49dd445781f3e33c02970134bd4a1d601b851ec09264038eae71ee22b3a5d
User & Date: csaba 2025-07-24 17:11:15.897
Context
2025-07-24
17:16
Tsw: Corrected a typo. check-in: 8723831003 user: csaba tags: trunk
17:11
Tsw: Minor improvements. check-in: a5d49dd445 user: csaba tags: trunk
2025-07-16
16:36
Removed superfluous close-brace. check-in: c7ec0962c1 user: clif tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to modules/tsw/scripts/elements.tcl.
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
	]
    }

    set elemInfoArr(default) 1
}

#------------------------------------------------------------------------------
# tsw::createElements_default-dark
#------------------------------------------------------------------------------
proc tsw::createElements_default-dark {} {
    variable elemInfoArr
    if {[info exists elemInfoArr(default-dark)]} {
	return ""
    }

    set troughData(1) {
<svg width="32" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="32" height="16" rx="8" }
    set troughData(2) {







|

|

|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
	]
    }

    set elemInfoArr(default) 1
}

#------------------------------------------------------------------------------
# tsw::createElements_defaultDark
#------------------------------------------------------------------------------
proc tsw::createElements_defaultDark {} {
    variable elemInfoArr
    if {[info exists elemInfoArr(defaultDark)]} {
	return ""
    }

    set troughData(1) {
<svg width="32" height="16" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="32" height="16" rx="8" }
    set troughData(2) {
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
	    selected		$sliderImg \
	    disabled		$sliderOffDisabledImg \
	    pressed		$sliderImg \
	    active		$sliderImg \
	]
    }

    set elemInfoArr(default-dark) 1
}

#------------------------------------------------------------------------------
# tsw::createElements_clam
#------------------------------------------------------------------------------
proc tsw::createElements_clam {} {
    set troughData(1) {







|







233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
	    selected		$sliderImg \
	    disabled		$sliderOffDisabledImg \
	    pressed		$sliderImg \
	    active		$sliderImg \
	]
    }

    set elemInfoArr(defaultDark) 1
}

#------------------------------------------------------------------------------
# tsw::createElements_clam
#------------------------------------------------------------------------------
proc tsw::createElements_clam {} {
    set troughData(1) {
Changes to modules/tsw/scripts/tclIndex.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Tcl autoload index file, version 2.0
# This file is generated by the "auto_mkindex" command
# and sourced to set up indexing information for one or
# more commands.  Typically each line is a command that
# sets an element in the auto_index array, where the
# element name is the name of a command and the value is
# a script that loads the command.

set auto_index(::tsw::svgFormat) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_default) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_default-dark) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_clam) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_droid) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_plastik) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awarc) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awbreeze) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awbreezedark) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awlight) [list source [file join $dir elements.tcl]]










|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Tcl autoload index file, version 2.0
# This file is generated by the "auto_mkindex" command
# and sourced to set up indexing information for one or
# more commands.  Typically each line is a command that
# sets an element in the auto_index array, where the
# element name is the name of a command and the value is
# a script that loads the command.

set auto_index(::tsw::svgFormat) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_default) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_defaultDark) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_clam) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_droid) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_plastik) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awarc) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awbreeze) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awbreezedark) [list source [file join $dir elements.tcl]]
set auto_index(::tsw::createElements_awlight) [list source [file join $dir elements.tcl]]
Changes to modules/tsw/scripts/toggleswitch.tcl.
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
	variable theme
	set themeMod $theme
	set mod ""

	if {$theme eq "default"} {
	    set fg [ttk::style lookup . -foreground]
	    if {[mwutil::isColorLight $fg]} {
		set themeMod default-dark
		set mod "Dark"
	    }
	}

	variable elemInfoArr
	if {[info exists elemInfoArr($themeMod)]} {
	    if {$theme eq "aqua"} {
		updateElements_$theme
	    }

	    return ""
	}

	switch $themeMod {
	    default - default-dark - clam - droid - plastik - awarc -
	    awbreeze - awbreezedark - awlight - awdark - vista - aqua {
		createElements_$themeMod
	    }
	    winnative - xpnative {
		ttk::style theme settings vista { createElements_vista }
		foreach n {1 2 3} {
		    ttk::style element create Switch$n.trough from vista
		    ttk::style element create Switch$n.slider from vista
		}
	    }
	    default {
		set fg [ttk::style lookup . -foreground {} black]
		if {[mwutil::isColorLight $fg] ||
		    [string match -nocase *dark* $theme]} {
		    set createCmd createElements_default-dark
		    set mod "Dark"
		} else {
		    set createCmd createElements_default
		}

		ttk::style theme settings default { $createCmd }
		foreach n {1 2 3} {
		    ttk::style element create ${mod}Switch$n.trough from default
		    ttk::style element create ${mod}Switch$n.slider from default
		}
	    }
	}
	set elemInfoArr($themeMod) 1







|














|














<

<
<


|







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
	variable theme
	set themeMod $theme
	set mod ""

	if {$theme eq "default"} {
	    set fg [ttk::style lookup . -foreground]
	    if {[mwutil::isColorLight $fg]} {
		set themeMod defaultDark
		set mod "Dark"
	    }
	}

	variable elemInfoArr
	if {[info exists elemInfoArr($themeMod)]} {
	    if {$theme eq "aqua"} {
		updateElements_$theme
	    }

	    return ""
	}

	switch $themeMod {
	    default - defaultDark - clam - droid - plastik - awarc -
	    awbreeze - awbreezedark - awlight - awdark - vista - aqua {
		createElements_$themeMod
	    }
	    winnative - xpnative {
		ttk::style theme settings vista { createElements_vista }
		foreach n {1 2 3} {
		    ttk::style element create Switch$n.trough from vista
		    ttk::style element create Switch$n.slider from vista
		}
	    }
	    default {
		set fg [ttk::style lookup . -foreground {} black]
		if {[mwutil::isColorLight $fg] ||
		    [string match -nocase *dark* $theme]} {

		    set mod "Dark"


		}

		ttk::style theme settings default { CreateElements_default$mod }
		foreach n {1 2 3} {
		    ttk::style element create ${mod}Switch$n.trough from default
		    ttk::style element create ${mod}Switch$n.slider from default
		}
	    }
	}
	set elemInfoArr($themeMod) 1
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
proc tsw::createBindings {} {
    bind Toggleswitch <KeyPress> continue
    bind Toggleswitch <FocusIn> {
	if {[focus -lastfor %W] eq "%W"} {
	    focus %W.scl
	}
    }
    bind Toggleswitch <Destroy>		{ tsw::onDestroy %W }
    bind Toggleswitch <<ThemeChanged>>	{ tsw::onThemeChanged %W }

    bindtags . [linsert [bindtags .] 1 TswMain]
    foreach event {<<ThemeChanged>> <<LightAqua>> <<DarkAqua>>} {
	bind TswMain $event { tsw::onThemeChanged %W }
    }

    #
    # Define the binding tag ToggleswitchKeyNav
    #
    mwutil::defineKeyNav Toggleswitch



    variable onAndroid
    if {!$onAndroid} {
	bind TswScale <Enter>	    { %W instate !disabled {%W state active} }
	bind TswScale <Leave>	    { %W state !active }
    }
    bind TswScale <B1-Leave>	    { # Preserves the "active" state. }







|
<










>
>







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
proc tsw::createBindings {} {
    bind Toggleswitch <KeyPress> continue
    bind Toggleswitch <FocusIn> {
	if {[focus -lastfor %W] eq "%W"} {
	    focus %W.scl
	}
    }
    bind Toggleswitch <Destroy>     { tsw::onDestroy %W }


    bindtags . [linsert [bindtags .] 1 TswMain]
    foreach event {<<ThemeChanged>> <<LightAqua>> <<DarkAqua>>} {
	bind TswMain $event { tsw::onThemeChanged %W }
    }

    #
    # Define the binding tag ToggleswitchKeyNav
    #
    mwutil::defineKeyNav Toggleswitch

    bind TswScale <<ThemeChanged>>  { tsw::onThemeChanged %W }

    variable onAndroid
    if {!$onAndroid} {
	bind TswScale <Enter>	    { %W instate !disabled {%W state active} }
	bind TswScale <Leave>	    { %W state !active }
    }
    bind TswScale <B1-Leave>	    { # Preserves the "active" state. }
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
#------------------------------------------------------------------------------
proc tsw::onThemeChanged w {
    variable theme [ttk::style theme use]

    if {$w eq "."} {
	condMakeLayouts
    } else {
	set scl $w.scl
	set stateSpec [$scl state !disabled]		;# needed for $scl set
	$scl set [expr {[$scl instate selected] ?
			[$scl cget -to] : [$scl cget -from]}]
	$scl state $stateSpec				;# restores the state
    }
}

#------------------------------------------------------------------------------
# tsw::onButton1
#------------------------------------------------------------------------------
proc tsw::onButton1 {w x y} {







<
|
|
<
|







667
668
669
670
671
672
673

674
675

676
677
678
679
680
681
682
683
#------------------------------------------------------------------------------
proc tsw::onThemeChanged w {
    variable theme [ttk::style theme use]

    if {$w eq "."} {
	condMakeLayouts
    } else {

	set stateSpec [$w state !disabled]		;# needed for $w set
	$w set [expr {[$w instate selected] ? [$w cget -to] : [$w cget -from]}]

	$w state $stateSpec				;# restores the state
    }
}

#------------------------------------------------------------------------------
# tsw::onButton1
#------------------------------------------------------------------------------
proc tsw::onButton1 {w x y} {