Scroller.st
changeset 6507 7ff968c1e269
parent 6490 3d1a00dd648f
equal deleted inserted replaced
6506:0f7404be1444 6507:7ff968c1e269
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
  1251             ifTrue:[thumbEnteredColor] 
  1249             ifTrue:[thumbEnteredColor] 
  1252             ifFalse:[thumbColor].
  1250             ifFalse:[thumbColor].
  1253     ].
  1251     ].
  1254 
  1252 
  1255     clr notNil ifTrue:[
  1253     clr notNil ifTrue:[
  1256         (styleSheet at:#'scroller.vista3DStyle' default:false) ifTrue:[
  1254         vistaStyle ifTrue:[
  1257             "/ color gradient drawing
  1255             "/ color gradient drawing
  1258             "/ with colors rougly smilar to the vista colors, which are:
  1256             "/ with colors rougly smilar to the vista colors, which are:
  1259             "/ 243 242 240 236 234 233 215 211 207 205 200 192 206
  1257             "/ 243 242 240 236 234 233 215 211 207 205 200 192 206
  1260             clr2 := styleSheet colorAt:#'scroller.vista3DStyleLightColor' default:self whiteColor.
  1258             clr2 := styleSheet colorAt:#'scroller.vista3DStyleLightColor' default:self whiteColor.
  1261             
  1259             
  1315             ] ifFalse:[
  1313             ] ifFalse:[
  1316                 (styleSheet at:#'scroller.roundStyle' default:false) ifTrue:[
  1314                 (styleSheet at:#'scroller.roundStyle' default:false) ifTrue:[
  1317                     "/ hack for osx
  1315                     "/ hack for osx
  1318                     (orientation == #vertical) ifTrue:[
  1316                     (orientation == #vertical) ifTrue:[
  1319                         1 to:3 do:[:i |
  1317                         1 to:3 do:[:i |
  1320                             |yLine left right|
  1318                             |yLine lefti righti|
  1321 
  1319 
  1322                             left := l+i-1.
  1320                             lefti := l+i-1.
  1323                             right := l+w-i+1.
  1321                             righti := l+w-i+1.
  1324                             yLine := t+3-i.
  1322                             yLine := t+3-i.
  1325                             gc displayLineFromX:left y:yLine toX:right y:yLine.    
  1323                             gc displayLineFromX:lefti y:yLine toX:righti y:yLine.    
  1326                             yLine := t+h-3-1+i. 
  1324                             yLine := t+h-3-1+i. 
  1327                             gc displayLineFromX:left y:yLine toX:right y:yLine.    
  1325                             gc displayLineFromX:lefti y:yLine toX:righti y:yLine.    
  1328                         ].
  1326                         ].
  1329                         gc fillRectangleX:l y:t+3 width:w height:h-6.
  1327                         gc fillRectangleX:l y:t+3 width:w height:h-6.
  1330                     ] ifFalse:[
  1328                     ] ifFalse:[
  1331                         1 to:3 do:[:i |
  1329                         1 to:3 do:[:i |
  1332                             |xLine top bot|
  1330                             |xLine topi boti|
  1333 
  1331 
  1334                             top := t+i-1.
  1332                             topi := t+i-1.
  1335                             bot := t+h-i+1.
  1333                             boti := t+h-i+1.
  1336                             xLine := l+3-i.
  1334                             xLine := l+3-i.
  1337                             gc displayLineFromX:xLine y:top toX:xLine y:bot.    
  1335                             gc displayLineFromX:xLine y:topi toX:xLine y:boti.    
  1338                             xLine := l+w-3-1+i. 
  1336                             xLine := l+w-3-1+i. 
  1339                             gc displayLineFromX:xLine y:top toX:xLine y:bot.    
  1337                             gc displayLineFromX:xLine y:topi toX:xLine y:boti.    
  1340                         ].
  1338                         ].
  1341                         gc fillRectangleX:l+3 y:t width:w-6 height:h.
  1339                         gc fillRectangleX:l+3 y:t width:w-6 height:h.
  1342                     ].
  1340                     ].
  1343                 ] ifFalse:[
  1341                 ] ifFalse:[
  1344                     gc fillRectangleX:l y:t width:w height:h.
  1342                     gc fillRectangleX:l y:t width:w height:h.
  1425 
  1423 
  1426     "iris style - draw tallys"
  1424     "iris style - draw tallys"
  1427     self drawTallyMarks.
  1425     self drawTallyMarks.
  1428 
  1426 
  1429     "Modified: / 29-11-2011 / 11:55:24 / cg"
  1427     "Modified: / 29-11-2011 / 11:55:24 / cg"
       
  1428     "Modified (format): / 16-11-2018 / 15:29:29 / Claus Gittinger"
  1430 !
  1429 !
  1431 
  1430 
  1432 drawThumbBackgroundInX:x y:y width:w height:h
  1431 drawThumbBackgroundInX:x y:y width:w height:h
  1433     "draw part of the thumbs background; defined as a separate
  1432     "draw part of the thumbs background; defined as a separate
  1434      method, to allow drawing of arbitrary patterns under thumb 
  1433      method, to allow drawing of arbitrary patterns under thumb 
  1961 
  1960 
  1962     "/ any change ?
  1961     "/ any change ?
  1963     thumbFrame = oldThumbFrame ifTrue:[
  1962     thumbFrame = oldThumbFrame ifTrue:[
  1964         ^ self
  1963         ^ self
  1965     ].
  1964     ].
       
  1965 
       
  1966     (styleSheet at:#'scroller.roundStyle' default:false) ifTrue:[
       
  1967         "/ q&d hack arround a redraw error with rounded thumb
       
  1968         self invalidate.
       
  1969         ^ self
       
  1970     ].
       
  1971     
  1966     thumbFrame isNil ifTrue:[
  1972     thumbFrame isNil ifTrue:[
  1967         self invalidate.
  1973         self invalidate.
  1968         ^ self
  1974         ^ self
  1969     ].
  1975     ].
  1970     oldThumbFrame isNil ifTrue:[
  1976     oldThumbFrame isNil ifTrue:[
  2045                 ^ self.
  2051                 ^ self.
  2046             ].
  2052             ].
  2047         ].
  2053         ].
  2048     ].
  2054     ].
  2049 
  2055 
  2050     self invalidate:(oldThumbFrame merge: thumbFrame).
  2056     self invalidate:(oldThumbFrame merge:thumbFrame).
  2051 
  2057 
  2052     "Modified: / 23.5.1999 / 13:50:41 / cg"
  2058     "Modified: / 23-05-1999 / 13:50:41 / cg"
       
  2059     "Modified (format): / 16-11-2018 / 15:59:21 / Claus Gittinger"
  2053 !
  2060 !
  2054 
  2061 
  2055 update:something with:aParameter from:changedObject
  2062 update:something with:aParameter from:changedObject
  2056     "handle update from a model (if any)"
  2063     "handle update from a model (if any)"
  2057 
  2064 
  2422 
  2429 
  2423     "Modified: 7.3.1997 / 16:05:57 / cg"
  2430     "Modified: 7.3.1997 / 16:05:57 / cg"
  2424 !
  2431 !
  2425 
  2432 
  2426 computeThumbFrame
  2433 computeThumbFrame
  2427     "compute the thumbs frame (a rectangle) whenever thumb is moved, 
  2434     "compute the thumb's frame (a rectangle) whenever thumb is moved, 
  2428      changed height or the scrollers size has changed.
  2435      changed height or the scroller's size has changed.
  2429      We take care, that the thumb will not become too small (i.e.
  2436      We take care, that the thumb will not become too small (i.e.
  2430      invisible or uncatchable).
  2437      invisible or uncatchable).
  2431      Also, for mswindows style, its height/width is constant."
  2438      Also, for mswindows style, its height/width is constant."
  2432 
  2439 
  2433     |newPos1 newPos2 newSize1 newSize2 nh nw ny nx 
  2440     |newPos1 newPos2 newSize1 newSize2 nh nw ny nx 
  2556 
  2563 
  2557     thumbFrame := Rectangle left:nx top:ny width:nw height:nh.
  2564     thumbFrame := Rectangle left:nx top:ny width:nw height:nh.
  2558 
  2565 
  2559     "Modified: / 12-05-1998 / 20:58:51 / cg"
  2566     "Modified: / 12-05-1998 / 20:58:51 / cg"
  2560     "Modified (comment): / 13-02-2017 / 20:30:04 / cg"
  2567     "Modified (comment): / 13-02-2017 / 20:30:04 / cg"
       
  2568     "Modified (comment): / 16-11-2018 / 15:23:36 / Claus Gittinger"
  2561 !
  2569 !
  2562 
  2570 
  2563 percentFromAbs:absValue
  2571 percentFromAbs:absValue
  2564     "given a number of pixels, compute percentage"
  2572     "given a number of pixels, compute percentage"
  2565 
  2573