Re: NSControl with NSCells
Re: NSControl with NSCells
- Subject: Re: NSControl with NSCells
- From: Timothy Ritchey <email@hidden>
- Date: Sun, 3 Mar 2002 09:51:27 -0500
There are many limitations to NSMatrix that Mr. Gehrman may be trying to
overcome, such as the fact that all cells have to be exactly the same
size. I have been writing my own reusable spreadsheet control with
independently resizable rows/columns, etc. (which I will hopefully have
an announcement about next week), and there is much you have to do.
First, yes, you will need to override mouseUp, mouseDown, mouseDragged,
etc.. Because cells do not keep their own frame location (as far as I
have been able to tell :-) you will need to keep track yourself of where
every cell in your control is, and determine which cell should receive
the events. As far as drawing is concerned, you will need to call every
cell's drawWithFrame:inView: in your controlViews drawRect: method. If
your control is large, and has many cells (as my spreadsheet does) you
will almost certainly need to optimize which cells you draw. As a couple
pointers:
1) don't just send a drawWIthFrame:inView: to every cell in the
control - check to make sure they are within the dirty rect.
2) check that you are not in a live resize. live resizes send the entire
new visible rect for redraw, which will cause your logic from (1) to
redraw every cell (VERY slow). If you are in a live resize, you will: a)
be shrinking, so no redrawing necessary, or b) probably only need to
draw those areas of the cell that are newly in view - this is not a
simple rectangle always, so you will have slightly more complex drawing
areas.
3) Keep into account that you might be in a NSScrollView, so your
visibleRect may not be the same as your frame. Luckily, scrolling is a
little smarter when asking for a redraw, as it copies the already
visible portions of your view, and only asks for the thin sliver that
has just come into view.
If you are only dealing with a small number of cells, then most of this
is probably overkill. In my case, I want the spreadsheet size to only be
limited by memory, so everything has to be optimized like crazy on the
drawing front.
Good Luck,
- tim
On Sunday, March 3, 2002, at 05:16 AM, Nick M|ller wrote:
On 03.03.2002 at 2:06 Uhr, Steve Gehrman wrote:
I can't seem to figure out how to correctly write a subclass of
NSControl with multiple NSCells.
Did you look at NSMatrix? This seems to be fitting.
Nick
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.