'From Squeak3.2alpha of 17 December 2001 [latest update: #4623] on 18 December 2001 at 9:15:59 pm'! "Change Set: ColoredScrollbars-ar Date: 18 December 2001 Author: Andreas Raab A set of colored scrollbars for windows. Handled by the following preference... " Preferences addPreference: #alternativeScrollbarLook categories: #(windows scrolling) default: true balloonHelp: 'When true, use scrollbars matching the #alternativeWindowLook preference'.! !Morph methodsFor: 'accessing' stamp: 'ar 12/18/2001 20:09'! adoptPaneColor: paneColor self submorphsDo:[:m| m adoptPaneColor: paneColor].! ! !ScrollPane methodsFor: 'initialization' stamp: 'ar 12/18/2001 20:03'! initialize retractableScrollBar _ (Preferences valueOfFlag: #inboardScrollbars) not. scrollBarOnLeft _ (Preferences valueOfFlag: #scrollBarsOnRight) not. super initialize. hasFocus _ false. borderWidth _ 2. borderColor _ Color black. scrollBar := ScrollBar new model: self slotName: 'scrollBar'. scrollBar borderWidth: 1; borderColor: Color black. scroller := TransformMorph new color: Color transparent. scroller offset: -3@0. self addMorph: scroller. scrollBar initializeEmbedded: retractableScrollBar not. retractableScrollBar ifFalse: [self addMorph: scrollBar]. self extent: 150@120! ! !ScrollPane methodsFor: 'access' stamp: 'ar 12/18/2001 20:09'! adoptPaneColor: paneColor super adoptPaneColor: paneColor. scrollBar adoptPaneColor: paneColor.! ! !Slider methodsFor: 'access' stamp: 'ar 12/18/2001 20:49'! sliderColor sliderColor ifNil: [^ Color veryLightGray]. ^ sliderColor! ! !Slider methodsFor: 'geometry' stamp: 'ar 12/18/2001 02:33'! sliderThickness ^ 15! ! !Slider methodsFor: 'other events' stamp: 'ar 12/18/2001 02:31'! mouseDownInSlider: event slider color: self sliderColor lighter. sliderShadow color: self sliderColor darker. sliderShadow cornerStyle: slider cornerStyle. sliderShadow bounds: slider bounds. sliderShadow show.! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:52'! adoptPaneColor: aColor "Adopt the given pane color" self alternativeScrollbarLook ifFalse:[^self]. aColor ifNil:[^self]. self sliderColor: aColor.! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:24'! initialize super initialize. scrollDelta _ 0.02. pageDelta _ 0.2. self alternativeScrollbarLook ifTrue:[ self borderStyle: ((BorderStyle complexFramed width: 2) "baseColor: Color gray")].! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:48'! initializeDownButton downButton := RectangleMorph newBounds: (self innerBounds bottomRight - self buttonExtent extent: self buttonExtent) color: Color lightGray. downButton on: #mouseDown send: #scrollDownInit to: self. downButton on: #mouseUp send: #finishedScrolling to: self. downButton addMorphCentered: (ImageMorph new image: (self cachedImageAt: (bounds isWide ifTrue: ['right'] ifFalse: ['down']) ifAbsentPut: [ self upArrow8Bit rotateBy: (bounds isWide ifTrue: [#right] ifFalse: [#pi]) centerAt: 0@0 ] ) ). self alternativeScrollbarLook ifTrue:[ downButton color: Color veryLightGray. downButton borderStyle: (BorderStyle complexRaised width: 3). ] ifFalse:[ downButton setBorderWidth: 1 borderColor: #raised. ]. self addMorph: downButton. ! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:41'! initializeEmbedded: aBool "aBool == true => inboard scrollbar aBool == false => flop-out scrollbar" self alternativeScrollbarLook ifFalse:[^self]. aBool ifTrue:[ self borderStyle: (BorderStyle inset width: 2). self cornerStyle: #square. ] ifFalse:[ self borderStyle: (BorderStyle width: 1 color: Color black). self cornerStyle: #rounded. ]. self removeAllMorphs. self initializeSlider.! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:48'! initializeMenuButton "Preferences disable: #scrollBarsWithoutMenuButton" "Preferences enable: #scrollBarsWithoutMenuButton" (Preferences valueOfFlag: #scrollBarsWithoutMenuButton) ifTrue: [^self]. self alternativeScrollbarLook ifTrue:[ menuButton := RectangleMorph newBounds: ((bounds isWide ifTrue: [upButton bounds topRight] ifFalse: [upButton bounds bottomLeft]) extent: self buttonExtent) ] ifFalse:[ menuButton := RectangleMorph newBounds: (self innerBounds topLeft extent: self buttonExtent) color: Color lightGray. ]. menuButton on: #mouseEnter send: #menuButtonMouseEnter: to: self. menuButton on: #mouseDown send: #menuButtonMouseDown: to: self. menuButton on: #mouseLeave send: #menuButtonMouseLeave: to: self. menuButton addMorphCentered: (RectangleMorph newBounds: (0@0 extent: 4@2) color: Color black). self alternativeScrollbarLook ifTrue:[ menuButton color: Color veryLightGray. menuButton borderStyle: (BorderStyle complexRaised width: 3). ] ifFalse:[ menuButton setBorderWidth: 1 borderColor: #raised. ]. self addMorph: menuButton ! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:04'! initializePagingArea pagingArea := RectangleMorph newBounds: self totalSliderArea color: (Color r: 0.6 g: 0.6 b: 0.8). pagingArea borderWidth: 0. pagingArea on: #mouseDown send: #scrollPageInit: to: self. pagingArea on: #mouseUp send: #finishedScrolling to: self. self addMorph: pagingArea. self alternativeScrollbarLook ifTrue:[pagingArea color: (Color gray: 0.9)].! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:51'! initializeSlider self alternativeScrollbarLook ifTrue:[ self initializeUpButton; initializeMenuButton; initializeDownButton; initializePagingArea. ] ifFalse:[ self initializeMenuButton; initializeUpButton; initializeDownButton; initializePagingArea. ]. super initializeSlider. self alternativeScrollbarLook ifTrue:[ slider cornerStyle: #rounded. slider borderStyle: (BorderStyle complexRaised width: 3). sliderShadow cornerStyle: #rounded. ]. self sliderColor: self sliderColor.! ! !ScrollBar methodsFor: 'initialize' stamp: 'ar 12/18/2001 20:49'! initializeUpButton self alternativeScrollbarLook ifTrue:[ upButton := RectangleMorph newBounds: (self innerBounds topLeft extent: self buttonExtent) ] ifFalse:[ upButton := RectangleMorph newBounds: ((menuButton ifNil: [self innerBounds topLeft] ifNotNil: [bounds isWide ifTrue: [menuButton bounds topRight] ifFalse: [menuButton bounds bottomLeft]]) extent: self buttonExtent) ]. upButton color: Color lightGray. upButton on: #mouseDown send: #scrollUpInit to: self. upButton on: #mouseUp send: #finishedScrolling to: self. upButton addMorphCentered: (ImageMorph new image: (self cachedImageAt: (bounds isWide ifTrue: ['left'] ifFalse: ['up']) ifAbsentPut: [ bounds isWide ifTrue: [ self upArrow8Bit rotateBy: #left centerAt: 0@0 ] ifFalse: [ self upArrow8Bit ] ] ) ). self alternativeScrollbarLook ifTrue:[ upButton color: Color veryLightGray. upButton borderStyle: (BorderStyle complexRaised width: 3). ] ifFalse:[ upButton setBorderWidth: 1 borderColor: #raised. ]. self addMorph: upButton! ! !ScrollBar methodsFor: 'access' stamp: 'ar 12/18/2001 21:15'! alternativeScrollbarLook ^Preferences alternativeScrollbarLook! ! !ScrollBar methodsFor: 'access' stamp: 'ar 12/18/2001 20:54'! sliderColor: aColor super sliderColor: aColor. self alternativeScrollbarLook ifFalse:[^self]. menuButton ifNotNil:[menuButton color: aColor lighter]. self color: Color transparent. upButton color: aColor lighter. downButton color: aColor lighter. slider color: aColor lighter. pagingArea color: aColor muchLighter. self borderStyle style == #simple ifTrue:[self borderColor: aColor darker darker] ifFalse:[self borderStyle baseColor: aColor].! ! !ScrollBar methodsFor: 'geometry' stamp: 'ar 12/18/2001 19:53'! totalSliderArea self alternativeScrollbarLook ifTrue:[ ^ bounds isWide ifTrue: [(menuButton ifNil:[upButton]) bounds topRight corner: downButton bounds bottomLeft] ifFalse: [(menuButton ifNil:[upButton]) bounds bottomLeft corner: downButton bounds topRight]. ] ifFalse:[ ^ bounds isWide ifTrue: [upButton bounds topRight corner: downButton bounds bottomLeft] ifFalse: [upButton bounds bottomLeft corner: downButton bounds topRight]. ].! ! !ScrollBar methodsFor: 'scrolling' stamp: 'ar 12/18/2001 20:19'! finishedScrolling self stopStepping. self scrollBarAction: nil. self alternativeScrollbarLook ifTrue:[ upButton borderStyle: (BorderStyle complexRaised width: upButton borderWidth). downButton borderStyle: (BorderStyle complexRaised width: downButton borderWidth). ] ifFalse:[ downButton borderRaised. upButton borderRaised. ]. ! ! !SystemWindow methodsFor: 'panes' stamp: 'ar 12/18/2001 20:10'! addMorph: aMorph fullFrame: aLayoutFrame super addMorph: aMorph fullFrame: aLayoutFrame. paneMorphs _ paneMorphs copyReplaceFrom: 1 to: 0 with: (Array with: aMorph). Preferences alternativeWindowLook ifFalse:[ aMorph borderWidth: 1. aMorph color: self paneColor. ] ifTrue:[ aMorph adoptPaneColor: self paneColor. aMorph borderWidth: 2; borderColor: #inset; color: Color transparent. ].! ! !SystemWindow methodsFor: 'panes' stamp: 'ar 12/18/2001 21:12'! paneColor: aColor self setProperty: #paneColor toValue: aColor. (Preferences alternativeWindowLook and:[aColor notNil]) ifTrue:[self color: aColor veryMuchLighter]. self adoptPaneColor: aColor.! ! !SystemWindow methodsFor: 'drawing' stamp: 'ar 12/18/2001 02:09'! scrollBarColor ^self paneColor! ! ScrollBar removeSelector: #broadcastPaneColor:! ScrollBar removeSelector: #initializeEmbedded! ScrollBar removeSelector: #initializeRetractable! ScrollBar removeSelector: #initializeSlider:! ScrollPane removeSelector: #broadcastPaneColor:! ScrollPane removeSelector: #colorForInsets! Morph removeSelector: #broadcastPaneColor:! Morph removeSelector: #scrollBarColor!