Re: Page margins and NSPrintInfo
Re: Page margins and NSPrintInfo
- Subject: Re: Page margins and NSPrintInfo
- From: Jonathan Jackel <email@hidden>
- Date: Sat, 27 Dec 2003 13:44:35 -0500
With thanks to Andrew Abernathy, I have figured out how to provide a
decent user experience for setting up margins for printing.
As Andrew explained off-list, the "Printer Margins" in the "Custom
Paper Size" view of Page Setup... are not what a typical user thinks of
as "margins." Rather, these margins represent the area that the
selected printer can print on. These margins are used to determine
-[NSPrintInfo imageablePageBounds]. They have nothing whatsoever to do
with -[NSPrintInfo leftMargin] or its compadres.
You have to provide your own UI for handling left/right/top/bottom
margins. You can set an accessory view to Page Setup..., or you can
have your own window/sheet available via a menu item. Personally, I
think it makes sense to provide both. The dedicated menu item will be
very obvious to users and let them know that your app allows the user
to change margins. The accessory view is convenient for when the user
wants to change paper and printer settings through Page Setup..., and
then double-check or change the margins. You can use the same view to
do double-duty.
Unfortunately, the accessory view is named whatever your app is named,
and there is no way to give it a more useful name in Cocoa. Andrew
says Carbon can, but I haven't the temerity to learn Carbon just for
that.
I have posted a simple example project here:
http://mywebpages.comcast.net/jjackel/CocoaExamples.html
The example also shows how to print a text view in newspaper-style
columns, and provides a UI for changing the number of columns.
I have also filed an enhancement request for setting margins. Cocoa
really ought to do this out-of-the-box for document-based applications.
Jonathan
On Dec 25, 2003, at 10:14 PM, Jonathan Jackel wrote:
I have two questions. First, a call for help. Second, a call for
opinions.
First, I'm printing a document. I initialize a custom view and pass
it the document's NSPrintInfo instance. In theory, this allows the
view to know the size of the paper and the margins of the page so it
can lay out the text accordingly. In practice, while the paper size
is correct, the margins are always 72 points left and right, 90 points
top and bottom. This is so even if I set up a "custom" paper size
with margins twice that size. I'm getting the paper size just fine,
so I know I am not getting a generic print info. But I'm not getting
the margins. I am reading the margins with, e.g., [printInfo
topMargin], which always returns 90.
What am I not doing?
Second, why is setting margins such a production in Cocoa? You don't
even see an option for adjusting margins unless you hunt for it. You
have to intuit (perhaps after the reading the "Summary" in the
settings list box of Page Setup... (as if "setup" is a real word) )
that there _MUST_ be a setting for margins somewhere. Then, perhaps,
you choose "Custom Paper Size," and see that, lo, there is someplace
for your margins. So you set some margins on a custom paper size
(which is probably just 8.5 x 11 -- nothing custom about that!), click
OK and print. And it does not work. Then, perhaps, you realize that
merely creating a custom paper size and clicking OK does not tell
Cocoa "That's what I want." So you revisit the Page Setup... and,
finally, select your custom paper size from the bottom of a list that
includes such oddities and "ROC 16K" and "Super B". There's no
apparent way to get rid of these oddball page sizes.
Does anyone else find this process bizarre?
If not, can someone explain the thought process that went into how the
page layout dialog is supposed to work, so that I can adjust my brain
accordingly?
Call me crazy, but I think Word handles this the right way. On the
Format menu there's an item called "Document," which actually allows
you to format the document, including the margins.
Jonathan
_______________________________________________
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.
_______________________________________________
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.