--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TranslWrpr.st Wed May 29 00:52:46 1996 +0200
@@ -0,0 +1,227 @@
+"
+ COPYRIGHT (c) 1996 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.
+"
+
+
+Wrapper subclass:#TranslatingWrapper
+ instanceVariableNames:'origin'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Graphics-Display Objects'
+!
+
+!TranslatingWrapper class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1996 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.
+"
+
+!
+
+documentation
+"
+ a wrapper which shifts the origin of its wrapped component.
+ This allows the wrapped thingy to think & draw in its own 0/0 based
+ coordinates.
+
+ Notice:
+ this class was implemented using protocol information
+ from alpha testers and from the Hopkins/Horan book.
+ - it may not be complete or compatible to the corresponding ST-80 class.
+ If you encounter any incompatibilities, please forward a note
+ describing the incompatibility verbal (i.e. no code) to the ST/X team.
+
+ [see also:]
+ Wrapper
+
+ [author:]
+ Claus Gittinger
+"
+!
+
+examples
+"
+ some components without translatingWrapper
+ [exBegin]
+ |t s v e component|
+
+ t := StandardSystemView extent:250@200.
+ s := HVScrollableView for:View miniScroller:true in:t.
+ s origin:0.0@0.0 corner:1.0@1.0.
+ v := s scrolledView.
+
+ e := Rectangle origin:10@10 corner:90@90.
+ component := FillingWrapper on:e.
+ component foregroundColor:Color red.
+ v addComponent:component.
+
+ e := EllipticalArc boundingBox:(10@10 corner:90@90)
+ startAngle:0 sweepAngle:360.
+ component := StrokingWrapper on:e.
+ component lineWidth:5.
+ v addComponent:component.
+
+ e := Arrow from:100@100 to:150@250.
+ component := StrokingWrapper on:e.
+ component lineWidth:2.
+ v addComponent:component.
+
+ t open
+ [exEnd]
+ the same components WITH translatingWrappers
+ [exBegin]
+ |t s v e component|
+
+ t := StandardSystemView extent:250@200.
+ s := HVScrollableView for:View miniScroller:true in:t.
+ s origin:0.0@0.0 corner:1.0@1.0.
+ v := s scrolledView.
+
+ e := Rectangle origin:0@0 corner:80@80.
+ component := FillingWrapper on:e.
+ component foregroundColor:Color red.
+ v addComponent:(TranslatingWrapper on:component at:10@10).
+
+ e := EllipticalArc boundingBox:(0@0 corner:80@80)
+ startAngle:0 sweepAngle:360.
+ component := StrokingWrapper on:e.
+ component lineWidth:5.
+ v addComponent:(TranslatingWrapper on:component at:10@10).
+
+ e := Arrow from:0@0 to:50@150.
+ component := StrokingWrapper on:e.
+ component lineWidth:2.
+ v addComponent:(TranslatingWrapper on:component at:100@100).
+
+ v addComponent:(TranslatingWrapper on:(Image fromFile:'SBrowser.xbm') at:0@100).
+
+ t open
+ [exEnd]
+ [exBegin]
+ |t s v e component|
+
+ t := StandardSystemView extent:250@200.
+ s := HVScrollableView for:View miniScroller:true in:t.
+ s origin:0.0@0.0 corner:1.0@1.0.
+ v := s scrolledView.
+
+ e := LabelAndIcon icon:(Image fromFile:'bitmaps/SBrowser.xbm')
+ string:'hello'.
+ v addComponent:(TranslatingWrapper on:e at:10@10).
+
+ t open
+ [exEnd]
+
+"
+! !
+
+!TranslatingWrapper class methodsFor:'instance creation'!
+
+on:aComponent at:originPoint
+ "create and return a translatingWrapper, which positions
+ aComponent at some originPoint"
+
+ ^ (self on:aComponent) translation:originPoint
+
+ "Created: 26.5.1996 / 16:07:29 / cg"
+ "Modified: 26.5.1996 / 16:12:28 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'accessing'!
+
+translation
+ "return the origin offset"
+
+ ^ origin
+
+ "Modified: 26.5.1996 / 16:06:32 / cg"
+!
+
+translation:originPoint
+ "set the origin offset"
+
+ origin := originPoint
+
+ "Modified: 26.5.1996 / 16:06:32 / cg"
+ "Created: 26.5.1996 / 16:07:47 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'accessing - bounds'!
+
+bounds
+ ^ component bounds + origin
+
+ "Created: 26.5.1996 / 16:13:05 / cg"
+ "Modified: 26.5.1996 / 16:44:26 / cg"
+!
+
+bounds:newBounds
+ component bounds:(newBounds - origin).
+
+ "Created: 26.5.1996 / 16:44:16 / cg"
+!
+
+preferredBounds
+ ^ component preferredBounds + origin
+
+ "Modified: 26.5.1996 / 16:44:26 / cg"
+ "Created: 26.5.1996 / 16:44:53 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'displaying'!
+
+displayOn:aGC
+ |oldTranslation oldPaint oldBgPaint|
+
+ oldTranslation := aGC translation.
+ oldPaint := aGC paint.
+ oldBgPaint := aGC backgroundPaint.
+
+ aGC translation:(origin + aGC translation).
+ aGC paint:fgColor on:bgColor.
+
+ component displayOn:aGC.
+
+ aGC translation:oldTranslation.
+ aGC paint:oldPaint on:oldBgPaint.
+
+ "Created: 26.5.1996 / 15:27:54 / cg"
+ "Modified: 26.5.1996 / 16:13:44 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'testing'!
+
+containsPoint:aPoint
+ ^ component containsPoint:(aPoint - origin)
+
+ "Created: 26.5.1996 / 16:48:14 / cg"
+!
+
+intersects:aRectangle
+ ^ component intersects:(aRectangle - origin)
+
+ "Created: 26.5.1996 / 16:48:33 / cg"
+! !
+
+!TranslatingWrapper class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/Attic/TranslWrpr.st,v 1.1 1996-05-28 22:52:46 cg Exp $'
+! !
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/TranslatingWrapper.st Wed May 29 00:52:46 1996 +0200
@@ -0,0 +1,227 @@
+"
+ COPYRIGHT (c) 1996 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.
+"
+
+
+Wrapper subclass:#TranslatingWrapper
+ instanceVariableNames:'origin'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Graphics-Display Objects'
+!
+
+!TranslatingWrapper class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1996 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.
+"
+
+!
+
+documentation
+"
+ a wrapper which shifts the origin of its wrapped component.
+ This allows the wrapped thingy to think & draw in its own 0/0 based
+ coordinates.
+
+ Notice:
+ this class was implemented using protocol information
+ from alpha testers and from the Hopkins/Horan book.
+ - it may not be complete or compatible to the corresponding ST-80 class.
+ If you encounter any incompatibilities, please forward a note
+ describing the incompatibility verbal (i.e. no code) to the ST/X team.
+
+ [see also:]
+ Wrapper
+
+ [author:]
+ Claus Gittinger
+"
+!
+
+examples
+"
+ some components without translatingWrapper
+ [exBegin]
+ |t s v e component|
+
+ t := StandardSystemView extent:250@200.
+ s := HVScrollableView for:View miniScroller:true in:t.
+ s origin:0.0@0.0 corner:1.0@1.0.
+ v := s scrolledView.
+
+ e := Rectangle origin:10@10 corner:90@90.
+ component := FillingWrapper on:e.
+ component foregroundColor:Color red.
+ v addComponent:component.
+
+ e := EllipticalArc boundingBox:(10@10 corner:90@90)
+ startAngle:0 sweepAngle:360.
+ component := StrokingWrapper on:e.
+ component lineWidth:5.
+ v addComponent:component.
+
+ e := Arrow from:100@100 to:150@250.
+ component := StrokingWrapper on:e.
+ component lineWidth:2.
+ v addComponent:component.
+
+ t open
+ [exEnd]
+ the same components WITH translatingWrappers
+ [exBegin]
+ |t s v e component|
+
+ t := StandardSystemView extent:250@200.
+ s := HVScrollableView for:View miniScroller:true in:t.
+ s origin:0.0@0.0 corner:1.0@1.0.
+ v := s scrolledView.
+
+ e := Rectangle origin:0@0 corner:80@80.
+ component := FillingWrapper on:e.
+ component foregroundColor:Color red.
+ v addComponent:(TranslatingWrapper on:component at:10@10).
+
+ e := EllipticalArc boundingBox:(0@0 corner:80@80)
+ startAngle:0 sweepAngle:360.
+ component := StrokingWrapper on:e.
+ component lineWidth:5.
+ v addComponent:(TranslatingWrapper on:component at:10@10).
+
+ e := Arrow from:0@0 to:50@150.
+ component := StrokingWrapper on:e.
+ component lineWidth:2.
+ v addComponent:(TranslatingWrapper on:component at:100@100).
+
+ v addComponent:(TranslatingWrapper on:(Image fromFile:'SBrowser.xbm') at:0@100).
+
+ t open
+ [exEnd]
+ [exBegin]
+ |t s v e component|
+
+ t := StandardSystemView extent:250@200.
+ s := HVScrollableView for:View miniScroller:true in:t.
+ s origin:0.0@0.0 corner:1.0@1.0.
+ v := s scrolledView.
+
+ e := LabelAndIcon icon:(Image fromFile:'bitmaps/SBrowser.xbm')
+ string:'hello'.
+ v addComponent:(TranslatingWrapper on:e at:10@10).
+
+ t open
+ [exEnd]
+
+"
+! !
+
+!TranslatingWrapper class methodsFor:'instance creation'!
+
+on:aComponent at:originPoint
+ "create and return a translatingWrapper, which positions
+ aComponent at some originPoint"
+
+ ^ (self on:aComponent) translation:originPoint
+
+ "Created: 26.5.1996 / 16:07:29 / cg"
+ "Modified: 26.5.1996 / 16:12:28 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'accessing'!
+
+translation
+ "return the origin offset"
+
+ ^ origin
+
+ "Modified: 26.5.1996 / 16:06:32 / cg"
+!
+
+translation:originPoint
+ "set the origin offset"
+
+ origin := originPoint
+
+ "Modified: 26.5.1996 / 16:06:32 / cg"
+ "Created: 26.5.1996 / 16:07:47 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'accessing - bounds'!
+
+bounds
+ ^ component bounds + origin
+
+ "Created: 26.5.1996 / 16:13:05 / cg"
+ "Modified: 26.5.1996 / 16:44:26 / cg"
+!
+
+bounds:newBounds
+ component bounds:(newBounds - origin).
+
+ "Created: 26.5.1996 / 16:44:16 / cg"
+!
+
+preferredBounds
+ ^ component preferredBounds + origin
+
+ "Modified: 26.5.1996 / 16:44:26 / cg"
+ "Created: 26.5.1996 / 16:44:53 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'displaying'!
+
+displayOn:aGC
+ |oldTranslation oldPaint oldBgPaint|
+
+ oldTranslation := aGC translation.
+ oldPaint := aGC paint.
+ oldBgPaint := aGC backgroundPaint.
+
+ aGC translation:(origin + aGC translation).
+ aGC paint:fgColor on:bgColor.
+
+ component displayOn:aGC.
+
+ aGC translation:oldTranslation.
+ aGC paint:oldPaint on:oldBgPaint.
+
+ "Created: 26.5.1996 / 15:27:54 / cg"
+ "Modified: 26.5.1996 / 16:13:44 / cg"
+! !
+
+!TranslatingWrapper methodsFor:'testing'!
+
+containsPoint:aPoint
+ ^ component containsPoint:(aPoint - origin)
+
+ "Created: 26.5.1996 / 16:48:14 / cg"
+!
+
+intersects:aRectangle
+ ^ component intersects:(aRectangle - origin)
+
+ "Created: 26.5.1996 / 16:48:33 / cg"
+! !
+
+!TranslatingWrapper class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/TranslatingWrapper.st,v 1.1 1996-05-28 22:52:46 cg Exp $'
+! !