Re: Drawing a rectangular matrix of circles - an NSMatrix?
Re: Drawing a rectangular matrix of circles - an NSMatrix?
- Subject: Re: Drawing a rectangular matrix of circles - an NSMatrix?
- From: John Pannell <email@hidden>
- Date: Thu, 1 Dec 2005 14:22:03 -0700
Hi Scott-
Just to add some food for your thought... I would not have multiple
views present (memory overhead for so many heavyweight view objects)
and instead go with a control view and cells approach (like
NSMatrix). The cells are a lighter weight object for drawing and the
control view keeps track of them and tells them to draw. You can use
the cells to draw the dots with numbers, and use the control view to
draw the line network.
In your position I would use an NSMatrix subclass and override the
drawRect to do [super drawRect] (to draw the cells) and then any
drawing commands to draw the line network.
I have a minesweeper game that uses an NSMatrix subclass
successfully, and I'm glad you posed this question: I had been
thinking of scrapping the NSMatrix for a custom view (it redraws
pretty slowly with large fields) and I realized I could improve the
performance by writing a custom cell instead of using fancy aqua
NSButtonCells :-)
HTH!
John
John Pannell
Positive Spin Media
http://www.positivespinmedia.com
On Dec 1, 2005, at 12:49 PM, Scott Ellsworth wrote:
I am working on a puzzle game, sort of like minesweeper, and I am
trying to figure out how best to draw the display. Should I draw
it all in one NSView's drawRect, should I figure out an NSMatrix,
or should I use a whole passel of much simpler NSView subclasses
for each dot?
The puzzle consists of an n x n matrix of dots, each listing the
number of network links it has to its neighbors. Lines may not
cross, and may go only to the eight neighbors around it.
The problem and solution will be in different windows, but the draw
code will be quite similar.
See <http://homepage.mac.com/fuz/dots.png> for the look I am after.
Eventually, I want the user to be able to click on a dot and drag a
line to the next dot, so I can draw a line. This is not hard a
priori - I have done stuff like this with one big DotView before,
but I am wondering if this is really the best way to handle this
situation. As mentioned above, the draw code would be simpler with
a whole passel of simpler NSViews as subviews of the main view, and
there is always NSMatrix.
_______________________________________________
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