[cells-gtk-devel] gtk first app

Johan Ur Riise johan at riise-data.no
Fri Jan 16 22:40:57 UTC 2009


> I even managed to get the cairo-canvas working.
> Here is a small sample programm:
> 
> 
> (require 'asdf)
> (require 'cl-cairo2)
> (require 'cl-cairo2-x11)
> (require 'cells-gtk)
> 
> (defpackage :cell-gtk-cairo (:use :cl :cells-gtk :cells))
> (in-package :cell-gtk-cairo)
> 
> (defparameter *gtk-debug* nil)
> 
> (defmodel my-app (gtk-app)
>   ()
>   (:default-initargs :title "cells"
>     :md-name :martin-top
>     :position :center
>     :width (c-in 200) :height (c-in 200)
>     :kids (c-in nil)))
> 
> (init-gtk)
> (start-win 'my-app)

I got this far. I had to push  :cells-gtk-threads to *features*, then
kill the fasls, then load cells-gtk again (to get the start-win function
compiled). A window appears, 

> 
> ; to destroy the window contents
> (progn
>   (not-to-be (find-widget :cairo-draw))
>   (setf (kids (find-widget :martin-top)) nil))
> 
> (setf 
>  (kids (find-widget :martin-top))
>  (list 
>   (mk-vbox 
>    :fm-parent (find-widget :martin-top)
>    :kids 
>    (kids-list?
>     (make-kid 'cairo-drawing-area
>           :expand t :fill t
>           :width (c-in 40)
>           :height (c-in 40)
>           :md-name :cairo-draw)
>     (mk-button 
>      :label "create rectangle"
>      :on-clicked 
>      (callback (w e d)
>        (mk-primitive (find-widget :cairo-draw)
>              :rectangle
>              :p1 (c-in (2d:v 10 10))
>              :p2 (c-in (2d:v 49 94))
>              :filled t
>              :selectable t
>              :draggable t
>              :rgb '(1 0 0))))
>     (mk-button 
>      :label "create text-label"
>      :on-clicked 
>      (callback (w e d)
>        (mk-primitive (find-widget :cairo-draw)
>              :text-label
>              :text "Hallo Welt!"
>              :p1 (c-in (2d:v 20 20))
>              :filled t
>              :selectable t
>              :draggable t
>              :rgb '(1 0 0))))
>     (mk-button 
>      :label "create line"
>      :on-clicked 
>      (callback (w e d)
>        (mk-primitive (find-widget :cairo-draw)
>              :line
>              :p1 (c-in (2d:v 0 0))
>              :p2 (c-in (2d:v 49 94))
>              :filled t
>              :selectable t
>              :draggable t
>              :rgb '(1 0 0))))))))
> 
> 

On compiling this I get a condition "There is no class named
CAIRO-DRAWING-AREA."


> I just run this in slime. I found out, that you can destroy the
> contents of
> the window with not-to-be. That is very convenient if you want to
> change
> the program on the fly.
> 
> I would really like to build a small raytracing program for lens
> systems.
> But unfortunately I'm somewhat stuck. I still don't understand how to
> create new widgets in the cairo panel in cell-style
> e.g. a lens which can be moved around or a ray that is refracted at a
> surface
> and whose angle can be changed by moving the intersection point with
> the
> mouse.
> 
> I guess it looks really cool once I have this working.
> 
> Martin
> 






More information about the cells-gtk-devel mailing list