diff options
Diffstat (limited to 'library/demos')
-rw-r--r-- | library/demos/combo.tcl | 1 | ||||
-rw-r--r-- | library/demos/ctext.tcl | 61 | ||||
-rw-r--r-- | library/demos/en.msg | 2 | ||||
-rw-r--r-- | library/demos/filebox.tcl | 15 | ||||
-rw-r--r-- | library/demos/fontchoose.tcl | 69 | ||||
-rw-r--r-- | library/demos/image2.tcl | 2 | ||||
-rw-r--r-- | library/demos/images/face.xbm | 173 | ||||
-rw-r--r-- | library/demos/images/ouster.png | bin | 0 -> 54257 bytes | |||
-rw-r--r-- | library/demos/items.tcl | 25 | ||||
-rw-r--r-- | library/demos/knightstour.tcl | 29 | ||||
-rw-r--r-- | library/demos/label.tcl | 11 | ||||
-rw-r--r-- | library/demos/mclist.tcl | 47 | ||||
-rw-r--r-- | library/demos/msgbox.tcl | 1 | ||||
-rw-r--r-- | library/demos/nl.msg | 2 | ||||
-rw-r--r-- | library/demos/pendulum.tcl | 6 | ||||
-rw-r--r-- | library/demos/text.tcl | 27 | ||||
-rw-r--r-- | library/demos/toolbar.tcl | 7 | ||||
-rw-r--r-- | library/demos/tree.tcl | 10 | ||||
-rw-r--r-- | library/demos/ttkbut.tcl | 1 | ||||
-rw-r--r-- | library/demos/ttkmenu.tcl | 1 | ||||
-rw-r--r-- | library/demos/ttknote.tcl | 7 | ||||
-rw-r--r-- | library/demos/ttkpane.tcl | 11 | ||||
-rw-r--r-- | library/demos/ttkprogress.tcl | 1 | ||||
-rw-r--r-- | library/demos/twind.tcl | 2 | ||||
-rw-r--r-- | library/demos/unicodeout.tcl | 103 | ||||
-rw-r--r-- | library/demos/widget | 25 |
26 files changed, 315 insertions, 324 deletions
diff --git a/library/demos/combo.tcl b/library/demos/combo.tcl index 5dad9f0..8631904 100644 --- a/library/demos/combo.tcl +++ b/library/demos/combo.tcl @@ -7,7 +7,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .combo catch {destroy $w} diff --git a/library/demos/ctext.tcl b/library/demos/ctext.tcl index e894bc2..4b8c644 100644 --- a/library/demos/ctext.tcl +++ b/library/demos/ctext.tcl @@ -17,7 +17,7 @@ wm iconname $w "Text" positionWindow $w set c $w.c -label $w.msg -font $font -wraplength 5i -justify left -text "This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification. The text also supports the following simple bindings for editing: +label $w.msg -font $font -wraplength 5i -justify left -text "This window displays a string of text to demonstrate the text facilities of canvas widgets. You can click in the boxes to adjust the position of the text relative to its positioning point or change its justification, and on a pie slice to change its angle. The text also supports the following simple bindings for editing: 1. You can point, click, and type. 2. You can also select with button 1. 3. You can copy the selection to the mouse position with button 2. @@ -50,36 +50,63 @@ $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 <2> "textPaste $c @%x,%y" # Next, create some items that allow the text's anchor position # to be edited. -proc mkTextConfig {w x y option value color} { +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 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 addtag config withtag $item +} set x 50 set y 50 set color LightSkyBlue1 -mkTextConfig $c $x $y -anchor se $color -mkTextConfig $c [expr {$x+30}] [expr {$y }] -anchor s $color -mkTextConfig $c [expr {$x+60}] [expr {$y }] -anchor sw $color -mkTextConfig $c [expr {$x }] [expr {$y+30}] -anchor e $color -mkTextConfig $c [expr {$x+30}] [expr {$y+30}] -anchor center $color -mkTextConfig $c [expr {$x+60}] [expr {$y+30}] -anchor w $color -mkTextConfig $c [expr {$x }] [expr {$y+60}] -anchor ne $color -mkTextConfig $c [expr {$x+30}] [expr {$y+60}] -anchor n $color -mkTextConfig $c [expr {$x+60}] [expr {$y+60}] -anchor nw $color +mkTextConfigBox $c $x $y -anchor se $color +mkTextConfigBox $c [expr {$x+30}] [expr {$y }] -anchor s $color +mkTextConfigBox $c [expr {$x+60}] [expr {$y }] -anchor sw $color +mkTextConfigBox $c [expr {$x }] [expr {$y+30}] -anchor e $color +mkTextConfigBox $c [expr {$x+30}] [expr {$y+30}] -anchor center $color +mkTextConfigBox $c [expr {$x+60}] [expr {$y+30}] -anchor w $color +mkTextConfigBox $c [expr {$x }] [expr {$y+60}] -anchor ne $color +mkTextConfigBox $c [expr {$x+30}] [expr {$y+60}] -anchor n $color +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 create text [expr {$x+45}] [expr {$y-5}] \ - -text {Text Position} -anchor s -font {Times 24} -fill brown + -text {Text Position} -anchor s -font {Times 20} -fill brown + +# Now create some items that allow the text's angle to be changed. + +set x 205 +set y 50 +set color Yellow +mkTextConfigPie $c $x $y 0 -angle 90 $color +mkTextConfigPie $c $x $y 30 -angle 120 $color +mkTextConfigPie $c $x $y 60 -angle 150 $color +mkTextConfigPie $c $x $y 90 -angle 180 $color +mkTextConfigPie $c $x $y 120 -angle 210 $color +mkTextConfigPie $c $x $y 150 -angle 240 $color +mkTextConfigPie $c $x $y 180 -angle 270 $color +mkTextConfigPie $c $x $y 210 -angle 300 $color +mkTextConfigPie $c $x $y 240 -angle 330 $color +mkTextConfigPie $c $x $y 270 -angle 0 $color +mkTextConfigPie $c $x $y 300 -angle 30 $color +mkTextConfigPie $c $x $y 330 -angle 60 $color +$c create text [expr {$x+45}] [expr {$y-5}] \ + -text {Text Angle} -anchor s -font {Times 20} -fill brown # Lastly, create some items that allow the text's justification to be # changed. @@ -87,11 +114,11 @@ $c create text [expr {$x+45}] [expr {$y-5}] \ set x 350 set y 50 set color SeaGreen2 -mkTextConfig $c $x $y -justify left $color -mkTextConfig $c [expr {$x+30}] $y -justify center $color -mkTextConfig $c [expr {$x+60}] $y -justify right $color +mkTextConfigBox $c $x $y -justify left $color +mkTextConfigBox $c [expr {$x+30}] $y -justify center $color +mkTextConfigBox $c [expr {$x+60}] $y -justify right $color $c create text [expr {$x+45}] [expr {$y-5}] \ - -text {Justification} -anchor s -font {Times 24} -fill brown + -text {Justification} -anchor s -font {Times 20} -fill brown $c bind config <Enter> "textEnter $c" $c bind config <Leave> "$c itemconf current -fill \$textConfigFill" diff --git a/library/demos/en.msg b/library/demos/en.msg index d4783fe..e364c81 100644 --- a/library/demos/en.msg +++ b/library/demos/en.msg @@ -18,7 +18,7 @@ ::msgcat::mcset en "Demo code: %s" ::msgcat::mcset en "About Widget Demo" ::msgcat::mcset en "Tk widget demonstration application" -::msgcat::mcset en "Copyright (c) %s" "Copyright \u00a9 %s" +::msgcat::mcset en "Copyright \u00a9 %s" ::msgcat::mcset en " @@title Tk Widget Demonstrations diff --git a/library/demos/filebox.tcl b/library/demos/filebox.tcl index 032e3d8..e06ebba 100644 --- a/library/demos/filebox.tcl +++ b/library/demos/filebox.tcl @@ -15,7 +15,10 @@ wm title $w "File Selection Dialogs" wm iconname $w "filebox" positionWindow $w -label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog." +ttk::frame $w._bg +place $w._bg -x 0 -y 0 -relwidth 1 -relheight 1 + +ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Enter a file name in the entry box or click on the \"Browse\" buttons to select a file name using the file selection dialog." pack $w.msg -side top ## See Code / Dismiss buttons @@ -23,10 +26,10 @@ set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x foreach i {open save} { - set f [frame $w.$i] - label $f.lab -text "Select a file to $i: " -anchor e - entry $f.ent -width 20 - button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i" + set f [ttk::frame $w.$i] + ttk::label $f.lab -text "Select a file to $i: " -anchor e + ttk::entry $f.ent -width 20 + ttk::button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $i" pack $f.lab -side left pack $f.ent -side left -expand yes -fill x pack $f.but -side left @@ -34,7 +37,7 @@ foreach i {open save} { } if {[tk windowingsystem] eq "x11"} { - checkbutton $w.strict -text "Use Motif Style Dialog" \ + ttk::checkbutton $w.strict -text "Use Motif Style Dialog" \ -variable tk_strictMotif -onvalue 1 -offvalue 0 pack $w.strict -anchor c diff --git a/library/demos/fontchoose.tcl b/library/demos/fontchoose.tcl new file mode 100644 index 0000000..def30c3 --- /dev/null +++ b/library/demos/fontchoose.tcl @@ -0,0 +1,69 @@ +# fontchoose.tcl -- +# +# Show off the stock font selector dialog + +if {![info exists widgetDemo]} { + error "This script should be run from the \"widget\" demo." +} + +package require Tk + +set w .fontchoose +catch {destroy $w} +toplevel $w +wm title $w "Font Selection Dialog" +wm iconname $w "fontchooser" +positionWindow $w + +catch {font create FontchooseDemoFont {*}[font actual TkDefaultFont]} + +# The font chooser needs to be configured and then shown. +proc SelectFont {parent} { + tk fontchooser configure -font FontchooseDemoFont \ + -command ApplyFont -parent $parent + tk fontchooser show +} + +proc ApplyFont {font} { + font configure FontchooseDemoFont {*}[font actual $font] +} + +# When the visibility of the fontchooser changes, the following event is fired +# to the parent widget. +# +bind $w <<TkFontchooserVisibility>> { + if {[tk fontchooser configure -visible]} { + %W.f.font state disabled + } else { + %W.f.font state !disabled + } +} + + +set f [ttk::frame $w.f -relief sunken -padding 2] + +text $f.msg -font FontchooseDemoFont -width 40 -height 6 -borderwidth 0 \ + -yscrollcommand [list $f.vs set] +ttk::scrollbar $f.vs -command [list $f.msg yview] + +$f.msg insert end "Press the buttons below to choose a new font for the\ + text shown in this window.\n" {} + +ttk::button $f.font -text "Set font ..." -command [list SelectFont $w] + +grid $f.msg $f.vs -sticky news +grid $f.font - -sticky e +grid columnconfigure $f 0 -weight 1 +grid rowconfigure $f 0 -weight 1 +bind $w <Visibility> { + bind %W <Visibility> {} + grid propagate %W.f 0 +} + +## See Code / Dismiss buttons +set btns [addSeeDismiss $w.buttons $w] + +grid $f -sticky news +grid $btns -sticky ew +grid columnconfigure $w 0 -weight 1 +grid rowconfigure $w 0 -weight 1 diff --git a/library/demos/image2.tcl b/library/demos/image2.tcl index 7b3d748..a17da31 100644 --- a/library/demos/image2.tcl +++ b/library/demos/image2.tcl @@ -36,7 +36,7 @@ proc loadDir w { proc selectAndLoadDir w { global dirName set dir [tk_chooseDirectory -initialdir $dirName -parent $w -mustexist 1] - if {[string length $dir] != 0} { + if {$dir ne ""} { set dirName $dir loadDir $w } diff --git a/library/demos/images/face.xbm b/library/demos/images/face.xbm deleted file mode 100644 index 03d829f..0000000 --- a/library/demos/images/face.xbm +++ /dev/null @@ -1,173 +0,0 @@ -#define face_width 108 -#define face_height 144 -#define face_x_hot 48 -#define face_y_hot 80 -static char face_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x09, - 0x20, 0x80, 0x24, 0x05, 0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x00, 0x88, - 0x24, 0x20, 0x80, 0x24, 0x00, 0x00, 0x00, 0x10, 0x80, 0x04, 0x00, 0x01, - 0x00, 0x01, 0x40, 0x0a, 0x09, 0x00, 0x92, 0x04, 0x80, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x40, 0x12, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x84, - 0x24, 0x40, 0x22, 0xa8, 0x02, 0x14, 0x84, 0x92, 0x40, 0x42, 0x12, 0x04, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, 0x52, 0x11, 0x00, 0x12, 0x00, - 0x40, 0x02, 0x00, 0x20, 0x00, 0x08, 0x00, 0xaa, 0x02, 0x54, 0x85, 0x24, - 0x00, 0x10, 0x12, 0x00, 0x00, 0x81, 0x44, 0x00, 0x90, 0x5a, 0x00, 0xea, - 0x1b, 0x00, 0x80, 0x40, 0x40, 0x02, 0x00, 0x08, 0x00, 0x20, 0xa2, 0x05, - 0x8a, 0xb4, 0x6e, 0x45, 0x12, 0x04, 0x08, 0x00, 0x00, 0x00, 0x10, 0x02, - 0xa8, 0x92, 0x00, 0xda, 0x5f, 0x10, 0x00, 0x10, 0xa1, 0x04, 0x20, 0x41, - 0x02, 0x00, 0x5a, 0x25, 0xa0, 0xff, 0xfb, 0x05, 0x41, 0x02, 0x04, 0x00, - 0x00, 0x08, 0x40, 0x80, 0xec, 0x9b, 0xec, 0xfe, 0x7f, 0x01, 0x04, 0x20, - 0x90, 0x02, 0x04, 0x00, 0x08, 0x20, 0xfb, 0x2e, 0xf5, 0xff, 0xff, 0x57, - 0x00, 0x04, 0x02, 0x00, 0x00, 0x20, 0x01, 0xc1, 0x6e, 0xab, 0xfa, 0xff, - 0xff, 0x05, 0x90, 0x20, 0x48, 0x02, 0x00, 0x04, 0x20, 0xa8, 0xdf, 0xb5, - 0xfe, 0xff, 0xff, 0x0b, 0x01, 0x00, 0x01, 0x00, 0x80, 0x80, 0x04, 0xe0, - 0xbb, 0xef, 0xff, 0xff, 0x7f, 0x01, 0x00, 0x04, 0x48, 0x02, 0x00, 0x20, - 0x80, 0xf4, 0x6f, 0xfb, 0xff, 0xff, 0xff, 0x20, 0x90, 0x40, 0x02, 0x00, - 0x00, 0x04, 0x08, 0xb8, 0xf6, 0xff, 0xff, 0xdf, 0xbe, 0x12, 0x45, 0x10, - 0x90, 0x04, 0x90, 0x00, 0x22, 0xfa, 0xff, 0xff, 0xff, 0xbb, 0xd7, 0xe9, - 0x3a, 0x02, 0x02, 0x00, 0x04, 0x90, 0x80, 0xfe, 0xdf, 0xf6, 0xb7, 0xef, - 0xbe, 0x56, 0x57, 0x40, 0x48, 0x09, 0x00, 0x04, 0x00, 0xfa, 0xf5, 0xdf, - 0xed, 0x5a, 0xd5, 0xea, 0xbd, 0x09, 0x00, 0x00, 0x40, 0x00, 0x92, 0xfe, - 0xbf, 0x7d, 0xb7, 0x6a, 0x55, 0xbf, 0xf7, 0x02, 0x11, 0x01, 0x00, 0x91, - 0x00, 0xff, 0xff, 0xaf, 0x55, 0x55, 0x5b, 0xeb, 0xef, 0x22, 0x04, 0x04, - 0x04, 0x00, 0xa4, 0xff, 0xf7, 0xad, 0xaa, 0xaa, 0xaa, 0xbe, 0xfe, 0x03, - 0x20, 0x00, 0x10, 0x44, 0x80, 0xff, 0x7f, 0x55, 0x12, 0x91, 0x2a, 0xeb, - 0xbf, 0x0b, 0x82, 0x02, 0x00, 0x00, 0xd1, 0x7f, 0xdf, 0xa2, 0xa4, 0x54, - 0x55, 0xfd, 0xfd, 0x47, 0x08, 0x08, 0x00, 0x21, 0xe4, 0xff, 0x37, 0x11, - 0x09, 0xa5, 0xaa, 0xb6, 0xff, 0x0d, 0x80, 0x00, 0x00, 0x04, 0xd0, 0xff, - 0x4f, 0x44, 0x20, 0x48, 0x55, 0xfb, 0xff, 0x27, 0x11, 0x02, 0x40, 0x40, - 0xe2, 0xfb, 0x15, 0x11, 0x4a, 0x55, 0x4a, 0x7d, 0xf7, 0x0f, 0x00, 0x00, - 0x04, 0x08, 0xf8, 0xdf, 0x52, 0x44, 0x01, 0x52, 0xb5, 0xfa, 0xff, 0x0f, - 0x49, 0x02, 0x00, 0x02, 0xe9, 0xf6, 0x0a, 0x11, 0xa4, 0x88, 0x4a, 0x6d, - 0xff, 0x5f, 0x00, 0x00, 0x10, 0x20, 0xf0, 0x2f, 0x21, 0x44, 0x10, 0x52, - 0xb5, 0xfa, 0xff, 0x0f, 0x44, 0x04, 0x80, 0x08, 0xf8, 0xab, 0x8a, 0x00, - 0x81, 0xa4, 0xd4, 0xd6, 0xfe, 0x2f, 0x00, 0x00, 0x04, 0x40, 0xb5, 0x2d, - 0x21, 0x08, 0x04, 0x90, 0xaa, 0xfa, 0xff, 0x1f, 0x11, 0x01, 0x00, 0x04, - 0xf0, 0x57, 0x0a, 0x22, 0x40, 0x4a, 0xda, 0x5e, 0xfb, 0x1f, 0x40, 0x00, - 0x40, 0x20, 0xba, 0x95, 0x90, 0x00, 0x01, 0xa0, 0xaa, 0xea, 0xff, 0x5f, - 0x02, 0x02, 0x00, 0x01, 0xe8, 0x57, 0x05, 0x00, 0x00, 0x12, 0xd5, 0xfe, - 0xfd, 0x1f, 0x48, 0x00, 0x04, 0x48, 0x7a, 0x95, 0x08, 0x02, 0x10, 0x40, - 0xaa, 0x55, 0xf7, 0x1f, 0x00, 0x09, 0x20, 0x00, 0xf8, 0x57, 0x22, 0x10, - 0x00, 0x28, 0xa9, 0xfa, 0xff, 0x5f, 0x02, 0x00, 0x00, 0x49, 0xdd, 0x29, - 0x01, 0x00, 0x80, 0x80, 0xaa, 0xd7, 0xff, 0x0f, 0x10, 0x00, 0x08, 0x00, - 0xf8, 0x96, 0x08, 0x00, 0x00, 0x20, 0x54, 0xfa, 0xee, 0x3f, 0x81, 0x04, - 0x40, 0x24, 0xfe, 0x55, 0x82, 0x00, 0x00, 0x82, 0xd2, 0xad, 0xff, 0x0f, - 0x08, 0x00, 0x04, 0x80, 0x6c, 0x97, 0x00, 0x00, 0x02, 0x20, 0xa9, 0xf6, - 0xdf, 0x5f, 0x00, 0x02, 0x20, 0x09, 0xfa, 0x49, 0x12, 0x00, 0x20, 0x84, - 0x54, 0xdb, 0xfe, 0x1f, 0x91, 0x00, 0x00, 0x00, 0xf8, 0x2b, 0x00, 0x20, - 0x00, 0x40, 0xa4, 0xf6, 0xbb, 0x1f, 0x04, 0x00, 0x44, 0x92, 0x7e, 0x95, - 0x02, 0x00, 0x00, 0x89, 0xaa, 0xdd, 0xff, 0x1f, 0x20, 0x09, 0x10, 0x00, - 0xf4, 0x57, 0x20, 0x01, 0x08, 0x20, 0xa9, 0x76, 0xff, 0x5f, 0x02, 0x00, - 0x00, 0x21, 0xfc, 0x4a, 0x05, 0x00, 0x01, 0x80, 0x54, 0xdb, 0xff, 0x1e, - 0x08, 0x02, 0x04, 0x08, 0xf9, 0x2b, 0x00, 0x00, 0x40, 0x28, 0xd2, 0xf6, - 0xff, 0xbf, 0x80, 0x00, 0x90, 0x00, 0xbc, 0x92, 0x08, 0x10, 0x00, 0x82, - 0x54, 0xdb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x44, 0xf9, 0x55, 0x02, 0x01, - 0x00, 0x20, 0xaa, 0xbd, 0xfd, 0x3f, 0x08, 0x04, 0x04, 0x10, 0xf4, 0x2a, - 0x01, 0x00, 0x22, 0x80, 0xd4, 0xf6, 0xff, 0x5f, 0x82, 0x00, 0x40, 0x02, - 0xf8, 0x55, 0x20, 0x00, 0x00, 0x50, 0x6a, 0xdf, 0xfe, 0x3f, 0x00, 0x00, - 0x00, 0x48, 0xe9, 0x4a, 0x05, 0x08, 0x00, 0xa5, 0xd5, 0xf5, 0xff, 0x3f, - 0x10, 0x01, 0x10, 0x01, 0xb0, 0xab, 0x92, 0x02, 0x40, 0xf8, 0xbf, 0xde, - 0xfe, 0x5f, 0x02, 0x04, 0x04, 0x48, 0xfa, 0xd4, 0x6f, 0x20, 0x84, 0xef, - 0xff, 0xfb, 0xff, 0x1f, 0x20, 0x00, 0x00, 0x00, 0xe0, 0xed, 0xbf, 0x0b, - 0xa1, 0x7e, 0xff, 0xbf, 0xfd, 0x5f, 0x04, 0x01, 0x20, 0x49, 0xd2, 0xfb, - 0xfe, 0x55, 0xd4, 0xff, 0xff, 0xf6, 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, - 0xc0, 0xaa, 0xfb, 0x2b, 0xa2, 0xfe, 0xff, 0xdf, 0xee, 0x1f, 0x91, 0x00, - 0x82, 0xa4, 0xa4, 0xf5, 0xff, 0x57, 0xd5, 0xff, 0xbf, 0xfd, 0xff, 0x4d, - 0x00, 0x00, 0x20, 0x00, 0x88, 0x5b, 0xff, 0x2f, 0x69, 0xff, 0xff, 0xdb, - 0xfe, 0x1f, 0x24, 0x02, 0x00, 0x49, 0xa2, 0xd6, 0xff, 0x5f, 0xea, 0xff, - 0x7f, 0x7f, 0x7f, 0x0d, 0x00, 0x00, 0x10, 0x00, 0x40, 0xab, 0xf7, 0xbb, - 0xf0, 0xdf, 0xff, 0xd5, 0xff, 0xbf, 0x82, 0x04, 0x42, 0x24, 0x91, 0xd5, - 0xaa, 0xae, 0xd4, 0xaa, 0x52, 0x7b, 0xff, 0x15, 0x08, 0x00, 0x00, 0x01, - 0x04, 0x55, 0xd5, 0x55, 0x70, 0x5b, 0x75, 0xdd, 0xdf, 0x1f, 0x40, 0x00, - 0x08, 0x48, 0xa0, 0x4a, 0xa9, 0x56, 0xea, 0x56, 0xad, 0x6a, 0x7d, 0x9b, - 0x04, 0x01, 0x00, 0x02, 0x42, 0x2a, 0xd5, 0xaa, 0xa8, 0xaa, 0xaa, 0xfa, - 0xdf, 0x2f, 0x10, 0x04, 0x22, 0x48, 0x08, 0x45, 0x2a, 0x15, 0x68, 0x55, - 0x55, 0xd7, 0x76, 0x1b, 0x00, 0x00, 0x00, 0x01, 0x40, 0x2a, 0x80, 0xa0, - 0xb2, 0x09, 0x48, 0xb9, 0xdf, 0x17, 0x22, 0x01, 0x00, 0x24, 0x45, 0x8a, - 0x24, 0x4a, 0x54, 0x51, 0x91, 0xf6, 0x6e, 0x4b, 0x00, 0x04, 0x90, 0x00, - 0x80, 0x52, 0x00, 0x20, 0x69, 0x05, 0xa4, 0xaa, 0xff, 0x1e, 0x48, 0x00, - 0x02, 0x92, 0x08, 0x05, 0x81, 0x94, 0xd4, 0x92, 0x40, 0xfd, 0xb6, 0x8b, - 0x00, 0x01, 0x40, 0x00, 0x82, 0x54, 0x00, 0x48, 0x68, 0x05, 0x90, 0xa4, - 0xef, 0x06, 0x24, 0x00, 0x08, 0x12, 0x10, 0x05, 0x00, 0x10, 0xb5, 0x01, - 0x42, 0xfb, 0xbf, 0x43, 0x00, 0x09, 0x00, 0x40, 0x81, 0xa8, 0x08, 0x4a, - 0xaa, 0x96, 0x90, 0xac, 0x6d, 0x15, 0x22, 0x00, 0x20, 0x09, 0x04, 0x15, - 0x80, 0x28, 0xdc, 0x01, 0x24, 0xfb, 0xbf, 0x01, 0x80, 0x04, 0x09, 0x00, - 0x40, 0x48, 0x02, 0x45, 0xb2, 0x2e, 0x41, 0x6d, 0xef, 0x05, 0x11, 0x00, - 0x40, 0x52, 0x02, 0x15, 0x29, 0x2a, 0xac, 0x42, 0x54, 0xfb, 0x3b, 0x51, - 0x84, 0x00, 0x08, 0x00, 0x20, 0x54, 0x80, 0x05, 0xb5, 0x3d, 0xa2, 0xb6, - 0xdf, 0x00, 0x20, 0x04, 0x20, 0x49, 0x89, 0xa8, 0x6a, 0x29, 0xac, 0xd6, - 0x54, 0xff, 0x3f, 0x84, 0x00, 0x01, 0x04, 0x10, 0x00, 0x94, 0xa8, 0x56, - 0xda, 0x5f, 0xab, 0xd5, 0x1e, 0x10, 0x48, 0x00, 0x90, 0x82, 0x48, 0xa8, - 0xb2, 0xac, 0xfd, 0x55, 0xd5, 0xfe, 0x9f, 0x80, 0x00, 0x0a, 0x02, 0x08, - 0x02, 0x55, 0x5a, 0x75, 0xff, 0xaf, 0xb6, 0xf7, 0x2d, 0x12, 0x92, 0x00, - 0x10, 0x20, 0x10, 0xa8, 0x54, 0xd5, 0xbf, 0x5d, 0xad, 0xdd, 0x0f, 0x00, - 0x00, 0x04, 0x40, 0x09, 0x84, 0xa8, 0xaa, 0x5a, 0xed, 0xeb, 0x6a, 0xff, - 0x9f, 0xa4, 0x24, 0x01, 0x02, 0xa0, 0x20, 0x50, 0x55, 0xd5, 0xbe, 0xae, - 0xad, 0xfd, 0x16, 0x00, 0x10, 0x04, 0x20, 0x0a, 0x08, 0xb4, 0xaa, 0x95, - 0xaa, 0x7b, 0xb7, 0xdb, 0x5f, 0x92, 0x04, 0x01, 0x84, 0x20, 0x21, 0x51, - 0xd5, 0x2a, 0xa9, 0xee, 0xd5, 0xfe, 0x0d, 0x00, 0x20, 0x04, 0x10, 0x00, - 0x08, 0x50, 0xe9, 0xd7, 0xd4, 0xfb, 0xb5, 0xff, 0x9f, 0x24, 0x09, 0x01, - 0x42, 0x4a, 0xa2, 0x64, 0xd5, 0x55, 0x7b, 0x7f, 0xda, 0x7d, 0x4f, 0x00, - 0x20, 0x04, 0x00, 0x80, 0x00, 0xa0, 0x2a, 0x13, 0x84, 0x6a, 0x55, 0xff, - 0x1d, 0x48, 0x8a, 0x00, 0x94, 0x24, 0x8a, 0xc8, 0xaa, 0x42, 0x20, 0x5d, - 0xf5, 0xff, 0x5f, 0x01, 0x00, 0x02, 0x01, 0x00, 0x20, 0xa2, 0x4a, 0x1a, - 0x82, 0x56, 0xda, 0xbd, 0x3f, 0x92, 0x92, 0x00, 0x90, 0x92, 0x00, 0x40, - 0x95, 0x6a, 0xf4, 0x55, 0x6d, 0xff, 0xd6, 0x00, 0x00, 0x0a, 0x04, 0x20, - 0x14, 0x49, 0x4b, 0xaa, 0xaa, 0x56, 0xf5, 0xff, 0xbf, 0xab, 0xa4, 0x00, - 0x20, 0x89, 0x40, 0x80, 0xaa, 0xaa, 0xaa, 0xaa, 0xde, 0xbf, 0xeb, 0x03, - 0x00, 0x02, 0x04, 0x02, 0x0a, 0x10, 0x2b, 0x2a, 0x55, 0x5b, 0xf5, 0xff, - 0xd7, 0x2f, 0x92, 0x00, 0x10, 0x28, 0x21, 0x01, 0x56, 0x95, 0xa0, 0x56, - 0xdf, 0xef, 0xea, 0x87, 0x40, 0x0a, 0x42, 0x41, 0x00, 0x90, 0xaa, 0x52, - 0xb6, 0xad, 0xfa, 0xff, 0xd5, 0x2f, 0x14, 0x00, 0x00, 0x04, 0x95, 0x04, - 0xaa, 0xac, 0x55, 0x6b, 0xff, 0xb7, 0xea, 0x9f, 0x40, 0x02, 0x28, 0x51, - 0x00, 0x40, 0x58, 0xd5, 0xda, 0xd6, 0x6e, 0x7f, 0xf9, 0x3f, 0x12, 0x04, - 0x02, 0x04, 0x49, 0x25, 0x55, 0xaa, 0x77, 0xab, 0xff, 0x2b, 0xfd, 0x3f, - 0x48, 0x01, 0x20, 0x41, 0x00, 0x00, 0x58, 0xa9, 0xda, 0xea, 0xfd, 0xaf, - 0xfa, 0xff, 0x02, 0x04, 0x08, 0x14, 0x29, 0x49, 0x52, 0x55, 0x55, 0x55, - 0xff, 0x8d, 0xfe, 0x3f, 0xa8, 0x00, 0x02, 0x41, 0x00, 0x02, 0xa0, 0xa2, - 0xaa, 0xea, 0xff, 0x53, 0xfd, 0xff, 0x02, 0x04, 0x50, 0x04, 0x25, 0xa8, - 0x54, 0x49, 0x52, 0xb5, 0xbf, 0x8a, 0xfe, 0xff, 0xa9, 0x08, 0x04, 0x50, - 0x80, 0x02, 0xa1, 0x2a, 0x95, 0xea, 0xff, 0xa1, 0xff, 0xff, 0x03, 0x02, - 0x90, 0x02, 0x09, 0x08, 0x44, 0x49, 0x52, 0xbd, 0x7f, 0xca, 0xff, 0xff, - 0x2b, 0x09, 0x04, 0x48, 0x40, 0x82, 0x90, 0x56, 0xa9, 0xf6, 0xbf, 0xd0, - 0xff, 0xff, 0x47, 0x00, 0x50, 0x02, 0x15, 0x11, 0x40, 0x95, 0xaa, 0xfd, - 0x2f, 0xe9, 0xff, 0xff, 0x8f, 0x0a, 0x84, 0x50, 0x40, 0x84, 0x14, 0xaa, - 0x6a, 0xff, 0x5f, 0xf2, 0xff, 0xff, 0x7f, 0x00, 0x10, 0x02, 0x09, 0x10, - 0x40, 0x7d, 0xf7, 0xff, 0x0b, 0xfc, 0xff, 0xff, 0xaf, 0x02, 0x84, 0x50, - 0x42, 0x85, 0x12, 0xd0, 0xdd, 0xff, 0xa7, 0xf2, 0xff, 0xff, 0xff, 0x04, - 0x00, 0x0a, 0x08, 0x10, 0x48, 0xf8, 0xff, 0xff, 0x0a, 0xfe, 0xff, 0xff, - 0x7f, 0x03, 0xa4, 0x80, 0xa2, 0x8a, 0x02, 0x68, 0xff, 0xff, 0x52, 0xfd, - 0xff, 0xff, 0xff, 0x07, 0x00, 0x2a, 0x08, 0x20, 0x28, 0xdc, 0xff, 0x5f, - 0x05, 0xff, 0xff, 0xff, 0xff, 0x0d, 0x92, 0x40, 0x22, 0x09, 0x02, 0xea, - 0xfb, 0xaf, 0x48, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x12, 0x81, 0xa0, - 0x48, 0x9c, 0x6e, 0x93, 0xa2, 0xff, 0xff, 0xff, 0xff, 0x07, 0xa8, 0x40, - 0x28, 0x0a, 0x02, 0x74, 0xb5, 0x45, 0x81, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x02, 0x0a, 0x81, 0x20, 0x08, 0xae, 0xaa, 0x90, 0xe8, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x90, 0x40, 0x28, 0x88, 0x12, 0x58, 0x15, 0x50, 0xd0, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x44, 0x0a, 0x41, 0x21, 0x08, 0xae, 0x04, 0x14, - 0xf0, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, 0x14, 0x88, 0x04, 0xba, - 0x02, 0x28, 0xe8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x42, 0x15, 0x41, 0x21, - 0x05, 0xad, 0x00, 0x05, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x40, - 0x24, 0x8a, 0x0e, 0x36, 0x00, 0x0a, 0xf4, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x42, 0x25, 0x90, 0xd0, 0x8b, 0xc2, 0x41, 0x05, 0xfc, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x10, 0x08, 0x05, 0xe8, 0x8e, 0x58, 0x80, 0x02, 0xfa, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x4a, 0x20, 0xa8, 0xba, 0x0b, 0x2b, 0x51, 0x01, - 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x8a, 0x02, 0xe8, 0xaf, 0x84, - 0x90, 0x04, 0xfd, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x52, 0x21, 0x54, 0xbf, - 0x1f, 0x15, 0xa5, 0x02, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x08, - 0x01, 0xfa, 0xb6, 0xa4, 0x52, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x4a, 0xa2, 0x54, 0xef, 0x5f, 0x4b, 0xa4, 0x80, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0x80, 0x10, 0x82, 0xfe, 0xbf, 0x92, 0x52, 0x42, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x12, 0x42, 0xa8, 0xbf, 0x1f, 0x24, 0x80, 0xa0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, 0x8a, 0xf7, 0x37, 0x80, - 0x52, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x10, 0x82, 0xe0, 0xff, - 0x1f, 0x00, 0x20, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x84, 0x28, - 0xca, 0xff, 0x1f, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, - 0x10, 0x42, 0xf0, 0xfd, 0x1b, 0x00, 0x50, 0xf0, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x0f, 0xa4, 0x10, 0xc5, 0xff, 0x1f, 0x00, 0x00, 0xe0, 0xff, 0xff, - 0xff, 0xff, 0xff, 0x0f, 0x00, 0x22, 0xf8, 0xff, 0x0e, 0x00, 0x00, 0xf0, - 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xaa, 0x88, 0xe2, 0xff, 0x0f, 0x10, - 0x00, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x25, 0xfa, 0xff, - 0x0f, 0x01, 0x11, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xfb, - 0xfb, 0xff, 0x7f, 0x5d, 0xd5, 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0f}; diff --git a/library/demos/images/ouster.png b/library/demos/images/ouster.png Binary files differnew file mode 100644 index 0000000..259b8f9 --- /dev/null +++ b/library/demos/images/ouster.png diff --git a/library/demos/items.tcl b/library/demos/items.tcl index 85bf5f3..31a1570 100644 --- a/library/demos/items.tcl +++ b/library/demos/items.tcl @@ -126,8 +126,8 @@ $c create text 25.5c 11c -anchor w -font $font1 -fill $blue \ -text "Several lines,\n each centered\nindividually,\nand all anchored\nat the left edge." \ -justify center -tags item $c create rectangle 24.9c 13.9c 25.1c 14.1c -$c create text 25c 14c -font $font2 -anchor c -fill $red -stipple gray50 \ - -text "Stippled characters" -tags item +$c create text 25c 14c -font $font2 -anchor c -fill $red -angle 15 \ + -text "Angled characters" -tags item $c create text 5c 16.2c -text Arcs -anchor n $c create arc 0.5c 17c 7c 20c -fill $green -outline black \ @@ -140,9 +140,13 @@ $c create arc 0.5c 20c 9.5c 24c -width 4m -style pieslice \ $c create arc 5.5c 20.5c 9.5c 23.5c -width 4m -style chord \ -fill $blue -outline {} -start 45 -extent 270 -tags item -$c create text 15c 16.2c -text Bitmaps -anchor n -$c create bitmap 13c 20c -tags item \ - -bitmap @[file join $tk_demoDirectory images face.xbm] +image create photo items.ousterhout \ + -file [file join $tk_demoDirectory images ouster.png] +image create photo items.ousterhout.active -format "png -alpha 0.5" \ + -file [file join $tk_demoDirectory images ouster.png] +$c create text 15c 16.2c -text "Bitmaps and Images" -anchor n +$c create image 13c 20c -tags item -image items.ousterhout \ + -activeimage items.ousterhout.active $c create bitmap 17c 18.5c -tags item \ -bitmap @[file join $tk_demoDirectory images noletter.xbm] $c create bitmap 17c 21.5c -tags item \ @@ -183,15 +187,18 @@ proc itemEnter {c} { return } set type [$c type current] - if {$type == "window"} { + if {$type == "window" || $type == "image"} { set restoreCmd {} return - } - if {$type == "bitmap"} { + } elseif {$type == "bitmap"} { set bg [lindex [$c itemconf current -background] 4] set restoreCmd [list $c itemconfig current -background $bg] $c itemconfig current -background SteelBlue2 return + } elseif {$type == "image"} { + set restoreCmd [list $c itemconfig current -state normal] + $c itemconfig current -state active + return } set fill [lindex [$c itemconfig current -fill] 4] if {(($type == "rectangle") || ($type == "oval") || ($type == "arc")) @@ -279,6 +286,6 @@ proc itemDrag {c x y} { # is invoked. proc butPress {w color} { - set i [$w create text 25c 18.1c -text "Ouch!!" -fill $color -anchor n] + set i [$w create text 25c 18.1c -text "Oooohhh!!" -fill $color -anchor n] after 500 "$w delete $i" } diff --git a/library/demos/knightstour.tcl b/library/demos/knightstour.tcl index b52e38f..73ca3a3 100644 --- a/library/demos/knightstour.tcl +++ b/library/demos/knightstour.tcl @@ -61,6 +61,8 @@ proc Next {square} { set minimum $count set nextSquare $testSquare } elseif {$count == $minimum} { + # to remove the enhancement to Warnsdorff's rule + # remove the next line: set nextSquare [Edgemost $nextSquare $testSquare] } } @@ -92,7 +94,7 @@ proc MovePiece {dlg last square} { $dlg.f.txt see end $dlg.f.c itemconfigure [expr {1+$last}] -state normal -outline black $dlg.f.c itemconfigure [expr {1+$square}] -state normal -outline red - $dlg.f.c coords knight [lrange [$dlg.f.c coords [expr {1+$square}]] 0 1] + $dlg.f.c moveto knight {*}[lrange [$dlg.f.c coords [expr {1+$square}]] 0 1] lappend visited $square set next [Next $square] if {$next ne -1} { @@ -125,8 +127,8 @@ proc Tour {dlg {square {}}} { $dlg.f.c itemconfigure $n -state disabled -outline black } if {$square eq {}} { - set square [expr {[$dlg.f.c find closest \ - {*}[$dlg.f.c coords knight] 0 65]-1}] + set coords [lrange [$dlg.f.c coords knight] 0 1] + set square [expr {[$dlg.f.c find closest {*}$coords 0 65]-1}] } variable initial $square after idle [list MovePiece $dlg $initial $initial] @@ -161,7 +163,7 @@ proc DragMotion {w x y} { } proc DragEnd {w x y} { set square [$w find closest $x $y 0 65] - $w coords selected [lrange [$w coords $square] 0 1] + $w moveto selected {*}[lrange [$w coords $square] 0 1] $w dtag selected variable dragging ; unset dragging } @@ -201,10 +203,21 @@ proc CreateGUI {} { -width 2 -state disabled } } - catch {eval font create KnightFont -size -24} - $c create text 0 0 -font KnightFont -text "\u265e" \ - -anchor nw -tags knight -fill black -activefill "#600000" - $c coords knight [lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1] + if {[tk windowingsystem] ne "x11"} { + catch {eval font create KnightFont -size -24} + $c create text 0 0 -font KnightFont -text "\u265e" \ + -anchor nw -tags knight -fill black -activefill "#600000" + } else { + # On X11 we cannot reliably tell if the \u265e glyph is available + # so just use a polygon + set pts { + 2 25 24 25 21 19 20 8 14 0 10 0 0 13 0 16 + 2 17 4 14 5 15 3 17 5 17 9 14 10 15 5 21 + } + $c create polygon $pts -tag knight -offset 8 \ + -fill black -activefill "#600000" + } + $c moveto knight {*}[lrange [$c coords [expr {1 + int(rand() * 64)}]] 0 1] $c bind knight <ButtonPress-1> [namespace code [list DragStart %W %x %y]] $c bind knight <Motion> [namespace code [list DragMotion %W %x %y]] $c bind knight <ButtonRelease-1> [namespace code [list DragEnd %W %x %y]] diff --git a/library/demos/label.tcl b/library/demos/label.tcl index a5cab10..13463f7 100644 --- a/library/demos/label.tcl +++ b/library/demos/label.tcl @@ -16,7 +16,7 @@ wm title $w "Label Demonstration" wm iconname $w "label" positionWindow $w -label $w.msg -font $font -wraplength 4i -justify left -text "Five labels are displayed below: three textual ones on the left, and a bitmap label and a text label on the right. Labels are pretty boring because you can't do anything with them." +label $w.msg -font $font -wraplength 4i -justify left -text "Five labels are displayed below: three textual ones on the left, and an image label and a text label on the right. Labels are pretty boring because you can't do anything with them." pack $w.msg -side top ## See Code / Dismiss buttons @@ -33,7 +33,8 @@ label $w.left.l3 -text "Third label, sunken" -relief sunken pack $w.left.l1 $w.left.l2 $w.left.l3 -side top -expand yes -pady 2 -anchor w # Main widget program sets variable tk_demoDirectory -label $w.right.bitmap -borderwidth 2 -relief sunken \ - -bitmap @[file join $tk_demoDirectory images face.xbm] -label $w.right.caption -text "Tcl/Tk Proprietor" -pack $w.right.bitmap $w.right.caption -side top +image create photo label.ousterhout \ + -file [file join $tk_demoDirectory images ouster.png] +label $w.right.picture -borderwidth 2 -relief sunken -image label.ousterhout +label $w.right.caption -text "Tcl/Tk Creator" +pack $w.right.picture $w.right.caption -side top diff --git a/library/demos/mclist.tcl b/library/demos/mclist.tcl index d1d3f47..7a4dd4c 100644 --- a/library/demos/mclist.tcl +++ b/library/demos/mclist.tcl @@ -8,7 +8,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .mclist catch {destroy $w} @@ -27,19 +26,22 @@ pack [addSeeDismiss $w.seeDismiss $w] -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" -if {[tk windowingsystem] ne "aqua"} { - ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview" - ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview" -} else { - scrollbar $w.vsb -orient vertical -command "$w.tree yview" - scrollbar $w.hsb -orient horizontal -command "$w.tree xview" -} +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 grid $w.tree $w.vsb -in $w.container -sticky nsew grid $w.hsb -in $w.container -sticky nsew grid column $w.container 0 -weight 1 grid row $w.container 0 -weight 1 +image create photo upArrow -data { + R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAImhI+ + py+1LIsJHiBAh+BgmiEAJQITgW6DgUQIAECH4JN8IPqYuNxUAOw==} +image create photo downArrow -data { + R0lGODlhDgAOAJEAANnZ2YCAgPz8/P///yH5BAEAAAAALAAAAAAOAA4AAAInhI+ + py+1I4ocQ/IgDEYIPgYJICUCE4F+YIBolEoKPEJKZmVJK6ZACADs=} +image create photo noArrow -height 14 -width 14 + ## The data we're going to insert set data { Argentina {Buenos Aires} ARS @@ -60,11 +62,15 @@ set data { } ## Code to insert the data nicely -set font [ttk::style lookup [$w.tree cget -style] -font] +set font [ttk::style lookup Heading -font] foreach col {country capital currency} name {Country Capital Currency} { - $w.tree heading $col -command [list SortBy $w.tree $col 0] -text $name - $w.tree column $col -width [font measure $font $name] + $w.tree heading $col -text $name -image noArrow -anchor w \ + -command [list SortBy $w.tree $col 0] + $w.tree column $col -width [expr { + [font measure $font $name] + [image width noArrow] + 5 + }] } +set font [ttk::style lookup Treeview -font] foreach {country capital currency} $data { $w.tree insert {} end -values [list $country $capital $currency] foreach col {country capital currency} { @@ -77,6 +83,16 @@ foreach {country capital currency} $data { ## Code to do the sorting of the tree contents when clicked on proc SortBy {tree col direction} { + # Determine currently sorted column and its sort direction + foreach c {country capital currency} { + set s [$tree heading $c state] + if {("selected" in $s || "alternate" in $s) && $col ne $c} { + # Sorted column has changed + $tree heading $c -image noArrow state {!selected !alternate !user1} + set direction [expr {"alternate" in $s}] + } + } + # Build something we can sort set data {} foreach row [$tree children {}] { @@ -92,5 +108,12 @@ proc SortBy {tree col direction} { } # Switch the heading so that it will sort in the opposite direction - $tree heading $col -command [list SortBy $tree $col [expr {!$direction}]] + $tree heading $col -command [list SortBy $tree $col [expr {!$direction}]] \ + state [expr {$direction?"!selected alternate":"selected !alternate"}] + 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"}] + } } diff --git a/library/demos/msgbox.tcl b/library/demos/msgbox.tcl index a8f7d17..bd98bf2 100644 --- a/library/demos/msgbox.tcl +++ b/library/demos/msgbox.tcl @@ -7,7 +7,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .msgbox catch {destroy $w} diff --git a/library/demos/nl.msg b/library/demos/nl.msg index b17ceaa..61832d8 100644 --- a/library/demos/nl.msg +++ b/library/demos/nl.msg @@ -18,7 +18,7 @@ ::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 (c) %s" "Copyright (c) %s" +::msgcat::mcset nl "Copyright \u00a9 %s" ::msgcat::mcset nl "Tk Widget Demonstrations" "Demostratie van Tk widgets" ::msgcat::mcset nl "This application provides a front end for several short scripts" \ diff --git a/library/demos/pendulum.tcl b/library/demos/pendulum.tcl index 2e3d459..d344d8d 100644 --- a/library/demos/pendulum.tcl +++ b/library/demos/pendulum.tcl @@ -49,9 +49,9 @@ for {set i 90} {$i>=0} {incr i -10} { # Coordinates of these items don't matter; they will be set properly below $w.k create line 0 0 1 1 -smooth true -tags graph$i -fill grey$i } -# FIXME: UNICODE labels -$w.k create text 0 0 -anchor ne -text "q" -font {Symbol 8} -tags label_theta -$w.k create text 0 0 -anchor ne -text "dq" -font {Symbol 8} -tags label_dtheta + +$w.k create text 0 0 -anchor ne -text "\u03b8" -tags label_theta +$w.k create text 0 0 -anchor ne -text "\u03b4\u03b8" -tags label_dtheta pack $w.k -in $w.p.l2 -fill both -expand true # Initialize some variables diff --git a/library/demos/text.tcl b/library/demos/text.tcl index 1b5f3b9..785e9e6 100644 --- a/library/demos/text.tcl +++ b/library/demos/text.tcl @@ -17,7 +17,8 @@ wm iconname $w "text" positionWindow $w ## See Code / Dismiss buttons -set btns [addSeeDismiss $w.buttons $w] +set btns [addSeeDismiss $w.buttons $w {} \ + {ttk::button $w.buttons.fontchooser -command fontchooserToggle}] pack $btns -side bottom -fill x text $w.text -yscrollcommand [list $w.scroll set] -setgrid 1 \ @@ -25,6 +26,30 @@ text $w.text -yscrollcommand [list $w.scroll set] -setgrid 1 \ scrollbar $w.scroll -command [list $w.text yview] pack $w.scroll -side right -fill y pack $w.text -expand yes -fill both + +# TIP 324 Demo: [tk fontchooser] +proc fontchooserToggle {} { + tk fontchooser [expr {[tk fontchooser configure -visible] ? + "hide" : "show"}] +} +proc fontchooserVisibility {w} { + $w configure -text [expr {[tk fontchooser configure -visible] ? + "Hide Font Dialog" : "Show Font Dialog"}] +} +proc fontchooserFocus {w} { + tk fontchooser configure -font [$w cget -font] \ + -command [list fontchooserFontSel $w] +} +proc fontchooserFontSel {w font args} { + $w configure -font [font actual $font] +} +tk fontchooser configure -parent $w +bind $w.text <FocusIn> [list fontchooserFocus $w.text] +fontchooserVisibility $w.buttons.fontchooser +bind $w <<TkFontchooserVisibility>> [list \ + fontchooserVisibility $w.buttons.fontchooser] +focus $w.text + $w.text insert 0.0 \ {This window is a text widget. It displays one or more lines of text and allows you to edit the text. Here is a summary of the things you diff --git a/library/demos/toolbar.tcl b/library/demos/toolbar.tcl index 541e8ba..e7c87e2 100644 --- a/library/demos/toolbar.tcl +++ b/library/demos/toolbar.tcl @@ -7,7 +7,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .toolbar destroy $w @@ -16,7 +15,7 @@ wm title $w "Toolbar Demonstration" wm iconname $w "toolbar" positionWindow $w -if {[tk windowingsystem] ne "aqua"} { +if {[tk windowingsystem] ne {}} { ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\ a toolbar that is styled correctly and which can be torn off. The\ buttons are configured to be \u201Ctoolbar style\u201D buttons by\ @@ -37,7 +36,7 @@ ttk::label $w.msg -wraplength 4i -text "This is a demonstration of how to do\ set t [frame $w.toolbar] ;# Must be a frame! ttk::separator $w.sep ttk::frame $t.tearoff -cursor fleur -if {[tk windowingsystem] ne "aqua"} { +if {[tk windowingsystem] ne {}} { ttk::separator $t.tearoff.to -orient vertical ttk::separator $t.tearoff.to2 -orient vertical pack $t.tearoff.to -fill y -expand 1 -padx 2 -side left @@ -48,7 +47,7 @@ grid $t.tearoff $t.contents -sticky nsew grid columnconfigure $t $t.contents -weight 1 grid columnconfigure $t.contents 1000 -weight 1 -if {[tk windowingsystem] ne "aqua"} { +if {[tk windowingsystem] ne {}} { ## Bindings so that the toolbar can be torn off and reattached bind $t.tearoff <B1-Motion> [list tearoff $t %X %Y] bind $t.tearoff.to <B1-Motion> [list tearoff $t %X %Y] diff --git a/library/demos/tree.tcl b/library/demos/tree.tcl index 14d5db8..71c32c1 100644 --- a/library/demos/tree.tcl +++ b/library/demos/tree.tcl @@ -8,7 +8,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .tree catch {destroy $w} @@ -72,13 +71,8 @@ proc populateTree {tree node} { ## Create the tree and set it up ttk::treeview $w.tree -columns {fullpath type size} -displaycolumns {size} \ -yscroll "$w.vsb set" -xscroll "$w.hsb set" -if {[tk windowingsystem] ne "aqua"} { - ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview" - ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview" -} else { - scrollbar $w.vsb -orient vertical -command "$w.tree yview" - scrollbar $w.hsb -orient horizontal -command "$w.tree xview" -} +ttk::scrollbar $w.vsb -orient vertical -command "$w.tree yview" +ttk::scrollbar $w.hsb -orient horizontal -command "$w.tree xview" $w.tree heading \#0 -text "Directory Structure" $w.tree heading size -text "File Size" $w.tree column size -stretch 0 -width 70 diff --git a/library/demos/ttkbut.tcl b/library/demos/ttkbut.tcl index 66ff1d7..904cd31 100644 --- a/library/demos/ttkbut.tcl +++ b/library/demos/ttkbut.tcl @@ -9,7 +9,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .ttkbut catch {destroy $w} diff --git a/library/demos/ttkmenu.tcl b/library/demos/ttkmenu.tcl index c01c9af..0084dd6 100644 --- a/library/demos/ttkmenu.tcl +++ b/library/demos/ttkmenu.tcl @@ -8,7 +8,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .ttkmenu catch {destroy $w} diff --git a/library/demos/ttknote.tcl b/library/demos/ttknote.tcl index 5683892..50a9258 100644 --- a/library/demos/ttknote.tcl +++ b/library/demos/ttknote.tcl @@ -8,7 +8,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .ttknote catch {destroy $w} @@ -53,10 +52,6 @@ ttk::frame $w.note.editor $w.note add $w.note.editor -text "Text Editor" -underline 0 text $w.note.editor.t -width 40 -height 10 -wrap char \ -yscroll "$w.note.editor.s set" -if {[tk windowingsystem] ne "aqua"} { - ttk::scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview" -} else { - scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview" -} +ttk::scrollbar $w.note.editor.s -orient vertical -command "$w.note.editor.t yview" pack $w.note.editor.s -side right -fill y -padx {0 2} -pady 2 pack $w.note.editor.t -fill both -expand 1 -pady 2 -padx {2 0} diff --git a/library/demos/ttkpane.tcl b/library/demos/ttkpane.tcl index a4d5738..7575d76 100644 --- a/library/demos/ttkpane.tcl +++ b/library/demos/ttkpane.tcl @@ -7,7 +7,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .ttkpane catch {destroy $w} @@ -51,7 +50,7 @@ proc every {delay script} { uplevel #0 $script after $delay [list every $delay $script] } -set zones { +set testzones { :Europe/Berlin :America/Argentina/Buenos_Aires :Africa/Johannesburg @@ -65,7 +64,13 @@ set zones { } # Force a pre-load of all the timezones needed; otherwise can end up # poor-looking synch problems! -foreach zone $zones {clock format 0 -timezone $zone} +set zones {} +foreach zone $testzones { + if {![catch {clock format 0 -timezone $zone}]} { + lappend zones $zone + } +} +if {[llength $zones] < 2} { lappend zones -0200 :GMT :UTC +0200 } foreach zone $zones { set city [string map {_ " "} [regexp -inline {[^/]+$} $zone]] if {$i} { diff --git a/library/demos/ttkprogress.tcl b/library/demos/ttkprogress.tcl index 87765d7..8a72cf9 100644 --- a/library/demos/ttkprogress.tcl +++ b/library/demos/ttkprogress.tcl @@ -7,7 +7,6 @@ if {![info exists widgetDemo]} { } package require Tk -package require Ttk set w .ttkprogress catch {destroy $w} diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl index e1d0b5b..8f3c12e 100644 --- a/library/demos/twind.tcl +++ b/library/demos/twind.tcl @@ -162,7 +162,7 @@ $t window create end -window $t.smallP $t insert end "\n\nFinally, images fit comfortably in text widgets too:" $t image create end -image \ - [image create bitmap -file [file join $tk_demoDirectory images face.xbm]] + [image create photo -file [file join $tk_demoDirectory images ouster.png]] proc textWindBigB w { diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl index 11cc933..faa9f90 100644 --- a/library/demos/unicodeout.tcl +++ b/library/demos/unicodeout.tcl @@ -9,26 +9,6 @@ if {![info exists widgetDemo]} { package require Tk -# On Windows, we need to determine whether the font system will render -# right-to-left text. - -if {[tk windowingsystem] eq {win32}} { - set rkey [join { - HKEY_LOCAL_MACHINE - SOFTWARE - Microsoft - {Windows NT} - CurrentVersion - LanguagePack - } \\] - set w32langs {} - if {![catch {package require registry}]} { - if {[catch {registry values $rkey} w32langs]} { - set w32langs {} - } - } -} - set w .unicodeout catch {destroy $w} toplevel $w @@ -50,11 +30,9 @@ pack $w.msg -side top set btns [addSeeDismiss $w.buttons $w] pack $btns -side bottom -fill x -pack [label $w.wait -text "Please wait while loading fonts..." \ - -font {Helvetica 12 italic}] -pack [frame $w.f] -expand 1 -fill both -padx 2m -pady 1m +## The frame that will contain the sample texts. +pack [frame $w.f] -side bottom -expand 1 -fill both -padx 2m -pady 1m grid columnconfigure $w.f 1 -weight 1 - set i 0 proc addSample {w language args} { global font i @@ -66,42 +44,87 @@ proc addSample {w language args} { grid configure $w.f.l$j -padx 1m } -# Processing when some characters are missing might take a while, so make -# sure we're displaying something in the meantime... +## A helper procedure that determines what form to use to express languages +## that have complex rendering rules... +proc usePresentationFormsFor {language} { + switch [tk windowingsystem] { + aqua { + # OSX wants natural character order; the renderer knows how to + # compose things for display for all languages. + return false + } + x11 { + # The X11 font renderers that Tk supports all know nothing about + # composing characters, so we need to use presentation forms. + return true + } + win32 { + # On Windows, we need to determine whether the font system will + # render right-to-left text. This varies by language! + try { + package require registry + set rkey [join { + HKEY_LOCAL_MACHINE + SOFTWARE + Microsoft + {Windows NT} + CurrentVersion + LanguagePack + } \\] + return [expr { + [string toupper $language] ni [registry values $rkey] + }] + } trap error {} { + # Cannot work it out, so use presentation forms. + return true + } + } + default { + # Default to using presentation forms. + return true + } + } +} +## Processing when some characters are not currently cached by the display +## engine might take a while, so make sure we're displaying something in the +## meantime... +pack [label $w.wait -text "Please wait while loading fonts..." \ + -font {Helvetica 12 italic}] set oldCursor [$w cget -cursor] $w conf -cursor watch update -if {[tk windowingsystem] eq {x11} - || (([tk windowingsystem] eq {win32}) && ({ARABIC} ni $w32langs))} { +## Add the samples... +if {[usePresentationFormsFor Arabic]} { # Using presentation forms (pre-layouted) addSample $w Arabic \ - "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \ - "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D" + "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \ + "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D" } else { # Using standard text characters addSample $w Arabic \ - "\u0627\u0644\u0643\u0644\u0645\u0629 " \ - "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" + "\u0627\u0644\u0643\u0644\u0645\u0629 " \ + "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" } -addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57" +addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57" addSample $w "Simpl. Chinese" "\u6C49\u8BED" +addSample $w French "Langue fran\u00E7aise" addSample $w Greek \ "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \ "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1" -if {[tk windowingsystem] eq {x11} - || (([tk windowingsystem] eq {win32}) && ({HEBREW} ni $w32langs))} { +if {[usePresentationFormsFor Hebrew]} { # Visual order (pre-layouted) addSample $w Hebrew \ - "\u05EA\u05D9\u05E8\u05D1\u05E2 " \ - "\u05D1\u05EA\u05DB" + "\u05EA\u05D9\u05E8\u05D1\u05E2 \u05D1\u05EA\u05DB" } else { # Standard logical order addSample $w Hebrew \ - "\u05DB\u05EA\u05D1 " \ - "\u05E2\u05D1\u05E8\u05D9\u05EA" + "\u05DB\u05EA\u05D1 \u05E2\u05D1\u05E8\u05D9\u05EA" } +addSample $w Hindi \ + "\u0939\u093f\u0928\u094d\u0926\u0940 \u092d\u093e\u0937\u093e" +addSample $w Icelandic "\u00CDslenska" addSample $w Japanese \ "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \ "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA" @@ -109,6 +132,6 @@ addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00" addSample $w Russian \ "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A" -# We're done processing, so change things back to normal running... +## We're done processing, so change things back to normal running... destroy $w.wait $w conf -cursor $oldCursor diff --git a/library/demos/widget b/library/demos/widget index d58f086..8b92f9a 100644 --- a/library/demos/widget +++ b/library/demos/widget @@ -13,7 +13,6 @@ exec wish "$0" ${1+"$@"} package require Tcl 8.5 package require Tk 8.5 package require msgcat -package require Ttk eval destroy [winfo child .] set tk_demoDirectory [file join [pwd] [file dirname [info script]]] @@ -318,16 +317,13 @@ addFormattedText { @@demo image1 Two labels displaying images @@demo image2 A simple user interface for viewing images @@demo labelframe Labelled frames - @@new @@demo ttkbut The simple Themed Tk widgets @@subtitle Listboxes and Trees @@demo states The 50 states @@demo colors Colors: change the color scheme for the application @@demo sayings A collection of famous and infamous sayings - @@new @@demo mclist A multi-column list of countries - @@new @@demo tree A directory browser tree @@subtitle Entries, Spin-boxes and Combo-boxes @@ -335,7 +331,6 @@ addFormattedText { @@demo entry2 Entries with scrollbars @@demo entry3 Validated entries and password fields @@demo spin Spin-boxes - @@new @@demo combo Combo-boxes @@demo form Simple Rolodex-like form @@ -345,7 +340,6 @@ addFormattedText { @@demo bind Hypertext (tag bindings) @@demo twind A text widget with embedded windows and other features @@demo search A search tool built with a text widget - @@new @@demo textpeer Peering text widgets @@subtitle Canvases @@ -356,7 +350,6 @@ addFormattedText { @@demo ruler A ruler with adjustable tab stops @@demo floor A building floor plan @@demo cscroll A simple scrollable canvas - @@new @@demo knightstour A Knight's tour of the chess board @@subtitle Scales and Progress Bars @@ -364,38 +357,30 @@ addFormattedText { @@demo vscale Vertical scale @@new @@demo ttkscale Themed scale linked to a label with traces - @@new @@demo ttkprogress Progress bar @@subtitle Paned Windows and Notebooks @@demo paned1 Horizontal paned window @@demo paned2 Vertical paned window - @@new @@demo ttkpane Themed nested panes - @@new @@demo ttknote Notebook widget @@subtitle Menus and Toolbars @@demo menu Menus and cascades (sub-menus) @@demo menubu Menu-buttons - @@new @@demo ttkmenu Themed menu buttons - @@new @@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 @@subtitle Animation - @@new @@demo anilabel Animated labels - @@new @@demo aniwave Animated wave - @@new @@demo pendulum Pendulum simulation - @@new @@demo goldberg A celebration of Rube Goldberg @@subtitle Miscellaneous @@ -724,10 +709,10 @@ proc PrintTextWin32 {filename} { proc tkAboutDialog {} { tk_messageBox -icon info -type ok -title [mc "About Widget Demo"] \ -message [mc "Tk widget demonstration application"] -detail \ -"[mc {Copyright (c) %s} {1996-1997 Sun Microsystems, Inc.}] -[mc {Copyright (c) %s} {1997-2000 Ajuba Solutions, Inc.}] -[mc {Copyright (c) %s} {2001-2007 Donal K. Fellows}] -[mc {Copyright (c) %s} {2002-2007 Daniel A. Steffen}]" +"[mc "Copyright \u00a9 %s" {1996-1997 Sun Microsystems, Inc.}] +[mc "Copyright \u00a9 %s" {1997-2000 Ajuba Solutions, Inc.}] +[mc "Copyright \u00a9 %s" {2001-2009 Donal K. Fellows}] +[mc "Copyright \u00a9 %s" {2002-2007 Daniel A. Steffen}]" } # Local Variables: |