Thanks Matt. You were absolutely correct; the problems I have were in -drawRect:. I'm still trying to track down a problem though, and I'm not sure where it is. I've actually cut it down to some fairly simple code. Here it is:

-(NSRect)rectForPage:(NSInteger)pageNumber
{
        // Note the current page
        currentPage = pageNumber-1;

        float pHeight = linesPerPage * lineHeight;
NSRect returnRect = NSMakeRect(0.0, pHeight * currentPage, pageRect.size.width, pHeight);
        
NSLog(@"x-origin: %f, y-origin, %f, height: %f, width: %f", returnRect.origin.x,
                  returnRect.origin.y, returnRect.size.height, 
returnRect.size.width);

        return returnRect;
}

-(void)drawRect:(NSRect)rect
{
        NSRect lineRect;
        lineRect.origin.y = 0;
        lineRect.origin.x = pageRect.origin.x;
        lineRect.size.width = pageRect.size.width;
        lineRect.size.height = lineHeight;
        
        for (NSUInteger i=0; i<500; i++)
        {
                // Draw line number
                lineRect.origin.y = (i * lineHeight);
                NSString *lineString = [NSString stringWithFormat:@"%d",i];
                [lineString drawInRect:lineRect withAttributes:attributes];
        }
}

Now, this should simply print a line of integers down the left side of the page. It does this for two pages - works perfectly - with lines 0 to 50 on the first page, and 51 to 100 on the second page, divided correctly so there is no splitting of lines and so on. But the rest of the pages are blank, and I can't figure out why. The NSLog from - rectForPage: looks like this:

x-origin: 0.000000, y-origin, 0.000000, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 606.899963, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 1213.799927, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 1820.699951, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 2427.599854, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 3034.499756, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 3641.399902, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 4248.299805, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 4855.199707, height: 606.899963, width: 576.000000 x-origin: 0.000000, y-origin, 5462.099609, height: 606.899963, width: 576.000000

... so it looks to me as if all the pages are being properly selected.

Oh, and if I change the paper size and orientation, similar things happen (but not entirely consistently). So, if I choose landscape, it only prints two pages. But if I choose envelope #10, it prints three pages. Thanks,

Darcy

Several lines down? Could that be the extra 500 you keep introducing?
Really, since what you need to say in rectForPage depends completely on how you draw in drawRect, which you don't show, it's hard to guess from here what rectForPage *should* be (or whether you even need to implement it)...
m.

--
matt neuburg, phd = m...@tidbits.com, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings




_______________________________________________

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