UIGalleryView.st
changeset 2502 c27a926cbe67
parent 2495 ead2b25a2c63
child 2504 8746b7a4d215
equal deleted inserted replaced
2501:43386f544f3d 2502:c27a926cbe67
   382         builder showDefaults:true.
   382         builder showDefaults:true.
   383     ].
   383     ].
   384 
   384 
   385     specification buildViewFor:builder in:self.
   385     specification buildViewFor:builder in:self.
   386 
   386 
       
   387     "/ components notEmptyOrNil ifTrue:[ self halt ].
   387     subViews size ~~ 0 ifTrue:[
   388     subViews size ~~ 0 ifTrue:[
   388         showBorders ifTrue:[
   389         showBorders ifTrue:[
   389             subViews do:[:v|
   390             subViews do:[:v|
   390                 (self findSpecFor:v) notNil ifTrue:[
   391                 (self findSpecFor:v) notNil ifTrue:[
   391                     v borderWidth:1
   392                     v borderWidth:1
   396     ].
   397     ].
   397 ! !
   398 ! !
   398 
   399 
   399 !UIGalleryView::Canvas methodsFor:'building'!
   400 !UIGalleryView::Canvas methodsFor:'building'!
   400 
   401 
   401 buildSpecFrom:aSpec
   402 recursiveBuildSpecFromSpecPrototype:aSpec
   402     "build spec out of spec"
   403     "build spec out of spec prototype"
   403 
   404 
   404     |spec comp coll|
   405     |spec comp coll|
   405 
   406 
   406     (aSpec notNil and:[aSpec canUIDrag]) ifFalse:[
   407     (aSpec notNil and:[aSpec canUIDrag]) ifFalse:[
   407         ^ nil
   408         ^ nil
   408     ].
   409     ].
   409 
   410 
   410     spec := aSpec copy.
   411     spec := aSpec copy.
   411 
       
   412     (aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[
   412     (aSpec class supportsSubComponents and:[aSpec component notNil]) ifFalse:[
   413         ^ spec
   413         ^ spec
   414     ].
   414     ].
   415     comp := aSpec component.
   415     comp := aSpec component.
   416     spec component:nil.
   416     spec component:nil.
   418     comp canUIDrag ifFalse:[
   418     comp canUIDrag ifFalse:[
   419         ^ spec
   419         ^ spec
   420     ].
   420     ].
   421     coll := OrderedCollection new.
   421     coll := OrderedCollection new.
   422 
   422 
   423     comp do:[:anEntry||spc|
   423     comp do:[:anEntry|
   424         (spc := self buildSpecFrom:anEntry) notNil ifTrue:[
   424         |spc|
       
   425 
       
   426         (spc := self recursiveBuildSpecFromSpecPrototype:anEntry) notNil ifTrue:[
   425             coll add:spc
   427             coll add:spc
   426         ]
   428         ]
   427     ].
   429     ].
   428     coll isEmpty ifTrue:[
   430     coll isEmpty ifTrue:[
   429         ^ spec
   431         ^ spec
   447 
   449 
   448     spec := clientSpecHolder value.
   450     spec := clientSpecHolder value.
   449     spec isNil ifTrue:[^ self].
   451     spec isNil ifTrue:[^ self].
   450 
   452 
   451     self withSelectionHiddenDo:[
   453     self withSelectionHiddenDo:[
   452         spec := self buildSpecFrom:spec.
   454         spec := self recursiveBuildSpecFromSpecPrototype:spec.
   453         spec name:nil.
   455         spec name:nil.
   454 
   456 
   455         dragObj := DropSpec for:selection specification:spec.
   457         dragObj := DropSpec for:selection specification:spec.
   456         offset  := clickPos - selection origin.
   458         offset  := clickPos - selection origin.
   457     ].
   459     ].
   603     aWidget notNil ifTrue:[
   605     aWidget notNil ifTrue:[
   604         name := aWidget name.
   606         name := aWidget name.
   605 
   607 
   606         specification do:[:aSpec|
   608         specification do:[:aSpec|
   607             (aSpec notNil and:[aSpec name = name]) ifTrue:[
   609             (aSpec notNil and:[aSpec name = name]) ifTrue:[
   608                 aSpec canUIDrag ifTrue:[^ aSpec ].
   610                 aSpec canUIDrag ifFalse:[^ nil ].
   609                 ^ nil
   611                 ^ aSpec
   610             ]
   612             ]
   611         ]
   613         ]
   612     ].
   614     ].
   613     ^ nil
   615     ^ nil
   614 
   616 
   639     "redraw all items selected"
   641     "redraw all items selected"
   640 
   642 
   641     (shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[
   643     (shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[
   642         self clippedByChildren:false.
   644         self clippedByChildren:false.
   643 
   645 
       
   646         self paint:Color black.
   644         self handlesOf:selection do:[:aRectangle|
   647         self handlesOf:selection do:[:aRectangle|
   645             self fillRectangle:aRectangle
   648             self fillRectangle:aRectangle
   646         ].
   649         ].
   647         self clippedByChildren:true.
   650         self clippedByChildren:true.
   648     ].
   651     ].
   655 
   658 
   656     selection == aView ifTrue:[^ self].
   659     selection == aView ifTrue:[^ self].
   657 
   660 
   658     self withSelectionHiddenDo:[
   661     self withSelectionHiddenDo:[
   659         spec := self findSpecFor:aView.
   662         spec := self findSpecFor:aView.
       
   663 
   660         selection := (spec isNil) ifTrue:[nil] ifFalse:[aView].
   664         selection := (spec isNil) ifTrue:[nil] ifFalse:[aView].
   661         clientSpecHolder value:spec.
   665         clientSpecHolder value:spec.
   662     ].
   666     ].
   663 !
   667 !
   664 
   668 
   665 withSelectionHiddenDo:aOneArgBlock
   669 withSelectionHiddenDo:aOneArgBlock
   666     |r|
   670     [ 
   667 
   671         |r forceExpose|
   668     [   
   672         
   669         hiddenCounter :=  hiddenCounter + 1.
   673         hiddenCounter :=  hiddenCounter + 1.
   670         hiddenCounter == 1 ifTrue:[
   674         hiddenCounter == 1 ifTrue:[
   671             (shown and:[selection notNil]) ifTrue:[
   675             (shown and:[selection notNil]) ifTrue:[
   672                 self clippedByChildren:false.
   676                 self clippedByChildren:false.
   673 
   677 
   676                     self invalidateRectangle:aRectangle repairNow:false.
   680                     self invalidateRectangle:aRectangle repairNow:false.
   677                 ].
   681                 ].
   678                 self clippedByChildren:true.
   682                 self clippedByChildren:true.
   679 
   683 
   680                 r := selection bounds.
   684                 r := selection bounds.
   681                 subViews notNil ifTrue:[
   685 
   682                     subViews do:[:sv|
   686                 forceExpose := 
       
   687                     [:sv|
   683                         |absOrg absFrame|
   688                         |absOrg absFrame|
   684 
   689 
   685                         (sv bounds intersects:r) ifTrue:[
   690                         (sv bounds intersects:r) ifTrue:[   
   686                             sv borderColor:(Color white).           "/ to force a redraw
   691                             sv isView ifTrue:[
   687                             sv borderColor:(Color black).
   692                                 sv borderColor:(Color white).           "/ kludge to force a redraw
   688 
   693                                 sv borderColor:(Color black).
   689                             sv withAllSubViewsDo:[:v|
   694 
   690                                 v realized ifTrue:[
   695                                 sv withAllSubViewsDo:[:v|
   691                                     v fill:v viewBackground.
   696                                     v realized ifTrue:[
   692                                     v exposeX:0 y:0 width:v width height:v height.
   697                                         v fill:v viewBackground.
       
   698                                         v exposeX:0 y:0 width:v width height:v height.
       
   699                                     ]
   693                                 ]
   700                                 ]
   694                             ]
   701                             ] ifFalse:[
       
   702                                 sv invalidate.
       
   703                             ].
   695                         ]
   704                         ]
   696                     ]
   705                     ].
   697                 ].
   706 
       
   707                 (subViews ? #()) do:forceExpose.
       
   708                 (components ? #()) do:forceExpose.
   698             ].
   709             ].
   699         ].
   710         ].
       
   711         self repairDamage.  "/ ensure that any outstanding clear/redraw of the unselect are done before
   700         aOneArgBlock value.
   712         aOneArgBlock value.
   701     ] ensure:[
   713     ] ensure:[
   702         self repairDamage.  "/ ensure that any outstanding clear/redraw of the unselect are done before
   714         self repairDamage.  "/ ensure that any outstanding clear/redraw of the unselect are done before
   703 
   715 
   704         hiddenCounter := hiddenCounter - 1.
   716         hiddenCounter := hiddenCounter - 1.