What is required to support the column autosize request for a view-based table? The docs are really unclear on this point, and seem to speak to cell-based views.
This is to handle a double click on a column separator.
I can make this work by implementing tableView:sizeToFitWidthOfColumn:
for an NSTableView
and outlineView:sizeToFitWidthOfColumn:
for an NSOutlineView
, but the docs say this is only necessary for large tables. Is there a more correct way to do this?
- (CGFloat)tableView:(NSTableView*)tableView sizeToFitWidthOfColumn:(NSInteger)column {
NSUInteger n = [self numberOfRowsInTableView:tableView];
CGFloat w = 30;
NSTableColumn* col = [[tableView tableColumns] objectAtIndex:column];
for (int i=0; i<MIN(n, 100); ++i) {
NSView* vw = [self tableView:tableView viewForTableColumn:col row:i];
w = MAX(w, [vw frame].size.width);
}
return w;
}