Initial commit of newLISP.
[newlisp.git] / guiserver / button-demo.lsp
blob7244dad964f4ad1b908f8dab9dd4950d8867b1d7
1 #!/usr/bin/newlisp
2 ;;
3 ; button-demo.lsp - demonstrate the button control
5 ;;;; initialization
6 (set-locale "C")
7 (load (append (env "NEWLISPDIR") "/guiserver.lsp"))
9 (gs:init)
10 (gs:set-trace true)
12 ;;;; describe the GUI
13 (gs:frame 'ButtonDemo 100 100 400 300 "Click on button or color panel")
14 (gs:set-resizable 'ButtonDemo nil)
15 (gs:panel 'ColorPanel 360 200)
16 (gs:set-background 'ColorPanel '(0 1 0) 0.2)
17 (gs:button 'aButton 'button-action "color")
18 (gs:set-flow-layout 'ButtonDemo "center" 2 15)
19 (gs:add-to 'ButtonDemo 'ColorPanel 'aButton)
20 (gs:set-visible 'ButtonDemo true)
22 (gs:mouse-event 'ColorPanel 'mouse-action)
24 ;;;; define actions
25 (define (button-action id)
26 (gs:set-color 'ColorPanel (random) (random) (random)))
28 (define (mouse-action id type x y button cnt mods)
29 (gs:set-text 'ButtonDemo (format "%8s %3d:%3d %d %d %2d" type x y button cnt mods))
32 ;;;; listen for incoming action requests and dispatch
33 (gs:listen)
35 ;; eof