269 |
269 |
270 self deleteSelectionBuffered: true |
270 self deleteSelectionBuffered: true |
271 ! |
271 ! |
272 |
272 |
273 deleteSelectionBuffered: buffered |
273 deleteSelectionBuffered: buffered |
274 "cut the selection into the cut&paste-buffer |
274 "cut the selection. If buffered is true, place it into the cut&paste-buffer" |
275 and open a transaction" |
275 |
276 |
276 |specs specsToRemove index oldSelection newSelection treeModel children size node| |
277 |specs coll index oldSelection newSelection treeModel children size nd| |
|
278 |
277 |
279 treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
278 treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
280 |
279 |
281 coll := self minSetOfSuperViews:(self selection). |
280 specsToRemove := self minClosedViewSetFor:(self selection). |
282 |
281 specsToRemove notEmptyOrNil ifTrue:[ |
283 coll notNil ifTrue:[ |
282 treeView canvasEventsDisabledDo:[ |
284 treeView cvsEventsDisabledDo:[ |
|
285 treeModel := treeView model. |
283 treeModel := treeView model. |
286 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
284 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
287 |
285 |
288 oldSelection notNil ifTrue:[ |
286 oldSelection notNil ifTrue:[ |
289 children := oldSelection parent children. |
287 children := oldSelection parent children. |
301 newSelection := 1 |
299 newSelection := 1 |
302 ]. |
300 ]. |
303 |
301 |
304 self hideSelection. |
302 self hideSelection. |
305 selection := nil. |
303 selection := nil. |
306 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
304 specs := specsToRemove collect:[:aView| self fullSpecFor:aView ]. |
307 |
305 |
308 self withinTransaction:#cut objects:coll do:[ |
306 self withinTransaction:#cut objects:specsToRemove do:[ |
309 coll reverseDo:[:aView| |
307 specsToRemove reverseDo:[:aView| |
310 self createUndoRemove:aView. |
308 self createUndoRemove:aView. |
311 self remove:aView. |
309 self remove:aView. |
312 ] |
310 ] |
313 ]. |
311 ]. |
314 buffered ifTrue: [self setClipboardObject:specs]. |
312 buffered ifTrue: [self setClipboardObject:specs]. |
315 treeView selection:nil. |
313 treeView selection:nil. |
316 treeView selection:(Array with: newSelection). |
314 treeView selection:(Array with: newSelection). |
317 (nd := treeView selectedNode) notNil ifTrue:[ |
315 (node := treeView selectedNode) notNil ifTrue:[ |
318 self setSelection:nd contents view withRedraw:true. |
316 self setSelection:node contents view withRedraw:true. |
319 ] |
317 ] |
320 ] |
318 ] |
321 ] |
319 ] |
322 ! |
320 ! |
323 |
321 |
367 |
365 |
368 self changeSelectionAfterPasteOf:sel. |
366 self changeSelectionAfterPasteOf:sel. |
369 ! |
367 ! |
370 |
368 |
371 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
369 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
372 "add the specs to the object view; returns list of pasted components" |
370 "add the specs to the object view; returns list of pasted widgets" |
373 |
371 |
374 ^ self |
372 ^ self |
375 pasteSpecifications:aSpecificationOrList |
373 pasteSpecifications:aSpecificationOrList |
376 keepLayout:keepLayout |
374 keepLayout:keepLayout |
377 at:nil |
375 at:nil |
378 |
376 |
379 "Modified: 11.8.1997 / 01:00:35 / cg" |
377 "Modified: 11.8.1997 / 01:00:35 / cg" |
380 ! |
378 ! |
381 |
379 |
382 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
380 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
383 "add the specs to the object view; returns list of pasted components" |
381 "add the specs to the object view; returns list of pasted widgets" |
384 |
382 |
385 ^ self |
383 ^ self |
386 pasteSpecifications:aSpecificationOrList |
384 pasteSpecifications:aSpecificationOrList |
387 keepLayout:keepLayout |
385 keepLayout:keepLayout |
388 keepPosition:false |
386 keepPosition:false |
389 at:aPointOrNil |
387 at:aPointOrNil |
390 ! |
388 ! |
391 |
389 |
392 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
390 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
393 "add the specs to the object view; returns list of pasted components" |
391 "add the specs to the object view; returns list of pasted widgets" |
394 |
392 |
395 |paste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto| |
393 |specsToPaste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto| |
396 |
394 |
397 treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
395 treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
398 |
396 |
399 containerToPasteInto := self singleSelection. |
397 containerToPasteInto := self singleSelection. |
400 containerToPasteInto isNil ifTrue:[ |
398 containerToPasteInto isNil ifTrue:[ |
511 |
508 |
512 |sel| |
509 |sel| |
513 |
510 |
514 sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true. |
511 sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true. |
515 self changeSelectionAfterPasteOf:sel. |
512 self changeSelectionAfterPasteOf:sel. |
|
513 ! |
|
514 |
|
515 replaceSelectionBy:aNewSpec |
|
516 "replace the selected widget by another one." |
|
517 |
|
518 |specs coll index oldSelection newSelection treeModel children size node |
|
519 container widgets builder newView property| |
|
520 |
|
521 treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
|
522 self assert:(self selection size == 1). |
|
523 |
|
524 treeModel := treeView model. |
|
525 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
526 property := oldSelection contents. |
|
527 property spec:aNewSpec. |
|
528 self halt. |
|
529 self rebuildView:(property view) fromSpec:aNewSpec withBuilder:nil forceNewView:true. |
|
530 |
|
531 "/ p := self propertyOfView:aView) |
|
532 "/ |
|
533 "/ builder := UIBuilder new isEditing:true. |
|
534 "/ newView := aNewSpec buildViewWithLayoutFor:builder in:(container contents view). |
|
535 self halt. |
|
536 ^self. |
|
537 self deleteSelectionBuffered:false. |
|
538 widgets := self pasteSpecifications:(Array with:aNewSpec) keepLayout:false. |
|
539 self select:widgets. |
|
540 ^ widgets. |
|
541 |
|
542 treeView canvasEventsDisabledDo:[ |
|
543 treeModel := treeView model. |
|
544 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
545 |
|
546 oldSelection notNil ifTrue:[ |
|
547 children := oldSelection parent children. |
|
548 (size := children size) > 1 ifTrue:[ |
|
549 index := children identityIndexOf:oldSelection. |
|
550 size == index ifTrue:[ |
|
551 index := index - 1 |
|
552 ]. |
|
553 newSelection := children at:index ifAbsent:1. |
|
554 ] ifFalse:[ |
|
555 newSelection := oldSelection parent |
|
556 ]. |
|
557 newSelection := treeModel indexOf:newSelection. |
|
558 ] ifFalse:[ |
|
559 newSelection := 1 |
|
560 ]. |
|
561 |
|
562 self hideSelection. |
|
563 selection := nil. |
|
564 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
565 |
|
566 self withinTransaction:#cut objects:coll do:[ |
|
567 coll reverseDo:[:aView| |
|
568 self createUndoRemove:aView. |
|
569 self remove:aView. |
|
570 ] |
|
571 ]. |
|
572 treeView selection:nil. |
|
573 treeView selection:(Array with: newSelection). |
|
574 (node := treeView selectedNode) notNil ifTrue:[ |
|
575 self setSelection:node contents view withRedraw:true. |
|
576 ] |
|
577 ] |
516 ! ! |
578 ! ! |
517 |
579 |
518 !UIPainterView methodsFor:'drag & drop'! |
580 !UIPainterView methodsFor:'drag & drop'! |
519 |
581 |
520 canDrop:aDropContext |
582 canDrop:aDropContext |
2060 |
2122 |
2061 addToSelection:anObject |
2123 addToSelection:anObject |
2062 "add an object to the selection |
2124 "add an object to the selection |
2063 " |
2125 " |
2064 (self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
2126 (self enabled and:[(self isSelected:anObject) not]) ifTrue:[ |
2065 selection isCollection ifFalse:[ |
2127 selection isCollection ifFalse:[ |
2066 selection isNil ifTrue:[ |
2128 selection isNil ifTrue:[ |
2067 selection := anObject |
2129 selection := anObject |
2068 ] ifFalse:[ |
2130 ] ifFalse:[ |
2069 selection := OrderedCollection with:selection with:anObject |
2131 selection := OrderedCollection with:selection with:anObject |
2070 ] |
2132 ] |
2071 ] ifTrue:[ |
2133 ] ifTrue:[ |
2072 "/ to enforce the change-message (value is identical to oldValue) |
2134 "/ to enforce the change-message (value is identical to oldValue) |
2073 selection isList ifTrue:[ |
2135 selection isList ifTrue:[ |
2074 selection add:anObject |
2136 selection add:anObject |
2075 ] ifFalse:[ |
2137 ] ifFalse:[ |
2076 selection := selection asOrderedCollection. |
2138 selection := selection asOrderedCollection. |
2077 selection := selection copyWith:anObject |
2139 selection := selection copyWith:anObject |
2078 ] |
2140 ] |
2079 ]. |
2141 ]. |
2080 self showSelected:anObject. |
2142 self showSelected:anObject. |
2081 treeView cvsSelectionAdd:anObject. |
2143 treeView canvasSelectionAdd:anObject. |
2082 ] |
2144 ] |
2083 |
2145 |
2084 "Modified: / 11.2.2000 / 01:39:05 / cg" |
2146 "Modified: / 11.2.2000 / 01:39:05 / cg" |
2085 ! |
2147 ! |
2086 |
2148 |
2087 removeFromSelection:anObject |
2149 removeFromSelection:anObject |
2088 "remove an object from the selection |
2150 "remove an object from the selection |
2089 " |
2151 " |
2090 (self isSelected:anObject) ifTrue:[ |
2152 (self isSelected:anObject) ifTrue:[ |
2091 self showUnselected:anObject. |
2153 self showUnselected:anObject. |
2092 |
2154 |
2093 selection size > 1 ifTrue:[ |
2155 selection size > 1 ifTrue:[ |
2094 selection isList ifTrue:[ |
2156 selection isList ifTrue:[ |
2095 selection remove:anObject ifAbsent:nil |
2157 selection remove:anObject ifAbsent:nil |
2096 ] ifFalse:[ |
2158 ] ifFalse:[ |
2097 "/ to enforce the change-message (value is identical to oldValue) |
2159 "/ to enforce the change-message (value is identical to oldValue) |
2098 selection := selection asOrderedCollection. |
2160 selection := selection asOrderedCollection. |
2099 selection := selection copyWithout:anObject |
2161 selection := selection copyWithout:anObject |
2100 ]. |
2162 ]. |
2101 self showSelection. |
2163 self showSelection. |
2102 ] ifFalse:[ |
2164 ] ifFalse:[ |
2103 selection := nil |
2165 selection := nil |
2104 ]. |
2166 ]. |
2105 treeView cvsSelectionRemove:anObject. |
2167 treeView canvasSelectionRemove:anObject. |
2106 ] |
2168 ] |
2107 |
2169 |
2108 "Modified: / 11.2.2000 / 01:41:11 / cg" |
2170 "Modified: / 11.2.2000 / 01:41:11 / cg" |
2109 ! |
2171 ! |
2110 |
2172 |
2111 select:something |
2173 select:something |
2112 "change selection to something |
2174 "change selection to something |
2113 " |
2175 " |
2114 (self enabled and:[something ~= self selection]) ifTrue:[ |
2176 (self enabled and:[something ~= self selection]) ifTrue:[ |
2115 something isNil |
2177 something isNil |
2116 ifTrue: [treeView selection: (Array with: 1)] |
2178 ifTrue: [treeView selection: (Array with: 1)] |
2117 ifFalse:[treeView cvsSelection:something]. |
2179 ifFalse:[treeView canvasSelection:something]. |
2118 self setSelection:something withRedraw:true |
2180 self setSelection:something withRedraw:true |
2119 ] |
2181 ] |
2120 |
|
2121 ! |
2182 ! |
2122 |
2183 |
2123 selectNextUpInHierarchy |
2184 selectNextUpInHierarchy |
2124 | sel | |
2185 | sel | |
2125 |
2186 |
2126 (sel := self selection) isNil ifTrue:[^self]. |
2187 (sel := self selection) isNil ifTrue:[^self]. |
2127 sel isCollection ifTrue:[ |
2188 sel isCollection ifTrue:[ |
2128 sel := self selection first. |
2189 sel := self selection first. |
2129 ]. |
2190 ]. |
2130 sel := sel superView. |
2191 sel := sel superView. |
2131 sel isNil ifTrue:[^self]. |
2192 sel isNil ifTrue:[^self]. |
2132 treeView cvsSelection: sel. |
2193 treeView canvasSelection: sel. |
2133 self selection: sel. |
2194 self selection: sel. |
2134 ! |
2195 ! |
2135 |
2196 |
2136 updateSelectionFromModel:aSelOrNil |
2197 updateSelectionFromModel:aSelOrNil |
2137 "update selection from a new selection |
2198 "update selection from a new selection |
2227 |
2288 |
2228 |
2289 |
2229 ! |
2290 ! |
2230 |
2291 |
2231 rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil |
2292 rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil |
|
2293 self |
|
2294 rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil forceNewView:false |
|
2295 ! |
|
2296 |
|
2297 rebuildView:aView fromSpec:aSpec withBuilder:aBuilderOrNil forceNewView:forceNewView |
2232 |v builder| |
2298 |v builder| |
2233 |
2299 |
2234 (builder := aBuilderOrNil) isNil ifTrue:[ |
2300 (builder := aBuilderOrNil) isNil ifTrue:[ |
2235 "/ create a dummy builder |
2301 "/ create a dummy builder |
2236 builder := UIBuilder new isEditing:true. |
2302 builder := UIBuilder new isEditing:true. |
2237 className notNil ifTrue:[ |
2303 className notNil ifTrue:[ |
2238 builder applicationClass:(self resolveName:className). |
2304 builder applicationClass:(self resolveName:className). |
2239 ]. |
2305 ]. |
2240 ]. |
2306 ]. |
2241 |
2307 |
2242 aSpec class isLayoutContainer ifTrue:[ |
2308 aSpec class isLayoutContainer ifTrue:[ |
2243 "/ TODO: |
2309 "/ TODO: |
2244 "/ go through subviews and let them resize to their default/preferred |
2310 "/ go through subviews and let them resize to their default/preferred |
2245 "/ needed if we change a containers layout from fit to non-fit. |
2311 "/ needed if we change a containers layout from fit to non-fit. |
2246 |
2312 |
2247 (aView subViews ? #()) do:[:aSubView | |
2313 (aView subViews ? #()) do:[:aSubView | |
2248 |fix spec prop| |
2314 |fix spec prop| |
2249 |
2315 |
2250 (prop := self propertyOfView:aSubView) notNil ifTrue:[ |
2316 (prop := self propertyOfView:aSubView) notNil ifTrue:[ |
2251 spec := prop spec. |
2317 spec := prop spec. |
2252 |
2318 |
2253 spec useDefaultExtent ifTrue:[ |
2319 spec useDefaultExtent ifTrue:[ |
2254 fix := aSubView sizeFixed:false. |
2320 fix := aSubView sizeFixed:false. |
2255 aSubView extent:aSubView preferredExtent. |
2321 aSubView extent:aSubView preferredExtent. |
2256 aSubView sizeFixed:fix |
2322 aSubView sizeFixed:fix |
2257 ] |
2323 ] |
2258 ] |
2324 ] |
2259 ]. |
2325 ]. |
2260 ]. |
2326 ]. |
2261 |
2327 |
2262 aSpec needsRebuildForAttributes ifTrue:[ |
2328 (forceNewView or:[aSpec needsRebuildForAttributes]) ifTrue:[ |
2263 "/ needs a full rebuild (in case view class depends upon spec-attribute) |
2329 "/ needs a full rebuild (in case view class depends upon spec-attribute) |
2264 v := aSpec buildViewWithLayoutFor:builder in:(self findContainerOfView:aView). |
2330 v := aSpec buildViewWithLayoutFor:builder in:(self findContainerOfView:aView). |
2265 v realize. |
2331 v realize. |
2266 aView destroy. |
2332 aView destroy. |
2267 device sync. |
2333 device sync. |
2268 device flush. |
2334 device flush. |
2269 aView becomeSameAs:v. |
2335 aView becomeSameAs:v. |
2270 "/ inputView raise. |
2336 "/ inputView raise. |
2271 ] ifFalse:[ |
2337 ] ifFalse:[ |
2272 aSpec setAttributesIn:aView with:builder. |
2338 aSpec setAttributesIn:aView with:builder. |
2273 self elementChangedSize:aView. |
2339 self elementChangedSize:aView. |
2274 ]. |
2340 ]. |
2275 |
|
2276 ! |
2341 ! |
2277 |
2342 |
2278 specFor:anObject |
2343 specFor:anObject |
2279 "returns spec assigned to an object |
2344 "returns spec assigned to an object |
2280 " |
2345 " |