FROM : Corbin Dunn
DATE : Thu Jul 20 19:23:07 2006
>
James,
> I have several NSOutlineViews that use NSBrowserCell to display file
> icons and names. I've already hacked up some subclasses of
> NSBrowserCell to draw icons+filenames, dim the text, another other
> stuff that NSBrowserCell doesn't normally do.
Well, my first question is why are you using an NSBrowserCell subclass
in an NSOutlineView? There is no reason why you have to do this, and
generally, the reason people do this is to share the cell with
NSBrowser.
>
> However, I'm hitting the wall: I need to draw things in the
> background (think FInder labels), do more elaborate selection
> indication,
This should be possible to do with a subclassed NSBrowserCell without
any trouble. Overriding drawInteriorWithFrame can let you do whatever
you want. For instance, the NSOpenPanel uses a subclass of
NSBrowserCell to draw the finder label background before everything
else.
> and eventually add animation.
This is possible too; Mail uses a custom cell to do its animation. It
keeps track of the animation state itself.
> But the NSBrowserCell class just wasn't built to be extended.
What are you having trouble extending? It is built to be extended.
> The only choice I see is to roll my own and replace NSBrowserCell
> entirely.
That would be fine too; there is nothing that requires an
NSBrowserCell to be used in an NSTableView or NSOutlineView.
> Here are my questions:
>
> The big deal will be getting the disclosure controls to work the
> same way they do in NSBrowserCell.
I think you have some confusion here; the disclosure triangle in an
NSOutlineView does not use an NSBrowserCell. It is an NSButtonCell. It
is not easily customizable, but you can customize it a little in
willDisplayOutlineCell (delegate method).
> I've looked at Joar's code on placing NSViews into a NSTable <http://www.stepwise.com/Articles/Technical/2003-12-20.01.html
> >, but that sounds very heavy handed or the disclosure triangle -- I
> don't want to add thousands of NSButton views to my table. I would
> assume that NSBrowserCell uses a single NSButtonCell to draw and
> animate all of the "buttons" in the table, but I have no idea how to
> use an NSCell to "fake" a button display. Does anyone have sample
> code that does this?
You can have an NSCell subclass which draws a button area and tracks
just that button area. You can also have a subclassed NSCell that uses
another NSButtonCell to delegate drawing and tracking to.
> Does anyone know how NSOutlineView handles the indenting of items in
> the column that controls the outline?
Yes -- I do know! What types of things are you wanting to know or do?
> Eventually, I also want to add progress views to the outline. I know
> that these can't be lightweight NSCell renderings because they have
> their own animation, but I can use Joar's technique (or a variation
> on it) to accomplish that.
Or, you can use an NSCell and set the state for it on each animation
tick.
What problems are you having drawing or tracking in your custom cell
that you can't get to work right?
thanks,
--corbin
PS: Another plug for WWDC, I'm covering some things on advanced cell
and control creation at WWDC in 'Beyond Buttons and Sliders'. Be sure
to attend!
DATE : Thu Jul 20 19:23:07 2006
>
James,
> I have several NSOutlineViews that use NSBrowserCell to display file
> icons and names. I've already hacked up some subclasses of
> NSBrowserCell to draw icons+filenames, dim the text, another other
> stuff that NSBrowserCell doesn't normally do.
Well, my first question is why are you using an NSBrowserCell subclass
in an NSOutlineView? There is no reason why you have to do this, and
generally, the reason people do this is to share the cell with
NSBrowser.
>
> However, I'm hitting the wall: I need to draw things in the
> background (think FInder labels), do more elaborate selection
> indication,
This should be possible to do with a subclassed NSBrowserCell without
any trouble. Overriding drawInteriorWithFrame can let you do whatever
you want. For instance, the NSOpenPanel uses a subclass of
NSBrowserCell to draw the finder label background before everything
else.
> and eventually add animation.
This is possible too; Mail uses a custom cell to do its animation. It
keeps track of the animation state itself.
> But the NSBrowserCell class just wasn't built to be extended.
What are you having trouble extending? It is built to be extended.
> The only choice I see is to roll my own and replace NSBrowserCell
> entirely.
That would be fine too; there is nothing that requires an
NSBrowserCell to be used in an NSTableView or NSOutlineView.
> Here are my questions:
>
> The big deal will be getting the disclosure controls to work the
> same way they do in NSBrowserCell.
I think you have some confusion here; the disclosure triangle in an
NSOutlineView does not use an NSBrowserCell. It is an NSButtonCell. It
is not easily customizable, but you can customize it a little in
willDisplayOutlineCell (delegate method).
> I've looked at Joar's code on placing NSViews into a NSTable <http://www.stepwise.com/Articles/Technical/2003-12-20.01.html
> >, but that sounds very heavy handed or the disclosure triangle -- I
> don't want to add thousands of NSButton views to my table. I would
> assume that NSBrowserCell uses a single NSButtonCell to draw and
> animate all of the "buttons" in the table, but I have no idea how to
> use an NSCell to "fake" a button display. Does anyone have sample
> code that does this?
You can have an NSCell subclass which draws a button area and tracks
just that button area. You can also have a subclassed NSCell that uses
another NSButtonCell to delegate drawing and tracking to.
> Does anyone know how NSOutlineView handles the indenting of items in
> the column that controls the outline?
Yes -- I do know! What types of things are you wanting to know or do?
> Eventually, I also want to add progress views to the outline. I know
> that these can't be lightweight NSCell renderings because they have
> their own animation, but I can use Joar's technique (or a variation
> on it) to accomplish that.
Or, you can use an NSCell and set the state for it on each animation
tick.
What problems are you having drawing or tracking in your custom cell
that you can't get to work right?
thanks,
--corbin
PS: Another plug for WWDC, I'm covering some things on advanced cell
and control creation at WWDC in 'Beyond Buttons and Sliders'. Be sure
to attend!
| Related mails | Author | Date |
|---|---|---|
| James Bucanek | Jul 20, 18:53 | |
| Corbin Dunn | Jul 20, 19:23 | |
| James Bucanek | Jul 20, 21:48 | |
| Corbin Dunn | Jul 20, 23:32 | |
| James Bucanek | Jul 21, 00:17 | |
| Corbin Dunn | Jul 21, 00:28 | |
| James Bucanek | Jul 21, 00:31 |






Cocoa mail archive

