diff options
author | dgp <dgp@users.sourceforge.net> | 2020-07-24 17:21:30 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2020-07-24 17:21:30 (GMT) |
commit | b2ee9201bc3958e8e48c7c5d0661efcbb1ab1be6 (patch) | |
tree | 362d8b1a3ca50fe6cf576537ba7850a4912fe7c2 /library | |
parent | aa7acf035dbe0876737e7f49343baadd36260d97 (diff) | |
parent | b00f202e7437c114c8c278c65c2ebe18c7bc85f7 (diff) | |
download | tk-b2ee9201bc3958e8e48c7c5d0661efcbb1ab1be6.zip tk-b2ee9201bc3958e8e48c7c5d0661efcbb1ab1be6.tar.gz tk-b2ee9201bc3958e8e48c7c5d0661efcbb1ab1be6.tar.bz2 |
merge 8.6
Diffstat (limited to 'library')
-rw-r--r-- | library/bgerror.tcl | 12 | ||||
-rw-r--r-- | library/demos/ctext.tcl | 14 | ||||
-rw-r--r-- | library/entry.tcl | 63 | ||||
-rw-r--r-- | library/fontchooser.tcl | 43 | ||||
-rw-r--r-- | library/tearoff.tcl | 10 |
5 files changed, 68 insertions, 74 deletions
diff --git a/library/bgerror.tcl b/library/bgerror.tcl index 8421924..fe8dfe0 100644 --- a/library/bgerror.tcl +++ b/library/bgerror.tcl @@ -41,7 +41,7 @@ proc ::tk::dialog::error::Details {} { set w .bgerrorDialog set caption [option get $w.function text {}] set command [option get $w.function command {}] - if { ($caption eq "") || ($command eq "") } { + if {($caption eq "") || ($command eq "")} { grid forget $w.function } lappend command [$w.top.info.text get 1.0 end-1c] @@ -50,7 +50,7 @@ proc ::tk::dialog::error::Details {} { } proc ::tk::dialog::error::SaveToLog {text} { - if { $::tcl_platform(platform) eq "windows" } { + if {$::tcl_platform(platform) eq "windows"} { set allFiles *.* } else { set allFiles * @@ -129,11 +129,11 @@ proc ::tk::dialog::error::bgerror {err {flag 1}} { set lines 0 set maxLine 45 foreach line [split $err \n] { - if { [string length $line] > $maxLine } { - append displayedErr "[string range $line 0 [expr {$maxLine-3}]]..." + if {[string length $line] > $maxLine} { + append displayedErr "[string range $line 0 $maxLine-3]..." break } - if { $lines > 4 } { + if {$lines > 4} { append displayedErr "..." break } else { @@ -182,7 +182,7 @@ proc ::tk::dialog::error::bgerror {err {flag 1}} { pack $W.text -side left -expand yes -fill both $W.text insert 0.0 "$err\n$info" $W.text mark set insert 0.0 - bind $W.text <ButtonPress-1> { focus %W } + bind $W.text <Button-1> {focus %W} $W.text configure -state disabled # 2. Fill the top part with bitmap and message diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index a3b4e8a..502c9d0 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -41,16 +41,16 @@ $c create rectangle 245 195 255 205 -outline black -fill red # First, create the text item and give it bindings so it can be edited. $c addtag text withtag [$c create text 250 200 -text "This is just a string of text to demonstrate the text facilities of canvas widgets. Bindings have been defined to support editing (see above)." -width 440 -anchor n -font $textFont -justify left] -$c bind text <1> "textB1Press $c %x %y" +$c bind text <Button-1> "textB1Press $c %x %y" $c bind text <B1-Motion> "textB1Move $c %x %y" -$c bind text <Shift-1> "$c select adjust current @%x,%y" +$c bind text <Shift-Button-1> "$c select adjust current @%x,%y" $c bind text <Shift-B1-Motion> "textB1Move $c %x %y" -$c bind text <KeyPress> "textInsert $c %A" +$c bind text <Key> "textInsert $c %A" $c bind text <Return> "textInsert $c \\n" $c bind text <Control-h> "textBs $c" $c bind text <BackSpace> "textBs $c" $c bind text <Delete> "textDel $c" -$c bind text <2> "textPaste $c @%x,%y" +$c bind text <Button-2> "textPaste $c @%x,%y" # Next, create some items that allow the text's anchor position # to be edited. @@ -58,14 +58,14 @@ $c bind text <2> "textPaste $c @%x,%y" proc mkTextConfigBox {w x y option value color} { set item [$w create rect $x $y [expr {$x+30}] [expr {$y+30}] \ -outline black -fill $color -width 1] - $w bind $item <1> "$w itemconf text $option $value" + $w bind $item <Button-1> "$w itemconf text $option $value" $w addtag config withtag $item } proc mkTextConfigPie {w x y a option value color} { set item [$w create arc $x $y [expr {$x+90}] [expr {$y+90}] \ -start [expr {$a-15}] -extent 30 -outline black -fill $color \ -width 1] - $w bind $item <1> "$w itemconf text $option $value" + $w bind $item <Button-1> "$w itemconf text $option $value" $w addtag config withtag $item } @@ -84,7 +84,7 @@ mkTextConfigBox $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color set item [$c create rect \ [expr {$x+40}] [expr {$y+40}] [expr {$x+50}] [expr {$y+50}] \ -outline black -fill red] -$c bind $item <1> "$c itemconf text -anchor center" +$c bind $item <Button-1> "$c itemconf text -anchor center" $c create text [expr {$x+45}] [expr {$y-5}] \ -text {Text Position} -anchor s -font {Times 20} -fill brown diff --git a/library/entry.tcl b/library/entry.tcl index da3f800..6539af7 100644 --- a/library/entry.tcl +++ b/library/entry.tcl @@ -58,7 +58,7 @@ bind Entry <<Paste>> { } bind Entry <<Clear>> { # ignore if there is no selection - catch { %W delete sel.first sel.last } + catch {%W delete sel.first sel.last} } bind Entry <<PasteSelection>> { if {$tk_strictMotif || ![info exists tk::Priv(mouseMoved)] @@ -74,7 +74,7 @@ bind Entry <<TraverseIn>> { # Standard Motif bindings: -bind Entry <1> { +bind Entry <Button-1> { tk::EntryButton1 %W %x %W selection clear } @@ -82,25 +82,25 @@ bind Entry <B1-Motion> { set tk::Priv(x) %x tk::EntryMouseSelect %W %x } -bind Entry <Double-1> { +bind Entry <Double-Button-1> { set tk::Priv(selectMode) word tk::EntryMouseSelect %W %x catch {%W icursor sel.last} } -bind Entry <Triple-1> { +bind Entry <Triple-Button-1> { set tk::Priv(selectMode) line tk::EntryMouseSelect %W %x catch {%W icursor sel.last} } -bind Entry <Shift-1> { +bind Entry <Shift-Button-1> { set tk::Priv(selectMode) char %W selection adjust @%x } -bind Entry <Double-Shift-1> { +bind Entry <Double-Shift-Button-1> { set tk::Priv(selectMode) word tk::EntryMouseSelect %W %x } -bind Entry <Triple-Shift-1> { +bind Entry <Triple-Shift-Button-1> { set tk::Priv(selectMode) line tk::EntryMouseSelect %W %x } @@ -114,22 +114,22 @@ bind Entry <B1-Enter> { bind Entry <ButtonRelease-1> { tk::CancelRepeat } -bind Entry <Control-1> { +bind Entry <Control-Button-1> { %W icursor @%x } bind Entry <<PrevChar>> { - tk::EntrySetCursor %W [expr {[%W index insert] - 1}] + tk::EntrySetCursor %W [expr {[%W index insert]-1}] } bind Entry <<NextChar>> { - tk::EntrySetCursor %W [expr {[%W index insert] + 1}] + tk::EntrySetCursor %W [expr {[%W index insert]+1}] } bind Entry <<SelectPrevChar>> { - tk::EntryKeySelect %W [expr {[%W index insert] - 1}] + tk::EntryKeySelect %W [expr {[%W index insert]-1}] tk::EntrySeeInsert %W } bind Entry <<SelectNextChar>> { - tk::EntryKeySelect %W [expr {[%W index insert] + 1}] + tk::EntryKeySelect %W [expr {[%W index insert]+1}] tk::EntrySeeInsert %W } bind Entry <<PrevWord>> { @@ -190,19 +190,19 @@ bind Entry <<SelectAll>> { bind Entry <<SelectNone>> { %W selection clear } -bind Entry <KeyPress> { +bind Entry <Key> { tk::CancelRepeat tk::EntryInsert %W %A } # Ignore all Alt, Meta, and Control 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, +# <Key> class binding will also fire and insert the character, # which is wrong. Ditto for Escape, Return, and Tab. -bind Entry <Alt-KeyPress> {# nothing} -bind Entry <Meta-KeyPress> {# nothing} -bind Entry <Control-KeyPress> {# nothing} +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} @@ -210,7 +210,7 @@ bind Entry <Tab> {# nothing} bind Entry <Prior> {# nothing} bind Entry <Next> {# nothing} if {[tk windowingsystem] eq "aqua"} { - bind Entry <Command-KeyPress> {# nothing} + bind Entry <Command-Key> {# nothing} } # Tk-on-Cocoa generates characters for these two keys. [Bug 2971663] bind Entry <<NextLine>> {# nothing} @@ -278,7 +278,7 @@ bind Entry <<TkStartIMEMarkedText>> { dict set ::tk::Priv(IMETextMark) "%W" [%W index insert] } bind Entry <<TkEndIMEMarkedText>> { - if { [catch {dict get $::tk::Priv(IMETextMark) "%W"} mark] } { + if {[catch {dict get $::tk::Priv(IMETextMark) "%W"} mark]} { bell } else { %W selection range $mark insert @@ -294,7 +294,7 @@ bind Entry <<TkAccentBackspace>> { # A few additional bindings of my own. if {[tk windowingsystem] ne "aqua"} { - bind Entry <2> { + bind Entry <Button-2> { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } @@ -305,7 +305,7 @@ if {[tk windowingsystem] ne "aqua"} { } } } else { - bind Entry <3> { + bind Entry <Button-3> { if {!$tk_strictMotif} { ::tk::EntryScanMark %W %x } @@ -391,10 +391,10 @@ proc ::tk::EntryMouseSelect {w x} { word { if {$cur < $anchor} { set before [tcl_wordBreakBefore [$w get] $cur] - set after [tcl_wordBreakAfter [$w get] [expr {$anchor-1}]] + set after [tcl_wordBreakAfter [$w get] $anchor-1] } elseif {$cur > $anchor} { set before [tcl_wordBreakBefore [$w get] $anchor] - set after [tcl_wordBreakAfter [$w get] [expr {$cur - 1}]] + set after [tcl_wordBreakAfter [$w get] $cur-1] } else { if {[$w index @$Priv(pressX)] < $anchor} { incr anchor -1 @@ -520,7 +520,7 @@ proc ::tk::EntryBackspace w { } else { set x [$w index insert] if {$x > 0} { - $w delete [expr {$x - 1}] + $w delete [expr {$x-1}] } if {[$w index @0] >= [$w index insert]} { set range [$w xview] @@ -580,7 +580,7 @@ proc ::tk::EntryTranspose w { } set first [expr {$i-2}] set data [$w get] - set new [string index $data [expr {$i-1}]][string index $data $first] + set new [string index $data $i-1][string index $data $first] $w delete $first $i $w insert insert $new EntrySeeInsert $w @@ -660,7 +660,7 @@ proc ::tk::EntryScanMark {w x} { proc ::tk::EntryScanDrag {w x} { # Make sure these exist, as some weird situations can trigger the # motion binding without the initial press. [Bug #220269] - if {![info exists ::tk::Priv(x)]} { set ::tk::Priv(x) $x } + if {![info exists ::tk::Priv(x)]} {set ::tk::Priv(x) $x} # allow for a delta if {abs($x-$::tk::Priv(x)) > 2} { set ::tk::Priv(mouseMoved) 1 @@ -677,19 +677,10 @@ proc ::tk::EntryScanDrag {w x} { proc ::tk::EntryGetSelection {w} { set entryString [string range [$w get] [$w index sel.first] \ - [expr {[$w index sel.last] - 1}]] + [$w index sel.last]-1] if {[$w cget -show] ne ""} { return [string repeat [string index [$w cget -show] 0] \ [string length $entryString]] } return $entryString } - - - - - - - - - diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 5395acb..3e2b6df 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -14,11 +14,11 @@ namespace eval ::tk::fontchooser { set S(W) .__tk__fontchooser set S(fonts) [lsort -dictionary [font families]] set S(styles) [list \ - [::msgcat::mc "Regular"] \ - [::msgcat::mc "Italic"] \ - [::msgcat::mc "Bold"] \ - [::msgcat::mc "Bold Italic"] \ - ] + [::msgcat::mc "Regular"] \ + [::msgcat::mc "Italic"] \ + [::msgcat::mc "Bold"] \ + [::msgcat::mc "Bold Italic"] \ + ] set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72} set S(strike) 0 @@ -36,9 +36,9 @@ proc ::tk::fontchooser::Setup {} { # Canonical versions of font families, styles, etc. for easier searching set S(fonts,lcase) {} - foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font]} + foreach font $S(fonts) {lappend S(fonts,lcase) [string tolower $font]} set S(styles,lcase) {} - foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style]} + foreach style $S(styles) {lappend S(styles,lcase) [string tolower $style]} set S(sizes,lcase) $S(sizes) ::ttk::style layout FontchooserFrame { @@ -145,10 +145,13 @@ proc ::tk::fontchooser::Create {} { wm title $S(W) $S(-title) wm transient $S(W) [winfo toplevel $S(-parent)] + set scaling [tk scaling] + set sizeWidth [expr {int([string length [::msgcat::mc "&Size:"]] * $scaling)}] + set outer [::ttk::frame $S(W).outer -padding {10 10}] ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"] ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"] - ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] + ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth ttk::entry $S(W).efont -width 18 \ -textvariable [namespace which -variable S](font) ttk::entry $S(W).estyle -width 10 \ @@ -199,7 +202,7 @@ proc ::tk::fontchooser::Create {} { set minsize(sizes) \ [expr {[font measure TkDefaultFont "-99"] + $scroll_width}] set min [expr {$minsize(gap) * 4}] - foreach {what width} [array get minsize] { incr min $width } + foreach {what width} [array get minsize] {incr min $width} wm minsize $S(W) $min 260 bind $S(W) <Return> [namespace code [list Done 1]] @@ -277,7 +280,7 @@ proc ::tk::fontchooser::Create {} { # Arguments: # ok true if user pressed OK # -proc ::tk::::fontchooser::Done {ok} { +proc ::tk::fontchooser::Done {ok} { variable S if {! $ok} { @@ -327,13 +330,13 @@ proc ::tk::fontchooser::Init {{defaultFont ""}} { set S(size) $F(-size) set S(strike) $F(-overstrike) set S(under) $F(-underline) - set S(style) "Regular" + set S(style) [::msgcat::mc "Regular"] if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} { - set S(style) "Bold Italic" + set S(style) [::msgcat::mc "Bold Italic"] } elseif {$F(-weight) eq "bold"} { - set S(style) "Bold" + set S(style) [::msgcat::mc "Bold"] } elseif {$F(-slant) eq "italic"} { - set S(style) "Italic" + set S(style) [::msgcat::mc "Italic"] } set S(first) 0 @@ -396,7 +399,7 @@ proc ::tk::fontchooser::Tracer {var1 var2 op} { } $S(W).l${var}s see $n } - if {!$bad} { Update } + if {!$bad} {Update} $S(W).ok configure -state $nstate } @@ -408,11 +411,11 @@ proc ::tk::fontchooser::Update {} { variable S set S(result) [list $S(font) $S(size)] - if {$S(style) eq "Bold"} { lappend S(result) bold } - if {$S(style) eq "Italic"} { lappend S(result) italic } - if {$S(style) eq "Bold Italic"} { lappend S(result) bold italic} - if {$S(strike)} { lappend S(result) overstrike} - if {$S(under)} { lappend S(result) underline} + if {$S(style) eq [::msgcat::mc "Bold"]} {lappend S(result) bold} + if {$S(style) eq [::msgcat::mc "Italic"]} {lappend S(result) italic} + if {$S(style) eq [::msgcat::mc "Bold Italic"]} {lappend S(result) bold italic} + if {$S(strike)} {lappend S(result) overstrike} + if {$S(under)} {lappend S(result) underline} $S(sample) configure -font $S(result) } diff --git a/library/tearoff.tcl b/library/tearoff.tcl index c2d2d6b..4c8b404 100644 --- a/library/tearoff.tcl +++ b/library/tearoff.tcl @@ -39,7 +39,7 @@ proc ::tk::TearOffMenu {w {x 0} {y 0}} { # Shift by height of tearoff entry minus height of window titlebar catch {incr y [expr {[$w yposition 1] - 16}]} # Avoid the native menu bar which sits on top of everything. - if {$y < 22} { set y 22 } + if {$y < 22} {set y 22} } } @@ -155,9 +155,9 @@ proc ::tk::MenuDup {src dst type} { while {[set index [string first $src $tags]] != -1} { if {$index > 0} { - append x [string range $tags 0 [expr {$index - 1}]]$dst + append x [string range $tags 0 $index-1]$dst } - set tags [string range $tags [expr {$index + $srcLen}] end] + set tags [string range $tags $index+$srcLen end] } append x $tags @@ -172,10 +172,10 @@ proc ::tk::MenuDup {src dst type} { while {[set index [string first $event $script]] != -1} { if {$index > 0} { - append x [string range $script 0 [expr {$index - 1}]] + append x [string range $script 0 $index-1] } append x $dst - set script [string range $script [expr {$index + $eventLen}] end] + set script [string range $script $index+$eventLen end] } append x $script |