Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Printing Confusion (Project Builder -> XCode changes)



I've been following the MathPaper example in "Building Cocoa Applications: A Step-by-Step Guide" (Garfinkel & Mahoney) and have got to the section about printing at the end of chapter 13.

The book claims that printing "just works" in multiple document Cocoa applications. Of course, I quickly found out this was not the case. Yes it's an old book, but I wasn't expecting something as fundamental as printing to have changed much over the years!

Eventually I tracked the problem down to the fact that XCode now links File >> Print to your NSDocument-subclass' printDocument: method, rather than print: which it evidently used to.

Having fixed the problem (by making File >> Print call print: again), I then set about trying to get the default setting to work, but ran into problems (see below).

So my questions are:

- why the change? It must have been done for a reason, so I'm keen to understand the rationale.

- how would I go about getting hold of an NSView to print from, from within my NSDocument-subclass? I tried to obtain the associated NSWindowController, then call window: on that. But that didn't work.

What is the right way to do this? The Apple Cocoa docs on printing assume that you have a printableView method ready to call:

- (void)printShowingPrintPanel:(BOOL)showPanels {

    // Obtain a custom view that will be printed
    NSView *printView = [self printableView];

    // Construct the print operation and setup Print panel
    NSPrintOperation *op = [NSPrintOperation
                printOperationWithView:printView
                printInfo:[self printInfo]];

    [op setShowPanels:showPanels];

    if (showPanels) {
        // Add accessory view, if needed
    }

    // Run operation, which shows the Print panel if showPanels was YES
    [self runModalPrintOperation:op
                delegate:nil
                didRunSelector:NULL
                contextInfo:NULL];
}

But it is the contents of what would go in printableView that has me stumped!

Any help much appreciated.

thanks,

Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.