|
Class: ScrollBar
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--ScrollBar
|
+--HorizontalScrollBar
|
+--SteppingSlider
- Package:
- stx:libwidg
- Category:
- Views-Interactors
- Version:
- rev:
1.100
date: 2018/11/09 23:27:09
- user: cg
- file: ScrollBar.st directory: libwidg
- module: stx stc-classLibrary: libwidg
- Author:
- Claus Gittinger
this class implements vertical scrollbars with scroller and
2 step-scroll buttons. when moved or stepped, it performs a
predefined action.
The action is specified by: the block to be evaluated for step-up
aScrollBar scrollUpAction:aBlock
(scrollLeftAction for hor-Scrollbars)
aScrollBar scrollDownAction:aBlock the block to be evaluated for step-down
(scrollRightAction for hor-Scrollbars)
aScrollbar scrollAction:aBlock the block to be evaluated for scroll
passing percentage as argument.
Scrollbars can scroll synchronous (i.e. every movement is notified immediately via the
scrollAction) or asynchronous (i.e. only one notification takes place at the end of the movement).
The choice is up to the user of the scrollbar (typically, views which are complicated to redraw,
will set it to asynchronous.)
Most often scrollbars are used hidden with ScrollableView or HVScrollableView (i.e. you
don't have to care for all the details).
The scrollBars and scrollers protocols have been made similar enough to
allow transparent use of either a scroller or a scrollBar in applications.
Scroller
Slider
ScrollableView
style changes
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
accessing
-
thumbHeight
-
return height of thumb in percent
-
thumbHeight: newHeight
-
set height of thumb in percent
-
thumbOrigin
-
return position of (top of) thumb in percent
-
thumbOrigin: newOrigin
-
set position of (top of) thumb in percent
-
thumbOrigin: newOrigin thumbHeight: newHeight
-
set origin and height of thumb (both in percent)
accessing-behavior
-
asynchronousOperation
-
-
beAsynchronous
-
set asynchronous-mode - scroll action is performed after movement
of scroller when mouse-button is finally released (no tracking).
This is forwarded to the scroller here.
-
beSynchronous
-
set synchronous-mode - scroll action is performed for every movement
of scroller (tracking).
This is forwarded to the scroller here.
-
isSynchronous
-
return true if the scroll-mode is synchronous.
If true, the scroll action is performed for every movement of the thumb (tracking).
If false, the scroll action is only performed at the end.
-
scrollAction: aBlock
-
set the action, aBlock to be performed when the scroller is moved.
This is forwarded to the scroller here.
-
scrollDownAction
-
return the action which is performed on scroll-down.
(vertical scrollBars)
-
scrollDownAction: aBlock
-
set the action, aBlock to be performed when the down-button is pressed.
(for vertical scrollBars)
-
scrollLeftAction
-
return the action which is performed on scroll-left
(for horizontal scrollBars)
-
scrollLeftAction: aBlock
-
set the action to be performed on scroll-left.
(for horizontal scrollBars)
-
scrollRightAction
-
return the action which is performed on scroll-right.
(for horizontal scrollBars)
-
scrollRightAction: aBlock
-
set the action to be performed on scroll-right.
(for horizontal scrollBars)
-
scrollUpAction
-
return the action which is performed on scroll-up.
(for vertical scrollBars)
-
scrollUpAction: aBlock
-
set the action, aBlock to be performed when the up-button is pressed.
(for vertical scrollBars)
-
synchronousOperation
-
accessing-components
-
downButton
-
return the down-button
(Please: only use this direct access for special applications)
-
thumb
-
return the thumb (i.e. the scroller subview)
(Please: only use this direct access for special applications)
-
upButton
-
return the up-button
(Please: only use this direct access for special applications)
accessing-look
-
allViewBackground: something if: condition
-
blocked for all scrollBars (I want my own background)
usage example(s):
^ super allViewBackground:something
|
-
orientation
-
for ST-80 compatibility, answer this query
-
orientation: aSymbol
-
set the orientation; either #horizontal or #vertical
-
thumbColor: aColor
-
set the thumbs color
-
upButtonLabel: label1 downButtonLabel: label2
-
set the labels shown in the buttons.
Because of the fixed button sizes, this only makes sense with
single-character strings or small bitmaps.
usage example(s):
also possible :
|v|
v := ScrollableView for:EditTextView.
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile).
v scrollBar upButtonLabel:'u' downButtonLabel:'d'.
v open
|
change & update
-
update: something with: aParameter from: changedObject
-
events
-
keyPress: key x: x y: y
-
(comment from inherited method)
a key has been pressed. If there are components,
pass it to the corresponding one.
Otherwise, forward it to the superview, if there is any.
-
sizeChanged: how
-
when my size changes, I have to resize/reposition the subviews.
Also, if I became too small, hide thumb/buttons.
focus handling
-
wantsFocusWithButtonPress
-
no, do not catch the keyboard focus on button click
forced scroll
-
pageDown
-
page down/right
-
pageUp
-
page up/left
-
scrollToBeginning
-
to top
-
scrollToEnd
-
to end
initialization
-
createElements
-
private: create my elements
-
defaultExtent
-
compute my extent from sub-components
-
initStyle
-
setup viewStyle specifics
-
initialize
-
setup; create the 2 buttons and a scroller
-
reinitialize
-
-
setElementPositions
-
position sub-components
native widget support
-
beNativeWidget
-
-
makeElementsInvisible
-
when using native widget, my elements are not visible.
(they are not destroyed, to keep a place for their attributes,
and to allow future dynamic switching and snapshot restore on
a non-native system)
-
nativeWindowType
-
return a symbol describing my native window type
(may be used internally by the device as a native window creation hint,
if the device supports native windows)
-
updateNativeWidget
-
private
-
changeVisibilityOf: aComponent to: aBoolean
-
-
enableDisableButtons
-
only used with styles which disable their buttons if the
thumb is at either end. Check where the thumb is and enable/disable
as appropriate.
private-scrollview interface
-
setThumbFor: aView
-
adjust thumb for aView
(i.e. adjust thumbs origin & size for views size & views contents).
This is forwarded to the scroller here.
-
setThumbHeightFor: aView
-
adjust thumbs height for aViews size & contents.
This is forwarded to the scroller here.
-
setThumbOriginFor: aView
-
adjust thumbs origin for aViews size & contents.
This is forwarded to the scroller here.
queries
-
computePreferredExtent
-
compute my extent from sub-components
-
isMiniScroller
-
-
isScrolling
-
true, if thumb is being moved (by user)
|