Re: where to put on-resize calculations in NSCell?
Re: where to put on-resize calculations in NSCell?
- Subject: Re: where to put on-resize calculations in NSCell?
- From: Greg Best <email@hidden>
- Date: Fri, 3 Mar 2006 04:04:32 -0800
Thanks. This confirms what I was finding. I'd prefer to not
customize the cell and the control as that disrupts my fragile
understanding of why the functionality was factored out in the first
place.... =)
I'm going to try and create a scaled version of the NSBezierPath at
init, check for a changed cell frame in the draw routine to preset an
NSAffineTransform, and adjust the basic path at draw time. I think
inverting the transform will allow me to handle mouse actions in a
consistent way.
On Mar 1, 2006, at 9:57 AM, Matt Neuburg wrote:
On Tue, 28 Feb 2006 19:06:15 -0800, Gregory Best <email@hidden> said:
Hey--
I'm building an NSCell whose interior requires a fair amount of
geometry
calculation that depends on the geometry of the cell frame. I need
to know the
geometry both for drawing the cell guts and for understanding user
mouse input
so I'd like to calculate the geometry only when the containing
control size
changes and store that information. Problem is, it doesn't appear
that any of
the cell sizing functions really get called.
I've instrumented:
-(void)calcDrawInfo:(NSRect)aRect
-(NSSize)cellSize
-(NSSize)cellSizeForBounds:(NSRect)aRect
-(NSRect)drawingRectForBounds:(NSRect)theRect
-(NSRect)imageRectForBounds:(NSRect)theRect
-(NSRect)titleRectForBounds:(NSRect)theRect
-(NSControlSize)controlSize
and none of them get tripped at launch or on resize.
It's probably a safe bet that whatever the user is interacting
with whatever
was last drawn, so I could probably do all of this in the
drawInteriorWithFrame:inView:, but that seems wrong to me. How is
this supposed
to be done? Are there any messages on resize other than draw?
An NSCell is a highly minimalist sort of entity. It is not a piece
of window
interface; it's something that a piece of window interface wraps,
as it
were, in order to delegate the instructions for drawing itself and
so forth.
It is that piece of window interface that you need to look to. You
may not
be able to be able to develop your functionality purely by subclassing
NSCell; you may have to subclass both NSCell and the control that
will wrap
it, because they must work together in order to operate. Working
out the
details can be quite tricky, because those details are not always
as well
documented as you would like (notice the diplomatic restraint of that
sentence). For example, in this instance you might consider calling
NSControl's calcSize, which will trigger calcDrawInfo in its cell
(s). Then
calcDrawInfo might store geometry data in ivars. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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