From 980d6be8ab01ee59ac92153bcf6f8a6ce62630ec Mon Sep 17 00:00:00 2001 From: Cyan Ogilvie Date: Tue, 20 May 2008 18:31:06 +0200 Subject: [PATCH] Fixes --- Makefile | 4 +- examples/test_radiogroup.tcl | 2 +- examples/toolbar.itk | 2 +- examples/wizard.tcl | 17 ++++- init.tcl | 42 +++++++++++-- pkgIndex.tcl | 2 +- scripts/border.itk | 2 +- scripts/checkgroup.itk | 62 +++++++++--------- scripts/confirm.itk | 11 ++-- scripts/date_lookup.itk | 11 ++-- scripts/dateentry.itk | 12 +--- scripts/deny.itk | 9 +-- scripts/form.itk | 25 ++++++-- scripts/form_sql_lookup.itk | 32 ++++++---- scripts/hoverbox.itk | 9 ++- scripts/infowin.itk | 7 ++- scripts/module.itk | 38 ++++++----- scripts/mytoplevel.itk | 25 ++++++-- scripts/mywidget.itk | 2 +- scripts/radiogroup.itk | 48 ++++++++------ scripts/spinner.itcl | 34 ++++------ scripts/splash.itk | 2 +- scripts/stategate_target.itcl | 5 +- scripts/theme.itk | 2 +- scripts/wizard.itk | 143 +++++++++++++++++++++++++++++++++++++++--- setup.iss | 46 -------------- teapot.txt | 2 +- 27 files changed, 378 insertions(+), 218 deletions(-) delete mode 100644 setup.iss diff --git a/Makefile b/Makefile index 8560cb6..dc712aa 100644 --- a/Makefile +++ b/Makefile @@ -39,8 +39,8 @@ refresh-teapot: teapot teacup install teapot/* force-refresh-teapot: teapot - teacup remove TLC - teacup install --force teapot/* + teacup remove TTLC + teacup install --force --timeout 1 teapot/* uninstall: -rm -rf $(MYDESTDIR) diff --git a/examples/test_radiogroup.tcl b/examples/test_radiogroup.tcl index c6611f3..a86003b 100755 --- a/examples/test_radiogroup.tcl +++ b/examples/test_radiogroup.tcl @@ -1,4 +1,4 @@ -#!/usr/bin/env tclsh8.4 +#!/usr/bin/env tclsh8.5 source "boilerplate.tcl" diff --git a/examples/toolbar.itk b/examples/toolbar.itk index fcb4f96..6271cb2 100755 --- a/examples/toolbar.itk +++ b/examples/toolbar.itk @@ -1,4 +1,4 @@ -#!/usr/bin/tclsh +#!/usr/bin/env tclsh8.5 source "boilerplate.tcl" diff --git a/examples/wizard.tcl b/examples/wizard.tcl index 6e47f74..d183f52 100755 --- a/examples/wizard.tcl +++ b/examples/wizard.tcl @@ -6,7 +6,7 @@ package require TLC 0.90.0 source "boilerplate.tcl" -Wizard .wizard -startpage start -routing { +Wizard .wizard -showhelp 1 -startpage start -routing { start { #<<< Next { {$dat(usefoo)} get_foo @@ -40,6 +40,7 @@ Wizard .wizard -startpage start -routing { #>>> } -pages { start { #<<< + title "Hello, Wizard" type form schema { _layout {row_args_sticky -resize none} @@ -59,9 +60,16 @@ Wizard .wizard -startpage start -routing { "Foo?" usefoo } } + help { +

This is the startpage of the wizard

+ +

Do you want some foo? If you don't, you'll need to provide + baz later on

+ } } #>>> get_foo { #<<< + title "Get Foo" type form schema { _layout {row_args_sticky -resize none} @@ -73,6 +81,9 @@ Wizard .wizard -startpage start -routing { "Foo" foo } } + help { + Please provide the Foo. + } } #>>> get_bar { #<<< @@ -134,12 +145,14 @@ Wizard .wizard -startpage start -routing { } } #>>> +} -oncancel { + exit 1 } blt::table . \ .wizard 1,1 -fill both -wm geometry . "450x250" +wm geometry . "600x320" .wizard waitfor finished diff --git a/init.tcl b/init.tcl index b7125ec..9814b70 100755 --- a/init.tcl +++ b/init.tcl @@ -43,7 +43,7 @@ if {[info exists tlc::custom_theme_object]} { } } -package provide TLC $::tlc::version +package provide TTLC $::tlc::version # Set saner defaults @@ -80,10 +80,6 @@ foreach {opt settingkey} { *Labelframe.font boldfont *labelFont boldfont *Button.padY button_pady - *frameRelief framerelief - *frameBorderwidth frameborderwidth - *Spinner.frameRelief entryrelief - *Spinner.frameBorderwidth entryborderwidth *Form.padding formpadding } { option add $opt [$tlc::theme setting $settingkey] startupFile @@ -122,3 +118,39 @@ namespace eval tlc::Form { set custom_types(sql_lookup) "tlc::form::Datavaultlookup" } +namespace eval tlc { + proc set_theme {name} { + ttk::setTheme $name + + ttk::style map TLabel -foreground {invalid red} + } + + # Try to choose a reasonable default + apply {{} { + switch -- [tk windowingsystem] { + "win32" { + set try [list xpnative winnative clam] + } + + "aqua" { + set try [list aqua clam] + } + + default - + "x11" { + set try [list clam] + } + } + + foreach theme $try { + if {[catch { + ::tlc::set_theme $try + } errmsg]} { + #puts "Could not use theme: ($theme): $errmsg\n$::errorInfo" + } else { + break + } + } + }} +} + diff --git a/pkgIndex.tcl b/pkgIndex.tcl index 14e9be7..6c80f2e 100755 --- a/pkgIndex.tcl +++ b/pkgIndex.tcl @@ -1,3 +1,3 @@ #Tcl package index file, version 1.0 -package ifneeded TLC 0.96.0 [list source [file join $dir init.tcl]] +package ifneeded TTLC 0.96.0 [list source [file join $dir init.tcl]] diff --git a/scripts/border.itk b/scripts/border.itk index 4022754..82c75c6 100644 --- a/scripts/border.itk +++ b/scripts/border.itk @@ -50,7 +50,7 @@ body tlc::Border::constructor {args} { #<<<1 set w $itk_interior set wdb [string range $w 1 end] - eval itk_initialize $args + itk_initialize {*}$args } diff --git a/scripts/checkgroup.itk b/scripts/checkgroup.itk index 1310d9f..249ecde 100644 --- a/scripts/checkgroup.itk +++ b/scripts/checkgroup.itk @@ -53,18 +53,12 @@ class tlc::Checkgroup { } -configbody tlc::Checkgroup::state { #<<<1 +configbody tlc::Checkgroup::state { #<<< [stategate_ref] configure -default [expr {$state == "normal"}] } - -body tlc::Checkgroup::constructor {args} { #<<<1 - if {[catch { - package require Tk 8.4 - } errmsg]} { - error "Need at least Tk 8.4 for Checkgroup" - } - +#>>> +body tlc::Checkgroup::constructor {args} { #<<< array set values {} array set dominos {} array set toggles {} @@ -90,15 +84,15 @@ body tlc::Checkgroup::constructor {args} { #<<<1 $dominos(need_rerender) attach_output [code $this rerender] $dominos(value_changed) attach_output [code $this value_changed] - eval itk_initialize $args + itk_initialize {*}$args if {[$dominos(need_rerender) pending]} { $dominos(need_rerender) tip_now } } - -body tlc::Checkgroup::rerender {} { #<<<1 +#>>> +body tlc::Checkgroup::rerender {} { #<<< foreach key [array names toggles] { array unset toggles $key } @@ -108,7 +102,7 @@ body tlc::Checkgroup::rerender {} { #<<<1 foreach signal [array names signals option_*] { array unset signals($signal) } - frame $w.border.inner + ttk::frame $w.border.inner pack $w.border.inner -fill both -expand true set cseq 1 @@ -129,15 +123,23 @@ body tlc::Checkgroup::rerender {} { #<<<1 set scoped_varname [scope values($key)] } - checkbutton $base.$cseq,$rseq -text "$name" \ + ttk::checkbutton $base.$cseq,$rseq -text "$name" \ -onvalue $onvalue -offvalue $offvalue \ -variable $scoped_varname tlc::StateToggle #auto toggles($cseq,$rseq) $base.$cseq,$rseq \ - -state {disabled normal} \ - -foreground [list $itk_option(-disabledforeground) \ - $itk_option(-foreground)] + -state {disabled normal} $toggles($cseq,$rseq) attach_input [stategate_ref] + $toggles($cseq,$rseq) attach_output [list apply { + {widget newstate} { + if {![winfo exists $widget]} return + if {$newstate} { + $widget state !disabled + } else { + $widget state disabled + } + } + } $base.$cseq,$rseq] tlc::Signal #auto signals(option_$key) -name "$w option $key selected" $signals(item_selected) attach_input $signals(option_$key) @@ -145,8 +147,8 @@ body tlc::Checkgroup::rerender {} { #<<<1 set keymap($key) "$cseq,$rseq" - eval [list blt::table $base $base.$cseq,$rseq $rseq,$cseq] \ - $cell_args + blt::table $base $base.$cseq,$rseq $rseq,$cseq \ + {*}$cell_args if {$orient == "h"} { incr cseq @@ -156,15 +158,15 @@ body tlc::Checkgroup::rerender {} { #<<<1 } } - -body tlc::Checkgroup::attach_signal {key signal {sense normal}} { #<<<1 +#>>> +body tlc::Checkgroup::attach_signal {key signal {sense normal}} { #<<< if {![info exists keymap($key)]} {error "No such key: ($key)"} return [$toggles($keymap($key)) attach_input $signal $sense] } - -body tlc::Checkgroup::path {key} { #<<<1 +#>>> +body tlc::Checkgroup::path {key} { #<<< if {[$dominos(need_rerender) pending]} { $dominos(need_rerender) tip_now } @@ -174,13 +176,13 @@ body tlc::Checkgroup::path {key} { #<<<1 return "$base.$keymap($key)" } - -body tlc::Checkgroup::option_changed {key newvalue} { #<<<1 +#>>> +body tlc::Checkgroup::option_changed {key newvalue} { #<<< invoke_handlers toggle $key $newvalue } - -body tlc::Checkgroup::value_changed {} { #<<<1 +#>>> +body tlc::Checkgroup::value_changed {} { #<<< switch -- $mode { "array" { set_textvariable [array get values] @@ -208,8 +210,8 @@ body tlc::Checkgroup::value_changed {} { #<<<1 } } - -body tlc::Checkgroup::textvariable_changed {newvalue} { #<<<1 +#>>> +body tlc::Checkgroup::textvariable_changed {newvalue} { #<<< switch -- $mode { "array" { array set values $newvalue @@ -232,4 +234,4 @@ body tlc::Checkgroup::textvariable_changed {newvalue} { #<<<1 } } - +#>>> diff --git a/scripts/confirm.itk b/scripts/confirm.itk index 1d69499..f6e78a3 100644 --- a/scripts/confirm.itk +++ b/scripts/confirm.itk @@ -16,16 +16,17 @@ class tlc::Confirm { body tlc::Confirm::constructor {args} { #<<<1 - eval itk_initialize $args + itk_initialize {*}$args option add *$wdb*Button.width 12 widgetDefault option add *$wdb*Button.highlightThickness 1 option add *$wdb*Button.takeFocus 1 - label $w.icon + ttk::label $w.icon set_icon - message $w.msg -justify left -width 400 - frame $w.opts + message $w.msg -justify left -width 400 \ + -background [ttk::style lookup $::ttk::currentTheme -background] + ttk::frame $w.opts blt::table $w -padx 5 -pady 5 \ $w.icon 1,1 \ @@ -49,7 +50,7 @@ body tlc::Confirm::ask {msg args} { #<<<1 set largs $args } foreach arg $largs { - button $w.opts.$i -text $arg -command [code $this choose $arg] + ttk::button $w.opts.$i -text $arg -command [code $this choose $arg] if {$i != [llength $args]} { blt::table $w.opts $w.opts.$i 1,$i -padx {0 4} } else { diff --git a/scripts/date_lookup.itk b/scripts/date_lookup.itk index ed49503..910799f 100644 --- a/scripts/date_lookup.itk +++ b/scripts/date_lookup.itk @@ -29,22 +29,19 @@ class tlc::Datelookup { configbody tlc::Datelookup::buttonrelief { #<<<1 if {![winfo ismapped $w.cal]} { - $itk_component(button) configure -relief $itk_option(-buttonrelief) + #$itk_component(button) configure -relief $itk_option(-buttonrelief) } } body tlc::Datelookup::constructor {args} { #<<<1 itk_component add button { - button $w.button -command [code $this toggle] + ttk::button $w.button -command [code $this toggle] # button $w.button -text "..." -font {Helvetica -12 bold} \ # -command [code $this toggle] -padx 2 -pady 0 } { - usual ignore -command keep -state - keep -borderwidth - keep -highlightbackground } set_icon @@ -103,7 +100,7 @@ body tlc::Datelookup::popup {} { #<<<1 wm overrideredirect $w.cal 1 wm positionfrom $w.cal user - $itk_component(button) configure -relief sunken + #$itk_component(button) configure -relief sunken # puts stderr "xy ([expr $botx - $listwidth], $boty)" set cal_x [expr {$botx + 2}] @@ -127,7 +124,7 @@ body tlc::Datelookup::popdown {} { #<<<1 grab release $w $w.cal hide - $itk_component(button) configure -relief $itk_option(-buttonrelief) + #$itk_component(button) configure -relief $itk_option(-buttonrelief) } } diff --git a/scripts/dateentry.itk b/scripts/dateentry.itk index 89d9c93..87f7576 100644 --- a/scripts/dateentry.itk +++ b/scripts/dateentry.itk @@ -56,18 +56,12 @@ configbody tlc::Dateentry::state { #<<<1 body tlc::Dateentry::constructor {args} { #<<<1 log debug $w itk_component add label { - label $w.label -textvariable [scope date] -takefocus 1 + ttk::entry $w.label -textvariable [scope date] } { - usual - rename -borderwidth -labelborderwidth labelBorderwidth LabelBorderwidth - rename -relief -labelrelief labelRelief LabelRelief - rename -background -textbackground textBackground TextBackground rename -width -labelwidth labelWidth LabelWidth - rename -highlightthickness -labelhighlightthickness labelHighlightThickness LabelHighlightThickness - rename -highlightbackground -labelhighlightbackground labelHighlightBackground LabelHighlightBackground - keep -anchor ignore -state } + $w.label state readonly bind $w.label [code $this request_lookup] itk_component add button { @@ -75,8 +69,6 @@ body tlc::Dateentry::constructor {args} { #<<<1 } { usual keep -buttonrelief - rename -borderwidth -buttonborderwidth buttonBorderwidth ButtonBorderwidth - rename -highlightbackground -buttonhighlightbackground buttonHighlightBackground ButtonHighLightBackground keep -resultformat -special_cb keep -validfrom -validto -state keep -onlyweekdays diff --git a/scripts/deny.itk b/scripts/deny.itk index 1e4581a..f3897be 100644 --- a/scripts/deny.itk +++ b/scripts/deny.itk @@ -14,16 +14,17 @@ class tlc::Deny { body tlc::Deny::constructor {args} { - eval itk_initialize $args + itk_initialize {*}$args option add *$wdb*Button.width 10 widgetDefault option add *$wdb*Button.highlightThickness 1 option add *$wdb*Button.takeFocus 1 - label $w.icon + ttk::label $w.icon set_icon - message $w.msg -justify left -width 200 - button $w.ok -text "OK" -command [code $this choose 1] + message $w.msg -justify left -width 200 \ + -background [ttk::style lookup $::ttk::currentTheme -background] + ttk::button $w.ok -text "OK" -command [code $this choose 1] blt::table $w -padx 5 -pady 5 \ $w.icon 1,1 -padx {5 0} \ diff --git a/scripts/form.itk b/scripts/form.itk index 447db41..5907472 100644 --- a/scripts/form.itk +++ b/scripts/form.itk @@ -172,6 +172,7 @@ body tlc::Form::constructor {args} { #<<<1 log debug "Setting name ($name) for $w" } set baselog_instancename $name + log debug $w } @@ -518,16 +519,26 @@ body tlc::Form::rerender {} { #<<<1 tlc::Gate #auto field_valid($varname) -name "$w field_valid $varname" \ -mode "and" -default 1 - #tlc::StateToggle #auto valid_toggles($varname) \ - # -mode "or" -default 1 \ - # $w.$row,$col,l \ - # -foreground {red black} tlc::StateToggle #auto valid_toggles($varname) \ -mode "or" -default 1 \ $w.$row,$col,l \ - -font [list [$tlc::theme setting boldfont] [$tlc::theme setting font]] + -foreground {red black} + #tlc::StateToggle #auto valid_toggles($varname) \ + # -mode "or" -default 1 \ + # $w.$row,$col,l + ## -font [list [$tlc::theme setting boldfont] [$tlc::theme setting font]] $valid_toggles($varname) attach_signal $signals(enabled) inverted $valid_toggles($varname) attach_signal $field_valid($varname) + $valid_toggles($varname) attach_output [list apply { + {widget newstate} { + if {![winfo exists $widget]} return + if {$newstate} { + $widget state !invalid + } else { + $widget state invalid + } + } + } $w.$row,$col,l] $valid_toggles($varname) attach_output \ [list $dominos(reasons_changed) tip] @@ -707,7 +718,9 @@ body tlc::Form::rerender {} { #<<<1 body tlc::Form::takefocus {} { #<<<1 $dominos(need_rerender) force_if_pending - focus $w.0,0,v + if {[winfo exists $w.0,0,v]} { + focus $w.0,0,v + } } diff --git a/scripts/form_sql_lookup.itk b/scripts/form_sql_lookup.itk index 5ae480f..644601d 100644 --- a/scripts/form_sql_lookup.itk +++ b/scripts/form_sql_lookup.itk @@ -20,6 +20,7 @@ class tlc::form::Datavaultlookup { method item_selected {} method selected_info {} method set_criteria {value} + method select_item {key} } protected { @@ -38,7 +39,6 @@ class tlc::form::Datavaultlookup { common datavaults {} - method select_item {key} method refresh_display {} method recompute_display {} method close_lookup {} @@ -114,25 +114,31 @@ body tlc::form::Datavaultlookup::constructor {args} { #<<< } } + set manage_enabled { + {widget newstate} { + if {![winfo exists $widget]} return + if {$newstate} { + $widget state !disabled + } else { + $widget state disabled + } + } + } + itk_component add entry { - entry $w.display -state readonly -textvariable [scope display_value] \ - -readonlybackground [$::tlc::theme setting textbackground] + ttk::entry $w.display -textvariable [scope display_value] } { keep -width } - tlc::StateToggle #auto toggles(entry) $w.display \ - -state {disabled readonly} + $w.display state readonly + $signals(enabled) attach_output [list apply $manage_enabled $w.display] itk_component add button { - button $w.button -borderwidth 1 -padx 2 -pady 0 -width 3 \ - -highlightthickness 0 -command [code $this toggle_lookup] \ + ttk::button $w.button -width 3 \ + -command [code $this toggle_lookup] \ -text "..." } {} - tlc::StateToggle #auto toggles(button) $w.button \ - -state {disabled normal} - - $toggles(entry) attach_input $signals(enabled) - $toggles(button) attach_input $signals(enabled) + $signals(enabled) attach_output [list apply $manage_enabled $w.button] blt::table $w \ $w.display 1,1 -fill x \ @@ -280,7 +286,7 @@ body tlc::form::Datavaultlookup::show_popup {} { #<<< $w.popup.criteria_ops 1,2 -anchor w \ $w.popup.list 2,1 -cspan 2 -fill both \ $w.popup.ops 3,1 -cspan 2 -fill x -pady {4 0} - blt::table configure $w.popup c1 r2 -resize none + blt::table configure $w.popup c1 r1 r3 -resize none $w.popup show grab $w.popup diff --git a/scripts/hoverbox.itk b/scripts/hoverbox.itk index e3cc2ee..8715828 100644 --- a/scripts/hoverbox.itk +++ b/scripts/hoverbox.itk @@ -45,18 +45,17 @@ class tlc::Hoverbox { body tlc::Hoverbox::constructor {args} { #<<<1 itk_component add display { - label $w.l -borderwidth 0 -relief flat -justify left + ttk::label $w.l -justify left } { - usual - keep -background -textvariable -font + keep -textvariable -font } blt::table $w \ $w.l -fill both bind $w [code $this overself] - wm overrideredirect $w 1 - eval itk_initialize $args + wm overrideredirect [component hull] 1 + itk_initialize {*}$args } diff --git a/scripts/infowin.itk b/scripts/infowin.itk index 7edcae5..2d0f404 100644 --- a/scripts/infowin.itk +++ b/scripts/infowin.itk @@ -22,11 +22,12 @@ body tlc::Infowin::constructor {args} { #<<<1 option add *$wdb*Button.highlightThickness 1 option add *$wdb*Button.takeFocus 1 - label $w.icon + ttk::label $w.icon - message $w.msg -justify left -width 400 + message $w.msg -justify left -width 400 \ + -background [ttk::style lookup $::ttk::currentTheme -background] - eval itk_initialize $args + itk_initialize {*}$args set_icon $::tlc::theme register_handler onchange [code $this set_icon] diff --git a/scripts/module.itk b/scripts/module.itk index b815ba2..c7b497c 100644 --- a/scripts/module.itk +++ b/scripts/module.itk @@ -94,7 +94,7 @@ configbody tlc::Module::menubar { #<<<1 configbody tlc::Module::geometry { #<<<1 if {$itk_option(-geometry) != ""} { - wm geometry $w $itk_option(-geometry) + wm geometry [component hull] $itk_option(-geometry) } } @@ -110,16 +110,26 @@ body tlc::Module::constructor {args} { #<<<1 set w $itk_interior set wdb [string trimleft $w .] - wm protocol $w WM_DELETE_WINDOW "$this closewin" - bind $itk_component(hull) "$this closewin" + wm protocol [component hull] WM_DELETE_WINDOW [code $this closewin] + bind $itk_component(hull) [code $this closewin] bind $itk_component(hull) [code $this _submit] - bind $itk_component(hull) "set {[scope bx]} \"%x\"; set {[scope by]} \"%y\"" - bind $itk_component(hull) "set {[scope bx]} \"%x\"; set {[scope by]} \"%y\"" + bind $itk_component(hull) [list apply { + {bx by x y} { + set $bx $x + set $by $y + } + } [scope bx] [scope by] %x %y] + bind $itk_component(hull) [list apply { + {bx by x y} { + set $bx $x + set $by $y + } + } [scope bx] [scope by] %x %y] bind $itk_component(hull) [code $this goto %X %Y %s] bind $itk_component(hull) [code $this savepos] - - eval itk_initialize $args + + itk_initialize {*}$args hide } @@ -132,13 +142,13 @@ body tlc::Module::visibility {args} { #<<<1 eval $cmd } update idletasks - wm deiconify $w + wm deiconify [component hull] } else { set cmd $itk_option(-onhide) if {$cmd != ""} { eval $cmd } - wm withdraw $w + wm withdraw [component hull] } } @@ -159,7 +169,7 @@ body tlc::Module::toggle {args} { #<<<1 body tlc::Module::raisewin {} { #<<<1 - raise $w + raise [component hull] } @@ -182,10 +192,10 @@ body tlc::Module::goto {rx ry st} { #<<<1 body tlc::Module::moveto {x y {snaprange 0}} { #<<<1 - set sw [winfo screenwidth $w] - set sh [winfo screenheight $w] - set width [winfo reqwidth $w] - set height [winfo reqheight $w] + set sw [winfo screenwidth [component hull]] + set sh [winfo screenheight [component hull]] + set width [winfo reqwidth [component hull]] + set height [winfo reqheight [component hull]] set x2 [expr $x + $width] set y2 [expr $y + $height] set dx1 [expr $x - 0] diff --git a/scripts/mytoplevel.itk b/scripts/mytoplevel.itk index 1f0fed1..a0a77cd 100644 --- a/scripts/mytoplevel.itk +++ b/scripts/mytoplevel.itk @@ -13,16 +13,18 @@ class tlc::Mytoplevel { private { variable topw + + method checkbackground {} } } -configbody tlc::Mytoplevel::title { #<<<1 +configbody tlc::Mytoplevel::title { #<<< wm title $topw $itk_option(-title) } - -body tlc::Mytoplevel::constructor {args} { #<<<1 +#>>> +body tlc::Mytoplevel::constructor {args} { #<<< set itk_interior [namespace tail $this] set topw $itk_interior @@ -31,14 +33,17 @@ body tlc::Mytoplevel::constructor {args} { #<<<1 } { keep -cursor -takefocus -menu -background } + $topw configure -background \ + [ttk::style lookup $ttk::currentTheme -background] bind tlc-delete-$topw [code itcl::delete object $this] bindtags $topw [concat [list tlc-delete-$topw] [bindtags $topw]] + bind $topw <> [code $this checkbackground] - eval itk_initialize $args + itk_initialize {*}$args } - -body tlc::Mytoplevel::destructor {} { #<<<1 +#>>> +body tlc::Mytoplevel::destructor {} { #<<< if {[winfo exists $topw]} { set bindtags [bindtags $topw] set idx [lsearch $bindtags tlc-delete-$topw] @@ -49,4 +54,12 @@ body tlc::Mytoplevel::destructor {} { #<<<1 } } +#>>> +body tlc::Mytoplevel::checkbackground {} { #<<< + if {[winfo exists $topw]} { + set new [ttk::style lookup $ttk::currentTheme -background] + $topw configure -background $new + } +} +#>>> diff --git a/scripts/mywidget.itk b/scripts/mywidget.itk index b504d1d..787409e 100644 --- a/scripts/mywidget.itk +++ b/scripts/mywidget.itk @@ -27,7 +27,7 @@ body tlc::Mywidget::constructor {args} { #<<<1 bind tlc-delete-$w [code if "\[itcl::is object [list $this]\]" [list $this widget_destroyed]] bindtags $w [concat [list tlc-delete-$w] [bindtags $w]] - eval itk_initialize $args + itk_initialize {*}$args } diff --git a/scripts/radiogroup.itk b/scripts/radiogroup.itk index 00210c4..c891ad4 100644 --- a/scripts/radiogroup.itk +++ b/scripts/radiogroup.itk @@ -18,6 +18,11 @@ class tlc::Radiogroup { itk_option define -foreground foreground Foreground black need_rerender itk_option define -disabledforeground disabledForeground Foreground grey need_rerender itk_option define -pady padY PadY 0 + itk_option define -borderwidth borderWidth BorderWidth 2 need_rerender + itk_option define -relief relief Relief "groove" need_rerender + itk_option define -text text Text "" need_rerender + itk_option define -labelwidget labelWidget LabelWidget "" need_rerender + itk_option define -labelanchor labelAnchor LabelAnchor "" need_rerender public { variable state "normal" @@ -27,6 +32,7 @@ class tlc::Radiogroup { variable initial_value variable value "" variable wrap_len "" + variable text "" method domino_ref {domino} method attach_signal {key signal {sense normal}} @@ -67,11 +73,6 @@ configbody tlc::Radiogroup::pady { #<<<1 body tlc::Radiogroup::constructor {args} { #<<<1 log debug - if {[catch { - package require Tk 8.4 - } errmsg]} { - error "Need at least Tk 8.4 for Radiogroup" - } array set dominos {} array set toggles {} @@ -82,20 +83,11 @@ body tlc::Radiogroup::constructor {args} { #<<<1 tlc::Gate #auto signals(item_selected) -name "$w item_selected" \ -mode "or" -default 0 - itk_component add border { - ttk::labelframe $w.border - } { - keep -borderwidth -relief -text -labelanchor -labelwidget - } - - blt::table $w \ - $w.border 1,1 -fill both - set base $w.border.inner $dominos(need_rerender) attach_output [code $this rerender] - eval itk_initialize $args + itk_initialize {*}$args #if {0 && [$dominos(need_rerender) pending]} { # log debug "forcing rerender in constructor" @@ -117,12 +109,32 @@ body tlc::Radiogroup::constructor {args} { #<<<1 body tlc::Radiogroup::rerender {} { #<<<1 log debug $w + if {[winfo exists $w.border]} { + destroy $w.border + } + if {$itk_option(-text) ne "" || $itk_option(-labelwidget) ne ""} { + set options {} + foreach option {text labelanchor labelwidget} { + if {$itk_option(-$option) ne ""} { + lappend options -$option $itk_option(-$option) + } + } + ttk::labelframe $w.border \ + -borderwidth $itk_option(-borderwidth) \ + -relief $itk_option(-relief) \ + {*}$options + } else { + ttk::frame $w.border \ + -borderwidth $itk_option(-borderwidth) \ + -relief $itk_option(-relief) + } + pack $w.border -fill both -expand true + foreach key [array names toggles] { array unset toggles $key } array unset keymap array set keymap {} - catch {eval destroy [winfo children $w.border]} foreach signal [array names signals option_*] { array unset signals($signal) } @@ -166,8 +178,8 @@ body tlc::Radiogroup::rerender {} { #<<<1 set keymap($key) "$c,$r" - eval [list blt::table $base $base.$c,$r $r,$c] \ - $cell_args + blt::table $base $base.$c,$r $r,$c \ + {*}$cell_args incr seq } diff --git a/scripts/spinner.itcl b/scripts/spinner.itcl index aee9eef..a3caa73 100644 --- a/scripts/spinner.itcl +++ b/scripts/spinner.itcl @@ -117,36 +117,24 @@ body tlc::Spinner::constructor {args} { #<<<1 } # Initialize bitmaps >>> - # Border hacks <<< - $itk_component(border) configure \ - -highlightthickness 1 \ - -takefocus 1 \ - -highlightcolor black - tlc::StateToggle #auto toggles(border) $itk_component(border) \ - -takefocus {0 1} - $toggles(border) attach_signal [stategate_ref] - bind $itk_component(border).inner \ - [code focus $itk_component(border)] - # Border hacks >>> - # Entry <<< itk_component add entry { - entry $w.entry -borderwidth 0 -highlightthickness 0 -state disabled \ + ttk::entry $w.entry \ -validate all -validatecommand [code $this validate_input %P] } { keep -width rename -background -textbackground textBackground TextBackground } - set enabled_fg [$tlc::theme setting foreground] - set enabled_bg [$tlc::theme setting textbackground] - set disabled_fg [$tlc::theme setting disabledforeground] - set disabled_bg [$tlc::theme setting disabledbackground] - tlc::StateToggle #auto toggles(entry) $itk_component(entry) \ - -foreground [list $disabled_fg $enabled_fg] \ - -background [list $disabled_bg $enabled_bg] \ - -disabledforeground [list $disabled_fg $enabled_fg] \ - -disabledbackground [list $disabled_bg $enabled_bg] - $toggles(entry) attach_signal [stategate_ref] + $w.entry state readonly + [stategate_ref] attach_output [list apply { + {widget newstate} { + if {$newstate} { + $widget state !disabled + } else { + $widget state disabled + } + } + } $w.entry] # Entry >>> # Spin buttons <<< diff --git a/scripts/splash.itk b/scripts/splash.itk index ec69e9a..9adc88c 100644 --- a/scripts/splash.itk +++ b/scripts/splash.itk @@ -152,7 +152,7 @@ body tlc::Splash::rerender {} { #<<<1 configure -background $general(bg) } - wm overrideredirect $w 1 + wm overrideredirect [component hull] 1 center_on_screen } diff --git a/scripts/stategate_target.itcl b/scripts/stategate_target.itcl index 407acf4..34784fa 100644 --- a/scripts/stategate_target.itcl +++ b/scripts/stategate_target.itcl @@ -1,7 +1,7 @@ # vim: foldmarker=<<<,>>> class tlc::Stategate_target { - inherit itk::Widget + inherit tlc::TLCWidget constructor {} {} destructor {} @@ -60,6 +60,9 @@ body tlc::Stategate_target::constructor {} { #<<<1 $sg_gate attach_output [code $this stategate_update] #nasty_hack 2 + ttk::frame $itk_interior.wf + pack $itk_interior.wf -fill both -expand true + set itk_interior $itk_interior.wf } diff --git a/scripts/theme.itk b/scripts/theme.itk index ac63e55..f9e306d 100644 --- a/scripts/theme.itk +++ b/scripts/theme.itk @@ -175,7 +175,7 @@ body tlc::Theme::setting {tag} { #<<<1 selectborderwidth {return 0} texthighlightbackground {return "#d9d9d9"} hidebg {return "#d9d9d9"} - framerelief {return "sunken"} + framerelief {return "flat"} frameborderwidth {return 0} button_pady {return [expr {$::tcl_platform(platform) == "windows" ? 1 : 2}]} } diff --git a/scripts/wizard.itk b/scripts/wizard.itk index 28560fa..6bc1583 100644 --- a/scripts/wizard.itk +++ b/scripts/wizard.itk @@ -1,7 +1,7 @@ # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4 class tlc::Wizard { - inherit tlc::Mywidget tlc::Signalsource tlc::Baselog + inherit tlc::Mywidget tlc::Signalsource tlc::Handlers tlc::Baselog constructor {args} {} destructor {} @@ -14,9 +14,16 @@ class tlc::Wizard { variable startpage "" variable state "" variable oncancel {} + variable showhelp 0 + variable helpwidth 200 + variable helpstyles { + } + variable linkhandler {} method set_data {args} method get_data {args} + method reset {} + method unfinish {} } private { @@ -36,22 +43,44 @@ class tlc::Wizard { method try_load_page {op page} method cancel {} method html_escape {text} + method helpshown_changed {newstate} + method htmlclick {widget x y} + method busy_changed {newstate} } } +configbody tlc::Wizard::showhelp { #<<< + $signals(helpshown) set_state $showhelp +} + +#>>> +configbody tlc::Wizard::helpstyles { #<<< + $w.help.html style $helpstyles +} + +#>>> configbody tlc::Wizard::state { #<<< $signals(enabled) set_state [expr {$state eq "normal"}] } #>>> +configbody tlc::Wizard::helpwidth { #<<< + $w.help.html configure -width $helpwidth +} + +#>>> body tlc::Wizard::constructor {args} { #<<< + package require Tkhtml 3.0 + array set dat {} array set page_details {} array set routing_tables {} array set pagesignals {} tlc::Signal #auto signals(enabled) -name "$w enabled" + tlc::Signal #auto signals(helpshown) -name "$w helpshown" + tlc::Signal #auto signals(busy) -name "$w busy" tlc::Gate #auto signals(back) -mode "and" -name "$w back" tlc::Gate #auto signals(next) -mode "and" -name "$w next" @@ -73,7 +102,25 @@ body tlc::Wizard::constructor {args} { #<<< $signals(next) attach_input $signals(finished) inverted $signals(finish) attach_input $signals(finished) inverted - frame $w.page + $signals(back) attach_input $signals(busy) inverted + $signals(next) attach_input $signals(busy) inverted + $signals(finish) attach_input $signals(busy) inverted + + ttk::label $w.title -font [$tlc::theme setting hugefont] + + ttk::frame $w.page + + # Help info <<< + ttk::frame $w.help + html $w.help.html -yscrollcommand [list $w.help.vsb set] + myscrollbar_win32 $w.help.vsb -orient v -command [list $w.help.html yview] + + bind $w.help.html [code $this htmlclick $w.help.html %x %y] + blt::table $w.help \ + $w.help.html 1,1 -fill both \ + $w.help.vsb 1,2 -fill y + blt::table configure $w.help c2 -resize none + # Help info >>> Tools $w.ops -buttonwidth 9 $w.ops add "< Back" [code $this apply_action back] right @@ -86,9 +133,13 @@ body tlc::Wizard::constructor {args} { #<<< $w.ops attach_signal "Finish" $signals(finish) blt::table $w \ - $w.page 1,1 -fill both \ - $w.ops 2,1 -fill x -pady {5 0} - blt::table configure $w r2 -resize none + $w.title 1,2 -anchor w -pady {0 5} \ + $w.page 2,2 -fill both \ + $w.ops 3,2 -fill x -pady 5 -padx 5 + blt::table configure $w c1 r1 r3 -resize none + blt::table configure $w r1 r3 -resize none + + $signals(helpshown) attach_output [code $this helpshown_changed] itk_initialize {*}$args @@ -103,6 +154,8 @@ body tlc::Wizard::constructor {args} { #<<< } } + $signals(busy) attach_output [code $this busy_changed] + load_page $startpage } @@ -134,9 +187,11 @@ body tlc::Wizard::get_data {args} { #<<< #>>> body tlc::Wizard::load_page {page} { #<<< + log debug "enter" if {![info exists page_details($page)]} { error "No such page: $page" "" [list invalid_page $page] } + $signals(busy) set_state 1 $signals(back_defined) set_state [info exists routing_tables(back,$page)] $signals(next_defined) set_state [info exists routing_tables(next,$page)] @@ -147,12 +202,24 @@ body tlc::Wizard::load_page {page} { #<<< if {[info exists unload_page]} { eval $unload_page - unset inload_page + unset unload_page } if {[winfo exists $w.page.child]} { destroy $w.page.child } + $w.help.html reset + if {[dict exists $details help]} { + $w.help.html style $helpstyles + $w.help.html parse -final [dict get $details help] + } + + if {[dict exists $details title]} { + $w.title configure -text [dict get $details title] + } else { + $w.title configure -text "" + } + switch -- $d(type) { form {load_page_form $details} html {load_page_html $details} @@ -163,10 +230,13 @@ body tlc::Wizard::load_page {page} { #<<< } set current_page $page + $signals(busy) set_state 0 + log debug "leave" } #>>> body tlc::Wizard::load_page_form {details} { #<<< + log debug "enter" array set d { options {} } @@ -182,12 +252,16 @@ body tlc::Wizard::load_page_form {details} { #<<< blt::table $w.page \ $w.page.child 1,1 -fill both + + $w.page.child takefocus + log debug "leave" } #>>> body tlc::Wizard::load_page_html {details} { #<<< + log debug "enter" package require Tkhtml 3 - frame $w.page.child + ttk::frame $w.page.child html $w.page.child.html \ -xscrollcommand [code $w.page.child.hsb set] \ -yscrollcommand [code $w.page.child.vsb set] @@ -195,6 +269,7 @@ body tlc::Wizard::load_page_html {details} { #<<< -command [code $w.page.child.html xview] myscrollbar_win32 $w.page.child.vsb -orient v \ -command [code $w.page.child.html yview] + bind $w.page.child.html [code $this htmlclick $w.page.child.html %x %y] if {[dict exists $details styles]} { $w.page.child.html style [dict get $details styles] @@ -229,11 +304,14 @@ body tlc::Wizard::load_page_html {details} { #<<< blt::table $w.page \ $w.page.child 1,1 -fill both + log debug "leave" } #>>> body tlc::Wizard::apply_action {op} { #<<< + log debug "enter" if {![$signals($op) state]} return + $signals(busy) set_state 1 set expressions $routing_tables($op,$current_page) # TODO: Handle non-forms @@ -267,6 +345,7 @@ body tlc::Wizard::apply_action {op} { #<<< return } + $signals(busy) set_state 0 error "No routing actions specified that are applicable" "" \ [list no_matches] } @@ -278,15 +357,18 @@ body tlc::Wizard::finish {} { #<<< #>>> body tlc::Wizard::try_load_page {op page} { #<<< + log debug "enter" if {[info exists routing_tables(skip_if,$page)]} { if $routing_tables(skip_if,$page) { # TODO: handle finish + log debug "skipping because ($routing_tables(skip_if,$page)) is false" set current_page $page apply_action $op return } } load_page $page + log debug "leave" } #>>> @@ -294,13 +376,18 @@ body tlc::Wizard::cancel {} { #<<< if {$oncancel ne {}} { uplevel #0 $oncancel } else { - array unset dat - array set dat {} - load_page $startpage + reset } } #>>> +body tlc::Wizard::reset {} { #<<< + array unset dat + array set dat {} + load_page $startpage +} + +#>>> body tlc::Wizard::html_escape {text} { #<<< return [string map { \xa0   \xa1 ¡ \xa2 ¢ \xa3 £ \xa4 ¤ @@ -361,3 +448,39 @@ body tlc::Wizard::html_escape {text} { #<<< } #>>> +body tlc::Wizard::helpshown_changed {newstate} { #<<< + if {$newstate} { + blt::table $w \ + $w.help 1,1 -rspan 3 -fill both + } else { + if {"$w.help" in [blt::table search $w]} { + blt::table forget $w.help + } + } +} + +#>>> +body tlc::Wizard::htmlclick {widget x y} { #<<< + set raw [$widget node -index $x $y] + if {$raw eq ""} return + + lassign $raw node byteoffset + set parent [$node parent] + if {[string tolower [$parent tag]] ne "a"} return + set href [$parent attribute -default "" href] + if {$href eq ""} return + + invoke_handlers html_link_clicked $href +} + +#>>> +body tlc::Wizard::unfinish {} { #<<< + $signals(finished) set_state 0 +} + +#>>> +body tlc::Wizard::busy_changed {newstate} { #<<< + log debug +} + +#>>> diff --git a/setup.iss b/setup.iss deleted file mode 100644 index b7b0384..0000000 --- a/setup.iss +++ /dev/null @@ -1,46 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -; -; $Log: setup.iss,v $ -; Revision 1.2 2004/12/30 11:25:31 cvs -; Spring cleaning in prep for sourceforge cvs import -; -; Revision 1.1.1.1 2003/04/22 11:10:05 root -; Imported -; -; -; Revision 1.7 2002/05/23 13:17:28 cyan -; Fixed Mylistbox behaviour with > -maxitems items -; -; Revision 1.6 2002/05/23 11:50:24 cyan -; Fixed form bug -; -; Revision 1.5 2002/05/13 15:50:31 cyan -; Fixed an incorrect delete class -; -; Revision 1.4 2002/05/13 15:33:20 cyan -; Bumped the version to 0.10.0 - includes the Mytoplevel widget and Module changes -; -; - -[Setup] -AppName=TLC -AppVerName=TLC 0.31.0 -OutputBaseFilename=tlc-0.31.0 -AppPublisher=Ogilvie Consulting -AppPublisherURL=http://sf.net/projects/tlc-tcl -AppSupportURL=http://sf.net/projects/tlc-tcl -AppUpdatesURL=http://sf.net/projects/tlc-tcl -DefaultDirName=C:\Tcl\lib\TLC -DefaultGroupName=TLC -AllowNoIcons=yes -AlwaysCreateUninstallIcon=yes -; uncomment the following line if you want your installation to run on NT 3.51 too. -; MinVersion=4,3.51 - -[Files] -Source: "tlc-base.tcl"; DestDir: "{app}"; CopyMode: alwaysoverwrite -Source: "tlc.tcl"; DestDir: "{app}"; CopyMode: alwaysoverwrite -Source: "pkgIndex.tcl"; DestDir: "{app}"; CopyMode: alwaysoverwrite -Source: "scripts\*.*"; DestDir: "{app}\scripts"; CopyMode: alwaysoverwrite -Source: "scripts\images\*.*"; DestDir: "{app}\scripts\images"; CopyMode: alwaysoverwrite diff --git a/teapot.txt b/teapot.txt index 8a43e7e..72fd9b4 100644 --- a/teapot.txt +++ b/teapot.txt @@ -1,4 +1,4 @@ -Package TLC 0.96.0 +Package TTLC 0.96.0 Meta description Meta entrysource init.tcl Meta included pkgIndex.tcl init.tcl scripts/tclIndex scripts/*.itcl -- 2.11.4.GIT