added left-right orientation.
SimpleView subclass:#UpDownButton
instanceVariableNames:'orientation upButton downButton'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
!
!UpDownButton class methodsFor:'documentation'!
documentation
"
an up/down button - simply two buttons in one view.
[author:]
Claus Gittinger
[see also:]
ArrowButton
ComboUpDownView
"
!
examples
"
[exBegin]
|top ud|
top := StandardSystemView new.
top extent:(300 @ 200).
ud := UpDownButton in:top.
ud origin:(10 @ 10).
ud upAction:[Transcript showCR:'up'].
ud downAction:[Transcript showCR:'down'].
top open.
[exEnd]
[exBegin]
|top ud|
top := StandardSystemView new.
top extent:(300 @ 200).
ud := UpDownButton in:top.
ud orientation:#horizontal.
ud origin:(10 @ 10).
ud upAction:[Transcript showCR:'up'].
ud downAction:[Transcript showCR:'down'].
top open.
[exEnd]
"
! !
!UpDownButton class methodsFor:'defaults'!
downButtonForm
"return the down-buttons image"
<resource: #style (#upDownButtonDownForm #upDownButtonDownFormFile)>
|fileName form|
form := StyleSheet at:'upDownButtonDownForm' default:nil.
form isNil ifTrue:[
fileName := StyleSheet at:'upDownButtonDownFormFile' default:'ComboDnB_win.xbm'.
form := Image fromFile:fileName.
].
form isNil ifTrue:[
form := Form width:16 height:7
fromArray:#[
2r00000000 2r00000000
2r00111111 2r11111100
2r00011111 2r11111000
2r00001111 2r11110000
2r00000111 2r11100000
2r00000011 2r11000000
2r00000001 2r10000000
]
on:Display.
].
form notNil ifTrue:[
^ form on:Display
].
^ nil
"Created: 1.4.1997 / 11:53:39 / cg"
"Modified: 1.4.1997 / 11:54:17 / cg"
!
leftButtonForm
"return the left-buttons image"
<resource: #style (#upDownButtonLeftForm #upDownButtonLeftFormFile)>
|fileName form|
form := StyleSheet at:'upDownButtonLeftForm' default:nil.
form isNil ifTrue:[
fileName := StyleSheet at:'upDownButtonLeftFormFile' default:'ComboLtB_win.xbm'.
form := Image fromFile:fileName.
].
form isNil ifTrue:[
form := Form width:7 height:16
fromArray:#[
2r00000000
2r00000000
2r00000100
2r00001100
2r00011100
2r00111100
2r01111100
2r11111100
2r11111100
2r01111100
2r00111100
2r00011100
2r00001100
2r00000100
2r00000000
2r00000000
]
on:Display.
].
form notNil ifTrue:[
^ form on:Display
].
^ nil
"Created: 1.4.1997 / 12:39:18 / cg"
"Modified: 1.4.1997 / 12:45:58 / cg"
!
rightButtonForm
"return the left-buttons image"
<resource: #style (#upDownButtonRightForm #upDownButtonRightFormFile)>
|fileName form|
form := StyleSheet at:'upDownButtonRightForm' default:nil.
form isNil ifTrue:[
fileName := StyleSheet at:'upDownButtonRightFormFile' default:'ComboRtB_win.xbm'.
form := Image fromFile:fileName.
].
form isNil ifTrue:[
form := Form width:7 height:16
fromArray:#[
2r00000000
2r00000000
2r01000000
2r01100000
2r01110000
2r01111000
2r01111100
2r01111110
2r01111110
2r01111100
2r01111000
2r01110000
2r01100000
2r01000000
2r00000000
2r00000000
]
on:Display.
].
form notNil ifTrue:[
^ form on:Display
].
^ nil
"Modified: 1.4.1997 / 11:54:17 / cg"
"Created: 1.4.1997 / 12:39:34 / cg"
!
upButtonForm
"return the up-buttons image"
<resource: #style (#upDownButtonUpForm #upDownButtonUpFormFile)>
|fileName form|
form := StyleSheet at:'upDownButtonUpForm' default:nil.
form isNil ifTrue:[
fileName := StyleSheet at:'upDownButtonUpFormFile' default:'ComboUpB_win.xbm'.
form := Image fromFile:fileName.
].
form isNil ifTrue:[
form := Form width:16 height:7
fromArray:#[
2r00000001 2r10000000
2r00000011 2r11000000
2r00000111 2r11100000
2r00001111 2r11110000
2r00011111 2r11111000
2r00111111 2r11111100
2r00000000 2r00000000
]
on:Display.
].
form notNil ifTrue:[
^ form on:Display
].
^ nil
"Modified: 29.3.1997 / 11:36:55 / cg"
"Created: 1.4.1997 / 11:54:13 / cg"
! !
!UpDownButton methodsFor:'accessing-behavior'!
downAction:aBlock
downButton action:aBlock
"Created: 1.4.1997 / 11:56:33 / cg"
!
upAction:aBlock
upButton action:aBlock
"Created: 1.4.1997 / 11:56:28 / cg"
! !
!UpDownButton methodsFor:'accessing-components'!
downButton
^ downButton
"Created: 1.4.1997 / 11:56:05 / cg"
!
upButton
^ upButton
"Created: 1.4.1997 / 11:55:52 / cg"
"Modified: 1.4.1997 / 11:56:02 / cg"
! !
!UpDownButton methodsFor:'accessing-look'!
orientation
^ orientation
"Created: 1.4.1997 / 12:42:01 / cg"
!
orientation:aSymbol
orientation := aSymbol.
self initializeButtonDimensions
"Created: 1.4.1997 / 12:42:17 / cg"
"Modified: 1.4.1997 / 12:42:29 / cg"
! !
!UpDownButton methodsFor:'initialization'!
initialize
orientation := #vertical.
super initialize.
self initializeButtons
"Created: 1.4.1997 / 11:58:07 / cg"
"Modified: 1.4.1997 / 12:47:58 / cg"
!
initializeButtonDimensions
orientation == #vertical ifTrue:[
upButton label:(self class upButtonForm).
downButton label:(self class downButtonForm).
upButton origin:0@0.
downButton origin:(0 @ upButton preferredExtent y).
self preferredExtent:(upButton preferredExtent x
@
(upButton preferredExtent y
+
downButton preferredExtent y)).
] ifFalse:[
upButton label:(self class rightButtonForm).
downButton label:(self class leftButtonForm).
downButton origin:0@0.
upButton origin:(downButton preferredExtent x @ 0).
self preferredExtent:((upButton preferredExtent x
+
downButton preferredExtent x)
@
upButton preferredExtent y).
].
"Modified: 1.4.1997 / 12:47:38 / cg"
!
initializeButtons
upButton := ArrowButton upIn:self.
upButton action:[self countUp].
upButton autoRepeat:true.
downButton := ArrowButton downIn:self.
downButton action:[self countDown].
downButton autoRepeat:true.
self initializeButtonDimensions
"Modified: 1.4.1997 / 12:42:58 / cg"
! !
!UpDownButton class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.2 1997-04-01 10:48:24 cg Exp $'
! !