DisplayObject.st
changeset 288 b10037dee2b5
parent 260 efd33ad1283e
child 505 ed95005f043b
equal deleted inserted replaced
287:7a733e0b5465 288:b10037dee2b5
   326 
   326 
   327 containsPoint: aPoint
   327 containsPoint: aPoint
   328     ^ frame containsPoint: aPoint
   328     ^ frame containsPoint: aPoint
   329 !
   329 !
   330 
   330 
   331 handlesKeyboardInput
   331 frameIsHitBy:aPoint withDelta:delta
   332     "return true, if the receiver handles keyboard input"
   332     "return true, if my frame is hit by aPoint"
   333 
       
   334     ^ false
       
   335 !
       
   336 
       
   337 hasFixedSize
       
   338     "return true, if the receiver has fixed size i.e. cannot be
       
   339      resized
       
   340      - by default, we do not allow resizing"
       
   341 
       
   342     ^ true
       
   343 !
       
   344 
       
   345 intersects:aRectangle
       
   346     "object must decide, if its intersecting a rectangle"
       
   347 
       
   348     ^ frame intersects:aRectangle
       
   349 !
       
   350 
       
   351 isContainedIn:aRectangle
       
   352     "object must decide, if its within a rectangle"
       
   353 
       
   354     ^ aRectangle contains:frame
       
   355 !
       
   356 
       
   357 isHitBy:aPoint
       
   358     "object must decide, if hit by a click at aPoint"
       
   359 
       
   360     ^ self isHitBy:aPoint withDelta:0
       
   361 !
       
   362 
       
   363 isHitBy:aPoint withDelta:delta
       
   364     "object must decide, if hit by a click at aPoint;
       
   365      usually this method is redefined in subclasses for a more complete
       
   366      check (i.e. if objects boundary is not rectangular)"
       
   367 
   333 
   368     |org left right top bott px py d2|
   334     |org left right top bott px py d2|
   369 
   335 
   370     frame isNil ifTrue:[
   336     frame isNil ifTrue:[
   371 	frame := self computeBoundingBox
   337         frame := self computeBoundingBox
   372     ].
   338     ].
   373     (delta == 0) ifTrue:[
   339     (delta == 0) ifTrue:[
   374 	^ frame containsPoint:aPoint
   340         ^ frame containsPoint:aPoint
   375     ].
   341     ].
   376 
   342 
   377     "
   343     "
   378      its quicker to not create a new rectangle for the test
   344      its quicker to not create a new rectangle for the test
   379      (which is not obvious for simple lines, but complex polygons 
   345      (which is not obvious for simple lines, but complex polygons 
   395 
   361 
   396     bott := top + frame height + d2.
   362     bott := top + frame height + d2.
   397     (py > bott) ifTrue:[^ false].   "aPoint is below my bottom edge"
   363     (py > bott) ifTrue:[^ false].   "aPoint is below my bottom edge"
   398 
   364 
   399     ^ true
   365     ^ true
       
   366 
       
   367     "Created: 5.6.1996 / 15:26:51 / cg"
       
   368 !
       
   369 
       
   370 handlesKeyboardInput
       
   371     "return true, if the receiver handles keyboard input"
       
   372 
       
   373     ^ false
       
   374 !
       
   375 
       
   376 hasFixedSize
       
   377     "return true, if the receiver has fixed size i.e. cannot be
       
   378      resized
       
   379      - by default, we do not allow resizing"
       
   380 
       
   381     ^ true
       
   382 !
       
   383 
       
   384 intersects:aRectangle
       
   385     "object must decide, if its intersecting a rectangle"
       
   386 
       
   387     ^ frame intersects:aRectangle
       
   388 !
       
   389 
       
   390 isContainedIn:aRectangle
       
   391     "object must decide, if its within a rectangle"
       
   392 
       
   393     ^ aRectangle contains:frame
       
   394 !
       
   395 
       
   396 isHitBy:aPoint
       
   397     "object must decide, if hit by a click at aPoint"
       
   398 
       
   399     ^ self isHitBy:aPoint withDelta:0
       
   400 !
       
   401 
       
   402 isHitBy:aPoint withDelta:delta
       
   403     "object must decide, if hit by a click at aPoint;
       
   404      usually this method is redefined in subclasses for a more complete
       
   405      check (i.e. if objects boundary is not rectangular)"
       
   406 
       
   407     ^ self frameIsHitBy:aPoint withDelta:delta
       
   408 
       
   409     "Modified: 5.6.1996 / 15:27:06 / cg"
   400 !
   410 !
   401 
   411 
   402 isOpaque
   412 isOpaque
   403     "return true, if the object fully covers its frame (i.e. is rectangular
   413     "return true, if the object fully covers its frame (i.e. is rectangular
   404      and has no 'holes'. Since we dont know, return false here"
   414      and has no 'holes'. Since we dont know, return false here"
   420 ! !
   430 ! !
   421 
   431 
   422 !DisplayObject class methodsFor:'documentation'!
   432 !DisplayObject class methodsFor:'documentation'!
   423 
   433 
   424 version
   434 version
   425     ^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.19 1996-05-12 18:41:21 cg Exp $'
   435     ^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.20 1996-06-05 14:00:20 cg Exp $'
   426 ! !
   436 ! !