|
Class: ThumbWheel
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ThumbWheel
- Package:
- stx:libwidg2
- Category:
- Views-Interactors
- Version:
- rev:
1.42
date: 2018/11/09 23:28:26
- user: cg
- file: ThumbWheel.st directory: libwidg2
- module: stx stc-classLibrary: libwidg2
- Author:
- Claus Gittinger
A thumbWheel is like a slider, but looks different ...
ThumbWheels are useful with 3D applications, to control
things like rotation, translation and magnification.
Slider
ScrollBar
StepSlider
accessing
-
keyboardStep
-
return the scrollers keyboard step. If non-nil,
that's the stepping value used with cursorUp/cursorDown keys.
(not used with Scrollers, but provided for subclasses)
-
keyboardStep: aNumber
-
set the scrollers keyboard step. If non-nil,
that's the stepping value used with cursorUp/cursorDown keys.
(not used with Scrollers, but provided for subclasses)
-
start
-
return the wheel's range minimum.
-
start: aNumber
-
set the wheel's range minimum.
-
start: start stop: stop
-
set the wheel's range.
-
step
-
return the wheel's range step.
-
step: aNumber
-
set the wheel's range step.
-
stop
-
return the wheel's range end.
-
stop: aNumber
-
set the wheel's range end.
-
thumbOrigin: pos
-
same as thumbPosition (for protocol compatibility with sliders)
-
thumbPosition
-
return the position
-
thumbPosition: pos
-
set the wheel's position;
the argument should be in the start..stop interval.
accessing-behavior
-
endMoveAction
-
return the endMoveAction, a block which is evaluated when the wheel
stops to move (i.e. the user releases the mouse).
The default is nil (i.e. no action)
-
endMoveAction: aBlock
-
set the endMoveAction, a block which is evaluated when the wheel
stops to move (i.e. the user releases the mouse).
-
endlessRotation: aBoolean
-
if true, rotation wraps and endless rotation is permitted.
If false (the default), rotation ends at rangeStart/rangeEnd.
-
scrollAction
-
return the scrollAction, a block which is evaluated when the wheel
is turned (i.e. for every change).
-
scrollAction: aBlock
-
set the scrollAction, a block which is evaluated when the wheel
is turned (i.e. for every change).
-
startMoveAction
-
return the startMoveAction, a block which is evaluated when the wheel
starts to turn (i.e. the user clicks on it).
The default is nil (i.e. no action)
-
startMoveAction: aBlock
-
set the startMoveAction, a block which is evaluated when the wheel
starts to turn (i.e. the user clicks on it).
accessing-look
-
orientation
-
return the wheels orientation; #horizontal or #vertical
-
orientation: aSymbol
-
set the wheels orientation; the argument may be one of
#horizontal or #vertical
drawing
-
redrawX: x y: y width: w height: h
-
redraw the thumbWheel.
Q: is it worth the effort - or should we simply use some bitmap ?
event handling
-
buttonMotion: state x: x y: y
-
scale acc. to angleRange
events
-
buttonPress: button x: x y: y
-
fetch the current value; to avoid a jump.
-
buttonRelease: button x: x y: y
-
(comment from inherited method)
button was released - check my components for a hit.
-
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
-
(comment from inherited method)
tell subviews that I changed size.
How is either #smaller, #larger or nil, and is used to control the order,
in which subviews are notified (possibly reducing redraw activity)
-
update: something with: aParameter from: changedObject
-
handle update from a model (if any)
forced scroll
-
scrollDown: amountToScroll
-
compatibility with SimpleView.
This allows mouse wheel actions on Scrollers & Wheels
Note: this is used for horizontal scrollers, too (scrollRight)
-
scrollStep: delta
-
step by some delta
-
scrollUp: amountToScroll
-
compatibility with SimpleView.
This allows mouse wheel actions on Scrollers & Wheels
Note: this is used for horizontal scrollers, too (scrollLeft)
initialization
-
initialize
-
initialize - setup instvars from defaults
private
-
tellOthers
-
notify others of a change
queries
-
computePreferredExtent
-
return a useful default extent
-
verticalScrollStep
-
mouse wheel: scroll step
Note: this is used for horizontal scrollers, too
basic setup:
|top wheel|
top := StandardSystemView new.
top extent:200@200.
wheel := ThumbWheel in:top.
wheel orientation:#vertical.
wheel level:1.
wheel origin:0.0@0.0; extent:(wheel preferredExtent).
top open.
|
two of them:
|top wheel1 wheel2|
top := StandardSystemView new.
top extent:200@200.
wheel1 := ThumbWheel in:top.
wheel1 orientation:#vertical.
wheel1 level:1.
wheel1 origin:0.0@0.0; extent:(wheel1 preferredExtent).
wheel2 := ThumbWheel in:top.
wheel2 orientation:#horizontal.
wheel2 level:1.
wheel2 origin:0.0@1.0; extent:(wheel2 preferredExtent).
wheel2 topInset:(wheel2 preferredExtent y negated).
wheel2 bottomInset:(wheel2 preferredExtent y).
top open.
|
performing an action:
|top wheel|
top := StandardSystemView new.
top extent:200@200.
wheel := ThumbWheel in:top.
wheel orientation:#vertical.
wheel level:1.
wheel origin:0.0@0.0; extent:(wheel preferredExtent).
wheel scrollAction:[:value | Transcript showCR:value rounded].
top open.
| operating on a model:
|top wheel model|
model := ValueHolder new.
model
onChangeSend:#value
to:[Transcript show:'value now: '; showCR:model value rounded].
top := StandardSystemView new.
top extent:200@200.
wheel := ThumbWheel in:top.
wheel orientation:#vertical.
wheel level:1.
wheel origin:0.0@0.0; extent:(wheel preferredExtent).
wheel model:model.
top open.
| endless rotation:
|top wheel model|
model := ValueHolder new.
model
onChangeSend:#value
to:[Transcript show:'value now: '; showCR:model value rounded].
top := StandardSystemView new.
top extent:200@200.
wheel := ThumbWheel in:top.
wheel orientation:#vertical.
wheel level:1.
wheel endlessRotation:true.
wheel origin:0.0@0.0; extent:(wheel preferredExtent).
wheel model:model.
top open.
| concrete example:
|top wheel1 wheel2 image magX magY hHolder vHolder imageView|
magX := magY := 1.
hHolder := ValueHolder new.
hHolder
onChangeSend:#value
to:[
magX := hHolder value * 2 / 360.
magX = 0 ifTrue:[magX := 0.01].
Transcript show:'magX now '; showCR:magX.
imageView clear.
imageView magnification:magX@magY].
vHolder := ValueHolder new.
vHolder
onChangeSend:#value
to:[
magY := vHolder value * 2 / 360.
magY = 0 ifTrue:[magY := 0.01].
Transcript show:'magY now '; showCR:magY.
imageView clear.
imageView magnification:magX@magY].
top := StandardSystemView new.
top extent:200@200.
wheel1 := ThumbWheel in:top.
wheel1 orientation:#vertical.
wheel1 level:1.
wheel1 origin:0.0@0.0; extent:(wheel1 preferredExtent).
wheel1 model:vHolder.
wheel2 := ThumbWheel in:top.
wheel2 orientation:#horizontal.
wheel2 level:1.
wheel2 origin:0.0@1.0; extent:(wheel2 preferredExtent).
wheel2 topInset:(wheel2 preferredExtent y negated).
wheel2 bottomInset:(wheel2 preferredExtent y).
wheel2 model:hHolder.
imageView := ImageEditView in:top.
imageView level:1.
imageView origin:0.0@0.0 corner:1.0@1.0.
imageView leftInset:(wheel1 preferredExtent x).
imageView bottomInset:(wheel2 preferredExtent y).
imageView image:(Image fromFile:'bitmaps/garfield.gif').
top open.
|
|