--- a/ScrollableView.st Fri Sep 02 11:33:22 2022 +0100
+++ b/ScrollableView.st Thu Nov 09 15:55:10 2023 +0000
@@ -91,7 +91,7 @@
of data (see example2) and at creation time, it is not known what type
of view is required (multidocument format applications).
- If you want to scroll a bunch of other views (instead of a views contents),
+ If you want to scroll a bunch of other views (instead of a view's contents),
you need a companion class (ViewScroller). See the documentation there.
By default, scrollbars are full size scrollbars - for horizontal scrolling
@@ -732,9 +732,9 @@
|newView dev|
aView notNil ifTrue:[
- dev := aView graphicsDevice
+ dev := aView graphicsDevice.
] ifFalse:[
- dev := Screen current
+ dev := Screen current.
].
newView := self basicNew device:dev.
"/ preset flags to avoid creation and later destruction of scrollBars ...
@@ -789,8 +789,9 @@
top open
"
- "Modified: 6.3.1997 / 18:42:40 / cg"
- "Modified: 19.3.1997 / 15:32:51 / stefan"
+ "Modified: / 06-03-1997 / 18:42:40 / cg"
+ "Modified: / 19-03-1997 / 15:32:51 / stefan"
+ "Modified (format): / 16-03-2021 / 13:48:11 / Stefan_Vogel"
!
forView:aView in:aSuperView
@@ -810,6 +811,15 @@
"Modified: 6.3.1997 / 23:19:12 / cg"
!
+forView:aView miniScroller:mini
+ "return a new scrolling view scrolling aView.
+ The view will have a miniScrollera, if mini is true."
+
+ ^ self forView:aView miniScrollerH:mini miniScrollerV:mini
+
+ "Created: / 19-10-2020 / 11:08:07 / exept MBP"
+!
+
forView:aView miniScrollerH:mini
"return a new scrolling view scrolling aView.
The view will have a full vertical scrollbar and a horizontal
@@ -968,10 +978,13 @@
updateStyleCache
"extract values from the styleSheet and cache them in class variables"
- <resource: #style (#'scrolledView.level' #'scrolledView.margin'
+ <resource: #style (#'scrolledView.level'
+ #'scrolledView.margin'
#'scrolledView.borderWidth'
- #'scrollBar.spacing' #'scrollBar.level'
- #'scrollableView.level' #'scrollableView.backgroundColor' )>
+ #'scrollBar.spacing'
+ #'scrollBar.level'
+ #'scrollableView.level'
+ #'scrollableView.backgroundColor' )>
|defLevel defMargin defSpacing|
@@ -996,7 +1009,8 @@
self updateStyleCache
"
- "Modified: / 31.10.1997 / 20:57:10 / cg"
+ "Modified: / 31-10-1997 / 20:57:10 / cg"
+ "Modified: / 30-10-2018 / 16:51:51 / Claus Gittinger"
! !
!ScrollableView methodsFor:'accessing-behavior'!
@@ -1013,6 +1027,18 @@
"Created: 19.3.1997 / 17:24:39 / cg"
!
+autoHideHorizontalScrollBar:hideHBoolean autoHideVerticalScrollBar:hideVBoolean
+ "set/clear the flag which controls if the scrollBars should
+ be made invisible dynamically, if there is nothing to scroll
+ (and shown if there is).
+ This flags setting is normally controlled by the styleSheet."
+
+ hideHScrollBar := hideHBoolean.
+ hideVScrollBar := hideVBoolean.
+
+ "Created: / 07-11-2023 / 17:11:00 / cg"
+!
+
autoHideScrollBars:aBoolean
"set/clear the flag which controls if scrollBars should
be made invisible dynamically, if there is nothing to scroll
@@ -1165,6 +1191,26 @@
"Modified: / 21.5.1998 / 00:48:25 / cg"
!
+horizontalMini:horizontalMiniBoolean verticalMini:verticalMiniBoolean
+ "control the scrollBars to be either a miniScroller, or a full scrollBar."
+
+ |newMiniH newMiniV|
+
+ newMiniH := horizontalMiniBoolean.
+ newMiniV := verticalMiniBoolean.
+ (styleSheet at:#'scrollBar.neverMini' default:false) == true ifTrue:[
+ newMiniH := newMiniV := false.
+ ].
+
+ ((horizontalMini ~~ newMiniH) or:[verticalMini ~~ newMiniV]) ifTrue:[
+ horizontalMini := newMiniH.
+ verticalMini := newMiniV.
+ self setupForChangedScrollbars.
+ ].
+
+ "Created: / 07-11-2023 / 13:24:02 / cg"
+!
+
horizontalScrollable:aBoolean
"enable/disable horizontal scrollability.
If disabled, the horizontal scrollBar is made invisible."
@@ -1183,21 +1229,61 @@
"enable/disable horizontal scrollability.
If disabled, the horizontal scrollBar is made invisible."
- |newMini|
-
- newMini := miniScrollerBoolean.
+ self
+ horizontalScrollable:scrollableBoolean miniScroller:miniScrollerBoolean
+ verticalScrollable:hasVerticalScrollBar miniScroller:verticalMini
+
+ "Modified: / 07-11-2023 / 17:27:24 / cg"
+!
+
+horizontalScrollable:scrollableHBoolean miniScroller:miniScrollerHBoolean
+ verticalScrollable:scrollableVBoolean miniScroller:miniScrollerVBoolean
+ "enable/disable scrollability.
+ If disabled, the scrollBar(s) are made invisible."
+
+ |newMiniH newMiniV|
+
+ newMiniH := miniScrollerHBoolean.
+ newMiniV := miniScrollerVBoolean.
(styleSheet at:#'scrollBar.neverMini' default:false) == true ifTrue:[
- newMini := false.
+ newMiniH := newMiniV := false.
].
- (hasHorizontalScrollBar ~~ scrollableBoolean
- or:[scrollableBoolean and:[horizontalMini ~~ newMini]]) ifTrue:[
- horizontalMini := newMini.
- hasHorizontalScrollBar := scrollableBoolean.
+ (hasHorizontalScrollBar ~~ scrollableHBoolean
+ or:[(scrollableHBoolean and:[horizontalMini ~~ newMiniH])
+ or:[(hasVerticalScrollBar ~~ scrollableVBoolean)
+ or:[scrollableVBoolean and:[verticalMini ~~ newMiniV]
+ ]]]) ifTrue:[
+ horizontalMini := newMiniH.
+ verticalMini := newMiniV.
+ hasHorizontalScrollBar := scrollableHBoolean.
+ hasVerticalScrollBar := scrollableVBoolean.
hScrollBarHidden := false.
+ "/ vScrollBarHidden := false.
self setupForChangedScrollbars.
].
- horizontalMini := newMini.
+ horizontalMini := newMiniH.
+ verticalMini := newMiniV.
+
+ "Created: / 07-11-2023 / 17:05:31 / cg"
+!
+
+horizontalScrollable:horizontalScrollableBoolean verticalScrollable:verticalScrollableBoolean
+ "enable/disable scrollability.
+ If disabled, the scrollBar(s) are made invisible."
+
+ ((hasVerticalScrollBar ~~ verticalScrollableBoolean)
+ or:[hasHorizontalScrollBar ~~ horizontalScrollableBoolean
+ ]) ifTrue:[
+ hasHorizontalScrollBar := horizontalScrollableBoolean.
+ hasVerticalScrollBar := verticalScrollableBoolean.
+ hScrollBarHidden := false.
+ "/ vScrollBarHidden := false.
+ self setupForChangedScrollbars.
+ ]
+
+ "Created: / 07-11-2023 / 13:28:12 / cg"
+ "Modified (format): / 07-11-2023 / 17:13:53 / cg"
!
setupForChangedScrollbars
@@ -1240,6 +1326,18 @@
"Created: / 7.3.1997 / 21:56:39 / cg"
"Modified: / 24.8.2001 / 14:55:20 / cg"
+!
+
+verticalScrollable:scrollableBoolean miniScroller:miniScrollerBoolean
+ "enable/disable vertical scrollability.
+ If disabled, the vertical scrollBar is made invisible."
+
+ self
+ horizontalScrollable:hasHorizontalScrollBar miniScroller:horizontalMini
+ verticalScrollable:scrollableBoolean miniScroller:miniScrollerBoolean
+
+ "Created: / 07-11-2023 / 13:31:54 / cg"
+ "Modified: / 07-11-2023 / 17:27:58 / cg"
! !
!ScrollableView methodsFor:'change & update'!
@@ -1418,11 +1516,23 @@
!ScrollableView methodsFor:'drag & drop'!
dropTarget
+ "returns the dropTarget (a DropTarget instance) or nil.
+ Can be either set staticallz (at init time), or created dynamically,
+ (bz redefining this method to return a DropTarget instance)
+ The dropTarget object provides infor about enter/leave/over/drop selectors,
+ to be sent to the view for a drag&drop operation.
+ If nil is returned, a default dropTarget instance is created bz the DnD manager."
+
scrolledView isNil ifTrue:[^ nil].
^ scrolledView dropTarget
!
dropTarget:aDropTarget
+ "set the dropTarget (a DropTarget instance) or nil.
+ The dropTarget object provides info about enter/leave/over/drop selectors,
+ to be sent to the view for a drag&drop operation.
+ If nil is returned, a default dropTarget instance is created by the DnD manager."
+
scrolledView isNil ifTrue:[^ self].
scrolledView dropTarget:aDropTarget
! !
@@ -1457,12 +1567,22 @@
]
!
+repairDamage
+ scrolledView repairDamage.
+ hScrollBar notNil ifTrue:[ hScrollBar repairDamage ].
+ vScrollBar notNil ifTrue:[ vScrollBar repairDamage ].
+ super repairDamage.
+!
+
requestAutoAccept
"request to accept: this is invoked when a dialog closes via accept or cancel.
This forces my value to be accepted into my model.
Any widget may suppress the ok/cancel, by returning false."
+ scrolledView isNil ifTrue:[^ true].
^ scrolledView requestAutoAccept
+
+ "Modified: / 19-06-2018 / 23:11:33 / Claus Gittinger"
!
sizeChanged:how
@@ -1779,6 +1899,9 @@
lockUpdates := false.
+ "/ if the view's contents is rerendered differently
+ "/ depending on the size (i.e. with HTMLView),
+ "/ turn off autohiding, as this may lead to ugly flicker
scrolledView notNil ifTrue:[
(scrolledView heightOfContentsDependsOnWidth
or:[scrolledView widthOfContentsDependsOnHeight]) ifTrue:[
@@ -1788,11 +1911,11 @@
vScrollBar notNil ifTrue:[
vScrollBar scrollAction:
- [:position |
+ [:positionInPercent |
"/ in case the event came after the view was already deconstructed
scrolledView notNil ifTrue:[
lockUpdates := true.
- scrolledView scrollVerticalToPercent:position.
+ scrolledView scrollVerticalToPercent:positionInPercent.
lockUpdates := false
].
].
@@ -1807,7 +1930,7 @@
scrolledView scrollToTop
] ifFalse:[
scrolledView scrollUp
- ]
+ ].
].
].
@@ -1822,18 +1945,18 @@
scrolledView scrollToBottom
] ifFalse:[
scrolledView scrollDown
- ]
+ ].
].
].
].
hScrollBar notNil ifTrue:[
hScrollBar scrollAction:
- [:position |
+ [:positionInPercent |
"/ in case the event came after the view was already deconstructed
scrolledView notNil ifTrue:[
lockUpdates := true.
- scrolledView scrollHorizontalToPercent:position.
+ scrolledView scrollHorizontalToPercent:positionInPercent.
lockUpdates := false
].
].
@@ -1849,7 +1972,7 @@
scrolledView scrollToLeft
] ifFalse:[
scrolledView scrollLeft
- ]
+ ].
].
].
@@ -1864,7 +1987,7 @@
scrolledView scrollToRight
] ifFalse:[
scrolledView scrollRight
- ]
+ ].
].
].
].
@@ -1877,8 +2000,8 @@
"
self delegate:(KeyboardForwarder toView:scrolledView).
- "Modified: 6.3.1997 / 17:03:43 / cg"
- "Created: 6.3.1997 / 18:06:23 / cg"
+ "Created: / 06-03-1997 / 18:06:23 / cg"
+ "Modified: / 06-11-2023 / 19:52:17 / cg"
!
setVertical:isVertical mini:miniV horizontal:isHorizontal mini:miniH
@@ -1891,7 +2014,9 @@
hasVerticalScrollBar := isVertical.
hasHorizontalScrollBar := isHorizontal.
- noMiniScrollers := StyleSheet at:#'scrollBar.neverMini' default:false.
+ "/ sigh: because this is possibly called BEFORE the stylesheet is setup,
+ "/ refer to the class variable as fallback here
+ noMiniScrollers := (StyleSheet) at:#'scrollBar.neverMini' default:false.
verticalMini := miniV.
horizontalMini := miniH.
@@ -1900,6 +2025,7 @@
horizontalMini := false.
].
+ "Modified: / 14-03-2021 / 14:56:37 / cg"
!
setupVertical:isVertical mini:miniV horizontal:isHorizontal mini:miniH
@@ -2250,6 +2376,32 @@
!ScrollableView methodsFor:'queries'!
+computePreferredExtent
+ "return my preferredExtent from the scrolledViews prefExtent
+ plus the size of the scrollBar"
+
+ |slavesPref prefX prefY margin|
+
+ scrolledView notNil ifTrue:[
+ slavesPref := scrolledView preferredExtent.
+ prefX := slavesPref x.
+ prefY := slavesPref y.
+ margin := (DefaultScrolledViewMargin * 2) + DefaultScrollBarSpacing.
+ vScrollBar notNil ifTrue:[
+ prefX := prefX + vScrollBar width + margin.
+ ].
+ hScrollBar notNil ifTrue:[
+ prefY := prefY + hScrollBar height + margin.
+ ].
+
+ ^ prefX @ prefY.
+ ].
+
+ ^ super computePreferredExtent.
+
+ "Created: / 09-11-2018 / 20:00:15 / Claus Gittinger"
+!
+
isHorizontalScrollable
"return true if I am horizontally scrollable"
@@ -2355,7 +2507,10 @@
!
respondsTo:aSelector
- scrolledView notNil ifTrue:[
+ "return true, if the receiver responds to a message.
+ Possibly delegated to my scrolled view"
+
+ scrolledView notNil ifTrue:[
(scrolledView respondsTo:aSelector) ifTrue:[^ true].
].
^ super respondsTo:aSelector.
@@ -2363,14 +2518,18 @@
"
self new respondsTo:#isScrolling
"
+
+ "Modified (comment): / 19-07-2019 / 10:49:01 / Claus Gittinger"
!
specClass
+ "returns my spec class (for UI editor)"
"redefined, since my subclasses also want ScrollableViewSpecs"
^ ScrollableViewSpec
- "Modified: / 31.10.1997 / 19:48:48 / cg"
+ "Modified: / 31-10-1997 / 19:48:48 / cg"
+ "Modified (comment): / 26-07-2020 / 11:53:01 / cg"
! !
!ScrollableView methodsFor:'slave-view messages'!