0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
105
|
13 |
'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:06:48 am'!
|
|
14 |
|
7
|
15 |
OrderedCollection subclass:#RadioButtonGroup
|
59
|
16 |
instanceVariableNames:''
|
|
17 |
classVariableNames:''
|
|
18 |
poolDictionaries:''
|
|
19 |
category:'Views-Support'
|
0
|
20 |
!
|
|
21 |
|
|
22 |
RadioButtonGroup comment:'
|
5
|
23 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
24 |
All Rights Reserved
|
0
|
25 |
|
130
|
26 |
$Header: /cvs/stx/stx/libwidg/RadioButtonGroup.st,v 1.11 1995-06-06 04:14:48 claus Exp $
|
38
|
27 |
'!
|
|
28 |
|
|
29 |
!RadioButtonGroup class methodsFor:'documentation '!
|
|
30 |
|
|
31 |
copyright
|
|
32 |
"
|
|
33 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
34 |
All Rights Reserved
|
0
|
35 |
|
38
|
36 |
This software is furnished under a license and may be used
|
|
37 |
only in accordance with the terms of that license and with the
|
|
38 |
inclusion of the above copyright notice. This software may not
|
|
39 |
be provided or otherwise made available to, or used by, any
|
|
40 |
other person. No title to or ownership of the software is
|
|
41 |
hereby transferred.
|
|
42 |
"
|
|
43 |
!
|
|
44 |
|
|
45 |
version
|
|
46 |
"
|
130
|
47 |
$Header: /cvs/stx/stx/libwidg/RadioButtonGroup.st,v 1.11 1995-06-06 04:14:48 claus Exp $
|
38
|
48 |
"
|
|
49 |
!
|
|
50 |
|
|
51 |
documentation
|
|
52 |
"
|
|
53 |
RadioButtonGroups control the interaction between RadioButtons
|
|
54 |
turning off other button(s) when one of the group is pressed.
|
63
|
55 |
To group some buttons (and have one-on behavior) use:
|
|
56 |
|
|
57 |
|g|
|
|
58 |
|
|
59 |
g := RadioButtonGroup new.
|
|
60 |
...
|
|
61 |
b1 := RadioButton label:....
|
|
62 |
g add:b1
|
|
63 |
...
|
|
64 |
b2 := RadioButton label:....
|
|
65 |
g add:b2
|
|
66 |
...
|
116
|
67 |
|
|
68 |
example (using Toggles for 'at most one-on behavior'):
|
|
69 |
|
|
70 |
|top panel toggle b g|
|
|
71 |
|
|
72 |
top := StandardSystemView new.
|
|
73 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
74 |
g := RadioButtonGroup new.
|
|
75 |
b := Toggle label:'one' in:panel.
|
|
76 |
g add:b.
|
|
77 |
b := Toggle label:'two' in:panel.
|
|
78 |
g add:b.
|
|
79 |
b := Toggle label:'three' in:panel.
|
|
80 |
g add:b.
|
130
|
81 |
top extent:(panel preferredExtent).
|
116
|
82 |
top open.
|
|
83 |
|
|
84 |
example (using RadioButtons for 'one-on behavior'):
|
|
85 |
|
|
86 |
|top panel toggle b g|
|
|
87 |
|
|
88 |
top := StandardSystemView new.
|
|
89 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
90 |
g := RadioButtonGroup new.
|
|
91 |
b := RadioButton label:'one' in:panel.
|
|
92 |
g add:b.
|
|
93 |
b := RadioButton label:'two' in:panel.
|
|
94 |
g add:b.
|
|
95 |
b := RadioButton label:'three' in:panel.
|
|
96 |
g add:b.
|
130
|
97 |
top extent:(panel preferredExtent).
|
116
|
98 |
top open.
|
|
99 |
|
|
100 |
example (same, with button 'two' initially on):
|
|
101 |
|
|
102 |
|top panel toggle b g|
|
|
103 |
|
|
104 |
top := StandardSystemView new.
|
|
105 |
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
106 |
g := RadioButtonGroup new.
|
|
107 |
b := RadioButton label:'one' in:panel.
|
|
108 |
g add:b.
|
|
109 |
b := RadioButton label:'two' in:panel.
|
|
110 |
g add:b.
|
|
111 |
b turnOn.
|
|
112 |
b := RadioButton label:'three' in:panel.
|
|
113 |
g add:b.
|
130
|
114 |
top extent:(panel preferredExtent).
|
116
|
115 |
top open.
|
38
|
116 |
"
|
|
117 |
! !
|
0
|
118 |
|
|
119 |
!RadioButtonGroup methodsFor:'adding / removing'!
|
|
120 |
|
|
121 |
add:aRadioButton
|
|
122 |
super add:aRadioButton.
|
130
|
123 |
aRadioButton model:self; changeMessage:#elementChanged:from:.
|
105
|
124 |
"/ aRadioButton addDependent:self.
|
|
125 |
(aRadioButton respondsTo:#group) ifTrue:[aRadioButton group:self]
|
0
|
126 |
! !
|
|
127 |
|
|
128 |
!RadioButtonGroup methodsFor:'update'!
|
|
129 |
|
59
|
130 |
update:something with:someArgument from:changedButton
|
|
131 |
(self includes:changedButton) ifFalse:[^ self].
|
|
132 |
|
0
|
133 |
"a RadioButton in this group has changed - notify the others"
|
|
134 |
|
105
|
135 |
"/ "in case we have a toggle in the group,
|
|
136 |
"/ and it has been turned off - turn it on again
|
|
137 |
"/ "
|
|
138 |
"/ changedButton isOn ifFalse:[
|
|
139 |
"/ changedButton toggleNoAction.
|
|
140 |
"/ ^ self
|
|
141 |
"/ ].
|
|
142 |
self do:[:aButton |
|
116
|
143 |
(aButton == changedButton) ifFalse:[
|
|
144 |
aButton isOn ifTrue:[
|
|
145 |
aButton turnOff
|
|
146 |
]
|
|
147 |
]
|
105
|
148 |
]
|
|
149 |
!
|
|
150 |
|
|
151 |
elementChanged:aToggle
|
0
|
152 |
self do:[:aButton |
|
116
|
153 |
(aButton == aToggle) ifFalse:[
|
|
154 |
aButton isOn ifTrue:[
|
|
155 |
aButton turnOff
|
|
156 |
]
|
|
157 |
]
|
0
|
158 |
]
|
105
|
159 |
!
|
0
|
160 |
|
105
|
161 |
elementChanged:newValue from:aToggle
|
|
162 |
self do:[:aButton |
|
116
|
163 |
(aButton == aToggle) ifFalse:[
|
|
164 |
aButton isOn ifTrue:[
|
|
165 |
aButton turnOff
|
|
166 |
]
|
|
167 |
]
|
105
|
168 |
]
|
0
|
169 |
! !
|
105
|
170 |
|