|
Class: MeterClackCounter
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
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.
copyrightCOPYRIGHT (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.
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 from: oldExtentOrNil
-
my view has changed the size (not the contents)
Usage example(s):
super sizeChanged:how from:oldExtentOrNil.
|
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 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
|
|