Initial revision
authorclaus
Sat, 18 Mar 1995 06:16:33 +0100
changeset 104 ca75c90df7a9
parent 103 87da77f6c88d
child 105 3d064ba4a0cc
Initial revision
RButtC.st
RadioButtonController.st
VarPanelC.st
VariablePanelController.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RButtC.st	Sat Mar 18 06:16:33 1995 +0100
@@ -0,0 +1,20 @@
+'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:07:27 am'!
+
+ToggleController subclass:#RadioButtonController
+	 instanceVariableNames:''
+	 classVariableNames:''
+	 poolDictionaries:''
+	 category:'Interface-Support'
+!
+
+!RadioButtonController methodsFor:'event handling'!
+
+buttonPress:button x:x y:y
+    "radiobuttons change only off-to-on; turning off is done by other
+     buttons"
+
+    pressed ifFalse:[
+        view toggle
+    ]
+! !
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RadioButtonController.st	Sat Mar 18 06:16:33 1995 +0100
@@ -0,0 +1,20 @@
+'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:07:27 am'!
+
+ToggleController subclass:#RadioButtonController
+	 instanceVariableNames:''
+	 classVariableNames:''
+	 poolDictionaries:''
+	 category:'Interface-Support'
+!
+
+!RadioButtonController methodsFor:'event handling'!
+
+buttonPress:button x:x y:y
+    "radiobuttons change only off-to-on; turning off is done by other
+     buttons"
+
+    pressed ifFalse:[
+        view toggle
+    ]
+! !
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VarPanelC.st	Sat Mar 18 06:16:33 1995 +0100
@@ -0,0 +1,228 @@
+"
+ 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:02'!
+
+Controller subclass:#VariablePanelController
+	 instanceVariableNames:'movedHandle prevPos startPos isHorizontal'
+	 classVariableNames:''
+	 poolDictionaries:''
+	 category:'Interface-Support'
+!
+
+!VariablePanelController 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/Attic/VarPanelC.st,v 1.1 1995-03-18 05:16:33 claus Exp $
+"
+! !
+
+!VariablePanelController methodsFor:'event handling'!
+
+buttonMotion:button x:bx y:by
+    "mouse-button was moved while pressed;
+     clear prev handleBar and draw handle bar at new position" 
+
+    |pos limitMin limitMax subViews barHeight|
+
+    movedHandle isNil ifTrue: [^ self].          "should not happen"
+
+    "speedup - if there is already another movement, 
+     ignore thisone ... "
+
+    view buttonMotionEventPending ifTrue:[^ self].
+
+    subViews := view subViews.
+    barHeight := view barHeight.
+
+    isHorizontal ifTrue:[
+	pos := bx - startPos.
+	"
+	 the two lines below will not allow resizing down to zero
+	 (so that some is always visible)
+	"
+"/        limitMin := barHeight // 2.
+"/        limitMax := view width - barHeight.
+	"
+	 these allow resizing to zero - which is better ?
+	"
+	limitMin := 0.
+	limitMax := view innerWidth.
+
+	movedHandle > 1 ifTrue:[
+	    limitMin := (subViews at:movedHandle) origin x + (barHeight // 2)
+	].
+	movedHandle < (subViews size - 1) ifTrue:[
+	    limitMax := (subViews at:(movedHandle + 2)) origin x - barHeight
+	].
+    ] ifFalse:[
+	pos := by - startPos.
+	"
+	 the two lines below will not allow resizing down to zero
+	 (so that some is always visible)
+	"
+"/        limitMin := barHeight // 2.
+"/        limitMax := view height - barHeight.
+	"
+	 these allow resizing to zero - which is better ?
+	"
+	limitMin := 0.
+	limitMax := view innerHeight.
+
+	movedHandle > 1 ifTrue:[
+	    limitMin := (subViews at:movedHandle) origin y + (barHeight // 2)
+	].
+	movedHandle < (subViews size - 1) ifTrue:[
+	    limitMax := (subViews at:(movedHandle + 2)) origin y - barHeight
+	].
+    ].
+
+    limitMax := limitMax - barHeight.
+    (pos < limitMin) ifTrue:[ "check against view limits"
+	pos := limitMin
+    ] ifFalse:[
+	(pos > limitMax) ifTrue:[
+	    pos := limitMax
+	]
+    ].
+
+    isHorizontal ifTrue:[
+	view invertHandleBarAtX:prevPos y:0.
+	view invertHandleBarAtX:pos y:0.
+    ] ifFalse:[
+	view invertHandleBarAtX:0 y:prevPos.
+	view invertHandleBarAtX:0 y:pos.
+    ].
+    prevPos := pos
+!
+
+buttonRelease:button x:x y:y
+    "end bar-move"
+
+    |aboveView belowView aboveIndex belowIndex 
+     newPos oldPos group subViews|
+
+    ((button == 1) or:[button == #select]) ifTrue:[
+	movedHandle isNil ifTrue:[^ self].
+
+	(group := view windowGroup) notNil ifTrue:[
+	    group restoreCursors
+	].
+
+	"undo the last invert"
+
+	isHorizontal ifTrue:[
+	    view invertHandleBarAtX:prevPos y:0. 
+	] ifFalse:[
+	    view invertHandleBarAtX:0 y:prevPos. 
+	].
+
+	"compute the new relative heights"
+
+	aboveIndex := movedHandle.
+	belowIndex := movedHandle + 1.
+	movedHandle := nil.
+	subViews := view subViews.
+
+	aboveView := subViews at:aboveIndex.
+	belowView := subViews at:belowIndex.
+
+	isHorizontal ifTrue:[
+	    oldPos := aboveView relativeCorner x.
+	    newPos := (prevPos + startPos / view width) asFloat.
+	    aboveView relativeCorner:newPos @ aboveView relativeCorner y.
+	    belowView relativeOrigin:newPos @ belowView relativeOrigin y.
+	] ifFalse:[
+	    oldPos := aboveView relativeCorner y.
+	    newPos := (prevPos + startPos / view height) asFloat.
+	    aboveView relativeCorner:aboveView relativeCorner x @ newPos.
+	    belowView relativeOrigin:belowView relativeOrigin x @ newPos.
+	].
+
+	view lockRedraw.
+
+	oldPos > newPos 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.
+
+	"
+	 search the handle, invert the first time
+	"
+	view handleOriginsDo:[:hPoint |
+	    |hx hy|
+
+	    isHorizontal ifTrue:[
+		hx := hPoint x.
+		(bx between:hx and:(hx + barHeight)) ifTrue:[
+		    movedHandle := handle.
+		    prevPos := hx.
+		    startPos := bx - hx.
+
+		    view invertHandleBarAtX:hx y:0.
+		    (group := view windowGroup) notNil ifTrue:[
+			group showCursor:view cursor
+		    ].
+		    ^ self
+		].
+	    ] ifFalse:[
+		hy := hPoint y.
+		(by between:hy and:(hy + barHeight)) ifTrue:[
+		    movedHandle := handle.
+		    prevPos := hy.
+		    startPos := by - hy.
+
+		    view invertHandleBarAtX:0 y:hy.
+		    (group := view windowGroup) notNil ifTrue:[
+			group showCursor:view cursor
+		    ].
+		    ^ self
+		].
+	    ].
+	    handle := handle + 1
+	].
+	movedHandle := nil
+    ] ifFalse:[
+	super buttonPress:button x:bx y:by
+    ]
+! !
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VariablePanelController.st	Sat Mar 18 06:16:33 1995 +0100
@@ -0,0 +1,228 @@
+"
+ 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:02'!
+
+Controller subclass:#VariablePanelController
+	 instanceVariableNames:'movedHandle prevPos startPos isHorizontal'
+	 classVariableNames:''
+	 poolDictionaries:''
+	 category:'Interface-Support'
+!
+
+!VariablePanelController 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/VariablePanelController.st,v 1.1 1995-03-18 05:16:33 claus Exp $
+"
+! !
+
+!VariablePanelController methodsFor:'event handling'!
+
+buttonMotion:button x:bx y:by
+    "mouse-button was moved while pressed;
+     clear prev handleBar and draw handle bar at new position" 
+
+    |pos limitMin limitMax subViews barHeight|
+
+    movedHandle isNil ifTrue: [^ self].          "should not happen"
+
+    "speedup - if there is already another movement, 
+     ignore thisone ... "
+
+    view buttonMotionEventPending ifTrue:[^ self].
+
+    subViews := view subViews.
+    barHeight := view barHeight.
+
+    isHorizontal ifTrue:[
+	pos := bx - startPos.
+	"
+	 the two lines below will not allow resizing down to zero
+	 (so that some is always visible)
+	"
+"/        limitMin := barHeight // 2.
+"/        limitMax := view width - barHeight.
+	"
+	 these allow resizing to zero - which is better ?
+	"
+	limitMin := 0.
+	limitMax := view innerWidth.
+
+	movedHandle > 1 ifTrue:[
+	    limitMin := (subViews at:movedHandle) origin x + (barHeight // 2)
+	].
+	movedHandle < (subViews size - 1) ifTrue:[
+	    limitMax := (subViews at:(movedHandle + 2)) origin x - barHeight
+	].
+    ] ifFalse:[
+	pos := by - startPos.
+	"
+	 the two lines below will not allow resizing down to zero
+	 (so that some is always visible)
+	"
+"/        limitMin := barHeight // 2.
+"/        limitMax := view height - barHeight.
+	"
+	 these allow resizing to zero - which is better ?
+	"
+	limitMin := 0.
+	limitMax := view innerHeight.
+
+	movedHandle > 1 ifTrue:[
+	    limitMin := (subViews at:movedHandle) origin y + (barHeight // 2)
+	].
+	movedHandle < (subViews size - 1) ifTrue:[
+	    limitMax := (subViews at:(movedHandle + 2)) origin y - barHeight
+	].
+    ].
+
+    limitMax := limitMax - barHeight.
+    (pos < limitMin) ifTrue:[ "check against view limits"
+	pos := limitMin
+    ] ifFalse:[
+	(pos > limitMax) ifTrue:[
+	    pos := limitMax
+	]
+    ].
+
+    isHorizontal ifTrue:[
+	view invertHandleBarAtX:prevPos y:0.
+	view invertHandleBarAtX:pos y:0.
+    ] ifFalse:[
+	view invertHandleBarAtX:0 y:prevPos.
+	view invertHandleBarAtX:0 y:pos.
+    ].
+    prevPos := pos
+!
+
+buttonRelease:button x:x y:y
+    "end bar-move"
+
+    |aboveView belowView aboveIndex belowIndex 
+     newPos oldPos group subViews|
+
+    ((button == 1) or:[button == #select]) ifTrue:[
+	movedHandle isNil ifTrue:[^ self].
+
+	(group := view windowGroup) notNil ifTrue:[
+	    group restoreCursors
+	].
+
+	"undo the last invert"
+
+	isHorizontal ifTrue:[
+	    view invertHandleBarAtX:prevPos y:0. 
+	] ifFalse:[
+	    view invertHandleBarAtX:0 y:prevPos. 
+	].
+
+	"compute the new relative heights"
+
+	aboveIndex := movedHandle.
+	belowIndex := movedHandle + 1.
+	movedHandle := nil.
+	subViews := view subViews.
+
+	aboveView := subViews at:aboveIndex.
+	belowView := subViews at:belowIndex.
+
+	isHorizontal ifTrue:[
+	    oldPos := aboveView relativeCorner x.
+	    newPos := (prevPos + startPos / view width) asFloat.
+	    aboveView relativeCorner:newPos @ aboveView relativeCorner y.
+	    belowView relativeOrigin:newPos @ belowView relativeOrigin y.
+	] ifFalse:[
+	    oldPos := aboveView relativeCorner y.
+	    newPos := (prevPos + startPos / view height) asFloat.
+	    aboveView relativeCorner:aboveView relativeCorner x @ newPos.
+	    belowView relativeOrigin:belowView relativeOrigin x @ newPos.
+	].
+
+	view lockRedraw.
+
+	oldPos > newPos 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.
+
+	"
+	 search the handle, invert the first time
+	"
+	view handleOriginsDo:[:hPoint |
+	    |hx hy|
+
+	    isHorizontal ifTrue:[
+		hx := hPoint x.
+		(bx between:hx and:(hx + barHeight)) ifTrue:[
+		    movedHandle := handle.
+		    prevPos := hx.
+		    startPos := bx - hx.
+
+		    view invertHandleBarAtX:hx y:0.
+		    (group := view windowGroup) notNil ifTrue:[
+			group showCursor:view cursor
+		    ].
+		    ^ self
+		].
+	    ] ifFalse:[
+		hy := hPoint y.
+		(by between:hy and:(hy + barHeight)) ifTrue:[
+		    movedHandle := handle.
+		    prevPos := hy.
+		    startPos := by - hy.
+
+		    view invertHandleBarAtX:0 y:hy.
+		    (group := view windowGroup) notNil ifTrue:[
+			group showCursor:view cursor
+		    ].
+		    ^ self
+		].
+	    ].
+	    handle := handle + 1
+	].
+	movedHandle := nil
+    ] ifFalse:[
+	super buttonPress:button x:bx y:by
+    ]
+! !