373 at:nil. |
373 at:nil. |
374 |
374 |
375 self changeSelectionAfterPasteOf:sel. |
375 self changeSelectionAfterPasteOf:sel. |
376 ! |
376 ! |
377 |
377 |
378 pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
378 pasteSpecifications:aSpecificationOrList into:aContainerOrNil beforeIndex:anIndexOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
379 "add the specs to the object view; returns list of pasted widgets" |
379 "add the specs to the object view; returns list of pasted widgets" |
380 |
380 |
381 |specsToPaste pasteOffset builder newSel |
381 |specsToPaste pasteOffset builder newSel |
382 bounds containerToPasteInto pastePoint| |
382 bounds containerToPasteInto pastePoint beforeIndex| |
383 |
383 |
384 treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
384 treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
385 |
385 |
386 containerToPasteInto := aContainerOrNil. |
386 containerToPasteInto := aContainerOrNil. |
387 |
387 |
452 ]. |
452 ]. |
453 bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent). |
453 bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent). |
454 |
454 |
455 pasteOffset := 0. |
455 pasteOffset := 0. |
456 |
456 |
|
457 (anIndexOrNil notNil and:[anIndexOrNil > 0]) ifTrue:[ |
|
458 beforeIndex := anIndexOrNil. |
|
459 ]. |
457 specsToPaste do:[:eachSpec| |
460 specsToPaste do:[:eachSpec| |
458 |view newOrigin uiPainterAttributes thisAbsOrigin| |
461 |view newOrigin uiPainterAttributes thisAbsOrigin| |
459 |
462 |
460 uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. |
463 uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. |
461 eachSpec otherAttributeAt:#uiPainterAttributes put:nil. |
464 eachSpec otherAttributeAt:#uiPainterAttributes put:nil. |
462 |
465 |
463 view := self addSpec:eachSpec builder:builder in:containerToPasteInto. |
466 view := self addSpec:eachSpec builder:builder in:containerToPasteInto beforeIndex:beforeIndex. |
|
467 beforeIndex notNil ifTrue:[ |
|
468 beforeIndex := beforeIndex + 1 |
|
469 ]. |
464 |
470 |
465 (keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ |
471 (keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ |
466 aPointOrNilOrKeep == #keep ifTrue:[ |
472 aPointOrNilOrKeep == #keep ifTrue:[ |
467 newOrigin := uiPainterAttributes at:#origin. |
473 newOrigin := uiPainterAttributes at:#origin. |
468 ] ifFalse:[ |
474 ] ifFalse:[ |
486 pasteOffset := pasteOffset + 4. |
492 pasteOffset := pasteOffset + 4. |
487 ]. |
493 ]. |
488 newOrigin notNil ifTrue:[ |
494 newOrigin notNil ifTrue:[ |
489 self moveObject:view to:newOrigin. |
495 self moveObject:view to:newOrigin. |
490 ]. |
496 ]. |
491 view realize. |
497 view realized ifFalse:[ |
|
498 view realize. |
|
499 ]. |
492 newSel add:view. |
500 newSel add:view. |
493 |
|
494 ]. |
501 ]. |
495 |
502 |
496 self withinTransaction:#paste objects:newSel do:[ |
503 self withinTransaction:#paste objects:newSel do:[ |
497 undoHistory addUndoSelector:#undoCreate: |
504 undoHistory addUndoSelector:#undoCreate: |
498 withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]). |
505 withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]). |
499 self undoHistoryChanged. |
506 self undoHistoryChanged. |
500 ]. |
507 ]. |
501 |
508 |
502 self realizeAllSubViews. |
509 self realizeAllSubViews. |
503 newSel do:[:v| v raise]. |
510 "/ newSel do:[:v| v raise]. |
504 self elementChangedSize:containerToPasteInto. |
511 self elementChangedSize:containerToPasteInto. |
505 |
512 |
506 newSel size == 1 ifTrue:[newSel := newSel at:1]. |
513 newSel size == 1 ifTrue:[newSel := newSel at:1]. |
507 ^ newSel |
514 ^ newSel |
508 |
515 |
509 "Modified: / 10.10.2001 / 14:15:12 / cg" |
516 "Modified: / 10.10.2001 / 14:15:12 / cg" |
|
517 ! |
|
518 |
|
519 pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
|
520 "add the specs to the object view; returns list of pasted widgets" |
|
521 |
|
522 ^ self pasteSpecifications:aSpecificationOrList |
|
523 into:aContainerOrNil |
|
524 beforeIndex:nil |
|
525 keepLayout:keepLayout |
|
526 keepPosition:keepPosition |
|
527 at:aPointOrNilOrKeep |
510 ! |
528 ! |
511 |
529 |
512 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
530 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
513 "add the specs to the object view; returns list of pasted widgets" |
531 "add the specs to the object view; returns list of pasted widgets" |
514 |
532 |
534 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
552 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
535 "add the specs to the object view; returns list of pasted widgets" |
553 "add the specs to the object view; returns list of pasted widgets" |
536 |
554 |
537 ^ self pasteSpecifications:aSpecificationOrList |
555 ^ self pasteSpecifications:aSpecificationOrList |
538 into:nil |
556 into:nil |
|
557 beforeIndex:nil |
539 keepLayout:keepLayout |
558 keepLayout:keepLayout |
540 keepPosition:keepPosition |
559 keepPosition:keepPosition |
541 at:aPointOrNilOrKeep |
560 at:aPointOrNilOrKeep |
542 ! |
561 ! |
543 |
562 |
568 ! |
587 ! |
569 |
588 |
570 replaceSelectionBy:aNewSpec |
589 replaceSelectionBy:aNewSpec |
571 "replace the selected widget by another one." |
590 "replace the selected widget by another one." |
572 |
591 |
573 |oldSelection treeModel widgets oldView container| |
592 |oldSelection treeModel newView oldView container specs| |
574 |
593 |
575 (self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ |
594 (self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ |
576 ^ self |
595 ^ self |
577 ]. |
596 ]. |
578 treeModel := treeView model. |
597 treeModel := treeView model. |
579 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
598 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
580 oldSelection isNil ifTrue:[^ self]. |
599 oldSelection isNil ifTrue:[^ self]. |
581 |
600 |
582 oldView := oldSelection contents view. |
601 oldView := oldSelection contents view. |
|
602 |
|
603 (oldSelection hasChildren and:[aNewSpec class supportsSubComponents]) ifTrue:[ |
|
604 specs := oldSelection children collect:[:each| |
|
605 self fullSpecWithAbsolutePositionFor:(each contents view) |
|
606 ]. |
|
607 ]. |
583 |
608 |
584 aNewSpec |
609 aNewSpec |
585 otherAttributeAt:#uiPainterAttributes |
610 otherAttributeAt:#uiPainterAttributes |
586 put:(Dictionary new |
611 put:(Dictionary new |
587 at:#origin put:oldView origin; |
612 at:#origin put:oldView origin; |
590 yourself). |
615 yourself). |
591 |
616 |
592 container := self singleSelection container. |
617 container := self singleSelection container. |
593 |
618 |
594 self withinTransaction:#replaceBy objects:(Array with:oldView) do:[ |
619 self withinTransaction:#replaceBy objects:(Array with:oldView) do:[ |
595 self deleteSelectionBuffered:false. |
620 self withSelectionHiddenDo:[ |
596 |
621 newView := self |
597 widgets := self |
622 pasteSpecifications:(Array with:aNewSpec) |
598 pasteSpecifications:(Array with:aNewSpec) |
623 into:container |
599 into:container |
624 beforeIndex:1 |
600 keepLayout:true |
625 keepLayout:true |
601 keepPosition:true |
626 keepPosition:true |
602 at:#keep. |
627 at:#keep. |
603 ]. |
628 |
604 self select:widgets. |
629 self deleteSelectionBuffered:false. |
605 ^ widgets. |
630 |
|
631 specs size > 0 ifTrue:[ |
|
632 self pasteSpecifications:specs |
|
633 into:newView |
|
634 keepLayout:(aNewSpec class canResizeSubComponents) |
|
635 keepPosition:(aNewSpec class isLayoutContainer not) |
|
636 at:nil. |
|
637 ]. |
|
638 self select:newView. |
|
639 ]. |
|
640 ]. |
|
641 ^ newView. |
606 ! ! |
642 ! ! |
607 |
643 |
608 !UIPainterView methodsFor:'drag & drop'! |
644 !UIPainterView methodsFor:'drag & drop'! |
609 |
645 |
610 canDrop:aDropContext |
646 canDrop:aDropContext |
2324 "/ remember view<->spec associations to tree |
2360 "/ remember view<->spec associations to tree |
2325 aBuilder componentCreationHook:[:aView :aSpec :builder| |
2361 aBuilder componentCreationHook:[:aView :aSpec :builder| |
2326 |newProperty copyOfSpec nameOfSpec beforeIndex| |
2362 |newProperty copyOfSpec nameOfSpec beforeIndex| |
2327 |
2363 |
2328 (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[ |
2364 (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[ |
2329 subviewToRealize := aFrame. |
2365 subviewToRealize := aView. |
2330 |
2366 |
2331 [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[ |
2367 [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[ |
2332 subviewToRealize := subviewToRealize superView. |
2368 subviewToRealize := subviewToRealize superView. |
2333 ]. |
2369 ]. |
2334 subviewToRealize notNil ifTrue:[ |
2370 subviewToRealize notNil ifTrue:[ |