eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MeterClackCounter':

Home

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

Class: MeterClackCounter


Inheritance:

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

Package:
stx:libwidg3
Category:
Views-Misc
Version:
rev: 1.15 date: 2017/11/28 18:27:00
user: cg
file: MeterClackCounter.st directory: libwidg3
module: stx stc-classLibrary: libwidg3
Author:
Timo Merkert tm@exept.de

Description:


a simple fun-view, displaying a numeric value as a milesCounter in Cars.
The model is a simple vlaueHolder, holding a number.
This widget can be used as a component what ever you like to count something.

The valueHolder always will be converted as an Array.
The values: I only like numbers like as 0123456789 and .<- point.


Related information:

    DigitalClockView
    Label
    ValueHolder

Class protocol:

images
o  digitWidth
return the width of each individual digit in the digitsBitmap.
usage example(s):
     self digitWidth

o  digitsBitmap
return the image providing the digit-images.
usage example(s):
     self digitsBitmap

o  initializeDigitsBitmap
read the image providing the digit-images and set the class variable DigitsBitmap.
Also set digitWidth, the width of each individual digit.
Somewhat of a kludge, as things are hardcoded here
usage example(s):
     self initializeDigitsBitmap


Instance protocol:

accessing
o  magnify
return the value of the instance variable 'magnify' (automatically generated)

o  magnify: aPoint
set the value of the instance variable 'magnify' (automatically generated)

o  numberOfDigits: n
specify the number of digits to display

o  numberScale: n
define the number of post-decimal-point digits

o  space: something
set the value of the instance variable 'space' (automatically generated)

accessing-color & font
o  backgroundColor: aColor
(comment from inherited method)
set the background color of the contents -
here, (since there is no contents), the viewBackground is changed.

change & update
o  update: something with: aParameter from: changedObject
redraw myself, when the model changes

drawing
o  clearDigitsPos: pos n: anzahl
clear number of n digits at position pos in View

o  drawCounter
draw my view

o  drawDigit: aDigitIndex atPos: pos
aDigitIndex is DigitNumber from 0 to 9 or 10=>'.', 11=>'-' or 12=>space

o  redraw
update my view

o  redrawCounter
update my view

events
o  sizeChanged: how
super sizeChanged:how.

initialization
o  initBitmap

o  initialize

private
o  getFullString: str
returns the string with leading zeros

o  getNilArray: str

o  getNilString: str

queries
o  preferredExtent
(comment from inherited method)
return my preferred extent - this is the minimum size I would like to have.
If the preferredExtent has been set, that one is returned.
Otherwise, if there are any components, a rectangle enclosing them
is returned. Otherwise, the actual extent is returned.

views
o  getMeterClackCounter


Examples:


displaying integers:
  |top num valueHolder|

  top := StandardSystemView extent:150@33.
  num := MeterClackCounter origin:0.0@0.0 corner:1.0@1.0 in:top.
  num numberOfDigits: 6.
  num model:(valueHolder := 12345 asValue).
  top openAndWait.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
displaying floats:
  |top num valueHolder|

  top := StandardSystemView extent:200@33.
  num := MeterClackCounter origin:0.0@0.0 corner:1.0@1.0 in:top.
  num numberOfDigits:9.
  num model:(valueHolder := 12345.123 asValue).
  top openAndWait.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork
displaying fixedPoint numbers:
  |top num valueHolder|

  top := StandardSystemView extent:200@33.
  num := MeterClackCounter origin:0.0@0.0 corner:1.0@30 in:top.
  num numberOfDigits:8.
  num model:(valueHolder := (12345.8 asFixedPoint:2) asValue).
  top openAndWait.

  [
      [top realized] whileTrue:[
          Delay waitForSeconds:1.
          valueHolder value:(valueHolder value + (0.1 asFixedPoint:2))
      ]
  ] fork
displaying aSpeedy milesCounter: but don`t drink and drive as fast
  |top num valueHolder|

  top := StandardSystemView extent:500@300.
  num := MeterClackCounter origin:0.0@0.0 corner:1.0@1.0 in:top.
  num numberOfDigits: 10.
  num space:5.
  num model:(valueHolder := 0123456789 asValue).
  top openAndWait.

  [
      [top realized] whileTrue:[
          Delay waitForMilliseconds:10.
          valueHolder value:(valueHolder value + 1)
      ]
  ] fork


ST/X 7.1.0.0; WebServer 1.663 at exept.de:8081; Sat, 17 Nov 2018 21:42:13 GMT