# HG changeset patch # User Claus Gittinger # Date 859891704 -7200 # Node ID c02e5db9b6f50bde1aae6f8ba05d4a1576c146f7 # Parent 1614b7fe98670b01000dc8540d2d1bf9194bf9c3 added left-right orientation. diff -r 1614b7fe9867 -r c02e5db9b6f5 UpDownButton.st --- a/UpDownButton.st Tue Apr 01 12:03:34 1997 +0200 +++ b/UpDownButton.st Tue Apr 01 12:48:24 1997 +0200 @@ -1,5 +1,5 @@ SimpleView subclass:#UpDownButton - instanceVariableNames:'upButton downButton' + instanceVariableNames:'orientation upButton downButton' classVariableNames:'' poolDictionaries:'' category:'Views-Interactors' @@ -35,6 +35,21 @@ 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] " ! ! @@ -75,6 +90,92 @@ "Modified: 1.4.1997 / 11:54:17 / cg" ! +leftButtonForm + "return the left-buttons image" + + + + |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" + + + + |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" @@ -138,40 +239,80 @@ "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 label:(self class upButtonForm). - upButton origin:0@0. upButton action:[self countUp]. upButton autoRepeat:true. downButton := ArrowButton downIn:self. - downButton label:(self class downButtonForm). - downButton origin:(0 @ upButton preferredExtent y). downButton action:[self countDown]. downButton autoRepeat:true. - self preferredExtent:(upButton preferredExtent x - @ - (upButton preferredExtent y - + - downButton preferredExtent y)). + self initializeButtonDimensions - "Created: 1.4.1997 / 11:58:11 / cg" - "Modified: 1.4.1997 / 11:58:43 / cg" + "Modified: 1.4.1997 / 12:42:58 / cg" ! ! !UpDownButton class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.1 1997-04-01 10:03:05 cg Exp $' + ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.2 1997-04-01 10:48:24 cg Exp $' ! !