FROM : Jim Correia
DATE : Tue Jan 29 23:12:45 2008
On Jan 29, 2008, at 1:34 PM, David Duncan wrote:
> The pagination methods are still the best way to do this. You would
> simply state that your content has exactly 1 page that fills the
> size of the paper. Then when your -drawRect is invoked, it will be
> invoked to draw within the bounds of the page size you specified
> previously.
I guess I'm confused as to what your advice specifically is here. The
rect passed to -drawRect: is the clipping rect. I use that to restrict
myself to only drawing what is necessary. The contents of the view are
already laid out (and possibly cached) relative to the view's bounds,
which remains unchanged.
In my sample view I've added:
- (BOOL)knowsPageRange:(NSRangePointer)range
{
range->location = 1;
range->length = 1;
return YES;
}
- (NSRect)rectForPage:(NSInteger)page
{
NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
NSPrintInfo *printInfo = [printOperation printInfo];
NSRect pageRect;
pageRect.origin = NSZeroPoint;
pageRect.size = [printInfo paperSize];
NSLog(@"-rectForPage: %@", NSStringFromRect(pageRect));
return pageRect;
}
At the top of -drawRect: I log
NSLog(@"-drawRect: %@, onScreen = %d, bounds = %@",
NSStringFromRect(rect), [[NSGraphicsContext currentContext]
isDrawingToScreen], NSStringFromRect([self bounds]));
When message as part of the print sequence, I see:
-rectForPage: {{0, 0}, {612, 792}}
-drawRect: {{0, 0}, {448, 205}}, onScreen = 0, bounds = {{0, 0}, {448,
205}}
Thanks,
Jim
DATE : Tue Jan 29 23:12:45 2008
On Jan 29, 2008, at 1:34 PM, David Duncan wrote:
> The pagination methods are still the best way to do this. You would
> simply state that your content has exactly 1 page that fills the
> size of the paper. Then when your -drawRect is invoked, it will be
> invoked to draw within the bounds of the page size you specified
> previously.
I guess I'm confused as to what your advice specifically is here. The
rect passed to -drawRect: is the clipping rect. I use that to restrict
myself to only drawing what is necessary. The contents of the view are
already laid out (and possibly cached) relative to the view's bounds,
which remains unchanged.
In my sample view I've added:
- (BOOL)knowsPageRange:(NSRangePointer)range
{
range->location = 1;
range->length = 1;
return YES;
}
- (NSRect)rectForPage:(NSInteger)page
{
NSPrintOperation *printOperation = [NSPrintOperation currentOperation];
NSPrintInfo *printInfo = [printOperation printInfo];
NSRect pageRect;
pageRect.origin = NSZeroPoint;
pageRect.size = [printInfo paperSize];
NSLog(@"-rectForPage: %@", NSStringFromRect(pageRect));
return pageRect;
}
At the top of -drawRect: I log
NSLog(@"-drawRect: %@, onScreen = %d, bounds = %@",
NSStringFromRect(rect), [[NSGraphicsContext currentContext]
isDrawingToScreen], NSStringFromRect([self bounds]));
When message as part of the print sequence, I see:
-rectForPage: {{0, 0}, {612, 792}}
-drawRect: {{0, 0}, {448, 205}}, onScreen = 0, bounds = {{0, 0}, {448,
205}}
Thanks,
Jim
| Related mails | Author | Date |
|---|---|---|
| Jim Correia | Jan 29, 15:18 | |
| David Duncan | Jan 29, 19:34 | |
| Jim Correia | Jan 29, 23:12 |






Cocoa mail archive

