Window zoom with a tableView
Window zoom with a tableView
I'm trying to zoom a window whose main feature is an NSTableView. Right
now I'm really just concerned with the height.
The easiest way to do this (I think?) would be to just subtract the
height of the tableView from [window frame].size.height and then add the
new, calculated height of the table.
The problem is that [tableView frame] is not returning the current frame
of the table unless that current frame is larger than the optimal frame.
In other words, if a scroll thumb is visible [tableView
frame].size.height always returns the same value. The results is that my
method works when *shrinking* a window, but not when *growing* it.
I've tried getting the frame of the scrollView and that didn't work
either. I suppose I could add up all the individual parts of the window,
but this has the potential to be so much cleaner.
Any ideas? TIA
- (NSRect)windowWillUseStandardFrame:(NSWindow *)sender
defaultFrame:(NSRect)defaultFrame
{
float oldHeight = 0.0;
float newHeight = 0.0;
NSRect newFrame = [sender frame];
NSSize intercellSpacing = [table intercellSpacing];
newHeight = [table numberOfRows] *
([table rowHeight] + intercellSpacing.height);
oldHeight = [table frame].size.height;
newHeight = [sender frame].size.height - oldHeight + newHeight;
// Adjust origin so the window sticks to the upper left
newFrame.origin.y = newFrame.origin.y +
newFrame.size.height - newHeight;
newFrame.size.height = newHeight;
return newFrame;
}
--
Nick Kocharhook -- <email@hidden> -- Rot-13
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.