• 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: NSBrowserCell not extensible; need sample using NSButtonCell
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSBrowserCell not extensible; need sample using NSButtonCell


  • Subject: Re: NSBrowserCell not extensible; need sample using NSButtonCell
  • From: Corbin Dunn <email@hidden>
  • Date: Thu, 20 Jul 2006 10:23:07 -0700



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!
_______________________________________________
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
  • Follow-Ups:
    • Re: NSBrowserCell not extensible; need sample using NSButtonCell
      • From: James Bucanek <email@hidden>
References: 
 >NSBrowserCell not extensible; need sample using NSButtonCell (From: James Bucanek <email@hidden>)

  • Prev by Date: How do you use NSTextView methods on a NSView ? (keywords: TextEdit, sort lines)
  • Next by Date: Re: Attributed strings and custom attributes
  • Previous by thread: NSBrowserCell not extensible; need sample using NSButtonCell
  • Next by thread: Re: NSBrowserCell not extensible; need sample using NSButtonCell
  • Index(es):
    • Date
    • Thread