Improved metadirective handling
[tcl-tlc.git] / scripts / infowin.itk
blob7edcae5564fc0cd3afdc634f0fdfdb3dd733e58f
1 # vim: foldmarker=<<<,>>>
3 class tlc::Infowin {
4         inherit tlc::Modal
6         constructor {args} {}
8         public {
9                 variable                type    "info"          set_icon
11                 method display {msg args}
12         }
14         private {
15                 method set_icon {}
16         }
20 body tlc::Infowin::constructor {args} { #<<<1
21         option add *$wdb*Button.width                           12      widgetDefault
22         option add *$wdb*Button.highlightThickness      1
23         option add *$wdb*Button.takeFocus                       1
25         label $w.icon
27         message $w.msg -justify left -width 400
29         eval itk_initialize $args
30         set_icon
32         $::tlc::theme register_handler onchange [code $this set_icon]
36 body tlc::Infowin::display {msg args} { #<<<1
37         if {[llength $args] == 0} {
38                 set args        "OK"
39         }
41         $w.msg configure -text $msg
43         if {[winfo exists $w.tools]} {
44                 destroy $w.tools
45         }
47         Tools $w.tools 
48         foreach button $args {
49                 $w.tools add $button [code $this choose $button]
50         }
51         
52         blt::table $w -padx 5 -pady 5 \
53                 $w.icon         1,1 \
54                 $w.msg          1,2 -padx {10 0} -fill x \
55                 $w.tools        2,1 -cspan 2 -pady {8 0}
56         blt::table configure $w c1 r2 -resize none
57         
58         $w.tools item_focus [lindex $args 0]
60         waitresult
61         
62         return $result
66 body tlc::Infowin::set_icon {} { #<<<1
67         switch -- $type {
68                 "exclamation" {
69                         set image       [$::tlc::theme get_icon exclaimation]
70                 }
72                 default {
73                         set image       [$::tlc::theme get_icon info]
74                 }
75         }
76         
77         $w.icon configure -image $image