--- a/DisplayObject.st Wed Nov 22 17:44:26 1995 +0100
+++ b/DisplayObject.st Thu Nov 23 02:26:40 1995 +0100
@@ -11,10 +11,10 @@
"
Object subclass:#DisplayObject
- instanceVariableNames:'frame'
- classVariableNames:''
- poolDictionaries:''
- category:'Graphics-Display Objects'
+ instanceVariableNames:'frame'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Graphics-Display Objects'
!
!DisplayObject class methodsFor:'documentation'!
@@ -33,15 +33,15 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.14 1995-11-15 16:23:09 cg Exp $'
-!
-
documentation
"
generic superclass for Display Objects held in ObjectViews
see DrawObject/LogicObject/DeskTopObject and subclasses for example use
"
+!
+
+version
+ ^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.15 1995-11-23 01:26:40 cg Exp $'
! !
!DisplayObject class methodsFor:'instance creation'!
@@ -60,81 +60,60 @@
^ true
! !
-!DisplayObject methodsFor:'initialization'!
-
-initialize
- ^ self
-!
-
-computeBoundingBoxFor:aDevice
- "compute my boundingBox into the local variable 'frame'.
- The box is to be computed for aDevice."
-
- "/ for backward compatibility, fall back to Display box computation
-
- ^ self computeBoundingBox
-!
+!DisplayObject methodsFor:'ST-80 drawing'!
-computeBoundingBox
- "compute my boundingBox into the local variable 'frame'.
- The box should be computed for Display."
-
- ^ self subclassResponsibility
-! !
-
-!DisplayObject methodsFor:'queries'!
-
-handlesKeyboardInput
- "return true, if the receiver handles keyboard input"
-
- ^ false
-!
-
-canBeMoved
- "return true, if the receiver can be moved around"
-
- ^ true
+displayOn: aDisplayMedium
+ self displayOn:aDisplayMedium
+ at:0@0
+ clippingBox:nil
+ rule:#copy
+ mask:nil
!
-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
+displayOn:aDisplayMedium at:aPoint
+ self displayOn:aDisplayMedium
+ at:aPoint
+ clippingBox:nil
+ rule:#copy
+ mask:nil
!
-intersects:aRectangle
- "object must decide, if its intersecting a rectangle"
-
- ^ frame intersects:aRectangle
+displayOn:aDisplayMedium at:aPoint clippingBox:clipRectangle
+ ^ self displayOn:aDisplayMedium
+ at:aPoint
+ clippingBox:clipRectangle
+ rule:#copy
+ mask:nil
!
-isOpaque
- "return true, if the object fully covers its frame (i.e. is rectangular
- and has no 'holes'. Since we dont know, return false here"
+displayOn:aDisplayMedium at:aPoint clippingBox:clip rule:rule mask: aForm
+ "in ST-80 programs, this is redefined"
- ^ false
-! !
-
-!DisplayObject methodsFor:'converting'!
-
-asDisplayObject
- ^ self
+ aDisplayMedium function:rule.
+ ^ self drawIn:aDisplayMedium
+ at:(aPoint + self origin)
! !
!DisplayObject methodsFor:'accessing'!
+corner
+ "return the frame corner"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame corner
+!
+
+extent
+ "return the extent of the frame"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame extent
+!
+
frame
"object must return a frame boundary rectangle"
@@ -144,15 +123,6 @@
^ frame
!
-width
- "return the width of the frame"
-
- frame isNil ifTrue:[
- frame := self computeBoundingBox
- ].
- ^ frame width
-!
-
height
"return the height of the frame"
@@ -162,15 +132,6 @@
^ frame height
!
-extent
- "return the extent of the frame"
-
- frame isNil ifTrue:[
- frame := self computeBoundingBox
- ].
- ^ frame extent
-!
-
origin
"return the frame origin"
@@ -180,15 +141,6 @@
^ frame origin
!
-corner
- "return the frame corner"
-
- frame isNil ifTrue:[
- frame := self computeBoundingBox
- ].
- ^ frame corner
-!
-
origin:origin
"object must calculate its dimension from outline"
@@ -199,23 +151,169 @@
"object must calculate its dimension from outline"
^ self subclassResponsibility
+!
+
+width
+ "return the width of the frame"
+
+ frame isNil ifTrue:[
+ frame := self computeBoundingBox
+ ].
+ ^ frame width
+! !
+
+!DisplayObject methodsFor:'converting'!
+
+asDisplayObject
+ ^ self
! !
-!DisplayObject methodsFor:'users actions'!
+!DisplayObject methodsFor:'drawing'!
+
+drawDragIn:aView
+ self class dragOutline ifTrue:[
+ self drawOutlineIn:aView offset:(0 @ 0)
+ ] ifFalse: [
+ self drawIn:aView offset:(0 @ 0)
+ ]
+!
+
+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))
+ ]
+!
-moveTo:aPoint
- "object must move to new origin
- - default is to stay; ought to be redefined in subclass"
+drawDragIn:aView offset:drawOrigin
+ self class dragOutline ifTrue:[
+ self drawOutlineIn:aView offset:drawOrigin
+ ] ifFalse: [
+ self drawIn:aView offset:drawOrigin
+ ]
+!
+
+drawIn:aView
+ "draw the receiver at its origin"
- ^ self
+ self drawIn:aView offset:(0@0)
+!
+
+drawIn:aView at:drawOrigin
+ "draw the receiver at drawOrigin, aPoint"
+
+ self drawIn:aView offset:(drawOrigin - (self origin))
+!
+
+drawIn:aView offset:anOffset
+ "draw the receiver at its origin offset by anOffset, aPoint"
+
+ ^ self subclassResponsibility
!
-keyInput:akey
+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)
+!
+
+drawOutlineIn:aView offset:anOffset
+ "draw the receivers outline at its origin offset by anOffset, aPoint"
+
+ |org|
+ org := self origin + anOffset.
+ aView displayRectangleX:org x y:org y
+ width:frame width height:frame height
+!
+
+drawSelectedIn:aView
+ "draw the receiver highlighted at its position"
+
+ self drawSelectedIn:aView offset:(0@0)
+!
+
+drawSelectedIn:aView offset:anOffset
+ "draw the receiver highlighted - this is usually redefined"
+
+ self drawIn:aView offset:anOffset.
+ self drawOutlineIn:aView offset:anOffset
+! !
+
+!DisplayObject methodsFor:'initialization'!
+
+computeBoundingBox
+ "compute my boundingBox into the local variable 'frame'.
+ The box should be computed for Display."
+
+ ^ self subclassResponsibility
+!
+
+computeBoundingBoxFor:aDevice
+ "compute my boundingBox into the local variable 'frame'.
+ The box is to be computed for aDevice."
+
+ "/ for backward compatibility, fall back to Display box computation
+
+ ^ self computeBoundingBox
+!
+
+initialize
^ self
! !
!DisplayObject methodsFor:'queries'!
+canBeMoved
+ "return true, if the receiver can be moved around"
+
+ ^ true
+!
+
+containsPoint: aPoint
+ ^ frame containsPoint: aPoint
+!
+
+handlesKeyboardInput
+ "return true, if the receiver handles keyboard input"
+
+ ^ false
+!
+
+hasFixedSize
+ "return true, if the receiver has fixed size i.e. cannot be
+ resized
+ - by default, we do not allow resizing"
+
+ ^ true
+!
+
+intersects:aRectangle
+ "object must decide, if its intersecting a rectangle"
+
+ ^ frame intersects:aRectangle
+!
+
+isContainedIn:aRectangle
+ "object must decide, if its within a rectangle"
+
+ ^ aRectangle contains:frame
+!
+
+isHitBy:aPoint
+ "object must decide, if hit by a click at aPoint"
+
+ ^ self isHitBy:aPoint withDelta:0
+!
+
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
@@ -255,122 +353,23 @@
^ true
!
-isHitBy:aPoint
- "object must decide, if hit by a click at aPoint"
+isOpaque
+ "return true, if the object fully covers its frame (i.e. is rectangular
+ and has no 'holes'. Since we dont know, return false here"
- ^ self isHitBy:aPoint withDelta:0
+ ^ false
! !
-!DisplayObject methodsFor:'ST-80 drawing'!
-
-displayOn: aDisplayMedium
- self displayOn:aDisplayMedium
- at:0@0
- clippingBox:nil
- rule:#copy
- mask:nil
-!
-
-displayOn:aDisplayMedium at:aPoint
- self displayOn:aDisplayMedium
- at:aPoint
- clippingBox:nil
- rule:#copy
- mask:nil
-!
-
-displayOn:aDisplayMedium at:aPoint clippingBox:clipRectangle
- ^ self displayOn:aDisplayMedium
- at:aPoint
- clippingBox:clipRectangle
- rule:#copy
- mask:nil
-!
+!DisplayObject methodsFor:'users actions'!
-displayOn:aDisplayMedium at:aPoint clippingBox:clip rule:rule mask: aForm
- "in ST-80 programs, this is redefined"
-
- aDisplayMedium function:rule.
- ^ 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 subclassResponsibility
-!
-
-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))
+keyInput:akey
+ ^ self
!
-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 displayRectangleX: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)
-!
+moveTo:aPoint
+ "object must move to new origin
+ - default is to stay; ought to be redefined in subclass"
-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))
- ]
-!
+ ^ self
+! !
-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)
- ]
-! !