eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ThumbWheel':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: ThumbWheel


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--ThumbWheel

Package:
stx:libwidg2
Category:
Views-Interactors
Version:
rev: 1.47 date: 2023/07/06 14:35:44
user: cg
file: ThumbWheel.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

Description:


A thumbWheel is like a slider, but looks different ...
ThumbWheels are useful with 3D applications, to control
things like rotation, translation and magnification.

copyright

COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Instance protocol:

accessing
o  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)

o  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)

o  start
return the wheel's range minimum.

o  start: aNumber
set the wheel's range minimum.

o  start: start stop: stop
set the wheel's range.

o  step
return the wheel's range step.

o  step: aNumber
set the wheel's range step.

o  stop
return the wheel's range end.

o  stop: aNumber
set the wheel's range end.

o  thumbOrigin: pos
same as thumbPosition (for protocol compatibility with sliders)

o  thumbPosition
return the position

o  thumbPosition: pos
set the wheel's position;
the argument should be in the start..stop interval.

accessing-behavior
o  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)

o  endMoveAction: aBlock
set the endMoveAction, a block which is evaluated when the wheel
stops to move (i.e. the user releases the mouse).

o  endlessRotation: aBoolean
if true, rotation wraps and endless rotation is permitted.
If false (the default), rotation ends at rangeStart/rangeEnd.

o  scrollAction
return the scrollAction, a block which is evaluated when the wheel
is turned (i.e. for every change).

o  scrollAction: aBlock
set the scrollAction, a block which is evaluated when the wheel
is turned (i.e. for every change).

o  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)

o  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
o  orientation
return the wheels orientation; #horizontal or #vertical

o  orientation: aSymbol
set the wheels orientation; the argument may be one of
#horizontal or #vertical

change & update
o  update: something with: aParameter from: changedObject
handle update from a model (if any)

drawing
o  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
o  buttonMotion: state x: x y: y
scale acc. to angleRange

events
o  buttonPress: button x: x y: y
fetch the current value; to avoid a jump.

o  buttonRelease: button x: x y: y
(comment from inherited method)
button was released - check my components for a hit.

o  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.

o  sizeChanged: how from: oldExtentOrNil
my view has changed the size (not the contents)

forced scroll
o  scrollDown: amountToScroll
compatibility with SimpleView.
This allows mouse wheel actions on Scrollers & Wheels
Note: this is used for horizontal scrollers, too (scrollRight)

o  scrollStep: delta
step by some delta

o  scrollUp: amountToScroll
compatibility with SimpleView.
This allows mouse wheel actions on Scrollers & Wheels
Note: this is used for horizontal scrollers, too (scrollLeft)

initialization
o  initialize
initialize - setup instvars from defaults

private
o  tellOthers
notify others of a change

queries
o  computePreferredExtent
return a useful default extent

o  verticalScrollStep
mouse wheel: scroll step
Note: this is used for horizontal scrollers, too


Examples:


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.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Fri, 13 Dec 2024 14:24:11 GMT