|
Class: MeterClackCounter
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--MeterClackCounter
- Package:
- stx:libwidg3
- Category:
- Views-Misc
- Version:
- rev:
1.17
date: 2019/03/13 20:50:07
- user: cg
- file: MeterClackCounter.st directory: libwidg3
- module: stx stc-classLibrary: libwidg3
- Author:
- Timo Merkert tm@exept.de
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.
DigitalClockView
Label
ValueHolder
images
-
digitWidth
-
return the width of each individual digit in the digitsBitmap.
usage example(s):
-
digitsBitmap
-
return the image providing the digit-images.
usage example(s):
-
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
|
accessing
-
magnify
-
return the value of the instance variable 'magnify' (automatically generated)
-
magnify: aPoint
-
set the value of the instance variable 'magnify' (automatically generated)
-
numberOfDigits: n
-
specify the number of digits to display
-
numberScale: n
-
define the number of post-decimal-point digits
-
space: something
-
set the value of the instance variable 'space' (automatically generated)
accessing-color & font
-
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
-
update: something with: aParameter from: changedObject
-
redraw myself, when the model changes
drawing
-
clearDigitsPos: pos n: anzahl
-
clear number of n digits at position pos in View
-
drawCounter
-
draw my view
-
drawDigit: aDigitIndex atPos: pos
-
aDigitIndex is DigitNumber from 0 to 9 or 10=>'.', 11=>'-' or 12=>space
-
redraw
-
update my view
-
redrawCounter
-
update my view
events
-
sizeChanged: how
-
super sizeChanged:how.
initialization
-
initBitmap
-
-
initialize
-
(comment from inherited method)
must be called if redefined
private
-
getFullString: str
-
returns the string with leading zeros
-
getNilArray: str
-
-
getNilString: str
-
queries
-
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
-
getMeterClackCounter
-
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
|
|