UIPainter.st
changeset 2256 2bd9e855e6ac
parent 2251 afc2987e67b1
child 2258 db98899b44d1
equal deleted inserted replaced
2255:4cca07c42e74 2256:2bd9e855e6ac
    18 	poolDictionaries:''
    18 	poolDictionaries:''
    19 	category:'Interface-UIPainter'
    19 	category:'Interface-UIPainter'
    20 !
    20 !
    21 
    21 
    22 SelectionInTreeView subclass:#TreeView
    22 SelectionInTreeView subclass:#TreeView
    23 	instanceVariableNames:'lastDrawnMaster cvsEventsDisabled windowSpec windowSpecClass'
    23 	instanceVariableNames:'lastDrawnMaster canvasEventsDisabled windowSpec windowSpecClass'
    24 	classVariableNames:''
    24 	classVariableNames:''
    25 	poolDictionaries:''
    25 	poolDictionaries:''
    26 	privateIn:UIPainter
    26 	privateIn:UIPainter
    27 !
    27 !
    28 
    28 
  4846         title: 'Window Spec'
  4846         title: 'Window Spec'
  4847 
  4847 
  4848 !
  4848 !
  4849 
  4849 
  4850 replaceWidgetByClass:aSpecOrWidgetClass
  4850 replaceWidgetByClass:aSpecOrWidgetClass
  4851     |specClass oldSpec newSpec sel painter|
  4851     |specClass oldSpec newSpec painter|
  4852 
  4852 
  4853     (aSpecOrWidgetClass isSubclassOf:UISpecification) ifTrue:[
  4853     (aSpecOrWidgetClass isSubclassOf:UISpecification) ifTrue:[
  4854         specClass := aSpecOrWidgetClass.
  4854         specClass := aSpecOrWidgetClass.
  4855     ] ifFalse:[
  4855     ] ifFalse:[
  4856         (aSpecOrWidgetClass isSubclassOf:View) ifTrue:[
  4856         (aSpecOrWidgetClass isSubclassOf:View) ifTrue:[
  4868     ].
  4868     ].
  4869     oldSpec := self selectedSpec.
  4869     oldSpec := self selectedSpec.
  4870     newSpec := specClass cloneFrom:oldSpec.
  4870     newSpec := specClass cloneFrom:oldSpec.
  4871 
  4871 
  4872     painter := self painter.
  4872     painter := self painter.
  4873     painter deleteSelectionBuffered:false.
  4873     painter replaceSelectionBy:newSpec.
  4874     sel := painter pasteSpecifications:(Array with:newSpec) keepLayout:false.
       
  4875     painter select:sel.
       
  4876 !
  4874 !
  4877 
  4875 
  4878 useSketch
  4876 useSketch
  4879     "select sketchfile to underly"
  4877     "select sketchfile to underly"
  4880 
  4878 
  5153     self application treeSelectionChanged.
  5151     self application treeSelectionChanged.
  5154 ! !
  5152 ! !
  5155 
  5153 
  5156 !UIPainter::TreeView methodsFor:'canvas selection'!
  5154 !UIPainter::TreeView methodsFor:'canvas selection'!
  5157 
  5155 
  5158 cvsSelection:aSelection
  5156 canvasSelection:aSelection
  5159     "canvas changed its selection
  5157     "canvas changed its selection
  5160     "
  5158     "
  5161     |sel list size|
  5159     |sel list size|
  5162 
  5160 
  5163     ((sel := aSelection) isNil or:[sel isCollection]) ifFalse:[
  5161     ((sel := aSelection) isNil or:[sel isCollection]) ifFalse:[
  5173                 model doMakeVisible:item.
  5171                 model doMakeVisible:item.
  5174             ]
  5172             ]
  5175         ].
  5173         ].
  5176         sel := list collect:[:anItem| self indexOfNode:anItem ].
  5174         sel := list collect:[:anItem| self indexOfNode:anItem ].
  5177     ].
  5175     ].
  5178     self cvsEventsDisabledDo:[ self selection:sel ].            
  5176     self canvasEventsDisabledDo:[ self selection:sel ].            
  5179 
  5177 !
  5180 
  5178 
  5181 
  5179 canvasSelectionAdd:aView
  5182 
       
  5183 !
       
  5184 
       
  5185 cvsSelectionAdd:aView
       
  5186     "canvas adds a view to current selection
  5180     "canvas adds a view to current selection
  5187     "
  5181     "
  5188     |item index oldSel|
  5182     |item index oldSel|
  5189 
  5183 
  5190     item := self itemOfView:aView.
  5184     item := self itemOfView:aView.
  5196             oldSel := selection copy.
  5190             oldSel := selection copy.
  5197             self addToSelection:index.
  5191             self addToSelection:index.
  5198             self selectionChangedFrom:oldSel
  5192             self selectionChangedFrom:oldSel
  5199         ]        
  5193         ]        
  5200     ]            
  5194     ]            
  5201 
  5195 !
  5202 
  5196 
  5203 
  5197 canvasSelectionRemove:aView
  5204 !
       
  5205 
       
  5206 cvsSelectionRemove:aView
       
  5207     "canvas removes a view from current selection
  5198     "canvas removes a view from current selection
  5208     "
  5199     "
  5209     |item index oldSel|
  5200     |item index oldSel|
  5210 
  5201 
  5211     (     (item := self itemOfView:aView) notNil
  5202     (     (item := self itemOfView:aView) notNil
  5214     ) ifTrue:[
  5205     ) ifTrue:[
  5215         oldSel := selection copy.
  5206         oldSel := selection copy.
  5216         self removeFromSelection:index.
  5207         self removeFromSelection:index.
  5217         self selectionChangedFrom:oldSel.
  5208         self selectionChangedFrom:oldSel.
  5218     ].
  5209     ].
  5219 
       
  5220 
       
  5221 ! !
  5210 ! !
  5222 
  5211 
  5223 !UIPainter::TreeView methodsFor:'change & update'!
  5212 !UIPainter::TreeView methodsFor:'change & update'!
  5224 
  5213 
  5225 canvasNameChanged:aName
  5214 canvasNameChanged:aName
  5364 
  5353 
  5365 ! !
  5354 ! !
  5366 
  5355 
  5367 !UIPainter::TreeView methodsFor:'event handling'!
  5356 !UIPainter::TreeView methodsFor:'event handling'!
  5368 
  5357 
  5369 cvsEventsDisabledDo:aBlock
  5358 canvasEventsDisabledDo:aBlock
  5370     "evaluates the block without raising selection changed notifications
  5359     "evaluates the block without raising selection changed notifications to canvas"
  5371      to canvas"
  5360 
  5372 
  5361     |restoreCanvasEvents|
  5373     |restoreCvsEvents|
  5362 
  5374 
  5363     restoreCanvasEvents  := canvasEventsDisabled.
  5375     restoreCvsEvents  := cvsEventsDisabled.
  5364     canvasEventsDisabled := true.
  5376     cvsEventsDisabled := true.
       
  5377     aBlock value.
  5365     aBlock value.
  5378     cvsEventsDisabled := restoreCvsEvents.
  5366     canvasEventsDisabled := restoreCanvasEvents.
  5379 
       
  5380 
       
  5381 !
  5367 !
  5382 
  5368 
  5383 doubleClicked
  5369 doubleClicked
  5384     "disables collapsing of the root item"
  5370     "disables collapsing of the root item"
  5385 
  5371 
  5413     "initialize the tree view; multiple select and tree item actions"
  5399     "initialize the tree view; multiple select and tree item actions"
  5414 
  5400 
  5415     super initialize.
  5401     super initialize.
  5416 
  5402 
  5417     self multipleSelectOk:true.
  5403     self multipleSelectOk:true.
  5418     cvsEventsDisabled := false.
  5404     canvasEventsDisabled := false.
  5419     self showDirectoryIndicator: true.
  5405     self showDirectoryIndicator: true.
  5420     self showDirectoryIndicatorForRoot: false.
  5406     self showDirectoryIndicatorForRoot: false.
  5421 
  5407 
  5422     self model 
  5408     self model 
  5423         iconAction: 
  5409         iconAction: 
  5459     |sel size|
  5445     |sel size|
  5460 
  5446 
  5461     super selectionChangedFrom:oldSelection.
  5447     super selectionChangedFrom:oldSelection.
  5462     size := selection size.
  5448     size := selection size.
  5463 
  5449 
  5464     cvsEventsDisabled ifFalse:[
  5450     canvasEventsDisabled ifFalse:[
  5465         (size ~~ 0 and:[size ~~ 1 or:[selection first ~~ 1]]) ifTrue:[
  5451         (size ~~ 0 and:[size ~~ 1 or:[selection first ~~ 1]]) ifTrue:[
  5466             sel := OrderedCollection new.
  5452             sel := OrderedCollection new.
  5467 
  5453 
  5468             selection do:[:i|
  5454             selection do:[:i|
  5469                 i ~~ 1 ifTrue:[sel add:(listOfNodes at:i) contents view]
  5455                 i ~~ 1 ifTrue:[sel add:(listOfNodes at:i) contents view]