Re: Printing
Re: Printing
- Subject: Re: Printing
- From: Paul Fox <email@hidden>
- Date: Sat, 7 Sep 2002 09:53:52 +0100
>
On Fri, 06 Sep 2002 08:38:52 +0100, email@hidden said:
>
>
>I am trying to add printing support to my app and am being totally stumped
>
>on how to do this. I have read all the apple docs and scoured the web -
>
>very few examples. I have scoured the list for past examples.
>
[snip]
>
>Ok - so if I dont call runOperation, but call
>
>
>
> [op runOperationModalForWindow: ...]
>
>
>
>I get the popup but the function appears to return straightaway.
>
>
I can think of two misconceptions you might be having.
>
>
(1) If you're coming from a REALbasic background - and it sounds vaguely as
>
if you might be - you may not understand what "modal" means in a Cocoa
>
context. The notion "run modal" in Cocoa has to do with limitations on what
>
events the application will accept; it does not, as in REALbasic, magically
>
and mysteriously stop the execution of the current method until the modal
>
window is gone. This is why it typically takes two or three methods to put
>
up a modal window in Cocoa: one to put it up (and it typically then returns
>
immediately), one to react to button presses, and (optionally) one to take
>
control when the modal state is brought to an end (by the second method).
No - I am not from REALbasic background but possibly what I want to do
is similar. Thanks for the hint about modality. So do I just
run a new [NSApp ...] method to wait until the dialog is dismissed?
>
(2) Printing in Cocoa, quite like printing in REALbasic, is simply drawing.
>
When you learn that your user wishes to print, construct your view and draw
>
it; when it's ready, hand it to +NSPrintOperation printOperationWithView:.
>
You are now ready to print, so take the result of that call, call
>
-runOperationModalForWindow (or whatever), and that's the end. You don't
>
care that the "function returns straightaway" because that's the end
>
anyhow. In other words, by the time you got to this point, you basically
>
already printed, because you already drew into your view. I oversimplify
>
but this should get you started.
It is not possible to 'construct' the view. What I am doing is creating
a temp-view object so I can react to the callbacks, and generate the
'document' line by line and page by page. The file I might
want to print could be megabytes or millions of lines long. I am a bit
confused as to whats needed here.
My presumption is that my view method gets called and asked 'how big is
your view' (in terms of rectangles or pages), and then drawRect gets
called once (or multiply times) and then I call the usual methods to
generate the formatted text.
My confusion in your description is how do I print when what I want to print
is hugely bigger than an on-screen view window would allow.
I am assuming if I blindly do:
- (void) drawRect: ...
{
draw-string-at-line-1;
draw-string-at-line-2;
....
draw-string-at-line-1000,000;
}
Then its buffering up potentially huge amounts of stuff so that when the
function returns it can then blast the data away to the printer?
I suppose that isnt so bad since it probably goes to a temp file rather
than stored in memory.
It looks like I need to reinvestigate the modal issue properly so I
can hang the application until the dialog is done with.
Thanks for your hints. Looks like I was close but just missing a
little piece of the jigsaw!
regards
>
>
m.
>
>
--
>
>
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt
>
pantes anthropoi tou eidenai oregontai phusei
_______________________________________________
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.