[cells-gtk-devel] cells-gtk drawing-area widget

Peter Denno peter.denno at nist.gov
Mon Jun 4 12:02:57 UTC 2007


On Sunday 03 June 2007 12:45, Martin Flack wrote:
> Hi all,
>
> I'm writing some stock equities charting software in Common Lisp
> for my own amusement and to learn the language. I'd like to start
> by porting over a simple program I had in Perl to draw daily price
> bars. I used Tk in Perl so I was planning to use LTK but cells-gtk
> caught my eye and looks interesting.
>
> I noticed the drawing.lisp is commented out in the asdf file - is
> anyone actively using this widget in their code? I uncommented it
> and got it to compile on SBCL.

I wrote it, but I'm not using it yet. 
>
> Secondly, I can't seem to get the widget to come up. I lifted some
> example code from Google, but something's wrong. What I'm trying is
> below - what happens is the program runs fine but there is no
> graphic element, just the text label and entry box.
>
> Tk does offer a canvas widget which might be helpful to my
> application, but I'm thinking that since the objects I'd want to
> handle will be conceptually higher than lines, rectangles, etc.
> that I could program my own canvas-type abstraction anyway.
>
> Any comments would be appreciated. Thanks! ;-)

I've got a paper due today, so I can't comment now, but I did get 
things to work. I had some ideas for the design of this thing that 
I'll try to recall. Tomorrow.

>
> Martin
>
>
> (require :cells)
> (require :cells-gtk)
>
> (defpackage hello-world
>   (:use :cl :cells :cells-gtk)
>   (:export :main))
>
> (in-package :hello-world)
>
> (defmodel hello-world (gtk-app)
>   ()
>   (:default-initargs
>
>     :title "Test"
>     :position :center
>     :width 650 :height 550
>     :kids (list
>
> 	   (mk-notebook
>
> 	    :tab-labels (list "Tab 1")
> 	    :kids (list
>
> 		   (mk-vbox
>
> 		    :kids (list
>
> (mk-label :text (c? (md-value (fm^ :mytext))))
> (mk-entry :md-name :mytext :auto-aupdate t :init "Hello, World.")
> (mk-drawing-area :md-name :drawing-area :width 100 :height 100
>
>  :draw-fn
>
>    #'(lambda (self)
>        (with-pixmap (p "demo" :widget self :width 100 :height 100)
>          (with-gc (p :fg "red")
>            (draw-line p 0 0 100 100))
>          (draw-text p "this is text" 10 70)
>          (draw-rectangle p 10 10 30 30)
>          (draw-rectangle p 1 1 97 97)
>          (insert-pixmap p 0 0)
>          p))))))))))
>
> (defun main (&optional dbg)
>   (cells-gtk-init)
>   (start-app 'hello-world :debug dbg))
>
> _______________________________________________
> cells-gtk-devel site list
> cells-gtk-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/cells-gtk-devel

-- 
Best regards,
  - Peter



More information about the cells-gtk-devel mailing list