eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ClockView':

Home

everywhere
www.exept.de
for:
[back]

Class: ClockView


Inheritance:

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

Package:
stx:libwidg3
Category:
Views-Fun
Version:
rev: 1.31 date: 2009/05/13 14:08:12
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

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

o  middleButtonMenu

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  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 6.1.1; WebServer 1.620 at exept:8081; Thu, 17 May 2012 16:15:36 GMT