13 |
13 |
14 |
14 |
15 "{ Package: 'stx:libtool2' }" |
15 "{ Package: 'stx:libtool2' }" |
16 |
16 |
17 ObjectView subclass:#UIObjectView |
17 ObjectView subclass:#UIObjectView |
18 instanceVariableNames:'saveSelection inputView undoHistory copiedExtent copiedLayout |
18 instanceVariableNames:'saveSelection undoHistory copiedExtent copiedLayout resizeData |
19 resizeData clipChildren selectionHiddenLevel gridParameters |
19 clipChildren selectionHiddenLevel gridParameters |
20 setOfSuperViewsSizeChanged' |
20 setOfSuperViewsSizeChanged' |
21 classVariableNames:'' |
21 classVariableNames:'' |
22 poolDictionaries:'' |
22 poolDictionaries:'' |
23 category:'Interface-UIPainter' |
23 category:'Interface-UIPainter' |
|
24 ! |
|
25 |
|
26 Object subclass:#PostEventHandler |
|
27 instanceVariableNames:'onView' |
|
28 classVariableNames:'' |
|
29 poolDictionaries:'' |
|
30 privateIn:UIObjectView |
24 ! |
31 ! |
25 |
32 |
26 Object subclass:#ResizeData |
33 Object subclass:#ResizeData |
27 instanceVariableNames:'object selector delta' |
34 instanceVariableNames:'object selector delta' |
28 classVariableNames:'' |
35 classVariableNames:'' |
484 ! |
488 ! |
485 |
489 |
486 exposeX:x y:y width:w height:h |
490 exposeX:x y:y width:w height:h |
487 "handle an expose event from device; redraw selection |
491 "handle an expose event from device; redraw selection |
488 " |
492 " |
489 |
|
490 resizeData isNil ifTrue:[ |
493 resizeData isNil ifTrue:[ |
491 super exposeX:x y:y width:w height:h. |
494 super exposeX:x y:y width:w height:h. |
492 |
495 |
493 "/ handle any expose events (for subcomponents) before |
496 "/ handle any expose events (for subcomponents) before |
494 "/ redrawing the handles. |
497 "/ redrawing the handles. |
495 (self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
498 (self sensor hasExposeEventFor:nil) ifTrue:[^ self]. |
496 |
499 |
497 self selectionDo:[:aComponent | |
500 self selectionDo:[:aComponent | |
498 aComponent withAllSubViewsDo:[:v | |
501 aComponent withAllSubViewsDo:[:v | |
499 v realized ifTrue:[ |
502 v realized ifTrue:[ |
500 self sensor flushExposeEventsFor:v. |
503 self sensor flushExposeEventsFor:v. |
501 v exposeX:0 y:0 width:v width height:v height. |
504 v exposeX:0 y:0 width:v width height:v height. |
502 ] |
505 ] |
503 ]. |
506 ]. |
504 self showSelected:aComponent |
507 self showSelected:aComponent |
505 ] |
508 ] |
506 ]. |
509 ]. |
507 |
510 |
508 "Modified: / 9.11.1998 / 12:50:34 / cg" |
511 "Modified: / 9.11.1998 / 12:50:34 / cg" |
509 ! |
512 ! |
510 |
513 |
554 |
557 |
555 processEvent:anEvent |
558 processEvent:anEvent |
556 "catch expose events for components, and redraw its handles after |
559 "catch expose events for components, and redraw its handles after |
557 the redraw when this happens |
560 the redraw when this happens |
558 " |
561 " |
559 |
562 |evView x y p| |
560 |evView| |
563 |
561 |
564 self testMode ifTrue:[^ false]. |
562 anEvent isDamage ifTrue:[ |
565 |
563 evView := anEvent view. |
566 evView := anEvent view. |
564 (self isSelected:evView) ifTrue:[ |
567 (evView isNil or:[evView == self]) ifTrue:[ |
565 self showSelected:evView |
568 ^ false |
566 ] |
569 ]. |
567 ]. |
570 |
|
571 (evView isComponentOf:self) ifFalse:[ |
|
572 ^ false |
|
573 ]. |
|
574 |
|
575 anEvent isInputEvent ifFalse:[ |
|
576 "/ #isDamage: handled in PostEventHandler |
|
577 |
|
578 "/ (shown and:[anEvent isDamage]) ifTrue:[ |
|
579 "/ (self isSelected:evView) ifTrue:[ |
|
580 "/ self showSelected:evView |
|
581 "/ ]. |
|
582 "/ ]. |
|
583 ^ false |
|
584 ]. |
|
585 |
|
586 (anEvent isButtonEvent or:[anEvent isKeyEvent]) ifFalse:[ |
|
587 ^ true |
|
588 ]. |
|
589 |
|
590 x := anEvent x. |
|
591 y := anEvent y. |
|
592 p := device translatePoint:(x@y) fromView:evView toView:self. |
|
593 |
|
594 "/ patch the event |
|
595 anEvent x:p x. |
|
596 anEvent y:p y. |
|
597 anEvent view:self. |
568 ^ false. |
598 ^ false. |
569 ! |
599 ! |
570 |
600 |
571 redrawX:nx y:ny width:nw height:nh |
601 redrawX:nx y:ny width:nw height:nh |
572 "ignore redraws - my components redraw themself |
602 "ignore redraws - my components redraw themself |
575 |
605 |
576 sizeChanged:how |
606 sizeChanged:how |
577 "size of a view(s) changed |
607 "size of a view(s) changed |
578 " |
608 " |
579 self withSelectionHiddenDo:[ |
609 self withSelectionHiddenDo:[ |
580 super sizeChanged:how |
610 super sizeChanged:how. |
581 ] |
611 ]. |
582 |
|
583 |
|
584 ! ! |
612 ! ! |
585 |
613 |
586 !UIObjectView methodsFor:'initialization'! |
614 !UIObjectView methodsFor:'initialization'! |
587 |
615 |
588 initialize |
616 initialize |
589 "setup attributes |
617 "setup attributes |
590 " |
618 " |
591 super initialize. |
619 super initialize. |
592 |
620 |
593 "funny: since I do not want the created widgets to get pointer |
|
594 events, I put an InputView on top of them, which catches those events |
|
595 and passes them back to me - have to take care, that this inputView |
|
596 is always on top |
|
597 " |
|
598 inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
|
599 setOfSuperViewsSizeChanged := IdentitySet new. |
621 setOfSuperViewsSizeChanged := IdentitySet new. |
600 |
|
601 inputView eventReceiver:self. |
|
602 inputView enableButtonEvents. |
|
603 inputView enableButtonMotionEvents. |
|
604 |
|
605 self setDefaultActions. |
622 self setDefaultActions. |
606 |
623 |
607 undoHistory := UndoHistory on:self. |
624 undoHistory := UndoHistory on:self. |
608 self enableChannel:(true asValue). |
625 self enableChannel:(true asValue). |
609 clipChildren := true. |
626 clipChildren := true. |
610 selectionHiddenLevel := 0. |
627 selectionHiddenLevel := 0. |
611 |
628 |
612 (self class gridShown) ifTrue:[ |
629 (self class gridShown) ifTrue:[ |
613 super showGrid |
630 super showGrid |
614 ]. |
631 ]. |
615 |
632 |
616 "Modified: / 20.7.1998 / 18:14:51 / cg" |
633 "Modified: / 20.7.1998 / 18:14:51 / cg" |
617 "Modified: / 30.3.1999 / 16:19:15 / stefan" |
634 "Modified: / 30.3.1999 / 16:19:15 / stefan" |
618 ! |
635 ! |
623 " |
640 " |
624 super map. |
641 super map. |
625 self showSelection. |
642 self showSelection. |
626 ! |
643 ! |
627 |
644 |
628 mapped |
|
629 "make certain that the input view is on top. |
|
630 " |
|
631 super mapped. |
|
632 inputView raise. |
|
633 |
|
634 "Created: / 20.7.1998 / 18:10:20 / cg" |
|
635 "Modified: / 20.7.1998 / 18:11:32 / cg" |
|
636 ! |
|
637 |
|
638 realize |
645 realize |
|
646 |windowGroup| |
|
647 |
639 super realize. |
648 super realize. |
640 self windowGroup postEventHook:self |
649 windowGroup := self windowGroup. |
641 |
650 windowGroup addPreEventHook:self. |
|
651 windowGroup addPostEventHook:(PostEventHandler new onView:self). |
642 ! |
652 ! |
643 |
653 |
644 remap |
654 remap |
645 "make the view visible on the screen and in case of a none empty |
655 "make the view visible on the screen and in case of a none empty |
646 selection the selection will be shown. |
656 selection the selection will be shown. |
1129 !UIObjectView methodsFor:'searching'! |
1128 !UIObjectView methodsFor:'searching'! |
1130 |
1129 |
1131 findObjectAt:aPoint |
1130 findObjectAt:aPoint |
1132 "find the origin/corner of the currentWidget |
1131 "find the origin/corner of the currentWidget |
1133 " |
1132 " |
1134 |view viewId lastId point listOfViews| |
1133 |view viewId lastId point| |
1135 |
1134 |
1136 point := aPoint + (device translatePoint:0@0 fromView:self toView:rootView). |
1135 point := aPoint + (device translatePoint:0@0 fromView:self toView:rootView). |
1137 |
|
1138 inputView lower. |
|
1139 |
1136 |
1140 viewId := rootView id. |
1137 viewId := rootView id. |
1141 [viewId notNil] whileTrue:[ |
1138 [viewId notNil] whileTrue:[ |
1142 lastId := viewId. |
1139 lastId := viewId. |
1143 viewId := device viewIdFromPoint:point in:lastId |
1140 viewId := device viewIdFromPoint:point in:lastId |
1144 ]. |
1141 ]. |
1145 |
1142 |
1146 inputView raise. |
|
1147 |
|
1148 view := device viewFromId:lastId. |
1143 view := device viewFromId:lastId. |
1149 |
1144 view == self ifTrue:[ ^ nil]. |
1150 view ~~ inputView ifTrue:[^ view]. |
1145 ^ view |
1151 |
1146 "/ view ~~ inputView ifTrue:[^ view]. |
1152 "/ look for 'hidden' views ... |
1147 "/ |
1153 |
1148 "/ "/ look for 'hidden' views ... |
1154 listOfViews := OrderedCollection new. |
1149 "/ |
1155 self allSubViewsDo:[:aView | |
1150 "/ listOfViews := OrderedCollection new. |
1156 |org| |
1151 "/ self allSubViewsDo:[:aView | |
1157 |
1152 "/ |org| |
1158 aView ~~ inputView ifTrue:[ |
1153 "/ |
1159 org := device translatePoint:0@0 fromView:aView toView:self. |
1154 "/ aView ~~ inputView ifTrue:[ |
1160 ((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
1155 "/ org := device translatePoint:0@0 fromView:aView toView:self. |
1161 listOfViews add:aView. |
1156 "/ ((org extent:aView extent) containsPoint:aPoint) ifTrue:[ |
1162 ] |
1157 "/ listOfViews add:aView. |
1163 ] |
1158 "/ ] |
1164 ]. |
1159 "/ ] |
1165 |
1160 "/ ]. |
1166 listOfViews size > 0 ifTrue:[ |
1161 "/ |
1167 ^ listOfViews last |
1162 "/ listOfViews size > 0 ifTrue:[ |
1168 ]. |
1163 "/ ^ listOfViews last |
1169 ^ nil |
1164 "/ ]. |
1170 |
1165 "/ ^ nil |
1171 "Modified: / 10.10.2001 / 14:05:07 / cg" |
1166 "/ |
|
1167 "/ "Modified: / 10.10.2001 / 14:05:07 / cg" |
|
1168 "/ |
|
1169 "/ |
1172 ! ! |
1170 ! ! |
1173 |
1171 |
1174 !UIObjectView methodsFor:'selections'! |
1172 !UIObjectView methodsFor:'selections'! |
1175 |
1173 |
1176 hideSelection |
1174 hideSelection |