UIGalleryView.st
changeset 239 ce46eb6f92a5
parent 205 1188254dcbfc
child 240 3f0dfabbb14d
equal deleted inserted replaced
238:882be7e03af4 239:ce46eb6f92a5
   490 !UIGalleryView::Canvas methodsFor:'searching'!
   490 !UIGalleryView::Canvas methodsFor:'searching'!
   491 
   491 
   492 findObjectAtX:x y:y
   492 findObjectAtX:x y:y
   493     "find the origin/corner of the currentWidget
   493     "find the origin/corner of the currentWidget
   494     "
   494     "
   495     |point id p e|
   495     |point id p|
   496 
   496 
   497     point := Point x:x y:y.
   497     point := Point x:x y:y.
   498     id    := inputView id.
   498     id    := inputView id.
   499 
   499 
   500     subViews do:[:v|
   500     subViews do:[:v|
       
   501 	|pX pY|
       
   502 
   501         v ~~ inputView ifTrue:[
   503         v ~~ inputView ifTrue:[
   502             p := device translatePoint:point from:id to:(v id).
   504             p := device translatePoint:point from:id to:(v id).
   503             (     p x >= 0 and:[p x <= v width
   505 	    pX := p x.
   504              and:[p y >= 0 and:[p y <= v height
   506 	    pY := p y.
       
   507             (     pX >= 0 and:[pX <= v width
       
   508              and:[pY >= 0 and:[pY <= v height
   505              and:[(self findSpecFor:v) notNil]]]]
   509              and:[(self findSpecFor:v) notNil]]]]
   506             ) ifTrue:[
   510             ) ifTrue:[
   507                 ^ v
   511                 ^ v
   508             ]
   512             ]
   509         ]
   513         ]
   514 !
   518 !
   515 
   519 
   516 findSpecFor:anObject
   520 findSpecFor:anObject
   517     "returns subspec assigned to instance or nil
   521     "returns subspec assigned to instance or nil
   518     "
   522     "
   519     |name components spec|
   523     |name|
   520 
   524 
   521     anObject notNil ifTrue:[
   525     anObject notNil ifTrue:[
   522         name := anObject name.
   526         name := anObject name.
   523 
   527 
   524         specification do:[:aSpec|
   528         specification do:[:aSpec|
   554 !
   558 !
   555 
   559 
   556 selection:anObject
   560 selection:anObject
   557     "selection changed
   561     "selection changed
   558     "
   562     "
   559     |name spec|
   563     |spec|
   560 
   564 
   561     selection ~~ anObject ifTrue:[
   565     selection ~~ anObject ifTrue:[
   562         self showUnselected.
   566         self showUnselected.
   563         spec := self findSpecFor:anObject.
   567         spec := self findSpecFor:anObject.
   564 
   568 
   634 !UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'!
   638 !UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'!
   635 
   639 
   636 for:aView specification:aSpec
   640 for:aView specification:aSpec
   637     "create drop object for a view derived from a specification
   641     "create drop object for a view derived from a specification
   638     "
   642     "
   639     |point extent root device|
   643     |point extent root device dO|
   640 
   644 
   641     device := aView device.
   645     device := aView device.
   642     root   := device rootView.
   646     root   := device rootView.
   643     extent := aView extent.
   647     extent := aView extent.
   644     point  := device translatePoint:0@0 from:(aView id) to:(root id).
   648     point  := device translatePoint:0@0 from:(aView id) to:(root id).
   645 
   649 
   646     DisplayObject := nil.
   650     dO := nil.
   647 
   651 
   648     (point x > 0 and:[point y > 0]) ifTrue:[
   652     (point x > 0 and:[point y > 0]) ifTrue:[
   649         point := point + extent.
   653         point := point + extent.
   650         (point x < root width and:[point y < root height]) ifTrue:[
   654         (point x < root width and:[point y < root height]) ifTrue:[
   651             aView topView raise.
   655             aView topView raise.
   652             device sync.
   656             device sync.
   653             aView invalidate.
   657             aView invalidate.
   654             aView windowGroup processExposeEvents.
   658             aView windowGroup processExposeEvents.
   655             DisplayObject := Image fromView:aView grab:false.
   659             dO := Image fromView:aView grab:false.
   656         ]
   660         ]
   657     ].
   661     ].
   658     DisplayObject isNil ifTrue:[
   662     dO isNil ifTrue:[
   659         DisplayObject := Form extent:extent depth:1.
   663         dO := Form extent:extent depth:1.
   660         DisplayObject colorMap:(Array with:Color white with:Color black).
   664         dO colorMap:(Array with:Color white with:Color black).
   661         DisplayObject fill:(Color colorId:0).
   665         dO fill:(Color colorId:0).
   662         DisplayObject paint:(Color colorId:1).
   666         dO paint:(Color colorId:1).
   663         DisplayObject displayRectangleX:0 y:0 width:aView extent x height:aView extent y.
   667         dO displayRectangleX:0 y:0 width:aView extent x height:aView extent y.
   664     ].
   668     ].
   665     aSpec class == UISubSpecification ifTrue:[
   669     aSpec class == UISubSpecification ifTrue:[
   666         aSpec layout:(LayoutOrigin fromPoint:0@0)
   670         aSpec layout:(LayoutOrigin fromPoint:0@0)
   667     ].
   671     ].
   668   ^ self new theObject:aSpec
   672   ^ self new theObject:aSpec