--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DisplayObject.st Fri Jul 16 11:42:12 1993 +0200
@@ -0,0 +1,317 @@
+"
+ COPYRIGHT (c) 1989-92 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.
+"
+
+Object subclass:#DisplayObject
+ instanceVariableNames:'frame'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Graphics-Display Objects'
+!
+
+DisplayObject comment:'
+
+COPYRIGHT (c) 1989-92 by Claus Gittinger
+ All Rights Reserved
+
+generic superclass for Display Objects held in ObjectViews
+see DrawObject/LogicObject/DeskTopObject and subclasses for example use
+
+%W% %E%
+written fall/winter 89 by claus
+'!
+
+!DisplayObject class methodsFor:'instance creation'!
+
+new
+ ^ self basicNew initialize
+! !
+
+!DisplayObject class methodsFor:'behavior'!
+
+dragOutline
+ "if true, dragging is done by drawing outline only;
+ if false, dragging is done by full draw (fast servers only)
+ - can be redefined in subclasses"
+
+ ^ true
+! !
+
+!DisplayObject methodsFor:'initialization'!
+
+initialize
+ ^ self
+! !
+
+!DisplayObject methodsFor:'queries'!
+
+canBeMoved
+ "return true, if the receiver can be moved around"
+
+ ^ true
+!
+
+hasFixedSize
+ "return true, if the receiver has fixed size i.e. cannot be
+ resized
+ - by default, we do not allow resizing"
+
+ ^ true
+!
+
+isContainedIn:aRectangle
+ "object must decide, if its within a rectangle"
+
+ ^ aRectangle contains:frame
+!
+
+containsPoint: aPoint
+ ^ frame containsPoint: aPoint
+!
+
+intersects:aRectangle
+ "object must decide, if its intersecting a rectangle"
+
+ ^ frame intersects:aRectangle
+! !
+
+!DisplayObject methodsFor:'accessing'!
+
+frame
+ "object must return a frame boundary rectangle"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame
+!
+
+width
+ "return the width of the frame"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame width
+!
+
+height
+ "return the height of the frame"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame height
+!
+
+extent
+ "return the extent of the frame"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame extent
+!
+
+origin
+ "return the frame origin"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame origin
+!
+
+corner
+ "return the frame corner"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame corner
+!
+
+origin:origin
+ "object must calculate its dimension from outline"
+
+ ^ self subclassResponsibility
+!
+
+origin:origin corner:corner
+ "object must calculate its dimension from outline"
+
+ ^ self subclassResponsibility
+! !
+
+!DisplayObject methodsFor:'users actions'!
+
+moveTo:aPoint
+ "object must move to new origin
+ - default is to stay; ought to be redefined in subclass"
+
+ ^ self
+!
+
+keyInput:akey
+ ^ self
+! !
+
+!DisplayObject methodsFor:'queries'!
+
+isHitBy:aPoint withDelta:delta
+ "object must decide, if hit by a click at aPoint;
+ usually this method is redefined in subclasses for a more complete
+ check (i.e. if objects boundary is not rectangular)"
+
+ |org left right top bott px py d2|
+
+ (delta == 0) ifTrue:[
+ ^ frame containsPoint:aPoint
+ ].
+
+ "its quicker to not create a new rectangle for the test"
+ org := frame origin.
+ left := org x - delta.
+
+ px := aPoint x.
+ (px < left) ifTrue:[^ false].
+
+ d2 := delta * 2.
+ right := left + frame width + d2.
+ (px > right) ifTrue:[^ false].
+
+ top := org y - delta.
+ py := aPoint y.
+ (py < top) ifTrue:[^ false].
+
+ bott := top + frame height + d2.
+ (py > bott) ifTrue:[^ false].
+
+ ^ true
+!
+
+isHitBy:aPoint
+ "object must decide, if hit by a click at aPoint"
+
+ ^ self isHitBy:aPoint withDelta:0
+! !
+
+!DisplayObject methodsFor:'ST-80 drawing'!
+
+displayOn: aDisplayMedium
+ self drawIn:aDisplayMedium offset:0@0
+"
+ self displayOn:aDisplayMedium
+ at:0@0
+ clippingBox:nil
+ rule:#copy
+ mask:nil
+"
+!
+
+displayOn:aDisplayMedium at:aPoint clippingBox:clipRectangle
+ ^ self displayOn:aDisplayMedium
+ at:aPoint
+ clippingBox:clipRectangle
+ rule:#copy
+ mask:nil
+!
+
+displayOn:aDisplayMedium at:aPoint clippingBox:clip rule:rule mask: aForm
+ aDisplayMedium function:rule.
+ ^ self drawIn:aDisplayMedium
+ at:(aPoint + self origin)
+!
+
+displayOn:aDisplayMedium at:aPoint
+ ^ self drawIn:aDisplayMedium
+ at:(aPoint + self origin)
+! !
+
+!DisplayObject methodsFor:'drawing'!
+
+drawIn:aView offset:anOffset
+ "draw the receiver at its origin offset by anOffset, aPoint"
+
+ ^ self subclassResponsiblitity
+!
+
+drawIn:aView
+ "draw the receiver at its origin"
+
+ self drawIn:aView offset:(0@0)
+!
+
+drawIn:aView at:drawOrigin
+ "draw the receiver at drawOrigin, aPoint"
+
+ self drawIn:aView offset:(drawOrigin - (self origin))
+!
+
+drawSelectedIn:aView offset:anOffset
+ "draw the receiver highlighted - this is usually redefined"
+
+ self drawIn:aView offset:anOffset.
+ self drawOutlineIn:aView offset:anOffset
+!
+
+drawSelectedIn:aView
+ "draw the receiver highlighted at its position"
+
+ self drawSelectedIn:aView offset:(0@0)
+!
+
+drawOutlineIn:aView offset:anOffset
+ "draw the receivers outline at its origin offset by anOffset, aPoint"
+
+ |org|
+ org := self origin + anOffset - aView viewOrigin.
+ aView drawRectangleX:(org x) y:(org y)
+ width:(frame width) height:(frame height)
+!
+
+drawOutlineIn:aView
+ "draw the receivers outline at its origin"
+
+ self drawOutlineIn:aView offset:(0@0)
+!
+
+drawOutlineIn:aView at:drawOrigin
+ "draw the receivers outline at drawOrigin, aPoint"
+
+ self drawOutlineIn:aView offset:(drawOrigin - (self origin))
+!
+
+drawDragIn:aView at:drawOrigin
+ "draw the receiver for dragging"
+
+ self class dragOutline ifTrue:[
+ self drawOutlineIn:aView offset:(drawOrigin - (self origin))
+ ] ifFalse: [
+ self drawIn:aView offset:(drawOrigin - (self origin))
+ ]
+!
+
+drawDragIn:aView offset:drawOrigin
+ self class dragOutline ifTrue:[
+ self drawOutlineIn:aView offset:drawOrigin
+ ] ifFalse: [
+ self drawIn:aView offset:drawOrigin
+ ]
+!
+
+drawDragIn:aView
+ self class dragOutline ifTrue:[
+ self drawOutlineIn:aView offset:(0 @ 0)
+ ] ifFalse: [
+ self drawIn:aView offset:(0 @ 0)
+ ]
+! !