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.43 date: 2023/07/06 14:36:56
user: cg
file: ClockView.st directory: libwidg3
module: stx stc-classLibrary: libwidg3

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.

copyright

COPYRIGHT (c) 1991 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.

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
(comment from inherited method)
button was pressed - check my components for a hit.

o  keyPress: key x: x y: y
(comment from inherited method)
a key has been pressed. If there are components,
pass it to the corresponding one.
Otherwise, forward it to the superview, if there is any.

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

o  sizeChanged: how from: oldExtentOrNil
my view has changed the size (not the contents)

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


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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:54:06 GMT