[ltk-user] resizing canvas, exiting main loop, fullscreen

Tamas K Papp tkpapp at gmail.com
Fri Apr 27 11:53:38 UTC 2012


Hi,

I am trying to write a small program that would do the following:

1. create a full screen window with no decorations

2. when the left mouse button is pressed, change the color of the window
according to the relative position (ie the color is calculated from the
position),

3. when the right mouse button is pressed, exit.

BTW, the application is for testing LCD screens.

I came up with the following:

(in-package :cl-user)
(require :ltk)
(use-package :ltk)

(defun hex-color (r g b)
  "Return a hexadecimal color string.  R G B should be in [0,1]."
  (flet ((normalize (x)
           (assert (<= 0 x 1))
           (round (* x 255))))
    (format nil "#~2,0x~2,0x~2,0x"
            (normalize r)
            (normalize g)
            (normalize b))))

(defun lcd-test ()
  (with-ltk ()
    (let* ((canvas (make-instance 'canvas))
           (down nil))
      (flet ((set-color (x-rel y-rel)
               (configure canvas "background"
                          (hex-color x-rel y-rel 0.5))))
        (pack canvas)
        (bind canvas "<ButtonPress-1>"
              (lambda (evt)
                (set-color (/ (event-x evt) (window-width canvas))
                           (/ (event-y evt) (window-height canvas)))
                (setf down t)))
        (bind canvas "<ButtonPress-2>"
              (lambda (evt)
                (declare (ignore evt))
                (setf *exit-mainloop* t)))))))

However, 

a. the application does not exit (maybe I am doing it wrong, I found
*exit-mainloop* in some examples),

b. I could not figure out how to make a full screen window,

c. when the window is resized, the canvas isn't (but of course with a
fullscreen window this would not be an issue).

Any help would be appreciated.

Tamas




More information about the ltk-user mailing list