31 classVariableNames: 'Grey CentPoint |
31 classVariableNames: 'Grey CentPoint |
32 ViewSpacing |
32 ViewSpacing |
33 DefaultStyle StyleSheet |
33 DefaultStyle StyleSheet |
34 DefaultViewBackgroundColor DefaultBorderColor |
34 DefaultViewBackgroundColor DefaultBorderColor |
35 DefaultLightColor DefaultShadowColor |
35 DefaultLightColor DefaultShadowColor |
36 DefaultBorderWidth DefaultFont' |
36 DefaultBorderWidth DefaultFont |
|
37 DefaultFocusColor DefaultFocusBorderWidth' |
37 poolDictionaries: '' |
38 poolDictionaries: '' |
38 category:'Views-Basic' |
39 category:'Views-Basic' |
39 ! |
40 ! |
40 |
41 |
41 View class instanceVariableNames:'ClassResources'! |
42 View class instanceVariableNames:'ClassResources'! |
42 |
43 |
43 View comment:' |
44 View comment:' |
44 COPYRIGHT (c) 1989 by Claus Gittinger |
45 COPYRIGHT (c) 1989 by Claus Gittinger |
45 All Rights Reserved |
46 All Rights Reserved |
46 |
47 |
47 $Header: /cvs/stx/stx/libview/View.st,v 1.25 1994-12-21 19:19:18 claus Exp $ |
48 $Header: /cvs/stx/stx/libview/View.st,v 1.26 1995-02-06 00:38:04 claus Exp $ |
48 '! |
49 '! |
49 |
50 |
50 "this flag controls (globally) how views look - it will vanish" |
51 "this flag controls (globally) how views look - it will vanish" |
51 |
52 |
52 Smalltalk at:#View3D put:false! |
53 Smalltalk at:#View3D put:false! |
762 change:changeMsg |
771 change:changeMsg |
763 "ST-80 style change notification. If a views changeSymbol is nonNil, |
772 "ST-80 style change notification. If a views changeSymbol is nonNil, |
764 it will send it to its model when something changes." |
773 it will send it to its model when something changes." |
765 |
774 |
766 changeSymbol := changeMsg |
775 changeSymbol := changeMsg |
|
776 ! |
|
777 |
|
778 changeSymbol |
|
779 "Return the symbol sent to the model if nonNil when something changes." |
|
780 |
|
781 ^ changeSymbol |
767 ! |
782 ! |
768 |
783 |
769 menu:menuMsg |
784 menu:menuMsg |
770 "ST-80 style menus. If a views menuSymbol is nonNil, it |
785 "ST-80 style menus. If a views menuSymbol is nonNil, it |
771 will send it to its model when the middleButton is pressed. |
786 will send it to its model when the middleButton is pressed. |
772 That method should return nil or the menu to be shown. |
787 That method should return nil or the menu to be shown. |
773 This is useful for very dynamic menus, where it does not |
788 This is useful for very dynamic menus, where it does not |
774 make sense to define an initial menu." |
789 make sense to define an initial menu." |
775 |
790 |
776 menuSymbol := menuMsg |
791 menuSymbol := menuMsg |
|
792 ! |
|
793 |
|
794 menuSymbol |
|
795 "Return the symbol sent to the model to aquire the menu" |
|
796 |
|
797 ^ menuSymbol |
777 ! ! |
798 ! ! |
778 |
799 |
779 !View methodsFor:'accessing-dimensions'! |
800 !View methodsFor:'accessing-dimensions'! |
780 |
801 |
781 left:aNumber |
802 left:aNumber |
938 "set the views origin; origin may be: |
962 "set the views origin; origin may be: |
939 a point where integer fields mean pixel-values |
963 a point where integer fields mean pixel-values |
940 and float values mean relative-to-superview; |
964 and float values mean relative-to-superview; |
941 or a block returning a point" |
965 or a block returning a point" |
942 |
966 |
943 |newLeft newTop pixelOrigin| |
967 |newLeft newTop pixelOrigin o| |
944 |
968 |
945 origin isBlock ifTrue:[ |
969 origin isBlock ifTrue:[ |
946 originRule := origin. |
970 originRule := origin. |
947 drawableId notNil ifTrue:[ |
971 drawableId notNil ifTrue:[ |
948 pixelOrigin := origin value |
972 pixelOrigin := origin value |
949 ] ifFalse:[ |
973 ] ifFalse:[ |
950 originChanged := true |
974 originChanged := true |
951 ] |
975 ] |
952 ] ifFalse:[ |
976 ] ifFalse:[ |
|
977 o := origin. |
953 newLeft := origin x. |
978 newLeft := origin x. |
954 newTop := origin y. |
979 newTop := origin y. |
|
980 newLeft isNil ifTrue:[newLeft := left]. |
|
981 newTop isNil ifTrue:[newTop := top]. |
|
982 o := newLeft @ newTop. |
955 ((newLeft isMemberOf:Float) or:[newTop isMemberOf:Float]) ifTrue:[ |
983 ((newLeft isMemberOf:Float) or:[newTop isMemberOf:Float]) ifTrue:[ |
956 relativeOrigin := origin. |
984 relativeOrigin := o. |
957 pixelOrigin := self originFromRelativeOrigin. |
985 pixelOrigin := self originFromRelativeOrigin. |
958 pixelOrigin isNil ifTrue:[ |
986 pixelOrigin isNil ifTrue:[ |
959 originChanged := true |
987 originChanged := true |
960 ] |
988 ] |
961 ] ifFalse:[ |
989 ] ifFalse:[ |
962 pixelOrigin := origin |
990 pixelOrigin := o |
963 ] |
991 ] |
964 ]. |
992 ]. |
965 pixelOrigin notNil ifTrue:[ |
993 pixelOrigin notNil ifTrue:[ |
966 self pixelOrigin:pixelOrigin |
994 self pixelOrigin:pixelOrigin |
967 ]. |
995 ]. |
1224 ! |
1255 ! |
1225 |
1256 |
1226 viewport:aRectangle |
1257 viewport:aRectangle |
1227 "define my extend in my superviews coordinate-system." |
1258 "define my extend in my superviews coordinate-system." |
1228 |
1259 |
1229 |relW relH relX relY winW winH| |
1260 "/ |relW relH relX relY winW winH| |
1230 |
1261 |
1231 viewport := aRectangle. |
1262 viewport := aRectangle. |
1232 self dimensionFromViewport |
1263 self dimensionFromViewport |
1233 " |
1264 "/ |
1234 superView notNil ifTrue:[ |
1265 "/ superView notNil ifTrue:[ |
1235 superView window isNil ifTrue:[ |
1266 "/ superView window isNil ifTrue:[ |
1236 winW := 1. |
1267 "/ winW := 1. |
1237 winH := 1 |
1268 "/ winH := 1 |
1238 ] ifFalse:[ |
1269 "/ ] ifFalse:[ |
1239 winW := superView window width. |
1270 "/ winW := superView window width. |
1240 winH := superView window height |
1271 "/ winH := superView window height |
1241 ]. |
1272 "/ ]. |
1242 relW := (aRectangle width / winW) asFloat. |
1273 "/ relW := (aRectangle width / winW) asFloat. |
1243 relH := (aRectangle height / winH) asFloat. |
1274 "/ relH := (aRectangle height / winH) asFloat. |
1244 relX := (aRectangle left / winW) asFloat. |
1275 "/ relX := (aRectangle left / winW) asFloat. |
1245 relY := (aRectangle top / winH) asFloat. |
1276 "/ relY := (aRectangle top / winH) asFloat. |
1246 self origin:(relX @ relY) extent:(relW @ relH) |
1277 "/ self origin:(relX @ relY) extent:(relW @ relH) |
1247 ] |
1278 "/ ] |
1248 " |
1279 "/ |
1249 ! |
1280 ! |
1250 |
1281 |
1251 window:aRectangle viewport:vRect |
1282 window:aRectangle viewport:vRect |
1252 window := aRectangle. |
1283 window := aRectangle. |
1253 self viewport:vRect. |
1284 self viewport:vRect. |
1254 subViews notNil ifTrue:[ |
1285 subViews notNil ifTrue:[ |
1255 subViews do:[:s | |
1286 subViews do:[:s | |
1256 s superViewChangedSize |
1287 s superViewChangedSize |
1257 ] |
1288 ] |
1258 ] |
1289 ] |
|
1290 ! |
|
1291 |
|
1292 scale |
|
1293 "return the scale factor (as point) of the transformation" |
|
1294 |
|
1295 transformation isNil ifTrue:[^ 1]. |
|
1296 ^ transformation scale |
|
1297 ! |
|
1298 |
|
1299 scale:aPoint |
|
1300 "set the scale factor of the transformation" |
|
1301 |
|
1302 transformation isNil ifTrue:[ |
|
1303 aPoint = 1 ifTrue:[^ self]. |
|
1304 transformation := WindowingTransformation scale:aPoint translation:0 |
|
1305 ]. |
|
1306 |
|
1307 transformation scale:aPoint. |
|
1308 self computeInnerClip |
1259 ! |
1309 ! |
1260 |
1310 |
1261 transformation |
1311 transformation |
1262 "return the transformation" |
1312 "return the transformation" |
1263 |
1313 |
1297 viewOrigin |
1347 viewOrigin |
1298 "return the viewOrigin; thats the coordinate of the contents |
1348 "return the viewOrigin; thats the coordinate of the contents |
1299 which is shown topLeft in the view |
1349 which is shown topLeft in the view |
1300 (i.e. the origin of the visible part of the contents)." |
1350 (i.e. the origin of the visible part of the contents)." |
1301 |
1351 |
1302 ^ viewOrigin |
1352 transformation isNil ifTrue:[ |
|
1353 ^ 0@0 |
|
1354 ]. |
|
1355 ^ transformation translation negated |
1303 ! |
1356 ! |
1304 |
1357 |
1305 setViewOrigin:aPoint |
1358 setViewOrigin:aPoint |
1306 "set the viewOrigin - i.e. virtually scroll without redrawing" |
1359 "set the viewOrigin - i.e. virtually scroll without redrawing" |
1307 |
1360 |
1308 viewOrigin := aPoint |
1361 |p| |
|
1362 |
|
1363 p := aPoint negated. |
|
1364 transformation isNil ifTrue:[ |
|
1365 transformation := WindowingTransformation scale:1 translation:p |
|
1366 ] ifFalse:[ |
|
1367 transformation translation:p |
|
1368 ]. |
|
1369 clipRect notNil ifTrue:[ |
|
1370 self setInnerClip. |
|
1371 ]. |
1309 ! |
1372 ! |
1310 |
1373 |
1311 xOriginOfContents |
1374 xOriginOfContents |
1312 "return the x coordinate of the viewOrigin; |
1375 "return the x coordinate of the viewOrigin in pixels; |
1313 used by scrollBars to compute thumb position within the document." |
1376 used by scrollBars to compute thumb position within the document." |
1314 |
1377 |
1315 ^ self viewOrigin x |
1378 ^ self viewOrigin x |
1316 ! |
1379 ! |
1317 |
1380 |
1318 yOriginOfContents |
1381 yOriginOfContents |
1319 "return the y coordinate of the viewOrigin; |
1382 "return the y coordinate of the viewOrigin in pixels; |
1320 used by scrollBars to compute thumb position within the document." |
1383 used by scrollBars to compute thumb position within the document." |
1321 |
1384 |
1322 ^ self viewOrigin y |
1385 ^ self viewOrigin y |
1323 ! |
1386 ! |
1324 |
1387 |
1325 heightOfContents |
1388 heightOfContents |
1326 "return the height of the contents in pixels |
1389 "return the height of the contents in logical units |
1327 - defaults to views visible area here. |
1390 - defaults to views visible area here. |
1328 This method MUST be redefined in all view classess which are |
1391 This method MUST be redefined in all view classess which are |
1329 going to be scrolled AND show data which has different size than |
1392 going to be scrolled AND show data which has different size than |
1330 the view. For example, a view showing A4-size documents should return |
1393 the view. For example, a view showing A4-size documents should return |
1331 the number of vertical pixels such a document has on this device. |
1394 the number of vertical pixels such a document has on this device. |
1332 A view showing a bitmap of height 1000 should return 1000. |
1395 A view showing a bitmap of height 1000 should return 1000. |
1333 If not redefined, scrollbars have no way of knowing the actual size |
1396 If not redefined, scrollbars have no way of knowing the actual size |
1334 of the contents being shown. This is called by scrollBars to compute |
1397 of the contents being shown. This is called by scrollBars to compute |
1335 the relative height of the document vs. the views actual size." |
1398 the relative height of the document vs. the views actual size. |
|
1399 The value returned here must be based on a scale of 1, since users |
|
1400 of this will scale as appropriate." |
1336 |
1401 |
1337 ^ self innerHeight |
1402 ^ self innerHeight |
1338 ! |
1403 ! |
1339 |
1404 |
1340 widthOfContents |
1405 widthOfContents |
1341 "return the width of the contents in pixels |
1406 "return the width of the contents in logical units |
1342 - defaults to views visible area here. |
1407 - defaults to views visible area here. |
1343 |
1408 |
1344 This method MUST be redefined in all view classess which are |
1409 This method MUST be redefined in all view classess which are |
1345 going to be scrolled AND show data which has different size than |
1410 going to be scrolled AND show data which has different size than |
1346 the view. For example, a view showing A4-size documents should return |
1411 the view. For example, a view showing A4-size documents should return |
1347 the number of horizontal pixels such a document has on this device. |
1412 the number of horizontal pixels such a document has on this device. |
1348 A view showing a bitmap of width 700 should return 700. |
1413 A view showing a bitmap of width 700 should return 700. |
1349 If not redefined, scrollbars have no way of knowing the actual size |
1414 If not redefined, scrollbars have no way of knowing the actual size |
1350 of the contents being shown. This is called by scrollBars to compute |
1415 of the contents being shown. This is called by scrollBars to compute |
1351 the relative width of the document vs. the views actual size." |
1416 the relative width of the document vs. the views actual size. |
|
1417 The value returned here must be based on a scale of 1, since users |
|
1418 of this will scale as appropriate." |
1352 |
1419 |
1353 ^ self innerWidth |
1420 ^ self innerWidth |
1354 ! ! |
1421 ! ! |
1355 |
1422 |
1356 !View methodsFor:'accessing-hierarchy'! |
1423 !View methodsFor:'accessing-hierarchy'! |
1937 tell dependents about the change (i.e. scrollers)." |
2004 tell dependents about the change (i.e. scrollers)." |
1938 |
2005 |
1939 self changed:#sizeOfContents |
2006 self changed:#sizeOfContents |
1940 ! ! |
2007 ! ! |
1941 |
2008 |
|
2009 !View methodsFor:'scrolling-basic'! |
|
2010 |
|
2011 scrollDown:nPixels |
|
2012 "change origin to scroll down some pixels" |
|
2013 |
|
2014 |count "{ Class:SmallInteger }" |
|
2015 m2 "{ Class:SmallInteger }" |
|
2016 w "{ Class:SmallInteger }" |
|
2017 h "{ Class:SmallInteger }" |
|
2018 hCont |
|
2019 ih "{ Class:SmallInteger }" |
|
2020 orgX orgY| |
|
2021 |
|
2022 hCont := self heightOfContents. |
|
2023 transformation isNil ifTrue:[ |
|
2024 orgY := orgX := 0 |
|
2025 ] ifFalse:[ |
|
2026 hCont := (transformation applyScaleY:hCont) rounded. |
|
2027 orgY := transformation translation y negated. |
|
2028 orgX := transformation translation x negated. |
|
2029 ]. |
|
2030 |
|
2031 count := nPixels. |
|
2032 ih := self innerHeight. |
|
2033 |
|
2034 ((orgY + nPixels + ih) > hCont) ifTrue:[ |
|
2035 count := hCont - orgY - ih |
|
2036 ]. |
|
2037 (count <= 0) ifTrue:[^ self]. |
|
2038 |
|
2039 self originWillChange. |
|
2040 self setViewOrigin:(orgX @ (orgY + count)). |
|
2041 |
|
2042 m2 := margin * 2. |
|
2043 (count >= ih) ifTrue:[ |
|
2044 self redrawDeviceX:margin y:margin |
|
2045 width:(width - m2) |
|
2046 height:(height - m2). |
|
2047 ] ifFalse:[ |
|
2048 h := height - m2 - count. |
|
2049 w := self width. |
|
2050 self catchExpose. |
|
2051 self copyFrom:self x:margin y:(count + margin) |
|
2052 toX:margin y:margin |
|
2053 width:w |
|
2054 height:h. |
|
2055 |
|
2056 self setInnerClip. |
|
2057 self redrawDeviceX:margin y:(h + margin) |
|
2058 width:(width - m2) height:count. |
|
2059 |
|
2060 self waitForExpose. |
|
2061 ]. |
|
2062 self originChanged:(0 @ count). |
|
2063 ! |
|
2064 |
|
2065 scrollUp:nPixels |
|
2066 "change origin to scroll up (towards the origin) by some pixels" |
|
2067 |
|
2068 |count "{ Class:SmallInteger }" |
|
2069 m2 "{ Class:SmallInteger }" |
|
2070 w "{ Class:SmallInteger }" |
|
2071 h "{ Class:SmallInteger }" |
|
2072 orgX |
|
2073 orgY "{ Class:SmallInteger }"| |
|
2074 |
|
2075 transformation isNil ifTrue:[ |
|
2076 orgY := orgX := 0 |
|
2077 ] ifFalse:[ |
|
2078 orgY := transformation translation y negated. |
|
2079 orgX := transformation translation x negated |
|
2080 ]. |
|
2081 |
|
2082 count := nPixels. |
|
2083 (count > orgY) ifTrue:[ |
|
2084 count := orgY |
|
2085 ]. |
|
2086 (count <= 0) ifTrue:[^ self]. |
|
2087 |
|
2088 self originWillChange. |
|
2089 self setViewOrigin:(orgX @ (orgY - count)). |
|
2090 |
|
2091 m2 := margin * 2. "top & bottom margins" |
|
2092 (count >= self innerHeight) ifTrue:[ |
|
2093 self redrawDeviceX:margin y:margin |
|
2094 width:(width - m2) |
|
2095 height:(height - m2). |
|
2096 ] ifFalse:[ |
|
2097 h := height - m2 - count. |
|
2098 w := width. |
|
2099 self catchExpose. |
|
2100 self copyFrom:self x:margin y:margin |
|
2101 toX:margin y:(count + margin) |
|
2102 width:w height:h. |
|
2103 |
|
2104 self setInnerClip. |
|
2105 self redrawDeviceX:margin y:margin |
|
2106 width:(width - m2) |
|
2107 height:count. |
|
2108 |
|
2109 self waitForExpose. |
|
2110 ]. |
|
2111 self originChanged:(0 @ count negated). |
|
2112 ! |
|
2113 |
|
2114 scrollLeft:nPixels |
|
2115 "change origin to scroll left some pixels" |
|
2116 |
|
2117 |count "{ Class:SmallInteger }" |
|
2118 m2 "{ Class:SmallInteger }" |
|
2119 h "{ Class:SmallInteger }" |
|
2120 orgX orgY| |
|
2121 |
|
2122 transformation isNil ifTrue:[ |
|
2123 orgY := orgX := 0 |
|
2124 ] ifFalse:[ |
|
2125 orgY := transformation translation y negated. |
|
2126 orgX := transformation translation x negated. |
|
2127 ]. |
|
2128 |
|
2129 count := nPixels. |
|
2130 (count > orgX) ifTrue:[ |
|
2131 count := orgX |
|
2132 ]. |
|
2133 (count <= 0) ifTrue:[^ self]. |
|
2134 |
|
2135 self originWillChange. |
|
2136 self setViewOrigin:(orgX - count) @ orgY. |
|
2137 |
|
2138 m2 := margin * 2. |
|
2139 (count >= self innerWidth) ifTrue:[ |
|
2140 self redrawDeviceX:margin y:margin |
|
2141 width:(width - m2) |
|
2142 height:(height - m2). |
|
2143 ] ifFalse:[ |
|
2144 h := (height - m2). |
|
2145 |
|
2146 self catchExpose. |
|
2147 self copyFrom:self x:margin y:margin |
|
2148 toX:(count + margin) y:margin |
|
2149 width:(width - m2 - count) |
|
2150 height:h. |
|
2151 |
|
2152 self setInnerClip. |
|
2153 self redrawDeviceX:margin y:margin |
|
2154 width:count height:(height - m2). |
|
2155 |
|
2156 self waitForExpose. |
|
2157 ]. |
|
2158 self originChanged:(count negated @ 0). |
|
2159 ! |
|
2160 |
|
2161 scrollRight:nPixels |
|
2162 "change origin to scroll right some pixels" |
|
2163 |
|
2164 |count "{ Class:SmallInteger }" |
|
2165 m2 "{ Class:SmallInteger }" |
|
2166 h "{ Class:SmallInteger }" |
|
2167 wCont |
|
2168 iw "{ Class:SmallInteger }" |
|
2169 orgX orgY| |
|
2170 |
|
2171 wCont := self widthOfContents. |
|
2172 transformation isNil ifTrue:[ |
|
2173 orgY := orgX := 0 |
|
2174 ] ifFalse:[ |
|
2175 wCont := (transformation applyScaleX:wCont) rounded. |
|
2176 orgY := transformation translation y negated. |
|
2177 orgX := transformation translation x negated. |
|
2178 ]. |
|
2179 |
|
2180 count := nPixels. |
|
2181 iw := self innerWidth. |
|
2182 |
|
2183 ((orgX + nPixels + iw) > wCont) ifTrue:[ |
|
2184 count := wCont - orgX - iw |
|
2185 ]. |
|
2186 (count <= 0) ifTrue:[^ self]. |
|
2187 |
|
2188 self originWillChange. |
|
2189 self setViewOrigin:(orgX + count) @ orgY. |
|
2190 |
|
2191 m2 := margin * 2. |
|
2192 (count >= iw) ifTrue:[ |
|
2193 self redrawDeviceX:margin y:margin |
|
2194 width:(width - m2) |
|
2195 height:(height - m2). |
|
2196 ] ifFalse:[ |
|
2197 m2 := margin * 2. |
|
2198 h := (height - m2). |
|
2199 |
|
2200 self catchExpose. |
|
2201 self copyFrom:self x:(count + margin) y:margin |
|
2202 toX:margin y:margin |
|
2203 width:(width - m2 - count) |
|
2204 height:h. |
|
2205 |
|
2206 self setInnerClip. |
|
2207 self redrawDeviceX:(width - margin - count) y:margin |
|
2208 width:count height:(height - m2). |
|
2209 |
|
2210 self waitForExpose. |
|
2211 ]. |
|
2212 self originChanged:(count @ 0). |
|
2213 ! ! |
|
2214 |
1942 !View methodsFor:'scrolling'! |
2215 !View methodsFor:'scrolling'! |
1943 |
2216 |
1944 widthForScrollBetween:yStart and:yEnd |
2217 widthForScrollBetween:yStart and:yEnd |
1945 "return the width in pixels for a scroll between yStart and yEnd |
2218 "return the width in pixels for a scroll between yStart and yEnd |
1946 - return full width here since we do not know how wide contents is. |
2219 - return full width here since we do not know how wide contents is. |
2027 scrollToTopLeft |
2312 scrollToTopLeft |
2028 "move viewOrigin to top/left" |
2313 "move viewOrigin to top/left" |
2029 |
2314 |
2030 self scrollVerticalTo:0. |
2315 self scrollVerticalTo:0. |
2031 self scrollHorizontalTo:0 |
2316 self scrollHorizontalTo:0 |
2032 ! |
|
2033 |
|
2034 scrollUp:nPixels |
|
2035 "change origin to scroll up (towards the origin) by some pixels" |
|
2036 |
|
2037 |count "{ Class:SmallInteger }" |
|
2038 m2 "{ Class:SmallInteger }" |
|
2039 w "{ Class:SmallInteger }" |
|
2040 h "{ Class:SmallInteger }" |
|
2041 viewOrigin |
|
2042 orgY "{ Class:SmallInteger }"| |
|
2043 |
|
2044 viewOrigin := self viewOrigin. |
|
2045 orgY := viewOrigin y. |
|
2046 |
|
2047 count := nPixels. |
|
2048 (count > orgY) ifTrue:[ |
|
2049 count := orgY |
|
2050 ]. |
|
2051 (count <= 0) ifTrue:[^ self]. |
|
2052 |
|
2053 self originWillChange. |
|
2054 self setViewOrigin:(viewOrigin x @ (orgY - count)). |
|
2055 |
|
2056 (count >= self innerHeight) ifTrue:[ |
|
2057 self redraw. |
|
2058 ] ifFalse:[ |
|
2059 m2 := margin * 2. "top & bottom margins" |
|
2060 h := height - m2 - count. |
|
2061 w := self widthForScrollBetween:orgY and:(orgY + h). |
|
2062 w := w min:(width - m2). |
|
2063 |
|
2064 self catchExpose. |
|
2065 self copyFrom:self x:margin y:margin |
|
2066 toX:margin y:(count + margin) |
|
2067 width:w height:h. |
|
2068 |
|
2069 self redrawDeviceX:margin y:margin |
|
2070 width:(width - m2) |
|
2071 height:count. |
|
2072 |
|
2073 self waitForExpose. |
|
2074 ]. |
|
2075 self originChanged:(0 @ count negated). |
|
2076 ! |
2317 ! |
2077 |
2318 |
2078 scrollUp |
2319 scrollUp |
2079 "scroll up by some amount; this is called when the scrollbars |
2320 "scroll up by some amount; this is called when the scrollbars |
2080 scroll-step up button is pressed." |
2321 scroll-step up button is pressed." |
2081 |
2322 |
2082 self scrollUp:(self verticalScrollStep) |
2323 self scrollUp:(self verticalScrollStep) |
2083 ! |
2324 ! |
2084 |
2325 |
2085 scrollDown:nPixels |
|
2086 "change origin to scroll down some pixels" |
|
2087 |
|
2088 |count "{ Class:SmallInteger }" |
|
2089 m2 "{ Class:SmallInteger }" |
|
2090 w "{ Class:SmallInteger }" |
|
2091 h "{ Class:SmallInteger }" |
|
2092 hCont "{ Class:SmallInteger }" |
|
2093 ih "{ Class:SmallInteger }" |
|
2094 viewOrigin orgY| |
|
2095 |
|
2096 viewOrigin := self viewOrigin. |
|
2097 orgY := viewOrigin y. |
|
2098 |
|
2099 count := nPixels. |
|
2100 hCont := self heightOfContents. |
|
2101 ih := self innerHeight. |
|
2102 |
|
2103 ((orgY + nPixels + ih) > hCont) ifTrue:[ |
|
2104 count := hCont - orgY - ih |
|
2105 ]. |
|
2106 (count <= 0) ifTrue:[^ self]. |
|
2107 |
|
2108 self originWillChange. |
|
2109 viewOrigin := viewOrigin x @ (orgY + count). |
|
2110 self setViewOrigin:viewOrigin. |
|
2111 |
|
2112 (count >= ih) ifTrue:[ |
|
2113 self redraw. |
|
2114 ] ifFalse:[ |
|
2115 m2 := margin * 2. |
|
2116 h := height - m2 - count. |
|
2117 w := self widthForScrollBetween:orgY and:(orgY + h). |
|
2118 w := w min:(width - m2). |
|
2119 |
|
2120 self catchExpose. |
|
2121 self copyFrom:self x:margin y:(count + margin) |
|
2122 toX:margin y:margin |
|
2123 width:w |
|
2124 height:h. |
|
2125 |
|
2126 self redrawDeviceX:margin y:(h + margin) |
|
2127 width:(width - m2) height:count. |
|
2128 |
|
2129 self waitForExpose. |
|
2130 ]. |
|
2131 self originChanged:(0 @ count). |
|
2132 ! |
|
2133 |
|
2134 scrollDown |
2326 scrollDown |
2135 "scroll down by some amount; this is called when the scrollbars |
2327 "scroll down by some amount; this is called when the scrollbars |
2136 scroll-step down button is pressed." |
2328 scroll-step down button is pressed." |
2137 |
2329 |
2138 self scrollDown:(self verticalScrollStep) |
2330 self scrollDown:(self verticalScrollStep) |
2139 ! |
2331 ! |
2140 |
2332 |
2141 scrollLeft:nPixels |
|
2142 "change origin to scroll left some pixels" |
|
2143 |
|
2144 |count "{ Class:SmallInteger }" |
|
2145 m2 "{ Class:SmallInteger }" |
|
2146 h "{ Class:SmallInteger }" |
|
2147 viewOrigin orgX| |
|
2148 |
|
2149 viewOrigin := self viewOrigin. |
|
2150 orgX := viewOrigin x. |
|
2151 |
|
2152 count := nPixels. |
|
2153 (count > orgX) ifTrue:[ |
|
2154 count := orgX |
|
2155 ]. |
|
2156 (count <= 0) ifTrue:[^ self]. |
|
2157 |
|
2158 self originWillChange. |
|
2159 viewOrigin := (orgX - count) @ viewOrigin y. |
|
2160 self setViewOrigin:viewOrigin. |
|
2161 |
|
2162 (count >= self innerWidth) ifTrue:[ |
|
2163 self redraw. |
|
2164 ] ifFalse:[ |
|
2165 m2 := margin * 2. |
|
2166 h := (height - m2). |
|
2167 |
|
2168 self catchExpose. |
|
2169 self copyFrom:self x:margin y:margin |
|
2170 toX:(count + margin) y:margin |
|
2171 width:(width - m2 - count) |
|
2172 height:h. |
|
2173 |
|
2174 self redrawDeviceX:margin y:margin |
|
2175 width:count height:(height - m2). |
|
2176 |
|
2177 self waitForExpose. |
|
2178 ]. |
|
2179 self originChanged:(count negated @ 0). |
|
2180 ! |
|
2181 |
|
2182 scrollLeft |
2333 scrollLeft |
2183 "scroll left by some amount; this is called when the scrollbars |
2334 "scroll left by some amount; this is called when the scrollbars |
2184 scroll-step left button is pressed." |
2335 scroll-step left button is pressed." |
2185 |
2336 |
2186 self scrollLeft:(self horizontalScrollStep) |
2337 self scrollLeft:(self horizontalScrollStep) |
2187 ! |
|
2188 |
|
2189 scrollRight:nPixels |
|
2190 "change origin to scroll right some pixels" |
|
2191 |
|
2192 |count "{ Class:SmallInteger }" |
|
2193 m2 "{ Class:SmallInteger }" |
|
2194 h "{ Class:SmallInteger }" |
|
2195 wCont "{ Class:SmallInteger }" |
|
2196 iw "{ Class:SmallInteger }" |
|
2197 viewOrigin orgX| |
|
2198 |
|
2199 viewOrigin := self viewOrigin. |
|
2200 orgX := viewOrigin x. |
|
2201 |
|
2202 count := nPixels. |
|
2203 wCont := self widthOfContents. |
|
2204 iw := self innerWidth. |
|
2205 |
|
2206 ((orgX + nPixels + iw) > wCont) ifTrue:[ |
|
2207 count := wCont - orgX - iw |
|
2208 ]. |
|
2209 (count <= 0) ifTrue:[^ self]. |
|
2210 |
|
2211 self originWillChange. |
|
2212 viewOrigin := (orgX + count) @ viewOrigin y. |
|
2213 self setViewOrigin:viewOrigin. |
|
2214 |
|
2215 (count >= iw) ifTrue:[ |
|
2216 self redraw. |
|
2217 ] ifFalse:[ |
|
2218 m2 := margin * 2. |
|
2219 h := (height - m2). |
|
2220 |
|
2221 self catchExpose. |
|
2222 self copyFrom:self x:(count + margin) y:margin |
|
2223 toX:margin y:margin |
|
2224 width:(width - m2 - count) |
|
2225 height:h. |
|
2226 |
|
2227 self redrawDeviceX:(width - margin - count) y:margin |
|
2228 width:count height:(height - m2). |
|
2229 |
|
2230 self waitForExpose. |
|
2231 ]. |
|
2232 self originChanged:(count @ 0). |
|
2233 ! |
2338 ! |
2234 |
2339 |
2235 scrollRight |
2340 scrollRight |
2236 "scroll right by some amount; this is called when the scrollbars |
2341 "scroll right by some amount; this is called when the scrollbars |
2237 scroll-step right button is pressed." |
2342 scroll-step right button is pressed." |
3041 |
3151 |
3042 self openModal:[true] |
3152 self openModal:[true] |
3043 ! |
3153 ! |
3044 |
3154 |
3045 openModal:aBlock |
3155 openModal:aBlock |
3046 "create a new windowgroup, but start processing in the current process |
3156 "create a new windowgroup, but start processing in the current process - |
3047 actually suspending event processing for the currently active group. |
3157 actually suspending event processing for the currently active group. |
3048 Stay in this modal loop while aBlock evaluates to true AND the receiver is |
3158 Stay in this modal loop while aBlock evaluates to true AND the receiver is |
3049 visible. |
3159 visible. |
3050 This makes any interaction with the current window impossible - |
3160 This makes any interaction with the current window impossible - |
3051 however, other views (in their groups) still work." |
3161 however, other views (in other windowgroups) still work." |
|
3162 |
|
3163 |activeGroup tops| |
3052 |
3164 |
3053 Processor activeProcessIsSystemProcess ifTrue:[ |
3165 Processor activeProcessIsSystemProcess ifTrue:[ |
3054 self realize |
3166 self realize |
3055 ] ifFalse:[ |
3167 ] ifFalse:[ |
|
3168 activeGroup := WindowGroup activeGroup. |
|
3169 |
3056 " |
3170 " |
3057 create a new window group and put myself into it |
3171 create a new window group and put myself into it |
3058 " |
3172 " |
3059 windowGroup := WindowGroup new. |
3173 windowGroup := WindowGroup new. |
3060 windowGroup addTopView:self. |
3174 windowGroup addTopView:self. |
3481 ly := transformation applyInverseToY:ly. |
3619 ly := transformation applyInverseToY:ly. |
3482 lw := transformation applyInverseScaleX:lw. |
3620 lw := transformation applyInverseScaleX:lw. |
3483 lh := transformation applyInverseScaleY:lh. |
3621 lh := transformation applyInverseScaleY:lh. |
3484 ]. |
3622 ]. |
3485 self redrawX:lx y:ly width:lw height:lh |
3623 self redrawX:lx y:ly width:lw height:lh |
|
3624 ! |
|
3625 |
|
3626 showFocus |
|
3627 "highlight myself somehow to tell user that I have the focus" |
|
3628 |
|
3629 |delta| |
|
3630 |
|
3631 drawableId notNil ifTrue:[ |
|
3632 delta := DefaultFocusBorderWidth - borderWidth. |
|
3633 delta ~~ 0 ifTrue:[ |
|
3634 device moveWindow:drawableId x:left-delta y:top-delta |
|
3635 ]. |
|
3636 device setWindowBorderWidth:DefaultFocusBorderWidth in:drawableId. |
|
3637 device setWindowBorderColor:(DefaultFocusColor on:device) colorId in:drawableId. |
|
3638 ] |
|
3639 ! |
|
3640 |
|
3641 showNoFocus |
|
3642 "undo the effect of showFocus" |
|
3643 |
|
3644 |delta| |
|
3645 |
|
3646 drawableId notNil ifTrue:[ |
|
3647 delta := DefaultFocusBorderWidth - borderWidth. |
|
3648 delta ~~ 0 ifTrue:[ |
|
3649 device moveWindow:drawableId x:left+delta y:top+delta |
|
3650 ]. |
|
3651 device setWindowBorderWidth:borderWidth in:drawableId. |
|
3652 self setBorderColor. |
|
3653 ] |
3486 ! ! |
3654 ! ! |
3487 |
3655 |
3488 !View methodsFor:'event handling'! |
3656 !View methodsFor:'event handling'! |
3489 |
3657 |
3490 destroyed |
3658 destroyed |
3821 nx := transformation applyToX:nx. |
4001 nx := transformation applyToX:nx. |
3822 ny := transformation applyToY:ny. |
4002 ny := transformation applyToY:ny. |
3823 nw := transformation applyScaleX:nw. |
4003 nw := transformation applyScaleX:nw. |
3824 nh := transformation applyScaleY:nh. |
4004 nh := transformation applyScaleY:nh. |
3825 ]. |
4005 ]. |
|
4006 " |
|
4007 adjust expose rectangle, to exclude the margin. |
|
4008 Care for rounding errors ... |
|
4009 " |
3826 (nx isMemberOf:SmallInteger) ifFalse:[ |
4010 (nx isMemberOf:SmallInteger) ifFalse:[ |
3827 nw := nw + (nx - nx truncated). |
4011 old := nx. |
3828 nx := nx truncated. |
4012 nx := nx truncated. |
|
4013 nw := nw + (nx - old). |
3829 ]. |
4014 ]. |
3830 (ny isMemberOf:SmallInteger) ifFalse:[ |
4015 (ny isMemberOf:SmallInteger) ifFalse:[ |
3831 nh := nh + (ny - ny truncated). |
4016 old := ny. |
3832 ny := ny truncated. |
4017 ny := ny truncated. |
|
4018 nh := nh + (ny - old). |
3833 ]. |
4019 ]. |
3834 (nw isMemberOf:SmallInteger) ifFalse:[ |
4020 (nw isMemberOf:SmallInteger) ifFalse:[ |
3835 nw := nw truncated + 1 |
4021 nw := nw truncated + 1 |
3836 ]. |
4022 ]. |
3837 (nh isMemberOf:SmallInteger) ifFalse:[ |
4023 (nh isMemberOf:SmallInteger) ifFalse:[ |
3838 nh := nh truncated + 1 |
4024 nh := nh truncated + 1 |
3839 ]. |
4025 ]. |
3840 (x < margin) ifTrue:[ |
4026 (nx < margin) ifTrue:[ |
|
4027 old := nx. |
3841 nx := margin. |
4028 nx := margin. |
3842 nw := nw - (nx - x). |
4029 nw := nw - (nx - old). |
3843 leftEdge := anyEdge := true. |
4030 leftEdge := anyEdge := true. |
3844 ]. |
4031 ]. |
3845 ((x + w - 1) >= (width - margin)) ifTrue:[ |
4032 ((nx + nw - 1) >= (width - margin)) ifTrue:[ |
3846 nw := (width - margin - nx). |
4033 nw := (width - margin - nx). |
3847 rightEdge := anyEdge := true. |
4034 rightEdge := anyEdge := true. |
3848 ]. |
4035 ]. |
3849 (y < margin) ifTrue:[ |
4036 (ny < margin) ifTrue:[ |
|
4037 old := ny. |
3850 ny := margin. |
4038 ny := margin. |
3851 nh := nh - (ny - y). |
4039 nh := nh - (ny - old). |
3852 topEdge := anyEdge := true. |
4040 topEdge := anyEdge := true. |
3853 ]. |
4041 ]. |
3854 ((y + h - 1) >= (height - margin)) ifTrue:[ |
4042 ((ny + nh - 1) >= (height - margin)) ifTrue:[ |
3855 nh := (height - margin - ny). |
4043 nh := (height - margin - ny). |
3856 botEdge := anyEdge := true. |
4044 botEdge := anyEdge := true. |
3857 ]. |
4045 ]. |
3858 transformation notNil ifTrue:[ |
4046 transformation notNil ifTrue:[ |
3859 " |
4047 " |