Hi, people have asked about a data grid on this list a few times.<br><br>This is the simplest possible approach. I've tried and abandoned other approaches when I realised they were too much work for my available free time.<br>
<br>Comments appreciated.<br><br>#lang scheme/gui<br>;; subclass pasteboard <br>(define grid-pasteboard%<br> (class pasteboard%<br> (init-field w h) ; cell width and height <br> ;; override insert to allow insert at a columm and row<br>
(define/override (insert snip c r) (super insert snip (* c w) (* r h)))<br> (super-new)))<br><br>(define data-grid-pasteboard%<br> (class grid-pasteboard%<br> (init-field data-grid)<br> (super-new (w 66) (h 26))<br>
; populate grid-pasteboard with data-grid to go here<br> ; ...<br> <br> ))<br><br>;; test<br>(define f (new frame% [label "Simple Edit"]<br> [width 200]<br> [height 200]))<br>
(define c (new editor-canvas% [parent f]))<br>(define t (new grid-pasteboard% (w 66) (h 26)))<br>(send t insert (make-object string-snip% "at23") 2 3)<br>(send t insert (make-object string-snip% "at23") 2 2)<br>
(send t insert (make-object string-snip% "at23") 3 2)<br>(send t insert (make-object string-snip% "at23") 1 1)<br>(send t insert (make-object string-snip% "at23") 0 0)<br>(send c set-editor t)<br>
(send f show #t)<br clear="all"><br>-- <br><br>--<br>Stephen De Gabrielle<br><a href="mailto:stephen.degabrielle@acm.org">stephen.degabrielle@acm.org</a><br>Telephone +44 (0)20 85670911<br>Mobile +44 (0)79 85189045<br>
<a href="http://www.degabrielle.name/stephen">http://www.degabrielle.name/stephen</a><br><br>