views:

122

answers:

1

I have a tree of data that I would like to present to the user in a top-down manner, the way you see parse trees presented. Conceptually, the data have a lot in common with what an NSOutlineView would present: hierarchical structure, tree nodes can be be expanded and reordered, etc. I'm trying to figure out how I might be able to manipulate or subclass NSOutlineView (or NSTableColumn?) in order to get the visual layout of tree nodes that I want, but I'm having a hard time getting started. Does anyone have any tips on a good way to go about this task? Should I just subclass NSControl and start from there?

Edit: I guess what it comes down to is that I'm trying to influence the way an outline is drawn, so that instead of the standard presentation, you get something that looks like this. My main problem is that I'm not sure how I should take over control of when and where the data cell draws its contents. Originally I had thought that NSTableColumn was responsible for drawing itself, but it appears I was wrong about that. So is all the layout of cells done by NSOutlineView's drawRect: method?

+4  A: 

I'm trying to figure out how I might be able to manipulate or subclass NSOutlineView (or NSTableColumn?) in order to get the visual layout of tree nodes that I want, but I'm having a hard time getting started.

An NSTableColumn is one column in a table view (or outline view, which is a kind of table view).

Should I just subclass NSControl and start from there?

That would be the hard way.

Edit: Oh, you mean presenting the data as a tree instead of an outline. Yeah, definitely make a custom control or view for that.

Does anyone have any tips on a good way to go about this task?

Appoint the controller object that owns your model as the data source of the outline view and make it conform to the NSOutlineViewDataSource protocol.

Peter Hosey
Damn, the hard way :) Though I guess it's easier than trying to make NSOutlineView do something it doesn't want to do.
zbrimhall