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.20 date: 2023/07/06 14:34:58
user: cg
file: MeterClackCounter.st directory: libwidg3
module: stx stc-classLibrary: libwidg3

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.

copyright

COPYRIGHT (c) 1998 by eXept Software AG 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.

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 from: oldExtentOrNil
my view has changed the size (not the contents)

Usage example(s):

super sizeChanged:how from:oldExtentOrNil.

initialization
o  initBitmap

o  initialize
(comment from inherited method)
must be called if redefined

private
o  getFullString: str
returns the string with leading zeros

o  getNilArray: str

o  getNilString: str

queries
o  computePreferredExtent
(comment from inherited method)
return my computed preferred extent - this is the minimum size I would like to have.
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 openAndWaitUntilVisible.

  [
      [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 openAndWaitUntilVisible.

  [
      [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 openAndWaitUntilVisible.

  [
      [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 openAndWaitUntilVisible.

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


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sun, 22 Dec 2024 01:02:45 GMT