Update tk to version 8.5.5
[msysgit.git] / mingw / lib / tk8.5 / demos / unicodeout.tcl
blob3d733e1519c73bac1f2f9fbe1d077e12a46d64b3
1 # unicodeout.tcl --
3 # This demonstration script shows how you can produce output (in label
4 # widgets) using many different alphabets.
6 # RCS: @(#) $Id: unicodeout.tcl,v 1.7 2007/12/13 15:27:07 dgp Exp $
8 if {![info exists widgetDemo]} {
9 error "This script should be run from the \"widget\" demo."
12 package require Tk
14 set w .unicodeout
15 catch {destroy $w}
16 toplevel $w
17 wm title $w "Unicode Label Demonstration"
18 wm iconname $w "unicodeout"
19 positionWindow $w
21 label $w.msg -font $font -wraplength 4i -anchor w -justify left \
22 -text "This is a sample of Tk's support for languages that use\
23 non-Western character sets. However, what you will actually see\
24 below depends largely on what character sets you have installed,\
25 and what you see for characters that are not present varies greatly\
26 between platforms as well. The strings are written in Tcl using\
27 UNICODE characters using the \\uXXXX escape so as to do so in a\
28 portable fashion."
29 pack $w.msg -side top
31 ## See Code / Dismiss buttons
32 set btns [addSeeDismiss $w.buttons $w]
33 pack $btns -side bottom -fill x
35 pack [label $w.wait -text "Please wait while loading fonts..." \
36 -font {Helvetica 12 italic}]
37 pack [frame $w.f] -expand 1 -fill both -padx 2m -pady 1m
38 grid columnconfigure $w.f 1 -weight 1
40 set i 0
41 proc addSample {w language args} {
42 global font i
43 set sample [join $args ""]
44 set j [incr i]
45 label $w.f.l$j -font $font -text "${language}:" -anchor nw -pady 0
46 label $w.f.s$j -font $font -text $sample -anchor nw -width 30 -pady 0
47 grid $w.f.l$j $w.f.s$j -sticky ew -pady 0
48 grid configure $w.f.l$j -padx 1m
51 # Processing when some characters are missing might take a while, so make
52 # sure we're displaying something in the meantime...
54 set oldCursor [$w cget -cursor]
55 $w conf -cursor watch
56 update
58 if {[tk windowingsystem] in {x11 win32}} {
59 # Using presentation forms (pre-layouted)
60 addSample $w Arabic \
61 "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \
62 "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D"
63 } else {
64 # Using standard text characters
65 addSample $w Arabic \
66 "\u0627\u0644\u0643\u0644\u0645\u0629 " \
67 "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
69 addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57"
70 addSample $w "Simpl. Chinese" "\u6C49\u8BED"
71 addSample $w Greek \
72 "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
73 "\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
74 if {[tk windowingsystem] in {x11 win32}} {
75 # Visual order (pre-layouted)
76 addSample $w Hebrew \
77 "\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 " \
78 "\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9"
79 } else {
80 # Standard logical order
81 addSample $w Hebrew \
82 "\u05D9\u05E9\u05E8\u05D0\u05D9\u05DC " \
83 "\u05D9\u05E8\u05D5\u05E9\u05DC\u05D9\u05DD"
85 addSample $w Japanese \
86 "\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
87 "\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"
88 addSample $w Korean "\uB300\uD55C\uBBFC\uAD6D\uC758 \uD55C\uAE00"
89 addSample $w Russian \
90 "\u0420\u0443\u0441\u0441\u043A\u0438\u0439 \u044F\u0437\u044B\u043A"
92 # We're done processing, so change things back to normal running...
93 destroy $w.wait
94 $w conf -cursor $oldCursor