Re: NSBrowserCell not extensible; need sample using NSButtonCell
Re: NSBrowserCell not extensible; need sample using NSButtonCell
- Subject: Re: NSBrowserCell not extensible; need sample using NSButtonCell
- From: James Bucanek <email@hidden>
- Date: Thu, 20 Jul 2006 15:17:40 -0700
Corbin Dunn wrote on Thursday, July 20, 2006:
>The layout is like this:
>
>
>|-------------------------------------------------
>| indent | + outline cell | your cell |
>|-------------------------------------------------
>| indent | + outline cell | your cell |
>|-------------------------------------------------
>.....
>
>Your cell (NSTextFieldCell) in this case has nothing to do with the
>disclosure triangle cell. They are separate.
Yep, I just figured that out by creating my own NSCell that just draws a rectangle in its frame and I see that the indentation created by NSOutlineView is not part of the cell, or even the disclosure triangle.
>> No you can't, and this is where I got stuck. [NSBrowserCell
>> drawInteriorWithFrame] draws everything, including the background
>> with a highlight color of the cell's choosing.
>
>Well..I know you can; as I said before, the NSOutlineView does this.
>
>> You can't call [super drawInteriorWithFrame] first, or everything
>> (including the background) is already drawn and you're just stuck
>> drawing over it. Anything you draw first gets wiped when [super
>> drawInteriorWithFrame] is called. So it's a catch-22 if you want to
>> draw your own background. You either don't, or you draw everything
>> yourself.
>
>Okay -- you need to make sure the cell's background color is set to
>[NSColor clearColor] or nil, and not white. So, you can draw your
>stuff without having it overwrite you when it draws the background.
>
>If you want to control the highlight color, you can use
>highlightColorWithFrame:inView: and return something special (or nil).
Thanks, I missed that before. The key is hightlightColorWithFrame:.
>> What I was really hoping or was a -[NSCell drawBackgroundOfFrame]
>> message that I could override to draw my own background, while
>> letting the base class draw the contents of the cell. (I feel that
>> this is an architectural oversight in the framework.)
>
>It will work; you just have to make sure the background color isn't set.
That's what was throwing me. Neither NSBrowserCell nor NSCell have any kind of "background" property to set. By overridding highlightColorWithFrame: you can return a clear color that effectively suppressed the background of the base class. So, NSBrowserCell does it one way and NSTextFieldCell does it completely differently. Oh, well. ;)
>Okay -- I'm still confused as to what you want to do.
It doesn't matter -- it's a moot point. The work that I thought NSBrowserCell was doing (and what I thought I would have to replicate) is done by NSOutlineView.
Thanks for getting me going in the right direction.
James
--
James Bucanek
_______________________________________________
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