[Different Time] Applet

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

[Different Time] Applet

Post by newdep »

Need a clock? ;-)
...here is a different time(r)...

(load "http://www.nodep.nl/downloads/newlisp/timer.lsp")

Enjoy.. Norman.

PS: this is forum article 8888 ... what a timing ;-)
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Very nice!

but just to be extra picky (because we are all learning the new GUI stuff), here are some simplifications:

Code: Select all

(gs:init)

(gs:frame 'F1 0 0 303 75 "A different Time")
(gs:set-look-and-feel "com.sun.java.swing.plaf.motif.MotifLookAndFeel")
(gs:set-resizable 'F1 nil)
(gs:set-grid-layout 'F1 3 1 0 0) ; changed from 3 0 to 3 1
;(gs:set-color 'F1 0 0 0 1) ; cannot set color of a frame

(dolist (x lazy)
 (gs:panel          (x 1))
 (gs:set-tool-tip   (x 1) (date))
 (gs:set-color      (x 1) 0 0 0 1)
 (gs:progress-bar   (x 0) 0 (x 2) 0)
 (gs:set-size       (x 0) 300 25)
 (gs:set-background (x 0) 0.5 0.5 0.5 1)
 (gs:set-foreground (x 0) (x 3) (x 4) (x 5) 0.9)
 (gs:add-to         (x 1) (x 0)))

(gs:add-to 'F1 'P1 'P2 'P3)
(gs:set-visible 'F1 true)

(while true
   (gs:set-value 'B1 (date (date-value) 0 "%H") 0 10)
   (gs:set-value 'B2 (date (date-value) 0 "%M") 0 10)
   (gs:set-value 'B3 (date (date-value) 0 "%S") 0 10)
   (sleep 1000))

(gs:listen) ; this is actually not necessary because never reached
(1) I took out all the (sym ...) casts because they were not necessary, you had already a symbol with (x 1)

(2) I also removed the (int ...) casts. guiserver eats numbers, no matter if they are floats or even strings: 1.0, 1, "1" and "1.0" are all the same for guiserver :-).

(3) (gs:set-color 'F1 0 0 0 1) will emit an error, because we cannot set the color of a frame or dialog (but of anything else).

Lutz

Ryon
Posts: 248
Joined: Thu Sep 26, 2002 12:57 am

Post by Ryon »

Both versions work fine on my XP machine, after I comment out the MotifLookAndFeel.

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

Thanks lutz for the corrections...

..1 remarkt though...
(3) (gs:set-color 'F1 0 0 0 1) will emit an error, because we cannot set the color of a frame or dialog (but of anything else).
Does work under linux and I do need to set it elese i see a "light-blue border shade" and i dont see any error on it either in (gs:set-trace true) .. So there is perhpas
some different behaviour between OSes..

(see here the screenshot... the left is without set-color on frame the right is with)
http://www.nodep.nl/downloads/newlisp/timer.png

Look at the left image on the bottom of the last progress-bar you see an extra
white line... it does not occeur on the one on the right... But when I indeed magnify the window they both dont have it..(still dont see the error).. I think
its a minor JAVA incorrection in the progress-bar border-width....



What I could not figure out either was how to catch the event that occeurs
when i press the [X] to close the window... The script now keeps hanging
because of the while loop, it seems..
-- (define? (Cornflakes))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Does work under linux and I do need to set it else i see a "light-blue border shade
this could be fixed, now gs:set-color/background will work on 'frame' and 'dialog' too and on all platforms.

Lutz

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Hier is a little trick to make you different-time.lsp appllication exit newLISP when closing the window:

Code: Select all

(while (= (length (net-sessions)) 2) 
    ... time display statements ...
   (sleep 1000)) 
As your program never enters the gs:listen loop it can watch net-sessions to see when one of the sockets goes away. At least a second after closing the windows newLISP will exit too.

Lutz

Locked