UpDownButton.st
author tz
Wed, 25 Feb 1998 22:39:49 +0100
changeset 788 826f9374823b
parent 779 0abab228a8fd
child 818 fbd05e92d506
permissions -rw-r--r--
take forms from the ArrowButton + resizing behavior added

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 methodsFor:'accessing-behavior'!

downAction:aBlock

    downButton action:aBlock
!

upAction:aBlock

    upButton action:aBlock
! !

!UpDownButton methodsFor:'accessing-components'!

downButton

    ^ downButton
!

upButton

    ^ upButton
! !

!UpDownButton methodsFor:'accessing-look'!

orientation

    ^ orientation
!

orientation:aSymbol

    orientation := aSymbol.

    self initializeButtonDimensions.
    self initializeButtonForms
! !

!UpDownButton methodsFor:'change & update'!

sizeChanged:how

    super sizeChanged:how.

    self initializeButtonDimensions
! !

!UpDownButton methodsFor:'initialization'!

initialize

    orientation := #vertical.

    super initialize.
    self initializeButtons
!

initializeButtonDimensions

    orientation == #vertical ifTrue:[
        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   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)
    ]
!

initializeButtonForms

    orientation == #vertical ifTrue:[
        upButton label:ArrowButton UpArrowForm.
        downButton label:ArrowButton DownArrowForm.
    ] ifFalse:[
        upButton label:ArrowButton LeftArrowForm.
        downButton label:ArrowButton RightArrowForm.
    ].
!

initializeButtons

    upButton := ArrowButton upIn:self.
    upButton autoRepeat:true.

    downButton := ArrowButton downIn:self.
    downButton autoRepeat:true.

    self initializeButtonDimensions.
    self initializeButtonForms
! !

!UpDownButton class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libwidg2/UpDownButton.st,v 1.6 1998-02-25 21:39:49 tz Exp $'
! !