eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ClockView':

Home

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

Class: ClockView


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--ClockView

Package:
stx:libwidg3
Category:
Views-Fun
Version:
rev: 1.40 date: 2019/05/06 08:21:45
user: cg
file: ClockView.st directory: libwidg3
module: stx stc-classLibrary: libwidg3
Author:
Claus Gittinger (spring 91)

Description:


xclock replacement

:-) not that I thought this clock is any better than xclock
    or that the world needs clocks ...

its showing how easy it is to program in Smalltalk - 
this took less than an hour to program - compare with xclock code ....

Since this is a subclass of view, you can use it as a widget in
more complex views.


Implementation note:
     this class was written long before multiple threads came to ST/X;
     therefore, it uses the Processors timedBlock facilities.
     Today, things would be written differently.
     As an excercise, you may rewrite it using an update process which 
     runs in the background.


Related information:

    Clock
    RoundClock
    Time
    ProcessorScheduler

Instance protocol:

accessing
o  beStopWatch

o  startMeasure

drawing
o  displayCenteredString: aString

o  drawArm: tick width: w len: l
draw an arm of the clock; argument tick specifies minute (0..59);
width is width in pixel, len is relative len - 1.0 is full

o  drawArmsFor: aTime
draw arms for a given time in current paint

o  redraw
redraw everything

o  redrawArms
redraw the arms

o  redrawStopWatchInfo

o  redrawTicks
redraw the ticks

o  redrawTimeFraction

o  showTime
executed every second (by timedBlock)

o  timeShown

o  updateArms
clear previous arms - draw new arms

o  updateArmsFor: aTime
clear previous arms - draw new arms

events
o  buttonPress: button x: x y: y

o  keyPress: key x: x y: y

o  mapped
view was mapped - launch a time-scheduled updateBlock

o  sizeChanged: how
my size has changed - have to clear & redraw

o  startClock
launch a time-scheduled updateBlock

o  toggleStopWatch
self updateArmsFor:(self timeShown).

initialization
o  initialize
initialize the view & precompute the tick-position-table

usage example(s):

initialize table of (normalized) x/y coordinates of ticks

o  middleButtonMenu
(comment from inherited method)
return the menu associated with the middle mouse button.
Here, return a hooked on menu, but usually redefined to provide a widget-specific
menu.

misc
o  showSeconds: aBoolean
toggle (and possibly redraw) the show-seconds flag

o  toggleSeconds
user wants to toggle the show-seconds flag

user actions
o  copyTimeDuration

o  destroy
the view was destroyed - remove time-scheduled updateBlock

o  resetStopWatch


Demonstration:


    Clock start


Examples:


in a topView:
 |top clk|

 top := StandardSystemView new.
 top label:'ST/X clock'.
 top extent:200@200.

 clk := ClockView origin:0.0@0.0 corner:1.0@1.0 in:top.

 top open
a stopWatch (click to start/stop):
 |top clk|

 top := StandardSystemView new.
 top label:'ST/X clock'.
 top extent:200@200.

 clk := ClockView origin:0.0@0.0 corner:1.0@1.0 in:top.
 clk beStopWatch.
 top open
as a component:
 |top frame clk fileList|

 top := StandardSystemView new.
 top extent:200@200.

 frame := View origin:1.0@0.0 corner:1.0@50 in:top.
 frame leftInset:-50; rightInset:4; topInset:2; bottomInset:2.
 frame level:-1.

 clk := ClockView origin:0.0@0.0 corner:1.0@1.0 in:frame.
 clk showSeconds:false.

 fileList := ScrollableView for:FileSelectionList in:top.
 fileList origin:0@50 corner:1.0@1.0. 

 top open


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 25 Apr 2024 17:19:00 GMT