"
COPYRIGHT (c) 1989 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 by Claus Gittinger
All Rights Reserved
$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.9 1994-11-17 14:24:56 claus Exp $
'!
!DisplayObject class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1989 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/libview2/DisplayObject.st,v 1.9 1994-11-17 14:24:56 claus Exp $
"
!
documentation
"
generic superclass for Display Objects held in ObjectViews
see DrawObject/LogicObject/DeskTopObject and subclasses for example use
"
! !
!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
!
computeBoundingBox
"compute my boundingBox into the local 'frame'"
^ self subclassResponsibility
! !
!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
!
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"
^ false
! !
!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
(which is not obvious for simple lines, but complex polygons may
call this for many of its components)
"
org := frame origin.
left := org x - delta.
px := aPoint x.
(px < left) ifTrue:[^ false]. "aPoint is to the left of my left edge"
d2 := delta * 2.
right := left + frame width + d2.
(px > right) ifTrue:[^ false]. "aPoint is to the right of my right edge"
top := org y - delta.
py := aPoint y.
(py < top) ifTrue:[^ false]. "aPoint is above my top edge"
bott := top + frame height + d2.
(py > bott) ifTrue:[^ false]. "aPoint is below my bottom edge"
^ 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 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
!
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))
!
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 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)
!
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)
]
! !