698 self displayForm:img x:x y:(y - ext y) |
720 self displayForm:img x:x y:(y - ext y) |
699 ]. |
721 ]. |
700 |
722 |
701 |
723 |
702 |
724 |
|
725 ! |
|
726 |
|
727 redrawVisibleLine:visLineNr |
|
728 self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor |
|
729 ! |
|
730 |
|
731 redrawVisibleLine:visLineNr from:startCol to:endCol |
|
732 self drawFromVisibleLine:visLineNr to:visLineNr with:fgColor and:bgColor |
703 ! ! |
733 ! ! |
704 |
734 |
705 !SelectionInTreeView methodsFor:'drawing basics'! |
735 !SelectionInTreeView methodsFor:'drawing basics'! |
706 |
736 |
707 drawLabelIndex:anIndex atX:x y:yCenter |
737 drawFromVisibleLine:startVisLineNr to:endVisLineNr with:fg and:bg |
708 "draw text label at x and y centered |
738 "redraw a visible line range with clearing the background |
709 " |
739 " |
710 |lbl y| |
740 |y h| |
711 |
741 |
712 (lbl := (listOfNodes at:anIndex) name) notNil ifTrue:[ |
742 y := self yOfVisibleLine:startVisLineNr. |
713 y := yCenter + labelOffsetY. |
743 h := endVisLineNr - startVisLineNr + 1 * fontHeight. |
714 self displayOpaqueString:lbl x:x y:y. |
744 |
715 ] |
745 y + h > height ifTrue:[ |
|
746 h := height - y |
|
747 ]. |
|
748 self redrawX:0 y:y width:width height:h. |
716 ! |
749 ! |
717 |
750 |
718 drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop |
751 drawVHLinesX:x0 y:y0 toX:x1 start:start stop:stop |
719 "redraw from line to line without clearing the background |
752 "redraw from line to line without clearing the background |
720 " |
753 " |
833 ]. |
866 ]. |
834 self mask:nil. |
867 self mask:nil. |
835 |
868 |
836 ! |
869 ! |
837 |
870 |
|
871 drawVisibleLineSelected:visLineNr with:fg and:bg |
|
872 "redraw a single line as selected." |
|
873 |y| |
|
874 |
|
875 (self visibleLineToListLine:visLineNr) isNil ifTrue:[ |
|
876 ^ super drawVisibleLine:visLineNr with:fg and:bg |
|
877 ]. |
|
878 self redrawX:0 |
|
879 y:(self yOfVisibleLine:visLineNr) |
|
880 width:width |
|
881 height:fontHeight |
|
882 ! |
|
883 |
|
884 redrawLabelAt:x y:yTop index:anIndex |
|
885 |isSelected y0 x0 x1 maxX w label i| |
|
886 |
|
887 label := (listOfNodes at:anIndex) name. |
|
888 isSelected := self isInSelection:anIndex. |
|
889 |
|
890 highlightMode == #label ifTrue:[ |
|
891 x0 := x + 4. |
|
892 |
|
893 isSelected ifTrue:[ |
|
894 w := (label notNil ifTrue:[label widthOn:self] ifFalse:[60]) + 8. |
|
895 self paint:hilightBgColor. |
|
896 self fillRectangleX:x y:yTop width:w height:fontHeight. |
|
897 ] |
|
898 ] ifFalse:[ |
|
899 x0 := x |
|
900 ]. |
|
901 |
|
902 label notNil ifTrue:[ |
|
903 isSelected ifTrue:[self paint:hilightFgColor on:hilightBgColor] |
|
904 ifFalse:[self paint:fgColor on:bgColor]. |
|
905 |
|
906 self displayOpaqueString:label x:x0 y:yTop + (fontHeight // 2) + labelOffsetY. |
|
907 ]. |
|
908 |
|
909 (isSelected and:[highlightMode == #label]) ifTrue:[ |
|
910 self redrawSelFrameAtX:x y:yTop toX:(x + w) |
|
911 ]. |
|
912 |
|
913 ! |
|
914 |
838 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop |
915 redrawLinesX:x0 y:y0 toX:x1 start:start stop:stop |
839 "redraw from line to line without clearing the background |
916 "redraw from line to line without clearing the background |
840 " |
917 " |
841 |node prevNode parent icon showIndc showIcon showText nxtPrnt |
918 |node prevNode parent icon showIndc showIcon showText nxtPrnt |
842 |
919 |
909 (showIcon and:[(icon := self figureFor:node) notNil]) ifTrue:[ |
986 (showIcon and:[(icon := self figureFor:node) notNil]) ifTrue:[ |
910 self displayForm:icon x:xIcon y:(yCtr - (icon height // 2)) |
987 self displayForm:icon x:xIcon y:(yCtr - (icon height // 2)) |
911 ]. |
988 ]. |
912 |
989 |
913 showText ifTrue:[ |
990 showText ifTrue:[ |
914 (self isInSelection:anIndex) ifFalse:[ |
991 self redrawLabelAt:xText y:(yBot - fontHeight) index:anIndex |
915 self paint:fgColor on:bgColor |
|
916 ] ifTrue:[ |
|
917 self paint:hilightFgColor on:hilightBgColor |
|
918 ]. |
|
919 self drawLabelIndex:anIndex atX:xText y:yCtr . |
|
920 ]. |
992 ]. |
921 (showIndc and:[node showIndicator]) ifTrue:[ |
993 (showIndc and:[node showIndicator]) ifTrue:[ |
922 icon := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator]. |
994 icon := node isCollapsable ifTrue:[openIndicator] ifFalse:[closeIndicator]. |
923 self displayForm:icon x:xIndc y:(yCtr - offIndcY) |
995 self displayForm:icon x:xIndc y:(yCtr - offIndcY) |
924 ]. |
996 ]. |
925 prevNode := node. |
997 prevNode := node. |
926 ] |
998 ] |
927 ! |
999 ! |
928 |
1000 |
929 redrawSelFrameForYs:aList fromX:x0 toX:x1 |
1001 redrawSelFrameAtX:x0 y:y0 toX:x1 |
930 "redraw selection frames for each line starting at an absolute |
1002 "redraw selection frame for a line |
931 y derived from the argument a list. |
1003 " |
932 " |
1004 | |
933 | |
|
934 spc "{ Class: SmallInteger }" |
|
935 dY "{ Class: SmallInteger }" |
|
936 w "{ Class: SmallInteger }" |
1005 w "{ Class: SmallInteger }" |
937 y "{ Class: SmallInteger }" |
1006 y "{ Class: SmallInteger }" |
938 x "{ Class: SmallInteger }" |
1007 x "{ Class: SmallInteger }" |
939 | |
1008 | |
940 aList isNil ifTrue:[ |
|
941 ^ self |
|
942 ]. |
|
943 strikeOut ifTrue:[ |
|
944 y := fontHeight // 2. |
|
945 self paint:bgColor. |
|
946 aList do:[:sY| self displayLineFromX:x0 y:(sY + y) toX:x1 y:(sY + y) ]. |
|
947 ^ self |
|
948 ]. |
|
949 spc := lineSpacing // 2. |
|
950 |
1009 |
951 hilightFrameColor notNil ifTrue:[ |
1010 hilightFrameColor notNil ifTrue:[ |
952 hilightLevel == 0 ifTrue:[ |
1011 hilightLevel == 0 ifTrue:[ |
953 dY := fontHeight - 1. |
|
954 self paint:hilightFrameColor. |
1012 self paint:hilightFrameColor. |
955 |
1013 self displayLineFromX:x0 y:y0 toX:x1 y:y0. |
956 aList do:[:sY| |
1014 y := y0 + fontHeight - 1. |
957 y := sY - spc. self displayLineFromX:x0 y:y toX:x1 y:y. |
1015 ^ self displayLineFromX:x0 y:y toX:x1 y:y. |
958 y := y + dY. self displayLineFromX:x0 y:y toX:x1 y:y. |
|
959 ]. |
|
960 ] |
1016 ] |
961 ] ifFalse:[ |
1017 ] ifFalse:[ |
962 hilightStyle == #motif ifTrue:[ |
1018 hilightStyle == #motif ifTrue:[ |
963 dY := fontHeight - spc - 2. |
|
964 self paint:bgColor. |
1019 self paint:bgColor. |
965 |
1020 |
966 aList do:[:sY| |
1021 y := y0 + 1. |
967 y := sY - spc + 1. self displayLineFromX:x0 y:y toX:x1 y:y. |
1022 self displayLineFromX:x0 y:y toX:x1 y:y. |
968 y := sY + dY. self displayLineFromX:x0 y:y toX:x1 y:y. |
1023 y := y0 + fontHeight - 2. |
|
1024 self displayLineFromX:x0 y:y toX:x1 y:y. |
|
1025 ] |
|
1026 ]. |
|
1027 |
|
1028 hilightLevel ~~ 0 ifTrue:[ |
|
1029 "/ draw edge |
|
1030 |
|
1031 highlightMode == #line ifTrue:[ |
|
1032 w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset. |
|
1033 x := margin - leftOffset. |
|
1034 ] ifFalse:[ |
|
1035 w := x1 - x0. |
|
1036 x := x0. |
|
1037 ]. |
|
1038 self drawEdgesForX:x y:y0 width:w height:fontHeight level:hilightLevel. |
|
1039 ] |
|
1040 |
|
1041 |
|
1042 |
|
1043 ! |
|
1044 |
|
1045 redrawX:x y:y width:w height:h |
|
1046 "a region must be redrawn" |
|
1047 |
|
1048 |savClip startLn sel |
|
1049 y0 "{ Class:SmallInteger }" |
|
1050 y1 "{ Class:SmallInteger }" |
|
1051 visStart "{ Class:SmallInteger }" |
|
1052 visEnd "{ Class:SmallInteger }" |
|
1053 stopLn "{ Class:SmallInteger }" |
|
1054 maxY "{ Class:SmallInteger }" |
|
1055 maxX "{ Class:SmallInteger }" |
|
1056 dltLine "{ Class:SmallInteger }" |
|
1057 startY "{ Class:SmallInteger }"| |
|
1058 |
|
1059 shown ifFalse:[^ self]. |
|
1060 |
|
1061 visStart := self visibleLineOfY:(y + 1). |
|
1062 startLn := self visibleLineToAbsoluteLine:visStart. |
|
1063 |
|
1064 self paint:bgColor. |
|
1065 self fillRectangleX:x y:y width:w height:h. |
|
1066 startLn isNil ifTrue:[ ^ self ]. |
|
1067 |
|
1068 sel := nil. |
|
1069 maxX := x + w. |
|
1070 maxY := y + h. |
|
1071 visEnd := self visibleLineOfY:maxY. |
|
1072 startY := self yOfVisibleLine:visStart. |
|
1073 dltLine := startLn - visStart. |
|
1074 stopLn := dltLine + visEnd. |
|
1075 savClip := clipRect. |
|
1076 |
|
1077 self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
|
1078 |
|
1079 (highlightMode == #line and:[self hasSelection]) ifTrue:[ |
|
1080 "/ redraw the background for all selected lines in the invalid range |
|
1081 |
|
1082 self selectionDo:[:lnNr| |
|
1083 (lnNr between:startLn and:stopLn) ifTrue:[ |
|
1084 sel isNil ifTrue:[ |
|
1085 sel := OrderedCollection new. |
|
1086 self paint:hilightBgColor. |
|
1087 ]. |
|
1088 sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)). |
|
1089 y1 := y0 + fontHeight min:maxY. |
|
1090 y0 := y0 max:y. |
|
1091 self fillRectangleX:x y:y0 width:w height:y1 - y0. |
969 ] |
1092 ] |
970 ] |
1093 ] |
971 ]. |
1094 ]. |
972 |
1095 self redrawLinesX:x y:startY toX:maxX start:startLn stop:stopLn. |
973 hilightLevel ~~ 0 ifTrue:[ |
1096 |
974 "/ draw edge |
1097 "/ draw selection frames |
975 |
1098 sel notNil ifTrue:[ |
976 w := ((width - (2 * margin)) max:(self widthOfContents)) + leftOffset. |
1099 sel do:[:y0| self redrawSelFrameAtX:x y:y0 toX:maxX] |
977 x := margin - leftOffset. |
1100 ]. |
978 |
1101 |
979 aList do:[:sY| |
1102 self clippingRectangle:savClip. |
980 self drawEdgesForX:x y:(sY - spc) width:w height:fontHeight level:hilightLevel. |
|
981 ] |
|
982 ] |
|
983 |
|
984 |
|
985 |
|
986 ! ! |
1103 ! ! |
987 |
1104 |
988 !SelectionInTreeView methodsFor:'enumerating'! |
1105 !SelectionInTreeView methodsFor:'enumerating'! |
989 |
1106 |
990 detectNode:aOneArgBlock |
1107 detectNode:aOneArgBlock |
1176 ^ super keyPress:key x:x y:y |
1293 ^ super keyPress:key x:x y:y |
1177 |
1294 |
1178 |
1295 |
1179 |
1296 |
1180 |
1297 |
1181 ! |
|
1182 |
|
1183 redrawX:x y:y width:w height:h |
|
1184 "a region must be redrawn" |
|
1185 |
|
1186 |savClip startLn sel |
|
1187 lnSpace "{ Class:SmallInteger }" |
|
1188 y0 "{ Class:SmallInteger }" |
|
1189 y1 "{ Class:SmallInteger }" |
|
1190 visStart "{ Class:SmallInteger }" |
|
1191 visEnd "{ Class:SmallInteger }" |
|
1192 stopLn "{ Class:SmallInteger }" |
|
1193 maxY "{ Class:SmallInteger }" |
|
1194 maxX "{ Class:SmallInteger }" |
|
1195 dltLine "{ Class:SmallInteger }" |
|
1196 startY "{ Class:SmallInteger }"| |
|
1197 |
|
1198 shown ifFalse:[^ self]. |
|
1199 |
|
1200 visStart := self visibleLineOfY:(y + 1). |
|
1201 startLn := self visibleLineToAbsoluteLine:visStart. |
|
1202 |
|
1203 self paint:bgColor. |
|
1204 self fillRectangleX:x y:y width:w height:h. |
|
1205 startLn isNil ifTrue:[ ^ self ]. |
|
1206 |
|
1207 sel := nil. |
|
1208 maxX := x + w. |
|
1209 maxY := y + h. |
|
1210 lnSpace := lineSpacing // 2. |
|
1211 visEnd := self visibleLineOfY:maxY. |
|
1212 startY := self yOfVisibleLine:visStart. |
|
1213 dltLine := startLn - visStart. |
|
1214 stopLn := dltLine + visEnd. |
|
1215 savClip := clipRect. |
|
1216 |
|
1217 self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
|
1218 |
|
1219 self hasSelection ifTrue:[ |
|
1220 "/ redraw the background for all selected lines in the invalid range |
|
1221 |
|
1222 self selectionDo:[:lnNr| |
|
1223 (lnNr between:startLn and:stopLn) ifTrue:[ |
|
1224 sel isNil ifTrue:[ |
|
1225 sel := OrderedCollection new. |
|
1226 self paint:hilightBgColor. |
|
1227 ]. |
|
1228 sel add:(y0 := self yOfVisibleLine:(lnNr - dltLine)). |
|
1229 y0 := y0 - lnSpace. |
|
1230 y1 := y0 + fontHeight min:maxY. |
|
1231 y0 := y0 max:y. |
|
1232 self fillRectangleX:x y:y0 width:w height:y1 - y0. |
|
1233 ] |
|
1234 ] |
|
1235 ]. |
|
1236 |
|
1237 self redrawLinesX:x y:startY - lnSpace toX:maxX start:startLn stop:stopLn. |
|
1238 |
|
1239 "/ draw selection frames |
|
1240 self redrawSelFrameForYs:sel fromX:x toX:maxX. |
|
1241 |
|
1242 self clippingRectangle:savClip. |
|
1243 ! ! |
1298 ! ! |
1244 |
1299 |
1245 !SelectionInTreeView methodsFor:'initialization'! |
1300 !SelectionInTreeView methodsFor:'initialization'! |
1246 |
1301 |
1247 create |
1302 create |