--- a/UpDownButton.st Wed Feb 25 15:56:07 1998 +0100
+++ b/UpDownButton.st Wed Feb 25 22:39:49 1998 +0100
@@ -1,6 +1,6 @@
SimpleView subclass:#UpDownButton
instanceVariableNames:'orientation upButton downButton'
- classVariableNames:'DefaultDownForm DefaultUpForm DefaultLeftForm DefaultRightForm'
+ classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
!
@@ -54,263 +54,88 @@
! !
-!UpDownButton class methodsFor:'defaults'!
-
-downButtonForm
- "return the down-buttons image"
-
- <resource: #style (#upDownButton.downForm #upDownButton.downFormFile)>
-
- |fileName form|
-
- DefaultDownForm notNil ifTrue:[
- ^ DefaultDownForm
- ].
-
- form := StyleSheet at:'upDownButton.downForm' default:nil.
- form isNil ifTrue:[
- fileName := StyleSheet at:'upDownButton.downFormFile' default:'ComboDnB_win.xbm'.
- form := Image fromFile:fileName.
- ].
- form isNil ifTrue:[
- form := Form width:10 height:6
- fromArray:#[
- 2r00000000 2r00000000
- 2r01111111 2r10000000
- 2r00111111 2r00000000
- 2r00011110 2r00000000
- 2r00001100 2r00000000
- 2r00000000 2r00000000
- ]
- on:Display.
- ].
- form notNil ifTrue:[
- DefaultDownForm := form.
- ^ form onDevice:Display
- ].
- ^ nil
-
- "Created: / 1.4.1997 / 11:53:39 / cg"
- "Modified: / 25.10.1997 / 14:24:20 / cg"
- "Modified: / 8.1.1998 / 16:33:54 / stefan"
-!
-
-leftButtonForm
- "return the left-buttons image"
-
- <resource: #style (#upDownButton.leftForm #upDownButton.leftFormFile)>
-
- |fileName form|
-
- DefaultLeftForm notNil ifTrue:[
- ^ DefaultLeftForm
- ].
-
- form := StyleSheet at:'upDownButton.leftForm' default:nil.
- form isNil ifTrue:[
- fileName := StyleSheet at:'upDownButton.leftFormFile' default:'ComboLtB_win.xbm'.
- form := Image fromFile:fileName.
- ].
- form isNil ifTrue:[
- form := Form width:6 height:10
- fromArray:#[
- 2r00000000
- 2r00001000
- 2r00011000
- 2r00111000
- 2r01111000
- 2r01111000
- 2r00111000
- 2r00011000
- 2r00001000
- 2r00000000
- ]
- on:Display.
- ].
- form notNil ifTrue:[
- DefaultLeftForm := form.
- ^ form onDevice:Display
- ].
- ^ nil
-
- "Created: / 1.4.1997 / 12:39:18 / cg"
- "Modified: / 25.10.1997 / 14:21:45 / cg"
- "Modified: / 8.1.1998 / 16:34:05 / stefan"
-!
-
-rightButtonForm
- "return the left-buttons image"
-
- <resource: #style (#upDownButton.rightForm #upDownButton.rightFormFile)>
-
- |fileName form|
-
- DefaultRightForm notNil ifTrue:[
- ^ DefaultRightForm
- ].
-
- form := StyleSheet at:'upDownButton.rightForm' default:nil.
- form isNil ifTrue:[
- fileName := StyleSheet at:'upDownButton.rightFormFile' default:'ComboRtB_win.xbm'.
- form := Image fromFile:fileName.
- ].
- form isNil ifTrue:[
- form := Form width:6 height:10
- fromArray:#[
- 2r00000000
- 2r01000000
- 2r01100000
- 2r01110000
- 2r01111000
- 2r01111000
- 2r01110000
- 2r01100000
- 2r01000000
- 2r00000000
- ]
- on:Display.
- ].
- form notNil ifTrue:[
- DefaultRightForm := form.
- ^ form onDevice:Display
- ].
- ^ nil
-
- "Created: / 1.4.1997 / 12:39:34 / cg"
- "Modified: / 25.10.1997 / 14:23:04 / cg"
- "Modified: / 8.1.1998 / 16:34:15 / stefan"
-!
-
-upButtonForm
- "return the up-buttons image"
-
- <resource: #style (#upDownButton.upForm #upDownButton.upFormFile)>
-
- |fileName form|
-
- DefaultUpForm notNil ifTrue:[
- ^ DefaultUpForm
- ].
-
- form := StyleSheet at:'upDownButton.upForm' default:nil.
- form isNil ifTrue:[
- fileName := StyleSheet at:'upDownButton.upFormFile' default:'ComboUpB_win.xbm'.
- form := Image fromFile:fileName.
- ].
- form isNil ifTrue:[
- form := Form width:10 height:6
- fromArray:#[
- 2r00000000 2r00000000
- 2r00001100 2r00000000
- 2r00011110 2r00000000
- 2r00111111 2r00000000
- 2r01111111 2r10000000
- 2r00000000 2r00000000
- ]
- on:Display.
- ].
- form notNil ifTrue:[
- DefaultUpForm := form.
- ^ form onDevice:Display
- ].
- ^ nil
-
- "Created: / 1.4.1997 / 11:54:13 / cg"
- "Modified: / 25.10.1997 / 14:23:49 / cg"
- "Modified: / 8.1.1998 / 16:34:36 / stefan"
-!
-
-updateStyleCache
- DefaultDownForm := DefaultUpForm := DefaultLeftForm := DefaultRightForm := nil.
-
- "Created: / 25.10.1997 / 14:11:48 / 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
+
+ self initializeButtonDimensions.
+ self initializeButtonForms
+! !
- "Created: 1.4.1997 / 12:42:17 / cg"
- "Modified: 1.4.1997 / 12:42:29 / cg"
+!UpDownButton methodsFor:'change & update'!
+
+sizeChanged:how
+
+ super sizeChanged:how.
+
+ self initializeButtonDimensions
! !
!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)).
+ upButton origin: 0@0.
+ upButton corner: (self extent x - 1)@(self extent y//2).
+ downButton origin: 0@(self extent y//2 + 1).
+ downButton corner: (self extent x - 1)@(self extent y - 1)
] ifFalse:[
- upButton label:(self class rightButtonForm).
- downButton label:(self class leftButtonForm).
-
- downButton origin:0@0.
- upButton origin:(downButton preferredExtent x @ 0).
+ upButton origin:0@0.
+ upButton corner: (self extent x//2)@(self extent y - 1).
+ downButton origin: (self extent x//2 + 1)@0.
+ downButton corner: (self extent x - 1)@(self extent y - 1)
+ ]
+!
- self preferredExtent:((upButton preferredExtent x
- +
- downButton preferredExtent x)
- @
- upButton preferredExtent y).
+initializeButtonForms
+
+ orientation == #vertical ifTrue:[
+ upButton label:ArrowButton UpArrowForm.
+ downButton label:ArrowButton DownArrowForm.
+ ] ifFalse:[
+ upButton label:ArrowButton LeftArrowForm.
+ downButton label:ArrowButton RightArrowForm.
].
-
- "Modified: 1.4.1997 / 12:47:38 / cg"
!
initializeButtons
@@ -321,11 +146,12 @@
downButton := ArrowButton downIn:self.
downButton autoRepeat:true.
- self initializeButtonDimensions
+ self initializeButtonDimensions.
+ self initializeButtonForms
! !
!UpDownButton class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.5 1998-02-23 18:28:01 tz Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.6 1998-02-25 21:39:49 tz Exp $'
! !