Re: Newbie on printing views
Re: Newbie on printing views
- Subject: Re: Newbie on printing views
- From: Scott Anguish <email@hidden>
- Date: Tue, 11 Jun 2002 02:13:27 -0400
On Tuesday, June 11, 2002, at 12:44 AM, Graham Gyatt wrote:
When my drawer is open, I would like to ALSO print, on the SAME page
(both will fit), the content of the drawer - so the user can print, in
effect, a snapshot of the entire app interface (less menu
bar). I'm new to Cocoa printing, and I'm trying to figure out the
easiest way to do this. Looks like I might have to somehow recreate
what I want to print in another view hierarchy offscreen?
Well, you could put views (the content of the window, and the
content of the drawer) into a single view, arranged as you want, and
then print the view that contains both.. the problem here is that you'll
need to remove both views from the UI at least momentarily. That sucks
Another option might be (and I'm just talking here), using the
NSPrintOperation to PDF to copy the content of the window view, and the
drawer view into individual NSData items that contain the PDF.. and THEN
make a new NSView with two NSImageViews in it, each one sized to the
size of the appropriate required rect for the drawer and window views,
and then load the PDF into each of the NSImageViews (via NSImage) and
finally send the print: to the new NSView that contains both the PDF
images.. (I hope that makes sense.. basically you'd copy the PDF from
both views, stick them into NSImages and then build the new view)..
Both of those seem pretty hackish mind you, as you say. Especially
the first...
But this seems clumsy and I suspect cocoa has a way to do this more
elegantly.
Any suggestions appreciated.
Well, not Cocoa necessarily, but OOP design..
The best option would be to make sure your model and view are nicely
separated and then make a new view specifically for printing... but
without knowing what is in the drawer and content view, that's hard to
give much input onto. If the drawer and the window contents are custom
or not would be the issue here (an indication of what they are might be
helpful) If you're dealing with, say an NSTableView in the drawer, and
an NSTextView in the window, both of these data sources (the datasource
and the NSTextStorage respectively) could be made available to other UI
items in the customized printing view, and that's a similar design..
remember that the view that is printed doesn't have to be the same
view that is displayed on the screen..
What exactly are in the views? Or do you really want a window with
the drawer printed?
_______________________________________________
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.