417 lastClickPoint := nil. |
417 lastClickPoint := nil. |
418 |
418 |
419 spec := clientSpecHolder value. |
419 spec := clientSpecHolder value. |
420 spec isNil ifTrue:[^ self]. |
420 spec isNil ifTrue:[^ self]. |
421 |
421 |
422 self hideSelection. |
422 self selectionHiddenDo:[ |
423 |
423 spec := self buildSpecFrom:spec. |
424 dragMode := true. |
424 spec name:nil. |
425 spec := self buildSpecFrom:spec. |
425 |
426 spec name:nil. |
426 dragObj := DropSpec for:selection specification:spec. |
427 |
427 offset := clickPos - selection origin. |
428 dragObj := DropSpec for:selection specification:spec. |
428 ]. |
429 offset := clickPos - selection origin. |
429 |
430 |
430 DragAndDropManager startDrag:dragObj from:evView offset:offset. |
431 DragAndDropManager startDrag:dragObj from:self offset:offset. |
|
432 ! ! |
431 ! ! |
433 |
432 |
434 !UIGalleryView::Canvas methodsFor:'event handling'! |
433 !UIGalleryView::Canvas methodsFor:'event handling'! |
435 |
434 |
436 processEvent:anEvent |
435 processEvent:anEvent |
437 |evView p| |
436 |evView p| |
438 |
437 |
439 dragMode ifTrue:[ |
|
440 anEvent isButtonReleaseEvent ifTrue:[ |
|
441 dragMode := false. |
|
442 lastClickPoint := nil. |
|
443 self invalidateSelection. |
|
444 ]. |
|
445 ^ false |
|
446 ]. |
|
447 |
|
448 evView := anEvent view. |
438 evView := anEvent view. |
449 evView isNil ifTrue:[ ^ false ]. |
439 evView isNil ifTrue:[ ^ false ]. |
450 |
440 |
451 evView == self ifFalse:[ |
441 evView == self ifFalse:[ |
452 (evView isComponentOf:self) ifFalse:[ ^ false ]. |
442 (evView isComponentOf:self) ifFalse:[ ^ false ]. |
453 ]. |
443 ]. |
454 |
444 |
455 anEvent isButtonEvent ifFalse:[ |
445 anEvent isButtonEvent ifFalse:[ |
456 anEvent isInputEvent ifTrue:[^ true]. |
446 anEvent isInputEvent ifTrue:[^ true]. |
457 anEvent isDamage ifTrue:[ self invalidateSelection ]. |
447 anEvent isDamage ifTrue:[ self redrawSelection ]. |
458 ^ false |
448 ^ false |
459 ]. |
449 ]. |
460 |
450 |
461 anEvent isButtonReleaseEvent ifTrue:[ |
451 anEvent isButtonReleaseEvent ifTrue:[ |
462 lastClickPoint := nil. |
452 lastClickPoint := nil. |
502 |
493 |
503 !UIGalleryView::Canvas methodsFor:'initialization'! |
494 !UIGalleryView::Canvas methodsFor:'initialization'! |
504 |
495 |
505 initialize |
496 initialize |
506 super initialize. |
497 super initialize. |
507 |
|
508 dragMode := false. |
|
509 buttonPressed := false. |
|
510 clientSpecHolder := nil asValue. |
498 clientSpecHolder := nil asValue. |
|
499 hiddenCounter := 0. |
511 ! |
500 ! |
512 |
501 |
513 realize |
502 realize |
514 super realize. |
503 super realize. |
515 self windowGroup addPreEventHook:self. |
504 self windowGroup addPreEventHook:self. |
516 ! ! |
|
517 |
|
518 !UIGalleryView::Canvas methodsFor:'private'! |
|
519 |
|
520 redrawSelection |
|
521 "redraw all items selected |
|
522 " |
|
523 (buttonPressed or:[selection isNil or:[shown not]]) ifTrue:[ |
|
524 ^ self |
|
525 ]. |
|
526 |
|
527 (self sensor hasEvent:#redrawSelection for:self) ifTrue:[^ self]. |
|
528 |
|
529 (buttonPressed or:[selection isNil ]) ifFalse:[ |
|
530 self clippedByChildren:false. |
|
531 |
|
532 self handlesOf:selection do:[:aRectangle| |
|
533 self fillRectangle:aRectangle |
|
534 ]. |
|
535 self clippedByChildren:true. |
|
536 ]. |
|
537 ! ! |
505 ! ! |
538 |
506 |
539 !UIGalleryView::Canvas methodsFor:'searching'! |
507 !UIGalleryView::Canvas methodsFor:'searching'! |
540 |
508 |
541 findObjectAt:aPoint |
509 findObjectAt:aPoint |
598 ] |
566 ] |
599 |
567 |
600 |
568 |
601 ! |
569 ! |
602 |
570 |
603 hideSelection |
571 redrawSelection |
604 "show unselected |
572 "redraw all items selected |
605 " |
573 " |
606 |r saveSelect| |
574 (shown and:[selection notNil and:[hiddenCounter == 0]]) ifTrue:[ |
607 |
575 self clippedByChildren:false. |
608 (shown and:[selection notNil]) ifFalse:[ |
576 |
609 ^ self |
577 self handlesOf:selection do:[:aRectangle| |
610 ]. |
578 self fillRectangle:aRectangle |
611 saveSelect := selection. |
579 ]. |
612 selection := nil. |
580 self clippedByChildren:true. |
613 |
|
614 self clippedByChildren:false. |
|
615 |
|
616 self handlesOf:saveSelect do:[:aRectangle| |
|
617 self clearRectangle:aRectangle |
|
618 ]. |
|
619 self clippedByChildren:true. |
|
620 |
|
621 r := saveSelect bounds. |
|
622 |
|
623 subViews do:[:sv| |
|
624 |absOrg absFrame| |
|
625 |
|
626 (sv bounds intersects:r) ifTrue:[ |
|
627 sv borderColor:(Color white). "/ to force a redraw |
|
628 sv borderColor:(Color black). |
|
629 |
|
630 sv withAllSubViewsDo:[:v| |
|
631 v realized ifTrue:[ |
|
632 v fill:v viewBackground. |
|
633 v exposeX:0 y:0 width:v width height:v height. |
|
634 ] |
|
635 ] |
|
636 ] |
|
637 ]. |
|
638 selection := saveSelect. |
|
639 ! |
|
640 |
|
641 invalidateSelection |
|
642 "show selected |
|
643 " |
|
644 (shown and:[selection notNil and:[buttonPressed not]]) ifTrue:[ |
|
645 self sensor pushUserEvent:#redrawSelection for:self withArguments:nil. |
|
646 ]. |
581 ]. |
647 ! |
582 ! |
648 |
583 |
649 selection:aView |
584 selection:aView |
650 "selection changed |
585 "selection changed |
651 " |
586 " |
652 |spec| |
587 |spec| |
653 |
588 |
654 selection == aView ifTrue:[^ self]. |
589 selection == aView ifTrue:[^ self]. |
655 |
590 |
656 self hideSelection. |
591 self selectionHiddenDo:[ |
657 spec := self findSpecFor:aView. |
592 spec := self findSpecFor:aView. |
658 |
593 |
659 spec notNil ifTrue:[ selection := aView ] |
594 spec notNil ifTrue:[ selection := aView ] |
660 ifFalse:[ selection := nil ]. |
595 ifFalse:[ selection := nil ]. |
661 |
596 |
662 clientSpecHolder value:spec. |
597 clientSpecHolder value:spec. |
663 self invalidateSelection. |
598 ]. |
|
599 ! |
|
600 |
|
601 selectionHiddenDo:aOneArgBlock |
|
602 |r| |
|
603 |
|
604 [ hiddenCounter := hiddenCounter + 1. |
|
605 |
|
606 hiddenCounter == 1 ifTrue:[ |
|
607 (shown and:[selection notNil]) ifTrue:[ |
|
608 self clippedByChildren:false. |
|
609 |
|
610 self handlesOf:selection do:[:aRectangle| |
|
611 self clearRectangle:aRectangle |
|
612 ]. |
|
613 self clippedByChildren:true. |
|
614 |
|
615 r := selection bounds. |
|
616 |
|
617 subViews do:[:sv| |
|
618 |absOrg absFrame| |
|
619 |
|
620 (sv bounds intersects:r) ifTrue:[ |
|
621 sv borderColor:(Color white). "/ to force a redraw |
|
622 sv borderColor:(Color black). |
|
623 |
|
624 sv withAllSubViewsDo:[:v| |
|
625 v realized ifTrue:[ |
|
626 v fill:v viewBackground. |
|
627 v exposeX:0 y:0 width:v width height:v height. |
|
628 ] |
|
629 ] |
|
630 ] |
|
631 ] |
|
632 ]. |
|
633 ]. |
|
634 aOneArgBlock value. |
|
635 ] ensure:[ |
|
636 hiddenCounter := hiddenCounter - 1. |
|
637 self redrawSelection. |
|
638 ]. |
664 ! ! |
639 ! ! |
665 |
640 |
666 !UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
641 !UIGalleryView::Canvas::DropSpec class methodsFor:'instance creation'! |
667 |
642 |
668 for:aView specification:aSpec |
643 for:aView specification:aSpec |