"
COPYRIGHT (c) 1995 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.4 on 6-mar-1995 at 20:00:05'!
VariableVerticalPanelController subclass:#VariableHorizontalPanelController
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Interface-Support'
!
!VariableHorizontalPanelController class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 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/VariableHorizontalPanelController.st,v 1.1 1995-03-06 21:05:56 claus Exp $
"
! !
!VariableHorizontalPanelController methodsFor:'event handling'!
buttonMotion:buttonMask x:bx y:by
"mouse-button was moved while pressed;
clear prev handleBar and draw handle bar at new position"
|xpos limitLeft limitRight subViews barHeight|
movedHandle isNil ifTrue: [^ self]. "should not happen"
"speedup - if there is already another movement,
ignore thisone ... "
view buttonMotionEventPending ifTrue:[^ self].
barHeight := view barHeight.
xpos := bx - start.
"see comment in VariableVerticalPanel>>buttonMotion:x:y:"
"/ limitLeft := barHeight // 2.
"/ limitRight := self width - barHeight.
limitLeft := 0.
limitRight := view innerWidth.
movedHandle > 1 ifTrue:[
limitLeft := (subViews at:movedHandle) origin x + (barHeight // 2)
].
movedHandle < (subViews size - 1) ifTrue:[
limitRight := (subViews at:(movedHandle + 2)) origin x - barHeight
].
limitRight := limitRight - barHeight.
(xpos < limitLeft) ifTrue:[ "check against view limits"
xpos := limitLeft
] ifFalse:[
(xpos > limitRight) ifTrue:[
xpos := limitRight
]
].
view invertHandleBarAtX:prev y:0.
view invertHandleBarAtX:xpos y:0.
prev := xpos
!
buttonRelease:button x:x y:y
"end bar-move"
|aboveView belowView aboveIndex belowIndex newX oldX group subViews|
((button == 1) or:[button == #select]) ifTrue:[
movedHandle isNil ifTrue:[^ self].
(group := view windowGroup) notNil ifTrue:[
group restoreCursors
].
"undo the last xor"
view invertHandleBarAtX:prev y:0.
"compute the new relative heights"
aboveIndex := movedHandle.
belowIndex := movedHandle + 1.
movedHandle := nil.
subViews := view subViews.
aboveView := subViews at:aboveIndex.
belowView := subViews at:belowIndex.
oldX := aboveView relativeCorner x.
newX := (prev + start / view width) asFloat.
aboveView relativeCorner:newX @ aboveView relativeCorner y.
belowView relativeOrigin:newX @ belowView relativeOrigin y.
view lockRedraw.
oldX > newX ifTrue:[
view resizeSubviewsFrom:aboveIndex to:belowIndex.
] ifFalse:[
view resizeSubviewsFrom:belowIndex to:aboveIndex.
].
view redrawHandlesFrom:aboveIndex to:belowIndex.
view unlockRedraw.
] ifFalse:[
super buttonRelease:button x:x y:y
]
!
buttonPress:button x:bx y:by
"button was pressed - if it hits a handle, start move"
|handle barHeight group|
((button == 1) or:[button == #select]) ifTrue:[
handle := 1.
barHeight := view barHeight.
view handleOriginsDo:[:hPoint |
|hx|
hx := hPoint x.
(bx between:hx and:(hx + barHeight)) ifTrue:[
movedHandle := handle.
prev := hx.
start := bx - hx.
view invertHandleBarAtX:hx y:0.
(group := view windowGroup) notNil ifTrue:[
group showCursor:view cursor
].
^ self
].
handle := handle + 1
].
movedHandle := nil
] ifFalse:[
super buttonPress:button x:bx y:by
]
! !