Hi all,
I hope there are (Mc)Clim users around here...
This is my first attempt to use clim, and I have to say that I'm a bit
lost.
My post here is threefold :
1) Is there any more-than-a-page tutorial for (Mc)Clim available online
? I must say I had a very hard time understanding the basics with what I
found...
2)
I tweak a bit the Clim Walkthrough and wanted to add a command that
would draw a rectangle to my drawing pane. I tried the following, but it
never did anything when I type "rect". What did I do wrong ?
(defpackage :kwak-ui
(:use :clim :clim-lisp :cl-user))
(in-package :kwak-ui)
(define-application-frame kwak-frame ()
()
(:panes
(drawing-pane :application :display-function 'display-drawing-pane)
(my-interactor :interactor))
(:layouts
(default
(vertically (:height 600 :width 800)
drawing-pane
my-interactor))))
(defmethod display-drawing-pane ((frame kwak-frame) stream)
(declare (ignore stream))
(let ((pane (get-frame-pane *application-frame* 'drawing-pane)))
(window-clear pane)
(draw-ellipse* pane 150 100 10 0 0 30)))
(define-kwak-frame-command (com-rect-frame :name t :menu "rect")
()
(draw-rectangle* (find-pane-named *application-frame* 'drawing-pane)
10 10 200 150 :filled t :line-thickness 2))
(clim:run-frame-top-level (clim:make-application-frame
'kwak-ui::kwak-frame))
3)
Now I want a lisp inside my interactor window. How do I do that ?
(I wanted to use Paul Grahams code in a "define-*-command" but it didn't
work :
(define-kwak-frame-command (com-lisp-frame :name t :menu "lisp")
()
(break-loop #'eval #'(lambda (x) (eq x :q)) ">> "))
(defun prompt (&rest args)
(apply #'format *query-io* args)
(read *query-io*))
(defun break-loop (fn quit &rest args)
(format *query-io* "Entering break-loop.~%")
(loop
(let ((in (apply #'prompt args)))
(if (funcall quit in)
(return)
(format *query-io* "~A~%" (funcall fn in))))))
Thanks for any help you may give.
Martin
Martin Raspaud wrote:
> 1) Is there any more-than-a-page tutorial for (Mc)Clim available online
> ? I must say I had a very hard time understanding the basics with what I
> found...
Franz has a User Guide:
http://www.franz.com/support/documentation/6.2/doc/clim-ug.pdf
But some things might be different in McCLIM.
--
,,
\../ / <<< The LISP Effect
|_\\ _==__
__ | |bb| | _________________________________________________
Martin Raspaud <······@free.fr> writes:
^^
Some of the McCLIM hackers are in Bordeaux. You might be interested
in attending LSM 2004:
http://www.cliki.net/Libre%20Software%20Meeting%202004
> I hope there are (Mc)Clim users around here...
You got at least one. Also, the CLIM mailing list is pretty quiet,
but there are real experts lurking there.
> 1) Is there any more-than-a-page tutorial for (Mc)Clim available
> online ? I must say I had a very hard time understanding the basics
The bad news is that there is no such thing. The good news is that,
if you are determined to learn CLIM, there is a lot of material you
can check, especially source code. Links to most of this material are
collected at the McCLIM site:
http://mcclim.cliki.net
A resource I found quite useful and insightful is the manual of
Franz's implementation of CLIM, titled "CLIM 2 User Guide". It's
available for download at their site.
> I tweak a bit the Clim Walkthrough and wanted to add a command that
> would draw a rectangle to my drawing pane. I tried the following, but
> it never did anything when I type "rect". What did I do wrong ?
Short answer: add the :DISPLAY-TIME option with an appropriate value,
such as NIL, to your application pane.
Long answer: CLIM applications run a command loop similar to the
traditional Lisp repl. A CLIM application reads commands, executes
them, and displays the results. The way results are displayed is
controlled by the :DISPLAY-TIME option of panes. From the CLIM 2
specification:
:display-time [Option]
This is used to indicate to CLIM when the pane's display function
should be run. If it is :command-loop , CLIM will clear the pane and
run the display function after each time a frame command is executed.
If it is t , the pane will be displayed once and not again until
(setf pane-needs-redisplay) is called on the pane. If it is nil , CLIM
will never run the display function until it is explicitly requested,
either via pane-needs-redisplay or redisplay-frame-pane . The default
for this option varies depending on the type of the pane.
The problem with your code is that the default for application panes
is :COMMAND-LOOP. So, your rectangle actually gets drawn, but it is
immediately erased by CLIM's command loop and your display function
DISPLAY-DRAWING-PANE called after the `rect' command is executed.
> (defmethod display-drawing-pane ((frame kwak-frame) stream)
> (declare (ignore stream))
> (let ((pane (get-frame-pane *application-frame* 'drawing-pane)))
> (window-clear pane)
> (draw-ellipse* pane 150 100 10 0 0 30)))
Why don't you draw on STREAM?
> Now I want a lisp inside my interactor window. How do I do that ?
You run the CLIM Listener included with McCLIM (see directory
Apps/Listener in the source distribution). As you can see, it takes
some more code.
Paolo
--
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
Recommended Common Lisp libraries/tools (Google for info on each):
- ASDF/ASDF-INSTALL: system building/installation
- CL-PPCRE: regular expressions
- UFFI: Foreign Function Interface