Re: Printing my document
Re: Printing my document
- Subject: Re: Printing my document
- From: Graham J Lee <email@hidden>
- Date: Tue, 24 May 2005 15:04:38 +0100
On 23 May 2005, at 17:00, Fritz Anderson wrote:
On 23 May 2005, at 7:42 AM, Graham J Lee wrote:
Now, how do I go about printing that? I've overridden
-printDocument: in my NSDocument subclass, and get the following
results:
-(void)printDocument:(id)sender
{
[super printDocument:sender]; /* does nothing */
[tableView print:sender]; /* print the contents (though not
column headings) of the table view */
[graphView print:sender]; /* print the graph view out very nicely
*/
}
However, the tableView and graphView prinouts get sent (perhaps
unsurprisingly) as separate print jobs. What I'd like to do is print
the tableView followed by the graphView on the same (printer)
document, even if they don't fit on the same page. How could I
acheive that?
Without promising to omit the headers or do it very nicely, I'd say
you create an NSView big enough to hold both views, lay them out
inside it, and print that. Return the views to their original
superviews when you're done.
OK, so assuming I don't exactly know how to do that... :-)
Actually, it's going quite well; following your suggestion and Ali
Lalani's post about constructing an offscreen NSView, I've done this:
-(void)printDocument:(id)sender
{
NSView *tvSuperview=[tableView superview];
NSView *gvSuperview=[graphView superview];
NSWindow *offscreen=[[NSWindow alloc]
initWithContentRect:NSMakeRect(-1000,-1000,800,600) styleMask:
NSTitledWindowMask|NSClosableWindowMask backing:
NSBackingStoreNonretained defer:NO];
[[offscreen contentView] addSubview:tableView];
[[offscreen contentView] addSubview:graphView positioned:NSWindowBelow
relativeTo:tableView];
[[offscreen contentView] print:sender];
[offscreen close];
[tvSuperview addSubview:tableView];
[gvSuperview addSubview:graphView];
}
What this currently doesn't do is sort out the relative origins of the
two subviews; how do I do that? Also, should I -retain each subview
when I add it to the [offscreen contentView] then -release it when I
-close the offscreen window?
Thanks, Graham.
--
Graham Lee GPG Key ID: 01D5B9D8
UNIX Systems Manager, Oxford Physics Practical Course
Coordinator, UKUUG Apple SIG
(http://lists.ukuug.org/mailman/listinfo/apple-sig)
Technical bod, Oxford Mac Users' Group (http://www.oxmug.org)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden