324 ! |
342 ! |
325 |
343 |
326 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
344 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
327 "add the specs to the object view; returns list of pasted components |
345 "add the specs to the object view; returns list of pasted components |
328 " |
346 " |
|
347 self |
|
348 pasteSpecifications:aSpecificationOrList |
|
349 keepLayout:keepLayout |
|
350 keepPosition:false |
|
351 at:aPointOrNil |
|
352 |
|
353 ! |
|
354 |
|
355 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil |
|
356 "add the specs to the object view; returns list of pasted components |
|
357 " |
329 |paste frame pasteOrigin pasteOffset builder newSel bounds| |
358 |paste frame pasteOrigin pasteOffset builder newSel bounds| |
330 |
359 |
331 (self canPaste:aSpecificationOrList) ifFalse:[ |
360 (self canPaste:aSpecificationOrList) ifFalse:[ |
332 ^ nil |
361 ^ nil |
333 ]. |
362 ]. |
338 paste := Array with:aSpecificationOrList |
367 paste := Array with:aSpecificationOrList |
339 ]. |
368 ]. |
340 (frame := self singleSelection) isNil ifTrue:[ |
369 (frame := self singleSelection) isNil ifTrue:[ |
341 frame := self |
370 frame := self |
342 ]. |
371 ]. |
|
372 |
343 self selection:nil. |
373 self selection:nil. |
344 |
374 |
345 newSel := OrderedCollection new. |
375 newSel := OrderedCollection new. |
346 builder := UIBuilder new isEditing:true. |
376 builder := UIBuilder new isEditing:true. |
347 |
377 |
348 className notNil ifTrue:[ |
378 className notNil ifTrue:[ |
349 builder applicationClass:(self resolveName:className) |
379 builder applicationClass:(self resolveName:className) |
350 ]. |
380 ]. |
351 |
381 |
352 keepLayout ifFalse:[ |
382 (keepLayout not or:[keepPosition]) ifTrue:[ |
353 pasteOffset := 0@0. |
383 pasteOffset := 0@0. |
354 |
384 |
355 aPointOrNil isNil ifTrue:[ |
385 keepPosition ifTrue:[ |
356 pasteOrigin := self sensor mousePoint. |
386 pasteOrigin := device translatePoint:0@0 |
357 pasteOrigin := device translatePoint:pasteOrigin |
|
358 from:device rootView id |
|
359 to:frame id. |
|
360 ] ifFalse:[ |
|
361 pasteOrigin := device translatePoint:aPointOrNil |
|
362 from:self id |
387 from:self id |
363 to:frame id. |
388 to:frame id. |
364 ] |
389 ] ifFalse:[ |
365 ]. |
390 aPointOrNil isNil ifTrue:[ |
366 keepLayout ifFalse:[ |
391 pasteOrigin := self sensor mousePoint. |
|
392 pasteOrigin := device translatePoint:pasteOrigin |
|
393 from:device rootView id |
|
394 to:frame id. |
|
395 ] ifFalse:[ |
|
396 pasteOrigin := device translatePoint:aPointOrNil |
|
397 from:self id |
|
398 to:frame id. |
|
399 ] |
|
400 ]. |
|
401 |
367 bounds := Rectangle origin:0@0 extent:(frame bounds extent) |
402 bounds := Rectangle origin:0@0 extent:(frame bounds extent) |
368 ]. |
403 ]. |
369 |
404 |
370 paste do:[:aSpec| |
405 paste do:[:aSpec| |
371 |view| |
406 |view newOrigin| |
372 |
407 |
373 view := self addSpec:aSpec builder:builder in:frame. |
408 view := self addSpec:aSpec builder:builder in:frame. |
374 |
409 |
375 keepLayout ifFalse:[ |
410 keepPosition ifTrue:[ |
376 (bounds containsPoint:pasteOrigin) ifFalse:[ |
411 self moveObject:view to:(view origin + pasteOrigin). |
377 self moveObject:view to:pasteOffset. |
412 ] ifFalse:[ |
378 ] ifTrue:[ |
413 keepLayout ifFalse:[ |
379 self moveObject:view to:pasteOrigin + pasteOffset. |
414 (bounds containsPoint:pasteOrigin) ifFalse:[ |
|
415 newOrigin := pasteOffset. |
|
416 ] ifTrue:[ |
|
417 newOrigin := pasteOrigin + pasteOffset. |
|
418 ]. |
|
419 self moveObject:view to:newOrigin. |
|
420 pasteOffset := pasteOffset + 4 |
380 ]. |
421 ]. |
381 pasteOffset := pasteOffset + 4 |
|
382 ]. |
422 ]. |
383 view realize. |
423 view realize. |
384 newSel add:view. |
424 newSel add:view. |
385 ]. |
425 ]. |
386 |
426 |