Added MDT::child_base method to get the path base for adding children to the tabset
[tcl-tlc.git] / scripts / combobox.itk
blob0ccb937b372edfa1763fc70aba9e9b1187959717
1 # vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
3 # TODO: reassess signals(valid) when the contents changes (set method, typing, etc)
5 class tlc::Combobox {
6         inherit tlc::Mywidget tlc::Baselog tlc::Signalsource tlc::Handlers
8         constructor {args} {}
9         destructor {}
11         public {
12                 variable state                  {}
13                 variable readonly               1
14                 variable initialvalue   ""
16                 method state {args} {return [$w.c state {*}$args]}
17                 method instate {args} {return [$w.c instate {*}$args]}
18                 method get {} {return [$w.c get]}
19                 method set {} {return [$w.c set]}
20                 method current {args} {return [$w.c current {*}$args]}
21         }
23         private {
24                 method newselection {}
25         }
29 configbody tlc::Combobox::initialvalue { #<<<
30         $w.c set $initialvalue
33 #>>>
34 configbody tlc::Combobox::state { #<<<
35         ::set states    {}
36         if {"disabled" in $state} {
37                 lappend states  "disabled"
38         } else {
39                 lappend states  "!disabled"
40         }
42         $w.c state $states
45 #>>>
46 configbody tlc::Combobox::readonly { #<<<
47         if {"readonly" in $state} {
48                 lappend states  "readonly"
49         } else {
50                 lappend states  "!readonly"
51         }
52         $w.c state $states
55 #>>>
56 body tlc::Combobox::constructor {args} { #<<<
57         tlc::Signal #auto signals(valid) -name "$w valid"
59         itk_component add combobox {
60                 ttk::combobox $w.c
61         } {
62                 keep -values -exportselection -justify -height -postcommand
63                 keep -textvariable -width
64         }
65         itk_initialize {*}$args
67         pack $w.c -fill both -expand true
69         $signals(valid) set_state [expr {[$w.c current] != -1}]
71         bind $w.c <<ComboboxSelected>> [code $this newselection]
74 #>>>
75 body tlc::Combobox::destructor {} { #<<<
78 #>>>
79 body tlc::Combobox::newselection {} { #<<<
80         $signals(valid) set_state [expr {[$w.c current] != -1}]
81         invoke_handlers onselect [$w.c get]
84 #>>>