[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Help needed for defining a 2-D table
- To: firstname.lastname@example.org
- Subject: Help needed for defining a 2-D table
- From: Andrew L. M. Shalit <alms>
- Date: Mon, 10 Dec 90 11:35:05 -0500
- Cc: info-macl
- In-reply-to: email@example.com's message of Sun, 9 Dec 90 14:05:19 EST <9012091905.AA15720@skorpio.USask.ca>
Date: Sun, 9 Dec 90 14:05:19 EST
I require a two dimensional table for my application.
In order to do this, you will need to define a way to map from
your data (perhaps a 2-d array?) to the cells of the table.
You do this by defining an obfun for CELL-CONTENTS which looks
up the appropriate element of your data.
It's up to you to associate the data with the table-dialog-item.
*SEQUENCE-DIALOG-ITEM* accomplishes this by having an instance
variable TABLE-SEQUENCE, an init-list keyword :TABLE-SEQUENCE,
and a definition for CELL-CONTENTS which calls ELT on the
Assuming you want to use a 2-d array, you could use something
like the following (which has *not* been tested!):
(defobject *2-d-table* *table-dialog-item*)
(defobfun (exist *2-d-table*) (init-list)
(have 'my-array (or (getf init-list :table-array nil)
(make-array (getf init-list :table-dimensions '(5 5)))))
(defobfun (cell-contents *2-d-table*) (h &optional v)
(let* ((point (make-point h v))
(h (point-h point))
(v (point-v point)))
(aref (objvar my-array) h v)))
I hope this helps.