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