My second idea is that I could just dynamically add and remove columns & rows, but the problem is that in order to display the group titles, the column they are displayed in needs to be wide...when I added multiple columns, the column of the group title was never wide enough - they would always get clipped. If I had continued down this line, I suspect I would have had trouble dynamically adding and removing columns as the user was resizing the NSPanel.

RE: group rows. Take a look at the DragNDropOutlineView example in Leopard, and this delegate method (return something for the nil column):

/*  Optional - Different cells for each row
A different data cell can be returned for any particular tableColumn and item, or a cell that will be used for the entire row (a full width cell). The returned cell should properly implement copyWithZone:, since the cell may be copied by NSTableView. If the tableColumn is non-nil, you should return a cell, and generally you will want to default to returning the result from [tableColumn dataCellForRow:row].

When each row (identified by the item) is being drawn, this method will first be called with a nil tableColumn. At this time, you can return a cell that will be used to draw the entire row, acting like a group. If you do return a cell for the 'nil' tableColumn, be prepared to have the other corresponding datasource and delegate methods to be called with a 'nil' tableColumn value. If don't return a cell, the method will be called once for each tableColumn in the tableView, as usual.
*/
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;



The third idea was to subclass NSTextFieldCell and do all of the drawing myself. Each group (Gradients, Hatches, Images, etc.) contains just a single row with a single subclass of a NSTextFieldCell. It is this implementation that is pictured above. As you can see it mostly works and I can dynamically alter the row height so each item fits and moves to different rows as needed.

I've seen this done both ways; with/without columns, or with a single cell. Multiple Columns might be easier, especially with group rows, but it might also be difficult, as you have to dynamically add/remove them as the window resizes. So, a single cell that draws multiple pieces might be easier -- you could use subcells to do the actual work.

The PhotoSearch example (easy to find on the developer site) is a good example to start from. It also shows group rows.

The problem I am having with this is that I cannot seem to get any help with tracking the mouse (see the thread http://tinyurl.com/ 9y8to9).

The PhotoSearch example shows how to do this. Instead of doing the tracking in the cell, you can forward the tracking to a sub-cell.


The final idea is to dump NSTextFieldCell, since it seems to be eating all mouseUp and mouse tracking information, and go with a completely custom cell. I understand this may be a lot of work, but I cannot see a way around it at the moment.

You could have a main cell that subclasses NSCell, and sub-cells in it that subclass NSTextFieldCell for drawing the text.

corbin


I am hoping that someone else might have some alternate ideas or a pointer to some sample code of a subclass of NSCell which was written to work with a NSTableView.

One alternative that had been suggested is to simulate a NSOutlineView with a NSCollectionView. However, it is unclear how well this would actually work. Would it support the editing of the names of the items? Would it support rows of different heights?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to