1# ttkpane.tcl --
2#
3# This demonstration script creates a Ttk pane with some content.
4
5if {![info exists widgetDemo]} {
6    error "This script should be run from the \"widget\" demo."
7}
8
9package require Tk
10
11set w .ttkpane
12catch {destroy $w}
13toplevel $w
14wm title $w "Themed Nested Panes"
15wm iconname $w "ttkpane"
16positionWindow $w
17
18ttk::label $w.msg -font $font -wraplength 4i -justify left -text "This demonstration shows off a nested set of themed paned windows. Their sizes can be changed by grabbing the area between each contained pane and dragging the divider."
19pack $w.msg [ttk::separator $w.msgSep] -side top -fill x
20
21## See Code / Dismiss
22pack [addSeeDismiss $w.seeDismiss $w] -side bottom -fill x
23
24ttk::frame $w.f
25pack $w.f -fill both -expand 1
26set w $w.f
27ttk::panedwindow $w.outer -orient horizontal
28$w.outer add [ttk::panedwindow $w.outer.inLeft -orient vertical]
29$w.outer add [ttk::panedwindow $w.outer.inRight -orient vertical]
30$w.outer.inLeft  add [ttk::labelframe $w.outer.inLeft.top  -text Button]
31$w.outer.inLeft  add [ttk::labelframe $w.outer.inLeft.bot  -text Clocks]
32$w.outer.inRight add [ttk::labelframe $w.outer.inRight.top -text Progress]
33$w.outer.inRight add [ttk::labelframe $w.outer.inRight.bot -text Text]
34if {[tk windowingsystem] eq "aqua"} {
35    foreach i [list inLeft.top inLeft.bot inRight.top inRight.bot] {
36	$w.outer.$i configure -padding 3
37    }
38}
39
40# Fill the button pane
41ttk::button $w.outer.inLeft.top.b -text "Press Me" -command {
42    tk_messageBox -type ok -icon info -message "Ouch!" -detail "That hurt..." \
43	    -parent .ttkpane -title "Button Pressed"
44}
45pack $w.outer.inLeft.top.b -padx 2 -pady 5
46
47# Fill the clocks pane
48set i 0
49proc every {delay script} {
50    uplevel #0 $script
51    after $delay [list every $delay $script]
52}
53set testzones {
54    :Europe/Berlin
55    :America/Argentina/Buenos_Aires
56    :Africa/Johannesburg
57    :Europe/London
58    :America/Los_Angeles
59    :Europe/Moscow
60    :America/New_York
61    :Asia/Singapore
62    :Australia/Sydney
63    :Asia/Tokyo
64}
65# Force a pre-load of all the timezones needed; otherwise can end up
66# poor-looking synch problems!
67set zones {}
68foreach zone $testzones {
69    if {![catch {clock format 0 -timezone $zone}]} {
70        lappend zones $zone
71    }
72}
73if {[llength $zones] < 2} { lappend zones -0200 :GMT :UTC +0200 }
74foreach zone $zones {
75    set city [string map {_ " "} [regexp -inline {[^/]+$} $zone]]
76    if {$i} {
77	pack [ttk::separator $w.outer.inLeft.bot.s$i] -fill x
78    }
79    ttk::label $w.outer.inLeft.bot.l$i -text $city -anchor w
80    ttk::label $w.outer.inLeft.bot.t$i -textvariable time($zone) -anchor w
81    pack $w.outer.inLeft.bot.l$i $w.outer.inLeft.bot.t$i -fill x
82    every 1000 "set time($zone) \[clock format \[clock seconds\] -timezone $zone -format %T\]"
83    incr i
84}
85
86# Fill the progress pane
87ttk::progressbar $w.outer.inRight.top.progress -mode indeterminate
88pack $w.outer.inRight.top.progress -fill both -expand 1
89$w.outer.inRight.top.progress start
90
91# Fill the text pane
92if {[tk windowingsystem] ne "aqua"} {
93    # The trick with the ttk::frame makes the text widget look like it fits with
94    # the current Ttk theme despite not being a themed widget itself. It is done
95    # by styling the frame like an entry, turning off the border in the text
96    # widget, and putting the text widget in the frame with enough space to allow
97    # the surrounding border to show through (2 pixels seems to be enough).
98    ttk::frame $w.outer.inRight.bot.f				-style TEntry
99    text $w.txt -wrap word -yscroll "$w.sb set" -width 30	-borderwidth 0
100    pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot.f	-pady 2 -padx 2
101    ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
102    pack $w.sb -side right -fill y -in $w.outer.inRight.bot
103    pack $w.outer.inRight.bot.f -fill both -expand 1
104    pack $w.outer -fill both -expand 1
105} else {
106    text $w.txt -wrap word -yscroll "$w.sb set" -width 30 -borderwidth 0
107    ttk::scrollbar $w.sb -orient vertical -command "$w.txt yview"
108    pack $w.sb -side right -fill y -in $w.outer.inRight.bot
109    pack $w.txt -fill both -expand 1 -in $w.outer.inRight.bot
110    pack $w.outer -fill both -expand 1 -padx 10 -pady {6 10}
111}
112
113