Scroller.st
changeset 1988 55184833642a
parent 1962 baf22110671e
child 2010 ca8dcc8723dc
equal deleted inserted replaced
1987:599825bed176 1988:55184833642a
   555             realNewHeight >= 100 ifTrue:[
   555             realNewHeight >= 100 ifTrue:[
   556                 nBg := DefaultFullViewBackground.
   556                 nBg := DefaultFullViewBackground.
   557             ] ifFalse:[
   557             ] ifFalse:[
   558                 nBg := DefaultViewBackground
   558                 nBg := DefaultViewBackground
   559             ].
   559             ].
   560             nBg := nBg on:device.
   560             nBg := nBg onDevice:device.
   561             nBg ~~ viewBackground ifTrue:[
   561             nBg ~~ viewBackground ifTrue:[
   562                 self viewBackground:nBg.
   562                 self viewBackground:nBg.
   563                 shown ifTrue:[self clear].
   563                 shown ifTrue:[self clear].
   564             ]
   564             ]
   565         ].
   565         ].
   783 
   783 
   784     newOrigin := originNumber - rangeStart / (range / 100).
   784     newOrigin := originNumber - rangeStart / (range / 100).
   785     newHeight := heightNumber / (range abs / 100).
   785     newHeight := heightNumber / (range abs / 100).
   786 
   786 
   787     (newHeight > 100) ifTrue:[
   787     (newHeight > 100) ifTrue:[
   788 	realNewHeight := 100
   788         realNewHeight := 100
   789     ] ifFalse:[
   789     ] ifFalse:[
   790 	realNewHeight := newHeight
   790         realNewHeight := newHeight
   791     ].
   791     ].
   792     ((newOrigin + realNewHeight) > 100) ifTrue:[
   792     ((newOrigin + realNewHeight) > 100) ifTrue:[
   793 	realNewOrigin := 100 - realNewHeight
   793         realNewOrigin := 100 - realNewHeight
   794     ] ifFalse: [
   794     ] ifFalse: [
   795 	realNewOrigin := newOrigin
   795         realNewOrigin := newOrigin
   796     ].
   796     ].
   797     (realNewOrigin < 0) ifTrue: [
   797     (realNewOrigin < 0) ifTrue: [
   798 	realNewOrigin := 0
   798         realNewOrigin := 0
   799     ].
   799     ].
   800 
   800 
   801     changed := (realNewHeight ~= thumbHeight) or:[realNewOrigin ~= thumbOrigin].
   801     changed := (realNewHeight ~= thumbHeight) or:[realNewOrigin ~= thumbOrigin].
   802     (changed or:[thumbFrame isNil]) ifTrue:[
   802     (changed or:[thumbFrame isNil]) ifTrue:[
   803 	old := self absFromPercent:thumbOrigin.
   803         old := self absFromPercent:thumbOrigin.
   804 	new := self absFromPercent:realNewOrigin.
   804         new := self absFromPercent:realNewOrigin.
   805 	changed := old ~~ new.
   805         changed := old ~~ new.
   806 	changed ifFalse:[
   806         changed ifFalse:[
   807 	    old := self absFromPercent:thumbHeight.
   807             old := self absFromPercent:thumbHeight.
   808 	    new := self absFromPercent:realNewHeight.
   808             new := self absFromPercent:realNewHeight.
   809 	    changed := (old ~~ new)
   809             changed := (old ~~ new)
   810 	].
   810         ].
   811 	(changed or:[thumbFrame isNil]) ifTrue:[
   811         (changed or:[thumbFrame isNil]) ifTrue:[
   812 	    thumbOrigin := realNewOrigin.
   812             thumbOrigin := realNewOrigin.
   813 	    thumbHeight := realNewHeight.
   813             thumbHeight := realNewHeight.
   814 
   814 
   815 	    (DefaultFullViewBackground notNil
   815             (DefaultFullViewBackground notNil
   816 	    and:[DefaultViewBackground notNil
   816             and:[DefaultViewBackground notNil
   817 	    and:[DefaultFullViewBackground ~~ DefaultViewBackground]]) ifTrue:[
   817             and:[DefaultFullViewBackground ~~ DefaultViewBackground]]) ifTrue:[
   818 		realNewHeight >= 100 ifTrue:[
   818                 realNewHeight >= 100 ifTrue:[
   819 		    nBg := DefaultFullViewBackground.
   819                     nBg := DefaultFullViewBackground.
   820 		] ifFalse:[
   820                 ] ifFalse:[
   821 		    nBg := DefaultViewBackground
   821                     nBg := DefaultViewBackground
   822 		].
   822                 ].
   823 		nBg := nBg on:device.
   823                 nBg := nBg onDevice:device.
   824 		nBg ~~ viewBackground ifTrue:[
   824                 nBg ~~ viewBackground ifTrue:[
   825 		    self viewBackground:nBg.
   825                     self viewBackground:nBg.
   826 		    shown ifTrue:[self clear].
   826                     shown ifTrue:[self clear].
   827 		]
   827                 ]
   828 	    ].
   828             ].
   829 
   829 
   830 	    shown ifTrue:[
   830             shown ifTrue:[
   831 		thumbFrame := nil.
   831                 thumbFrame := nil.
   832 		self invalidate.
   832                 self invalidate.
   833 
   833 
   834 "/                thumbFrame notNil ifTrue:[
   834 "/                thumbFrame notNil ifTrue:[
   835 "/                    self drawThumbBackgroundInX:(thumbFrame left)
   835 "/                    self drawThumbBackgroundInX:(thumbFrame left)
   836 "/                                              y:(thumbFrame top) 
   836 "/                                              y:(thumbFrame top) 
   837 "/                                          width:(thumbFrame width) 
   837 "/                                          width:(thumbFrame width) 
   838 "/                                         height:(thumbFrame height).
   838 "/                                         height:(thumbFrame height).
   839 "/                ].
   839 "/                ].
   840 "/                self computeThumbFrame.
   840 "/                self computeThumbFrame.
   841 "/                self drawThumb
   841 "/                self drawThumb
   842 	    ] ifFalse:[
   842             ] ifFalse:[
   843 		thumbFrame := nil
   843                 thumbFrame := nil
   844 	    ]
   844             ]
   845 	]
   845         ]
   846     ]
   846     ]
   847 
   847 
   848     "Modified: / 21.1.1998 / 19:32:41 / cg"
   848     "Modified: / 21.1.1998 / 19:32:41 / cg"
   849 ! !
   849 ! !
   850 
   850 
   980 
   980 
   981     <resource: #style (#name)>
   981     <resource: #style (#name)>
   982 
   982 
   983     |avgColor|
   983     |avgColor|
   984 
   984 
   985     thumbColor := aColor on:device.
   985     thumbColor := aColor onDevice:device.
   986     (styleSheet name ~~ #normal) ifTrue:[
   986     (styleSheet name ~~ #normal) ifTrue:[
   987         avgColor := aColor averageColorIn:(0@0 corner:7@7).
   987         avgColor := aColor averageColorIn:(0@0 corner:7@7).
   988         thumbShadowColor := avgColor darkened on:device.
   988         thumbShadowColor := avgColor darkened onDevice:device.
   989         thumbLightColor := avgColor lightened on:device.
   989         thumbLightColor := avgColor lightened onDevice:device.
   990         thumbHalfShadowColor := thumbShadowColor darkened on:device.
   990         thumbHalfShadowColor := thumbShadowColor darkened onDevice:device.
   991         thumbHalfLightColor := thumbLightColor lightened on:device.
   991         thumbHalfLightColor := thumbLightColor lightened onDevice:device.
   992     ].
   992     ].
   993     self invalidate
   993     self invalidate
   994 
   994 
   995     "Modified: 8.2.1997 / 15:15:58 / cg"
   995     "Modified: 8.2.1997 / 15:15:58 / cg"
   996 ! !
   996 ! !
  1010 ! !
  1010 ! !
  1011 
  1011 
  1012 !Scroller methodsFor:'drawing'!
  1012 !Scroller methodsFor:'drawing'!
  1013 
  1013 
  1014 drawHandleFormAtX:x y:y
  1014 drawHandleFormAtX:x y:y
  1015     thumbShadowColor := thumbShadowColor on:device.
  1015     thumbShadowColor := thumbShadowColor onDevice:device.
  1016 
  1016 
  1017     self paint:thumbShadowColor.
  1017     self paint:thumbShadowColor.
  1018     self displayForm:shadowForm x:x y:y.
  1018     self displayForm:shadowForm x:x y:y.
  1019     lightForm notNil ifTrue:[
  1019     lightForm notNil ifTrue:[
  1020 	thumbLightColor := thumbLightColor on:device.
  1020         thumbLightColor := thumbLightColor onDevice:device.
  1021 	self paint:thumbLightColor.
  1021         self paint:thumbLightColor.
  1022 	self displayForm:lightForm x:x y:y.
  1022         self displayForm:lightForm x:x y:y.
  1023     ].
  1023     ].
  1024 
  1024 
  1025     "Modified: / 19.5.1998 / 16:26:49 / cg"
  1025     "Modified: / 19.5.1998 / 16:26:49 / cg"
  1026 !
  1026 !
  1027 
  1027 
  1827 fetchDeviceResources
  1827 fetchDeviceResources
  1828     "fetch device colors, to avoid reallocation at redraw time"
  1828     "fetch device colors, to avoid reallocation at redraw time"
  1829 
  1829 
  1830     super fetchDeviceResources.
  1830     super fetchDeviceResources.
  1831 
  1831 
  1832     thumbShadowColor notNil ifTrue:[thumbShadowColor := thumbShadowColor on:device].
  1832     thumbShadowColor notNil ifTrue:[thumbShadowColor := thumbShadowColor onDevice:device].
  1833     thumbLightColor notNil ifTrue:[thumbLightColor := thumbLightColor on:device].
  1833     thumbLightColor notNil ifTrue:[thumbLightColor := thumbLightColor onDevice:device].
  1834     thumbHalfShadowColor notNil ifTrue:[thumbHalfShadowColor := thumbHalfShadowColor on:device].
  1834     thumbHalfShadowColor notNil ifTrue:[thumbHalfShadowColor := thumbHalfShadowColor onDevice:device].
  1835     thumbHalfLightColor notNil ifTrue:[thumbHalfLightColor := thumbHalfLightColor on:device].
  1835     thumbHalfLightColor notNil ifTrue:[thumbHalfLightColor := thumbHalfLightColor onDevice:device].
  1836 
  1836 
  1837     thumbEnteredColor notNil ifTrue:[thumbEnteredColor := thumbEnteredColor on:device].
  1837     thumbEnteredColor notNil ifTrue:[thumbEnteredColor := thumbEnteredColor onDevice:device].
  1838     ghostColor notNil ifTrue:[ghostColor := ghostColor on:device].
  1838     ghostColor notNil ifTrue:[ghostColor := ghostColor onDevice:device].
  1839     ghostFrameColor notNil ifTrue:[ghostFrameColor := ghostFrameColor on:device].
  1839     ghostFrameColor notNil ifTrue:[ghostFrameColor := ghostFrameColor onDevice:device].
  1840 
  1840 
  1841     "Modified: 13.1.1997 / 21:56:38 / cg"
  1841     "Modified: 13.1.1997 / 21:56:38 / cg"
  1842 !
  1842 !
  1843 
  1843 
  1844 initCursor
  1844 initCursor
  1942                 thumbColor := Color grey
  1942                 thumbColor := Color grey
  1943             ].
  1943             ].
  1944         ].
  1944         ].
  1945     ].
  1945     ].
  1946 
  1946 
  1947     thumbColor := thumbColor on:device.
  1947     thumbColor := thumbColor onDevice:device.
  1948     thumbShadowColor notNil ifTrue:[
  1948     thumbShadowColor notNil ifTrue:[
  1949         thumbShadowColor := thumbShadowColor onDevice:device.
  1949         thumbShadowColor := thumbShadowColor onDevice:device.
  1950     ].
  1950     ].
  1951     thumbLightColor notNil ifTrue:[
  1951     thumbLightColor notNil ifTrue:[
  1952         thumbLightColor := thumbLightColor onDevice:device.
  1952         thumbLightColor := thumbLightColor onDevice:device.
  2400 ! !
  2400 ! !
  2401 
  2401 
  2402 !Scroller class methodsFor:'documentation'!
  2402 !Scroller class methodsFor:'documentation'!
  2403 
  2403 
  2404 version
  2404 version
  2405     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.134 1999-07-12 14:24:33 cg Exp $'
  2405     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.135 1999-08-18 14:37:19 cg Exp $'
  2406 ! !
  2406 ! !