373 at:nil. |
373 at:nil. |
374 |
374 |
375 self changeSelectionAfterPasteOf:sel. |
375 self changeSelectionAfterPasteOf:sel. |
376 ! |
376 ! |
377 |
377 |
378 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
378 pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
379 "add the specs to the object view; returns list of pasted widgets" |
|
380 |
|
381 ^ self |
|
382 pasteSpecifications:aSpecificationOrList |
|
383 keepLayout:keepLayout |
|
384 keepPosition:true |
|
385 at:nil |
|
386 |
|
387 "Modified: 11.8.1997 / 01:00:35 / cg" |
|
388 ! |
|
389 |
|
390 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
391 "add the specs to the object view; returns list of pasted widgets" |
|
392 |
|
393 ^ self |
|
394 pasteSpecifications:aSpecificationOrList |
|
395 keepLayout:keepLayout |
|
396 keepPosition:true |
|
397 at:aPointOrNil |
|
398 ! |
|
399 |
|
400 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
|
401 "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" |
402 |
380 |
403 |specsToPaste pasteOffset builder newSel |
381 |specsToPaste pasteOffset builder newSel |
404 bounds containerToPasteInto pastePoint| |
382 bounds containerToPasteInto pastePoint| |
405 |
383 |
406 treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
384 treeView askForSelectionChangeAllowed ifFalse:[^ nil]. |
|
385 |
|
386 containerToPasteInto := aContainerOrNil. |
407 |
387 |
408 (aPointOrNilOrKeep == #keep |
388 (aPointOrNilOrKeep == #keep |
409 or:[ self window sensor shiftDown |
389 or:[ self window sensor shiftDown |
410 or:[ self window sensor ctrlDown ]]) ifTrue:[ |
390 or:[ self window sensor ctrlDown ]]) ifTrue:[ |
411 "/ paste into the selection |
391 "/ paste into the selection |
412 containerToPasteInto := self singleSelection. |
392 containerToPasteInto isNil ifTrue:[ |
|
393 containerToPasteInto := self singleSelection. |
|
394 ]. |
413 ] ifFalse:[ |
395 ] ifFalse:[ |
414 "/ ignore the selection and paste where we drop!! |
396 "/ ignore the selection and paste where we drop!! |
415 pastePoint := aPointOrNilOrKeep. |
397 pastePoint := aPointOrNilOrKeep. |
416 pastePoint isNil ifTrue:[ |
398 pastePoint isNil ifTrue:[ |
417 pastePoint := device |
399 pastePoint := device |
418 translatePoint:(self sensor mousePoint) |
400 translatePoint:(self sensor mousePoint) |
419 fromView:nil |
401 fromView:nil |
420 toView:self. |
402 toView:self. |
421 ]. |
403 ]. |
422 containerToPasteInto := self findObjectAt:pastePoint |
404 containerToPasteInto isNil ifTrue:[ |
|
405 containerToPasteInto := self findObjectAt:pastePoint. |
|
406 ]. |
423 ]. |
407 ]. |
424 |
408 |
425 containerToPasteInto isNil ifTrue:[ |
409 containerToPasteInto isNil ifTrue:[ |
426 self selection size > 0 ifTrue:[ |
410 self selection size > 0 ifTrue:[ |
427 containerToPasteInto := self commonContainerOf:self selection |
411 containerToPasteInto := self commonContainerOf:self selection |
472 |
456 |
473 specsToPaste do:[:eachSpec| |
457 specsToPaste do:[:eachSpec| |
474 |view newOrigin uiPainterAttributes thisAbsOrigin| |
458 |view newOrigin uiPainterAttributes thisAbsOrigin| |
475 |
459 |
476 uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. |
460 uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. |
477 "/ eachSpec otherAttributeAt:#uiPainterAttributes put:nil. |
461 "/ eachSpec otherAttributeAt:#uiPainterAttributes put:nil. |
478 |
462 |
479 view := self addSpec:eachSpec builder:builder in:containerToPasteInto. |
463 view := self addSpec:eachSpec builder:builder in:containerToPasteInto. |
480 |
464 |
481 (keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ |
465 (keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ |
482 aPointOrNilOrKeep == #keep ifTrue:[ |
466 aPointOrNilOrKeep == #keep ifTrue:[ |
523 ^ newSel |
507 ^ newSel |
524 |
508 |
525 "Modified: / 10.10.2001 / 14:15:12 / cg" |
509 "Modified: / 10.10.2001 / 14:15:12 / cg" |
526 ! |
510 ! |
527 |
511 |
|
512 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout |
|
513 "add the specs to the object view; returns list of pasted widgets" |
|
514 |
|
515 ^ self |
|
516 pasteSpecifications:aSpecificationOrList |
|
517 keepLayout:keepLayout |
|
518 keepPosition:true |
|
519 at:nil |
|
520 |
|
521 "Modified: 11.8.1997 / 01:00:35 / cg" |
|
522 ! |
|
523 |
|
524 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil |
|
525 "add the specs to the object view; returns list of pasted widgets" |
|
526 |
|
527 ^ self |
|
528 pasteSpecifications:aSpecificationOrList |
|
529 keepLayout:keepLayout |
|
530 keepPosition:true |
|
531 at:aPointOrNil |
|
532 ! |
|
533 |
|
534 pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep |
|
535 "add the specs to the object view; returns list of pasted widgets" |
|
536 |
|
537 ^ self pasteSpecifications:aSpecificationOrList |
|
538 into:nil |
|
539 keepLayout:keepLayout |
|
540 keepPosition:keepPosition |
|
541 at:aPointOrNilOrKeep |
|
542 ! |
|
543 |
528 pasteWithLayout |
544 pasteWithLayout |
529 "add the objects in the paste-buffer to the object view - keep the old layout" |
545 "add the objects in the paste-buffer to the object view - keep the old layout" |
530 |
546 |
531 |sel| |
547 |sel| |
532 |
548 |
552 ! |
568 ! |
553 |
569 |
554 replaceSelectionBy:aNewSpec |
570 replaceSelectionBy:aNewSpec |
555 "replace the selected widget by another one." |
571 "replace the selected widget by another one." |
556 |
572 |
557 |specs coll index oldSelection newSelection treeModel children size node |
573 |oldSelection treeModel widgets oldView container| |
558 container widgets builder newView property| |
574 |
559 |
575 (self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ |
560 treeView askForSelectionChangeAllowed ifFalse:[^ self]. |
576 ^ self |
561 self assert:(self selection size == 1). |
577 ]. |
562 |
578 treeModel := treeView model. |
563 treeModel := treeView model. |
|
564 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
579 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
565 property := oldSelection contents. |
580 oldSelection isNil ifTrue:[^ self]. |
566 property spec:aNewSpec. |
581 |
567 |
582 oldView := oldSelection contents view. |
568 self rebuildView:(property view) fromSpec:aNewSpec withBuilder:nil forceNewView:true. |
583 |
569 |
584 aNewSpec |
570 "/ p := self propertyOfView:aView) |
585 otherAttributeAt:#uiPainterAttributes |
571 "/ |
586 put:(Dictionary new |
572 "/ builder := UIBuilder new isEditing:true. |
587 at:#origin put:oldView origin; |
573 "/ newView := aNewSpec buildViewWithLayoutFor:builder in:(container contents view). |
588 at:#extent put:oldView extent; |
574 self halt. |
589 at:#absOrigin put:(oldView originRelativeTo:self); |
575 "/ ^self. |
590 yourself). |
576 self deleteSelectionBuffered:false. |
591 |
577 widgets := self pasteSpecifications:(Array with:aNewSpec) keepLayout:false. |
592 container := self singleSelection container. |
|
593 |
|
594 self withinTransaction:#replaceBy objects:(Array with:oldView) do:[ |
|
595 self deleteSelectionBuffered:false. |
|
596 |
|
597 widgets := self |
|
598 pasteSpecifications:(Array with:aNewSpec) |
|
599 into:container |
|
600 keepLayout:true |
|
601 keepPosition:true |
|
602 at:#keep. |
|
603 ]. |
578 self select:widgets. |
604 self select:widgets. |
579 ^ widgets. |
605 ^ widgets. |
580 |
|
581 treeView canvasEventsDisabledDo:[ |
|
582 treeModel := treeView model. |
|
583 oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. |
|
584 |
|
585 oldSelection notNil ifTrue:[ |
|
586 children := oldSelection parent children. |
|
587 (size := children size) > 1 ifTrue:[ |
|
588 index := children identityIndexOf:oldSelection. |
|
589 size == index ifTrue:[ |
|
590 index := index - 1 |
|
591 ]. |
|
592 newSelection := children at:index ifAbsent:1. |
|
593 ] ifFalse:[ |
|
594 newSelection := oldSelection parent |
|
595 ]. |
|
596 newSelection := treeModel indexOf:newSelection. |
|
597 ] ifFalse:[ |
|
598 newSelection := 1 |
|
599 ]. |
|
600 |
|
601 self hideSelection. |
|
602 selection := nil. |
|
603 specs := coll collect:[:aView| self fullSpecFor:aView ]. |
|
604 |
|
605 self withinTransaction:#cut objects:coll do:[ |
|
606 coll reverseDo:[:aView| |
|
607 self createUndoRemove:aView. |
|
608 self remove:aView. |
|
609 ] |
|
610 ]. |
|
611 treeView selection:nil. |
|
612 treeView selection:(Array with: newSelection). |
|
613 (node := treeView selectedNode) notNil ifTrue:[ |
|
614 self setSelection:node contents view withRedraw:true. |
|
615 ] |
|
616 ] |
|
617 ! ! |
606 ! ! |
618 |
607 |
619 !UIPainterView methodsFor:'drag & drop'! |
608 !UIPainterView methodsFor:'drag & drop'! |
620 |
609 |
621 canDrop:aDropContext |
610 canDrop:aDropContext |