1 # vim: foldmarker=<<<,>>>
3 proc tlc::splash {pathName args} {
4 uplevel tlc::Splash $pathName $args
15 variable splashfile "" rerender
17 method progress {{int {}} {msg {}}}
26 method parsefile {filename}
32 body tlc::Splash::constructor {args} { #<<<1
35 option add *$wdb*Tile ""
37 eval itk_initialize $args
41 body tlc::Splash::destructor {} { #<<<1
42 catch {image delete $general(image)}
46 body tlc::Splash::progress {{int {}} {msg {}}} { #<<<1
50 set range [expr {$bar(x2) - $bar(x1)}]
51 set sofar [expr {double($range) * $int/100.0}]
52 $w.splash coords bar \
54 [expr {$bar(x1) + $sofar}] $bar(y2)
55 $w.splash itemconfigure text -text $msg
62 body tlc::Splash::parsefile {filename} { #<<<1
63 set dirname [file dirname $filename]
64 set fp [open $filename r]
65 set dat [read -nonewline $fp]
68 if {[catch {array set info $dat} err]} {
69 usererror "Error parsing splash screen file: ($filename)\n$err"
72 set reqfields {image bar}
73 foreach reqfield {image bar} {
74 if {![info exists info($reqfield)]} {
75 usererror "Error parsing splash screen file: ($filename)\nMust have at least ($reqfields) defined"
78 set general(imagefile) $info(image)
79 set bar(x1) [lindex $info(bar) 0]
80 set bar(y1) [lindex $info(bar) 1]
81 set bar(x2) [lindex $info(bar) 2]
82 set bar(y2) [lindex $info(bar) 3]
84 # Defaults for optional params
85 set general(bg) $::cfg(background)
86 set general(borderwidth) 4
87 set general(relief) raised
88 set bar(colour) "blue"
89 set text(x) [expr {($bar(x2) - $bar(x1)) / 2.0 + $bar(x1)}]
90 set text(y) [expr {($bar(y2) - $bar(y1)) / 2.0 + $bar(y1)}]
91 set text(anchor) "center"
92 set text(colour) "black"
93 set text(font) $tlc::config(normalfont)
95 # Optional params (should have reasonable defaults set above
96 if {[info exists info(background)]} {set general(bg) $info(background)}
97 if {[info exists info(borderwidth)]} {set general(borderwidth) $info(borderwidth)}
98 if {[info exists info(relief)]} {set general(relief) $info(relief)}
99 if {[info exists info(bar_colour)]} {set bar(colour) $info(bar_colour)}
100 if {[info exists info(text)]} {
101 set text(x) [lindex $info(text) 0]
102 set text(y) [lindex $info(text) 1]
104 if {[info exists info(text_anchor)]} {set text(anchor) $info(text_anchor)}
105 if {[info exists info(text_colour)]} {set text(colour) $info(text_colour)}
106 if {[info exists info(text_font)]} {set text(font) $info(text_font)}
107 if {[string tolower $text(font)] == "bold"} {
108 set text(font) $tlc::config(boldfont)
111 set general(imagefile) [file join $dirname $general(imagefile)]
112 set general(image) [image create photo -file $general(imagefile)]
116 body tlc::Splash::rerender {} { #<<<1
117 if {$splashfile == ""} return
119 catch {eval destroy [winfo children $w]}
121 parsefile $splashfile
124 -borderwidth $general(borderwidth) \
125 -relief $general(relief) \
126 -highlightthickness 0 \
127 -width [image width $general(image)] \
128 -height [image height $general(image)] \
129 -background $general(bg)
131 $w.splash create image 0 0 -anchor nw -image $general(image)
133 $w.splash create rectangle \
136 -outline $bar(colour) \
137 -fill $bar(colour) -tags bar
139 $w.splash create text \
141 -anchor $text(anchor) -fill $text(colour) -font $text(font) -tags text
143 $w.splash yview moveto 0.0
144 $w.splash xview moveto 0.0
147 $w.splash 1,1 -fill both
149 table configure $w r1 c1 -resize none
151 if {$general(bg) != ""} {
152 configure -background $general(bg)
155 wm overrideredirect $w 1