[plt-scheme] Make a grid / table control in GUI
Hi, people have asked about a data grid on this list a few times.
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.
Comments appreciated.
#lang scheme/gui
;; subclass pasteboard
(define grid-pasteboard%
(class pasteboard%
(init-field w h) ; cell width and height
;; override insert to allow insert at a columm and row
(define/override (insert snip c r) (super insert snip (* c w) (* r h)))
(super-new)))
(define data-grid-pasteboard%
(class grid-pasteboard%
(init-field data-grid)
(super-new (w 66) (h 26))
; populate grid-pasteboard with data-grid to go here
; ...
))
;; test
(define f (new frame% [label "Simple Edit"]
[width 200]
[height 200]))
(define c (new editor-canvas% [parent f]))
(define t (new grid-pasteboard% (w 66) (h 26)))
(send t insert (make-object string-snip% "at23") 2 3)
(send t insert (make-object string-snip% "at23") 2 2)
(send t insert (make-object string-snip% "at23") 3 2)
(send t insert (make-object string-snip% "at23") 1 1)
(send t insert (make-object string-snip% "at23") 0 0)
(send c set-editor t)
(send f show #t)
--
--
Stephen De Gabrielle
stephen.degabrielle at acm.org
Telephone +44 (0)20 85670911
Mobile +44 (0)79 85189045
http://www.degabrielle.name/stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090908/630d0b65/attachment.html>