Re: Paginating an NSTableView
Re: Paginating an NSTableView
- Subject: Re: Paginating an NSTableView
- From: Brian Webster <email@hidden>
- Date: Wed, 27 Nov 2002 09:13:48 -0600
On Wednesday, November 27, 2002, at 12:00 AM,
email@hidden wrote:
I've made an address-book-like application, and overcome the
(relatively easy) hurdles of implementing printInfo: and its related
methods, but I'm having some problems with actually printing the table
view--the last row on the page doesn't completely display, and
overflows onto the next page.
I've tried overriding drawRect: (with the doc-provided conditional to
see whether it is printing to screen or to a printer), then drawRow:,
for my table view, but I've had no success in paginating the table
view.
Has anyone had a similar experience, and how have they overcome it?
There is a set of methods that you can override in NSView to perform
pagination while printing. No modification to your drawRect code is
needed, as the printing system will call it once for each page, passing
in the rectangle that is has determined should be rendered on that
page. This is a piece of code that I've used in a subclass of
NSTableView to paginate such that rows are not split between pages.
- (void)adjustPageHeightNew:(float *)newBottom top:(float)top
bottom:(float)proposedBottom limit:(float)bottomLimit
{
int cutoffRow = [self rowAtPoint:NSMakePoint(0, proposedBottom)];
NSRect rowBounds;
if (cutoffRow != -1)
{
rowBounds = [self rectOfRow:cutoffRow];
if (proposedBottom < NSMaxY(rowBounds))
{
*newBottom = NSMinY(rowBounds);
}
else
{
*newBottom = proposedBottom;
}
}
else
{
*newBottom = proposedBottom;
}
}
--
Brian Webster
email@hidden
http://homepage.mac.com/bwebster
_______________________________________________
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.