• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: where to put on-resize calculations in NSCell?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: where to put on-resize calculations in NSCell?


  • Subject: Re: where to put on-resize calculations in NSCell?
  • From: Camillo Lugaresi <email@hidden>
  • Date: Wed, 1 Mar 2006 19:32:05 +0100

On 01/mar/06, at 04:06, Gregory Best wrote:

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?

calcDrawInfo depends on collaboration from the enclosing control. If you're using the cell in a custom control, you can have the control call its calcSize method, which in turn should call calcDrawInfo on its cell.
If you cannot depend on that, just cache the last cell frame, and trigger calcDrawInfo at the beginning of the draw and mouseDown methods if the requested frame is different.


Camillo
_______________________________________________
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


  • Prev by Date: Executable linking
  • Next by Date: Re: Programmatically setting the value of a bound TextField
  • Previous by thread: Re: where to put on-resize calculations in NSCell?
  • Next by thread: Bizarre problems and ahs_main()
  • Index(es):
    • Date
    • Thread