1 # vim: foldmarker=<<<,>>>
3 option add *Dateentry.labelBorderwidth 2 widgetDefault
4 option add *Dateentry.labelRelief sunken widgetDefault
5 option add *Dateentry.labelWidth 14 widgetDefault
6 option add *Dateentry.anchor nw widgetDefault
7 option add *Dateentry.buttonBorderwidth 1 widgetDefault
8 option add *Dateentry.resultFormat "%d/%m/%Y" widgetDefault
10 class tlc::Dateentry {
11 inherit tlc::Mywidget tlc::Handlers tlc::Textvariable
15 itk_option define -command command Command {}
16 itk_option define -state state State "normal"
17 itk_option define -textbackground textBackground TextBackground white
20 method rerender_dom_ref {}
25 method textvariable_changed {newvalue}
31 method request_lookup {}
32 method newselection {newdate}
37 configbody tlc::Dateentry::textbackground { #<<<1
38 if {$itk_option(-state) != "disabled"} {
39 $w.label configure -background $itk_option(-textbackground)
44 configbody tlc::Dateentry::state { #<<<1
45 log debug "$w -state reconfigured: ($itk_option(-state))"
47 $w.label configure -background \
48 [expr {$itk_option(-state) == "disabled" ? \
49 $::tlc::config(disabledbackground) : $::tlc::config(textbackground)}]
50 $w.label configure -foreground \
51 [expr {$itk_option(-state) == "disabled" ? \
52 $::tlc::config(disabledforeground) : $::tlc::config(enabledforeground)}]
56 body tlc::Dateentry::constructor {args} { #<<<1
58 itk_component add label {
59 ttk::entry $w.label -textvariable [scope date]
61 rename -width -labelwidth labelWidth LabelWidth
64 $w.label state readonly
65 bind $w.label <Button-1> [code $this request_lookup]
67 itk_component add button {
68 Datelookup $w.datelookup -newselection [code $this newselection]
72 keep -resultformat -special_cb
73 keep -validfrom -validto -state
78 eval itk_initialize $args
81 $w.label 1,1 -fill x \
82 $w.datelookup 1,2 -anchor e -pady {0 1}
83 table configure $w r1 c2 -resize none
87 body tlc::Dateentry::request_lookup {} { #<<<1
89 if {$itk_option(-state) != "disabled"} {
97 body tlc::Dateentry::newselection {newdate} { #<<<1
100 set_textvariable $date
101 if {$itk_option(-command) != ""} {
102 uplevel #0 $itk_option(-command) [list $newdate]
104 invoke_handlers onselect [list $newdate]
108 body tlc::Dateentry::rerender_dom_ref {} { #<<<1
109 return [[[$w.datelookup component popup] component calendar] rerender_dom_ref]
113 body tlc::Dateentry::textvariable_changed {newvalue} { #<<<1
119 body tlc::Dateentry::get_date {} { #<<<1