[cells-gtk-devel] cells-gtk drawing-area widget
Peter Hildebrandt
peter.hildebrandt at gmail.com
Mon Jun 4 20:39:46 UTC 2007
On Mon, 04 Jun 2007 05:02:57 -0700, Peter Denno <peter.denno at nist.gov>
wrote:
> 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.
I am in a similar situation, so if you guys would like to collaborate on
the issue, that'd be great.
I'm writing a little GUI app as a frontend for my research project. I
really like the way cells-gtk works, but I miss the drawing-area widget.
My approach so far is based on Cairo (exporting the graphs to svg or
postscript would be awesome, given I'd like to use them in a paper).
I started with Warren Wilkinson's patch (posted here on May 22):
http://www3.telus.net/public/thomasw2/dl/cells-gtk-cairo-patch.diff
I have fixed the button handlers to work properly. Now I am in the
process of rewriting the drawing methods to use cairo internally. My idea
is to store all objects in a (hash-)table, which is a cells slot in the
drawing-area. draw-* functions will just drop new entries in the list,
and return a unique handle for every object. update functions can take
this handle and update existing objects (move them, change color, etc.). A
delete method can delete them.
The draw-fn function will iterate over the list to draw the current
layout. Later some export-to-svg or -ps can be implemented.
In a final version it might make sense to use a hash-table. For now I am
playing with a simple list, the entries of which are cons of an id and a
struct like (defstruct circle center-x center-y radius color).
There are cairo bindings for lisp out there, and it might be useful to
integrate them. I am looking into them right now.
http://www.cliki.net/cl-cairo
http://cairographics.org/cl-cairo/
>>
>> 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! ;-)
Same from my side.
Thanks,
Peter
> 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
>
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the cells-gtk-devel
mailing list