[cells-gtk-devel] cells-gtk drawing-area widget
Martin Flack
martin at martinflack.com
Sun Jun 3 16:45:14 UTC 2007
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.
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! ;-)
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))
More information about the cells-gtk-devel
mailing list