FROM : Ricky Sharp
DATE : Thu Dec 16 21:08:00 2004
On Wednesday, December 15, 2004, at 10:38PM, Donald Hall <<email_removed>> 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)
DATE : Thu Dec 16 21:08:00 2004
On Wednesday, December 15, 2004, at 10:38PM, Donald Hall <<email_removed>> 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)
| Related mails | Author | Date |
|---|---|---|
| Donald Hall | Dec 16, 05:37 | |
| Dave Rosborough | Dec 16, 05:50 | |
| Ricky Sharp | Dec 16, 21:08 | |
| Jiri Volejnik | Dec 17, 11:16 | |
| Robert Clair | Dec 17, 14:24 |






Cocoa mail archive

