Re: best way to handle periodic table of the elements
Re: best way to handle periodic table of the elements
- Subject: Re: best way to handle periodic table of the elements
- From: Ricky Sharp <email@hidden>
- Date: Thu, 16 Dec 2004 14:08:00 -0600
On Wednesday, December 15, 2004, at 10:38PM, Donald Hall <email@hidden> wrote:
>I am starting to work on an application that will use the periodic
>table of the elements in its on screen interface. The user will roll
>the mouse over the elements in the table and various things will be
>displayed elsewhere in the window depending on the position of the
>cursor. I am wondering what the best App Kit object would be to
>represent the table. I am thinking a custom NSTableView - custom
>because the periodic table is not rectangular - some of the cells in
>the NSTableView grid of cells would have borders and some would not
>(e.g. all those empty cells between Hydrogen and Helium). Or is their
>a better approach?
I would create a custom NSView that would represent an individual element. You'd then just place those views in a window in the appropriate locations. Note that you no longer have to deal with having empty cells; you just don't place these views at those locations. You could do quite a bit with this approach to include having attributes that could represent different things. For example, groups could have different background colors.
Also have your view manage a tracking rectangle. Ultimately, your mouseEntered: could then call some controller method passing in say the atomic number. Your controller then can update the other controls as needed.
Note that if you must stick with using cells (with say an NSMatrix or NSTableView, you will need to do more work to handle the roll-over (mouseover) logic as cells don't have tracking rectangles. You would thus have to subclass NSMatrix, etc. to ensure you pass on any relevant events.
An almost opposite approach is just to use a single custom NSView that would just display a static image of the entire table. Have it manage a single trancking rectangle. Then, do some math based upon cursor position to see what element you're over.
I'm sure there are many other possible solutions as well.
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden