.
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:06:48 am'!
OrderedCollection subclass:#RadioButtonGroup
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Views-Support'
!
RadioButtonGroup comment:'
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
$Header: /cvs/stx/stx/libwidg/Attic/RButtGrp.st,v 1.10 1995-04-11 16:24:11 claus Exp $
'!
!RadioButtonGroup class methodsFor:'documentation '!
copyright
"
COPYRIGHT (c) 1991 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
version
"
$Header: /cvs/stx/stx/libwidg/Attic/RButtGrp.st,v 1.10 1995-04-11 16:24:11 claus Exp $
"
!
documentation
"
RadioButtonGroups control the interaction between RadioButtons
turning off other button(s) when one of the group is pressed.
To group some buttons (and have one-on behavior) use:
|g|
g := RadioButtonGroup new.
...
b1 := RadioButton label:....
g add:b1
...
b2 := RadioButton label:....
g add:b2
...
example (using Toggles for 'at most one-on behavior'):
|top panel toggle b g|
top := StandardSystemView new.
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
g := RadioButtonGroup new.
b := Toggle label:'one' in:panel.
g add:b.
b := Toggle label:'two' in:panel.
g add:b.
b := Toggle label:'three' in:panel.
g add:b.
top extent:(panel preferedExtent).
top open.
example (using RadioButtons for 'one-on behavior'):
|top panel toggle b g|
top := StandardSystemView new.
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
g := RadioButtonGroup new.
b := RadioButton label:'one' in:panel.
g add:b.
b := RadioButton label:'two' in:panel.
g add:b.
b := RadioButton label:'three' in:panel.
g add:b.
top extent:(panel preferedExtent).
top open.
example (same, with button 'two' initially on):
|top panel toggle b g|
top := StandardSystemView new.
panel := HorizontalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
g := RadioButtonGroup new.
b := RadioButton label:'one' in:panel.
g add:b.
b := RadioButton label:'two' in:panel.
g add:b.
b turnOn.
b := RadioButton label:'three' in:panel.
g add:b.
top extent:(panel preferedExtent).
top open.
"
! !
!RadioButtonGroup methodsFor:'adding / removing'!
add:aRadioButton
super add:aRadioButton.
aRadioButton model:self; change:#elementChanged:from:.
"/ aRadioButton addDependent:self.
(aRadioButton respondsTo:#group) ifTrue:[aRadioButton group:self]
! !
!RadioButtonGroup methodsFor:'update'!
update:something with:someArgument from:changedButton
(self includes:changedButton) ifFalse:[^ self].
"a RadioButton in this group has changed - notify the others"
"/ "in case we have a toggle in the group,
"/ and it has been turned off - turn it on again
"/ "
"/ changedButton isOn ifFalse:[
"/ changedButton toggleNoAction.
"/ ^ self
"/ ].
self do:[:aButton |
(aButton == changedButton) ifFalse:[
aButton isOn ifTrue:[
aButton turnOff
]
]
]
!
elementChanged:aToggle
self do:[:aButton |
(aButton == aToggle) ifFalse:[
aButton isOn ifTrue:[
aButton turnOff
]
]
]
!
elementChanged:newValue from:aToggle
self do:[:aButton |
(aButton == aToggle) ifFalse:[
aButton isOn ifTrue:[
aButton turnOff
]
]
]
! !