View.st
changeset 89 ea2bf46eb669
parent 87 b64ce99ebeaa
child 94 8931597dfa3c
equal deleted inserted replaced
88:8f9c629a4245 89:ea2bf46eb669
    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!
    67 "
    68 "
    68 !
    69 !
    69 
    70 
    70 version
    71 version
    71 "
    72 "
    72 $Header: /cvs/stx/stx/libview/View.st,v 1.25 1994-12-21 19:19:18 claus Exp $
    73 $Header: /cvs/stx/stx/libview/View.st,v 1.26 1995-02-06 00:38:04 claus Exp $
    73 "
    74 "
    74 !
    75 !
    75 
    76 
    76 documentation
    77 documentation
    77 "
    78 "
   141 ! !
   142 ! !
   142 
   143 
   143 !View class methodsFor:'initialization'!
   144 !View class methodsFor:'initialization'!
   144 
   145 
   145 initialize
   146 initialize
   146     "Workstation initialize."
       
   147 
       
   148     super initialize.
   147     super initialize.
   149     Form initialize.
   148     Form initialize.
   150     Color initialize.
   149     Color initialize.
       
   150 "/    self updateStyleCache
   151 ! !
   151 ! !
   152 
   152 
   153 !View class methodsFor:'defaults'!
   153 !View class methodsFor:'defaults'!
   154 
   154 
   155 defaultExtent
   155 defaultExtent
   309     DefaultBorderWidth := StyleSheet at:'borderWidth' default:0.
   309     DefaultBorderWidth := StyleSheet at:'borderWidth' default:0.
   310     DefaultBorderColor := StyleSheet colorAt:'borderColor' default:Black.
   310     DefaultBorderColor := StyleSheet colorAt:'borderColor' default:Black.
   311     DefaultViewBackgroundColor := StyleSheet colorAt:'viewBackground' default:bgGrey.
   311     DefaultViewBackgroundColor := StyleSheet colorAt:'viewBackground' default:bgGrey.
   312     DefaultShadowColor := StyleSheet colorAt:'shadowColor'.
   312     DefaultShadowColor := StyleSheet colorAt:'shadowColor'.
   313     DefaultLightColor := StyleSheet colorAt:'lightColor'.
   313     DefaultLightColor := StyleSheet colorAt:'lightColor'.
       
   314     DefaultFocusColor := StyleSheet colorAt:'focusColor' default:Color red.
       
   315     DefaultFocusBorderWidth := StyleSheet at:'focusBorderWidth' default:2.
       
   316 
   314     DefaultFont := StyleSheet at:'font'.
   317     DefaultFont := StyleSheet at:'font'.
   315     DefaultFont isNil ifTrue:[
   318     DefaultFont isNil ifTrue:[
   316 	DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12.
   319 	DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12.
   317     ].
   320     ].
   318 
   321 
   536      and the style specific setup in initStyle. Each view should be prepared
   539      and the style specific setup in initStyle. Each view should be prepared
   537      for a stylechange by being sent another initStyle with a new style value.
   540      for a stylechange by being sent another initStyle with a new style value.
   538      (in this case, it should set all of its style-dependent things, but
   541      (in this case, it should set all of its style-dependent things, but
   539       leave the state and contents as-is)"
   542       leave the state and contents as-is)"
   540 
   543 
   541     |ext|
   544     |ext controllerClass|
   542 
   545 
   543     super initialize.
   546     super initialize.
   544 
   547 
   545     font := DefaultFont.
   548     font := DefaultFont.
   546 
   549 
   571     viewOrigin := 0@0.
   574     viewOrigin := 0@0.
   572     originChanged := extentChanged := false.
   575     originChanged := extentChanged := false.
   573     bitGravity := nil.
   576     bitGravity := nil.
   574     viewGravity := nil.
   577     viewGravity := nil.
   575 
   578 
   576 "
   579     controllerClass := self defaultController.
   577     controller := self defaultController new.
   580     controllerClass notNil ifTrue:[
   578     controller view:self.
   581 	controller := controllerClass new.
   579 "
   582 	controller view:self.
       
   583 	model notNil ifTrue:[
       
   584 	    controller model:model
       
   585 	]
       
   586     ].
   580 !
   587 !
   581 
   588 
   582 defaultController
   589 defaultController
   583     ^ Controller
   590     ^ nil "/ Controller
   584 !
   591 !
   585 
   592 
   586 initStyle
   593 initStyle
   587     "this method sets up all style dependent things"
   594     "this method sets up all style dependent things"
   588 
   595 
   717 
   724 
   718 controller:aController
   725 controller:aController
   719     "set the controller"
   726     "set the controller"
   720 
   727 
   721     controller := aController.
   728     controller := aController.
   722     controller view:self.
   729     controller notNil ifTrue:[
   723     controller model:model
   730 	controller view:self.
       
   731 	controller model:model
       
   732     ]
   724 !
   733 !
   725 
   734 
   726 model
   735 model
   727     "return the model, for non-MVC views,
   736     "return the model, for non-MVC views,
   728      this is usually the receiver"
   737      this is usually the receiver"
   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
   905     "set the views extent; extent may be:
   926     "set the views extent; extent may be:
   906      a point where integer fields mean pixel-values
   927      a point where integer fields mean pixel-values
   907      and float values mean relative-to-superview;
   928      and float values mean relative-to-superview;
   908      or a block returning a point"
   929      or a block returning a point"
   909 
   930 
   910     |w h pixelExtent|
   931     |w h pixelExtent e|
   911 
   932 
   912     extent isBlock ifTrue:[
   933     extent isBlock ifTrue:[
   913 	extentRule := extent.
   934 	extentRule := extent.
   914 	drawableId notNil ifTrue:[
   935 	drawableId notNil ifTrue:[
   915 	    pixelExtent := extent value
   936 	    pixelExtent := extent value
   917 	    extentChanged := true
   938 	    extentChanged := true
   918 	]
   939 	]
   919     ] ifFalse:[
   940     ] ifFalse:[
   920 	w := extent x.
   941 	w := extent x.
   921 	h := extent y.
   942 	h := extent y.
       
   943 	w isNil ifTrue:[w := width].
       
   944 	h isNil ifTrue:[h := height].
       
   945 	e := w@h.
   922 	((w isMemberOf:Float) or:[h isMemberOf:Float]) ifTrue:[
   946 	((w isMemberOf:Float) or:[h isMemberOf:Float]) ifTrue:[
   923 	    relativeExtent := extent.
   947 	    relativeExtent := e.
   924 	    pixelExtent := self extentFromRelativeExtent.
   948 	    pixelExtent := self extentFromRelativeExtent.
   925 	    pixelExtent isNil ifTrue:[
   949 	    pixelExtent isNil ifTrue:[
   926 		extentChanged := true
   950 		extentChanged := true
   927 	    ]
   951 	    ]
   928 	] ifFalse:[
   952 	] ifFalse:[
   929 	    pixelExtent := extent
   953 	    pixelExtent := e
   930 	]
   954 	]
   931     ].
   955     ].
   932     pixelExtent notNil ifTrue:[
   956     pixelExtent notNil ifTrue:[
   933 	self pixelExtent:pixelExtent
   957 	self pixelExtent:pixelExtent
   934     ]
   958     ]
   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     ].
  1158     "set the views  corner;  corner may be:
  1186     "set the views  corner;  corner may be:
  1159      a point where integer fields mean pixel-values
  1187      a point where integer fields mean pixel-values
  1160      and float values mean relative-to-superview;
  1188      and float values mean relative-to-superview;
  1161      or a block returning a point"
  1189      or a block returning a point"
  1162 
  1190 
  1163     |x y pixelCorner|
  1191     |x y pixelCorner c|
  1164 
  1192 
  1165     corner isBlock ifTrue:[
  1193     corner isBlock ifTrue:[
  1166 	cornerRule := corner.
  1194 	cornerRule := corner.
  1167 	drawableId notNil ifTrue:[    
  1195 	drawableId notNil ifTrue:[    
  1168 	    pixelCorner := corner value
  1196 	    pixelCorner := corner value
  1170 	    extentChanged := true
  1198 	    extentChanged := true
  1171 	]
  1199 	]
  1172     ] ifFalse:[
  1200     ] ifFalse:[
  1173 	x := corner x.
  1201 	x := corner x.
  1174 	y := corner y.
  1202 	y := corner y.
       
  1203 	x isNil ifTrue:[x := self corner x].
       
  1204 	y isNil ifTrue:[y := self corner y].
       
  1205 	c := x @ y.
  1175 	((x isMemberOf:Float) or:[y isMemberOf:Float]) ifTrue:[
  1206 	((x isMemberOf:Float) or:[y isMemberOf:Float]) ifTrue:[
  1176 	    relativeCorner := corner.
  1207 	    relativeCorner := c.
  1177 	    pixelCorner := self cornerFromRelativeCorner.
  1208 	    pixelCorner := self cornerFromRelativeCorner.
  1178 	    pixelCorner isNil ifTrue:[
  1209 	    pixelCorner isNil ifTrue:[
  1179 		extentChanged := true
  1210 		extentChanged := true
  1180 	    ]
  1211 	    ]
  1181 	] ifFalse:[
  1212 	] ifFalse:[
  1182 	    pixelCorner := corner
  1213 	    pixelCorner := c
  1183 	]
  1214 	]
  1184     ].
  1215     ].
  1185 
  1216 
  1186     pixelCorner notNil ifTrue:[
  1217     pixelCorner notNil ifTrue:[
  1187 	self pixelCorner:pixelCorner
  1218 	self pixelCorner:pixelCorner
  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.
  1967 !
  2240 !
  1968 
  2241 
  1969 scrollVerticalToPercent:percent
  2242 scrollVerticalToPercent:percent
  1970     "scroll to a position given in percent of total"
  2243     "scroll to a position given in percent of total"
  1971 
  2244 
       
  2245     |hCont|
       
  2246 
       
  2247     hCont := self heightOfContents.
       
  2248     transformation notNil ifTrue:[
       
  2249 	hCont := transformation applyScaleY:hCont.
       
  2250     ].
  1972     self scrollVerticalTo:
  2251     self scrollVerticalTo:
  1973 	    ((((self heightOfContents * percent) / 100.0) + 0.5) asInteger)
  2252 	    ((((hCont * percent) / 100.0) + 0.5) asInteger)
  1974 !
  2253 !
  1975 
  2254 
  1976 scrollVerticalTo:aPixelOffset
  2255 scrollVerticalTo:aPixelOffset
  1977     "change origin to make aPixelOffset be the top line"
  2256     "change origin to make aPixelOffset be the top line"
  1978 
  2257 
  1990 !
  2269 !
  1991 
  2270 
  1992 scrollHorizontalToPercent:percent
  2271 scrollHorizontalToPercent:percent
  1993     "scroll to a position given in percent of total"
  2272     "scroll to a position given in percent of total"
  1994 
  2273 
       
  2274     |wCont|
       
  2275 
       
  2276     wCont := self widthOfContents.
       
  2277     transformation notNil ifTrue:[
       
  2278 	wCont := transformation applyScaleX:wCont.
       
  2279     ].
  1995     self scrollHorizontalTo:
  2280     self scrollHorizontalTo:
  1996 	    ((((self widthOfContents * percent) / 100.0) + 0.5) asInteger)
  2281 	    ((((wCont * percent) / 100.0) + 0.5) asInteger)
  1997 !
  2282 !
  1998 
  2283 
  1999 scrollHorizontalTo:aPixelOffset
  2284 scrollHorizontalTo:aPixelOffset
  2000     "change origin to make aPixelOffset be the left col"
  2285     "change origin to make aPixelOffset be the left col"
  2001 
  2286 
  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."
  2822 
  2927 
  2823     ^ self
  2928     ^ self
  2824 !
  2929 !
  2825 
  2930 
  2826 fixSize
  2931 fixSize
  2827     "adjust size of window according to either relative/abs or
  2932     "This is called right before the view is made visible.
  2828      block extent; also set origin"
  2933      Adjust the size of the view according to either relative/abs or
       
  2934      block extent; also set origin. Also, subclasses may redefine this
       
  2935      method to adjust the size based on some extent (for example, PopUpMenus
       
  2936      do so to take care of changed number of menu entries)."
  2829 
  2937 
  2830     window notNil ifTrue:[
  2938     window notNil ifTrue:[
  2831 	^ self superViewChangedSize
  2939 	^ self superViewChangedSize
  2832     ].
  2940     ].
  2833 
  2941 
  2906 !
  3014 !
  2907 
  3015 
  2908 realizeInGroup
  3016 realizeInGroup
  2909     "special realize - leave windowgroup as is; for special applications"
  3017     "special realize - leave windowgroup as is; for special applications"
  2910 
  3018 
  2911     |superGroup groupChange|
       
  2912 
       
  2913     drawableId isNil ifTrue:[
  3019     drawableId isNil ifTrue:[
  2914 	self create.
  3020 	self create.
  2915     ].
  3021     ].
  2916 
  3022 
  2917     hidden ifTrue:[
  3023     hidden ifTrue:[
  2968 	device synchronizeOutput. 
  3074 	device synchronizeOutput. 
  2969 "
  3075 "
  2970     ].
  3076     ].
  2971 
  3077 
  2972     model notNil ifTrue:[
  3078     model notNil ifTrue:[
  2973 	model removeDependent:self
  3079 	model removeDependent:self.
  2974     ].
  3080 	model := nil.
  2975     controller := nil.
  3081     ].
       
  3082     controller notNil ifTrue:[
       
  3083 	controller release.
       
  3084 	controller := nil.
       
  3085     ].
  2976 
  3086 
  2977     subs := subViews.
  3087     subs := subViews.
  2978     subs notNil ifTrue:[
  3088     subs notNil ifTrue:[
  2979 	"stupid: destroy removes itself from the subview list
  3089 	"stupid: destroy removes itself from the subview list
  2980 	 - therefore we have to loop over a copy here"
  3090 	 - therefore we have to loop over a copy here"
  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.
  3064 	"
  3178 	"
  3065 	Object abortSignal handle:[:ex |
  3179 	Object abortSignal handle:[:ex |
  3066 	    self hide.
  3180 	    self hide.
  3067 	    ex return.
  3181 	    ex return.
  3068 	] do:[
  3182 	] do:[
  3069 	    windowGroup startupModal:[realized and:aBlock]
  3183 	    [
  3070 	].
  3184 		windowGroup startupModal:[realized and:aBlock]
       
  3185 	    ] valueOnUnwindDo:[
       
  3186 		self hide.
       
  3187 	    ]
       
  3188 	].
       
  3189 	"
       
  3190 	 return input focus to previously active groups top.
       
  3191 	 This helps with windowmanagers which need an explicit click
       
  3192 	 on the view for the focus.
       
  3193 	"
       
  3194 	activeGroup notNil ifTrue:[
       
  3195 	    tops := activeGroup topViews.
       
  3196 	    (tops notNil and:[tops notEmpty]) ifTrue:[
       
  3197 		tops first getKeyboardFocus
       
  3198 	    ]
       
  3199 	]
  3071     ]
  3200     ]
  3072 !
  3201 !
  3073 
  3202 
  3074 openAutonomous
  3203 openAutonomous
  3075     "create and schedule a new windowgroup for me and open the view.
  3204     "create and schedule a new windowgroup for me and open the view.
  3239 		     halfLight:nil
  3368 		     halfLight:nil
  3240 		     style:nil.
  3369 		     style:nil.
  3241 !
  3370 !
  3242 
  3371 
  3243 drawLeftEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
  3372 drawLeftEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
  3244     |leftFg leftHalfFg paint
  3373     |leftFg leftHalfFg paint b
  3245      count "{ Class: SmallInteger }" |
  3374      count "{ Class: SmallInteger }" |
  3246 
  3375 
  3247     count := level.
  3376     count := level.
  3248     count == 0 ifTrue:[^ self].
  3377     count == 0 ifTrue:[^ self].
  3249     
  3378     
  3257     ].
  3386     ].
  3258     leftHalfFg isNil ifTrue:[
  3387     leftHalfFg isNil ifTrue:[
  3259 	leftHalfFg := leftFg
  3388 	leftHalfFg := leftFg
  3260     ].
  3389     ].
  3261 
  3390 
  3262     super lineWidth:0.
       
  3263     ((edgeStyle == #soft) and:[level > 0]) ifTrue:[
  3391     ((edgeStyle == #soft) and:[level > 0]) ifTrue:[
  3264 	paint := leftHalfFg
  3392 	paint := leftHalfFg
  3265     ] ifFalse:[
  3393     ] ifFalse:[
  3266 	paint := leftFg
  3394 	paint := leftFg
  3267     ].
  3395     ].
  3268 
       
  3269     super paint:paint.
  3396     super paint:paint.
       
  3397     super lineWidth:0.
       
  3398 
       
  3399     b := height - 1.
  3270     0 to:(count - 1) do:[:i |
  3400     0 to:(count - 1) do:[:i |
  3271 	super displayDeviceLineFromX:i y:i toX:i y:(height - 1 - i)
  3401 	super displayDeviceLineFromX:i y:i toX:i y:(b - i)
  3272     ].
  3402     ].
  3273 
  3403 
  3274     ((edgeStyle == #soft) and:[level > 2]) ifTrue:[
  3404     ((edgeStyle == #soft) and:[level > 2]) ifTrue:[
  3275 	super paint:Black.
  3405 	super paint:Black.
  3276 	super displayDeviceLineFromX:0 y:0 toX:0 y:height-1. 
  3406 	super displayDeviceLineFromX:0 y:0 toX:0 y:b. 
  3277     ]
  3407     ]
  3278 !
  3408 !
  3279 
  3409 
  3280 drawRightEdge
  3410 drawRightEdge
  3281     "draw right 3D edge into window frame"
  3411     "draw right 3D edge into window frame"
  3289 !
  3419 !
  3290 
  3420 
  3291 drawRightEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
  3421 drawRightEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
  3292     |rightFg
  3422     |rightFg
  3293      count "{ Class: SmallInteger }" 
  3423      count "{ Class: SmallInteger }" 
  3294      r|
  3424      r b|
  3295 
  3425 
  3296     count := level.
  3426     count := level.
  3297     count == 0 ifTrue:[^ self].
  3427     count == 0 ifTrue:[^ self].
  3298 
  3428 
  3299     (count < 0) ifTrue:[
  3429     (count < 0) ifTrue:[
  3304 	    rightFg := halfShadowColor
  3434 	    rightFg := halfShadowColor
  3305 	] ifFalse:[
  3435 	] ifFalse:[
  3306 	    rightFg := shadowColor
  3436 	    rightFg := shadowColor
  3307 	].
  3437 	].
  3308     ].
  3438     ].
  3309 
  3439     super paint:rightFg.
  3310     super lineWidth:0.
  3440     super lineWidth:0.
  3311     super paint:rightFg.
  3441 
       
  3442     b := height - 1.
  3312     0 to:(count - 1) do:[:i |
  3443     0 to:(count - 1) do:[:i |
  3313 	r := width - 1 - i.
  3444 	r := width - 1 - i.
  3314 	super displayDeviceLineFromX:r y:i toX:r y:(height - 1 - i)
  3445 	super displayDeviceLineFromX:r y:i toX:r y:(b - i)
  3315     ].
  3446     ].
  3316     ((edgeStyle == #soft) and:[level > 1]) ifTrue:[
  3447     ((edgeStyle == #soft) and:[level > 1]) ifTrue:[
       
  3448 	r := width - 1.
  3317 	super paint:shadowColor.
  3449 	super paint:shadowColor.
  3318 	super displayDeviceLineFromX:width-1 y:1 toX:width-1 y:height-1. 
  3450 	super displayDeviceLineFromX:r y:1 toX:r y:b. 
  3319     ]
  3451     ]
  3320 !
  3452 !
  3321 
  3453 
  3322 drawTopEdge
  3454 drawTopEdge
  3323     "draw top 3D edge into window frame"
  3455     "draw top 3D edge into window frame"
  3329 		    halfLight:nil
  3461 		    halfLight:nil
  3330 		    style:nil.
  3462 		    style:nil.
  3331 !
  3463 !
  3332 
  3464 
  3333 drawTopEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
  3465 drawTopEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle 
  3334     |topFg topHalfFg
  3466     |topFg topHalfFg paint r
  3335      count "{ Class: SmallInteger }" |
  3467      count "{ Class: SmallInteger }" |
  3336 
  3468 
  3337     count := level.
  3469     count := level.
  3338     count == 0 ifTrue:[^ self].
  3470     count == 0 ifTrue:[^ self].
  3339 
  3471 
  3347     ].
  3479     ].
  3348     topHalfFg isNil ifTrue:[
  3480     topHalfFg isNil ifTrue:[
  3349 	topHalfFg := topFg
  3481 	topHalfFg := topFg
  3350     ].
  3482     ].
  3351 
  3483 
       
  3484     ((edgeStyle == #soft) and:[level > 0]) ifTrue:[
       
  3485 	paint := topHalfFg
       
  3486     ] ifFalse:[
       
  3487 	paint := topFg
       
  3488     ].
       
  3489     super paint:paint.
  3352     super lineWidth:0.
  3490     super lineWidth:0.
  3353     ((edgeStyle == #soft) and:[level > 0]) ifTrue:[
  3491 
  3354 	super paint:topHalfFg
  3492     r := width - 1.
  3355     ] ifFalse:[
       
  3356 	super paint:topFg
       
  3357     ].
       
  3358     0 to:(count - 1) do:[:i |
  3493     0 to:(count - 1) do:[:i |
  3359 	super displayDeviceLineFromX:i y:i toX:(width - 1 - i) y:i
  3494 	super displayDeviceLineFromX:i y:i toX:(r - i) y:i
  3360     ].
  3495     ].
  3361     ((edgeStyle == #soft) and:[level > 2]) ifTrue:[
  3496     ((edgeStyle == #soft) and:[level > 2]) ifTrue:[
  3362 	super paint:Black.
  3497 	super paint:Black.
  3363 	super displayDeviceLineFromX:0 y:0 toX:width-1 y:0. 
  3498 	super displayDeviceLineFromX:0 y:0 toX:r y:0. 
  3364     ]
  3499     ]
  3365 !
  3500 !
  3366 
  3501 
  3367 drawBottomEdge
  3502 drawBottomEdge
  3368     "draw bottom 3D edge into window frame"
  3503     "draw bottom 3D edge into window frame"
  3376 !
  3511 !
  3377 
  3512 
  3378 drawBottomEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
  3513 drawBottomEdgeLevel:level shadow:shadowColor light:lightColor halfShadow:halfShadowColor halfLight:halfLightColor style:edgeStyle
  3379     |botFg
  3514     |botFg
  3380      count "{ Class: SmallInteger }" 
  3515      count "{ Class: SmallInteger }" 
  3381      b|
  3516      b r|
  3382 
  3517 
  3383     count := level.
  3518     count := level.
  3384     count == 0 ifTrue:[^ self].
  3519     count == 0 ifTrue:[^ self].
  3385 
  3520 
  3386     (count < 0) ifTrue:[
  3521     (count < 0) ifTrue:[
  3391 	    botFg := halfShadowColor
  3526 	    botFg := halfShadowColor
  3392 	] ifFalse:[
  3527 	] ifFalse:[
  3393 	    botFg := shadowColor
  3528 	    botFg := shadowColor
  3394 	].
  3529 	].
  3395     ].
  3530     ].
  3396 
  3531     super paint:botFg.
  3397     super lineWidth:0.
  3532     super lineWidth:0.
  3398     super paint:botFg.
  3533 
       
  3534     r := width - 1.
  3399     0 to:(count - 1) do:[:i |
  3535     0 to:(count - 1) do:[:i |
  3400 	b := height - 1 - i.
  3536 	b := height - 1 - i.
  3401 	super displayDeviceLineFromX:i y:b toX:(width "- 1" - i) y:b
  3537 	super displayDeviceLineFromX:i y:b toX:(r - i) y:b
  3402     ].
  3538     ].
       
  3539 
  3403     ((edgeStyle == #soft) and:[level > 1]) ifTrue:[
  3540     ((edgeStyle == #soft) and:[level > 1]) ifTrue:[
       
  3541 	b := height - 1.
  3404 	super paint:shadowColor.
  3542 	super paint:shadowColor.
  3405 	super displayDeviceLineFromX:1 y:height-1 toX:width-1 y:height-1. 
  3543 	super displayDeviceLineFromX:1 y:b toX:r y:b. 
  3406     ]
  3544     ]
  3407 !
  3545 !
  3408 
  3546 
  3409 redrawEdges
  3547 redrawEdges
  3410     "redraw my edges (if any)"
  3548     "redraw my edges (if any)"
  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
  3791      nothing done here"
  3959      nothing done here"
  3792 
  3960 
  3793     ^ self
  3961     ^ self
  3794 !
  3962 !
  3795 
  3963 
       
  3964 focusIn
       
  3965     "got keyboard focus"
       
  3966 
       
  3967     self showFocus
       
  3968 !
       
  3969 
       
  3970 focusOut
       
  3971     "lost keyboard focus"
       
  3972 
       
  3973     self showNoFocus
       
  3974 !
       
  3975 
  3796 exposeX:x y:y width:w height:h
  3976 exposeX:x y:y width:w height:h
  3797     "a low level redraw event from device
  3977     "a low level redraw event from device
  3798       - let subclass handle the redraw and take care of edges here"
  3978       - let subclass handle the redraw and take care of edges here"
  3799 
  3979 
  3800     |leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh|
  3980     |leftEdge topEdge rightEdge botEdge anyEdge nx ny nw nh old|
  3801 
  3981 
  3802     nw := w.
  3982     nw := w.
  3803     nh := h.
  3983     nh := h.
  3804     nx := x.
  3984     nx := x.
  3805     ny := y.
  3985     ny := y.
  3806 
  3986 
  3807     anyEdge := false.
  3987     anyEdge := false.
  3808 
  3988 
  3809     "
  3989     "
  3810      check if there is a need to draw an edge
  3990      check if there is a need to draw an edge (i.e. if margin is hit)
  3811     "
  3991     "
  3812     (margin ~~ 0) ifTrue:[
  3992     (margin ~~ 0) ifTrue:[
  3813 	leftEdge := false.
  3993 	leftEdge := false.
  3814 	topEdge := false.
  3994 	topEdge := false.
  3815 	rightEdge := false.
  3995 	rightEdge := false.
  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 	    "
  3864 	    nw := transformation applyInverseScaleX:nw.
  4052 	    nw := transformation applyInverseScaleX:nw.
  3865 	    nh := transformation applyInverseScaleY:nh.
  4053 	    nh := transformation applyInverseScaleY:nh.
  3866 	].
  4054 	].
  3867     ].
  4055     ].
  3868 
  4056 
  3869     "redraw inside area"
  4057     "
  3870 
  4058      redraw inside area
       
  4059     "
  3871     self redrawX:nx y:ny width:nw height:nh.
  4060     self redrawX:nx y:ny width:nw height:nh.
  3872 
  4061 
  3873     "redraw edge(s)"
  4062     "
  3874 
  4063      redraw edge(s)
       
  4064     "
  3875     anyEdge ifTrue:[
  4065     anyEdge ifTrue:[
  3876 	self clipRect:nil.
  4066 	self clipRect:nil.
  3877 	(topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
  4067 	(topEdge and:[leftEdge and:[botEdge and:[rightEdge]]]) ifTrue:[
  3878 	    self drawEdges
  4068 	    self drawEdges
  3879 	] ifFalse:[
  4069 	] ifFalse:[