eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ThumbWheel':

Home

everywhere
www.exept.de
for:
[back]

Class: ThumbWheel


Inheritance:

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

Package:
stx:libwidg3
Category:
Views-Interactors
Version:
rev: 1.31 date: 2006/03/20 08:37:28
user: cg
file: ThumbWheel.st directory: libwidg3
module: stx stc-classLibrary: libwidg3
Author:
Claus Gittinger

Description:


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


Related information:

    Slider
    ScrollBar
    StepSlider

Instance protocol:

accessing
o  keyboardStep
return the scrollers keyboard step. If non-nil,
thats 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,
thats the stepping value used with cursorUp/cursorDown keys.
(not used with Scrollers, but provided for subclasses)

o  start
return the wheels range minimum.

o  start: aNumber
set the wheels range minimum.

o  start: start stop: stop
set the wheels range minimum.

o  step
return the wheels range step.

o  step: aNumber
set the wheels range step.

o  stop
return the wheels range end.

o  stop: aNumber
set the wheels range end.

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

o  thumbPosition
sreturn the position

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

accessing-behavior
o  endMoveAction
set 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

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 ?

events
o  buttonMotion: state x: x y: y

o  buttonPress: button x: x y: y

o  buttonRelease: button x: x y: y

o  keyPress: key x: x y: y

o  sizeChanged: how

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

forced scroll
o  scrollDown: amountToScroll
compatibility with SimpleView. This allows mouse wheel actions on Scrollers
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
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  preferredExtent
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 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 21:37:20 GMT