Fixes
[tcl-tlc.git] / scripts / label_link.itk
blobfcfe1d93f7fa910e1569ecfd8a39f9ab59926003
1 # vim: foldmarker=<<<,>>>
3 #option add *Label_link.linkColour      blue    widgetDefault
4 #option add *Label_link.linkActive      red             widgetDefault
6 class tlc::Label_link {
7         inherit tlc::Mywidget
9         constructor {args} {}
11         itk_option define -linkcolour linkColour LinkColour "blue"
12         itk_option define -linkactive linkActive LinkActive "red"
13         itk_option define -linkdisabled linkDisabled LinkDisabled $::tlc::config(disabledbackground)
14         itk_option define -linkfont linkFont LinkFont [lreplace $::tlc::config(normalfont) 2 2 {underline italic bold}]
16         public {
17                 variable target         ""
18                 variable uri_reg        "tlc::uri"
19                 variable state          "normal"                update_fg
21                 method invoke {}
22         }
24         public {
25                 variable active
27                 method enter {}
28                 method leave {}
29                 method update_fg {args}
30         }
34 configbody tlc::Label_link::linkfont { #<<<1
35         $w.link configure -font $itk_option(-linkfont)
39 body tlc::Label_link::constructor {args} { #<<<1
40         Signal #auto active -name "$this active"
42         itk_component add label {
43                 label $w.link
44         } {
45                 usual
46                 keep -text
47                 ignore -foreground
48                 rename -background -linkbackground linkBackground LinkBackground
49         }
50         bind $w.link <Button-1> [code $this invoke]
51         bind $w.link <Enter> [code $this enter]
52         bind $w.link <Leave> [code $this leave]
54         eval itk_initialize $args
56         $active attach_output [code $this update_fg]
58         table $w \
59                         $w.link 1,1 -fill x
63 body tlc::Label_link::invoke {} { #<<<1
64         if {$state != "disabled"} {
65                 $uri_reg dispatch $target
66         }
70 body tlc::Label_link::enter {} { #<<<1
71         $active set_state 1
75 body tlc::Label_link::leave {} { #<<<1
76         $active set_state 0
80 body tlc::Label_link::update_fg {args} { #<<<1
81         if {$state == "disabled"} {
82                 $w.link configure -foreground $itk_option(-linkdisabled)
83         } else {
84                 if {[$active state]} {
85                         $w.link configure -foreground $itk_option(-linkactive)
86                 } else {
87                         $w.link configure -foreground $itk_option(-linkcolour)
88                 }
89         }