1 # vim: foldmarker=<<<,>>>
3 option add *Formdialog.padding 2 widgetDefault
4 option add *Formdialog.frameRelief groove widgetDefault
5 option add *Formdialog.frameBorderwidth 2 widgetDefault
6 option add *Formdialog.formIPadX 5 widgetDefault
7 option add *Formdialog.formIPadY 3 widgetDefault
9 proc tlc::formdialog {pathName args} {
10 uplevel tlc::Formdialog $pathName $args
14 class tlc::Formdialog {
20 # Equivalence the old hack for setting tlc::Border's settings
21 itk_option define -formrelief formRelief Relief "groove" {
22 $w.form configure -framerelief $itk_option(-formrelief)
24 itk_option define -formborderwidth formBorderwidth Borderwidth 2 {
25 $w.form configure -frameborderwidth $itk_option(-formborderwidth)
29 variable mode "inline"
33 method ask {arrayvar args}
34 method set_tips {args} {return [eval [list $w.form set_tips] $args]}
35 method get_data {args} {return [eval [list $w.form get_data] $args]}
39 method form_valid_changed {isvalid reasons}
44 configbody tlc::Formdialog::name { #<<<1
45 $w.form configure -name $name
49 configbody tlc::Formdialog::preface { #<<<1
50 set preface [string trim $preface]
52 if {[winfo exists $w.preface]} {
53 blt::table forget $w.preface
56 blt::table configure $w r1 -height 0
58 if {[winfo exists $w.preface]} {
59 $w.preface configure -text $preface
61 message $w.preface -text $preface -aspect 200
62 blt::table $w $w.preface 1,1 -anchor nw -pady {0 8}
67 body tlc::Formdialog::constructor {args} { #<<<1
68 option add $wdb*Button.width 12 widgetDefault
70 itk_component add form {
73 keep -padding -tooltipdelay -tooltiptimeout -winding
74 #rename -relief -formrelief formRelief FormRelief
75 #rename -borderwidth -formborderwidth formBorderWidth FormBorderWidth
76 keep -framerelief -frameborderwidth
77 rename -ipadx -formipadx formIPadX FormIPadX
78 rename -ipady -formipady formIPadY FormIPadY
80 $w.form register_handler valid_status_changed [code $this form_valid_changed]
82 $w.tools add "OK" [code $this choose 1] right
83 $w.tools add "Cancel" [code $this choose 0] right
85 $w.tools attach_signal "OK" [$w.form signal_ref form_valid]
87 $w.form force_form_valid_update
89 blt::table $w -padx 5 -pady 5 \
91 $w.tools 3,1 -fill x -pady {5 0}
92 blt::table configure $w r1 r3 -resize none
94 eval itk_initialize $args
98 body tlc::Formdialog::destructor {} { #<<<1
99 if {[winfo exists $w.form]} {delete object $w.form}
103 body tlc::Formdialog::ask {arrayvar args} { #<<<1
105 if {![info exists arr]} {
109 if {![array exists arr]} {
110 error "$arrayvar is not an array"
115 $w.form configure -schema [lindex $args 0]
119 $w.form configure -schema $args
124 $w.form set_data [array get arr]
131 array set arr [$w.form get_data]
138 body tlc::Formdialog::form_valid_changed {isvalid reasons} { #<<<1
140 $w.tools set_tips "OK" ""
142 #puts stderr [[$w.form signal_ref form_valid] explain_txt]
143 $w.tools set_tips "OK" [join $reasons \n]