|
Class: DigitalClockView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--DigitalClockView
- Package:
- stx:libwidg3
- Category:
- Views-Misc
- Version:
- rev:
1.26
date: 2023/07/06 14:34:52
- user: cg
- file: DigitalClockView.st directory: libwidg3
- module: stx stc-classLibrary: libwidg3
another clock replacement ...
This is a regular view - it can also be placed into another one.
copyrightCOPYRIGHT (c) 1997 by Claus Gittinger
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.
startup
-
isVisualStartable
-
yes, I can be started via double click in the browser
-
open
-
open a topView containing a digitalClock
Usage example(s):
accessing
-
model: aValueHolder
-
-
showMillis: aBoolean
-
-
showSeconds: aBoolean
-
-
timeHolder: aValueHolder
-
if set, this provides the time;
otherwise I will be a free running clock
drawing
-
redraw
-
update my view
-
showTime: whichTime
-
executed every second (by timedBlock)
-
updateTime
-
executed every second (by timedBlock)
events
-
destroy
-
the view was destroyed - remove time-scheduled updateBlock
-
mapped
-
view was mapped - launch a time-scheduled updateBlock
-
sizeChanged: how from: oldExtentOrNil
-
my view has changed the size (not the contents)
-
update: aspect with: parameter from: changedObject
-
(comment from inherited method)
an update request
initialization
-
fetchDeviceResources
-
fetch device colors, to avoid reallocation at redraw time
-
initialize
-
DigitalClockView new open
-
startClock
-
launch a time-scheduled updateBlock
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.
clock in a topView:
|top clk prefSize|
top := StandardSystemView new.
top label:'ST/X clock'.
clk := DigitalClockView in:top.
prefSize := clk preferredExtent.
top extent:prefSize.
top minExtent:prefSize.
top maxExtent:prefSize.
top open
|
clock as a component:
|top frame clk fileList sz|
top := StandardSystemView new.
top extent:200@200.
clk := DigitalClockView new.
clk showSeconds:false.
sz := clk preferredExtent.
frame := View origin:1.0@0.0 corner:1.0@(sz y) in:top.
frame leftInset:(sz x negated - 4); rightInset:4; topInset:2; bottomInset:-2.
frame level:-1.
clk := DigitalClockView in:frame.
fileList := ScrollableView for:FileSelectionList in:top.
fileList origin:0@50 corner:1.0@1.0.
top open
|
time via an external valueholder:
|top frame clk fileList sz timeHolder startTime|
startTime := Time nowWithMilliseconds.
timeHolder := startTime asValue.
top := StandardSystemView new.
top windowTitle:'Stopwatch'.
top extent:200@200.
clk := DigitalClockView new.
clk showMillis:true.
clk timeHolder:timeHolder.
sz := clk preferredExtent.
frame := View origin:1.0@0.0 corner:1.0@(sz y) in:top.
frame leftInset:(sz x negated - 4); rightInset:4; topInset:2; bottomInset:-2.
frame level:-1.
frame addComponent:clk.
fileList := ScrollableView for:FileSelectionList in:top.
fileList origin:0@50 corner:1.0@1.0.
top openAndWaitUntilVisible.
[top isOpen] whileTrue:[
timeHolder value:(Time nowWithMilliseconds - startTime).
Delay waitForSeconds:0.05.
].
|
|