1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors calendar calendar.format fonts grouping kernel
4 math sequences splitting timers ui ui.gadgets ui.gadgets.labels ;
7 : lcd-digit ( digit row -- str )
8 [ dup CHAR: : = [ drop 10 ] [ CHAR: 0 - ] if ] dip {
10 " | | | _| _| |_| |_ |_ | |_| |_| * "
11 " |_| | |_ _| | _| |_| | |_| | * "
13 } nth 4 <groups> nth ;
15 : lcd-row ( row digit -- string )
16 '[ _ lcd-digit ] { } map-as concat ;
18 : lcd ( digit-str -- string )
19 4 <iota> [ lcd-row ] with map join-lines ;
21 TUPLE: time-display < label timer ;
23 : <time-display> ( -- gadget )
24 "99:99:99" lcd time-display new-label
26 dup '[ now timestamp>hms lcd _ string<< ]
27 f 1 seconds <timer> >>timer ;
29 M: time-display graft*
30 [ timer>> start-timer ] [ call-next-method ] bi ;
32 M: time-display ungraft*
33 [ timer>> stop-timer ] [ call-next-method ] bi ;
35 MAIN-WINDOW: time-window { { title "Time" } }
36 <time-display> >>gadgets ;