Printing multiple columns
Printing multiple columns
- Subject: Printing multiple columns
- From: James Spencer <email@hidden>
- Date: Sat, 25 Jun 2005 15:15:31 -0500
This is going to demonstrate my ignorance and also probably my
inability to read documentation. I want to print some data from a
table laid out in two columns with multiple pages depending on how
long the text is. For some reason, while the first column on the
first page is printing fine, the second column is never displayed (I
haven't tried an example with more than one page yet as it is very
unlikely to ever occur; typically the data will fit in one or two
columns so will all fit on one page.) I have run out of ideas for
even how to debug this so any suggestions would be very gratefully
received. I apologize for this being so long but I wanted to be
clear without making someone read all my very poor code.
I am implementing - (void)printShowingPrintPanel:(BOOL)showPanels in
which, after building my output text as a string, I create a large
view (one page wide but 32000 long) to contain the text views
(JPSPrintView which is directly derived from NSView). I then create
an NSTextStorage initializing it with the output text, create a
layout manager which is added to the text, create a container which
is added to the layout manager and then allocating a text view which
is initialized with the container. My document object is set as the
layout manager's delegate and I implement layoutManager:
(NSLayoutManager *)aLayoutManager didCompleteLayoutForTextContainer:
(NSTextContainer *)aTextContainer atEnd:(BOOL)flag to see if we have
enough containers.
In the delegate method, which I have confirmed is being called, I
create a new container, allocate a new text view which is initialized
with that container, and then add the new text view to the
JPSPrintView. In my JPSPrintView, I am calculating the number of
pages required in knowsPageRange: (which seems to be working fine)
and calculate the page area for a given page (in my testing always
page 1) in rectForPage:.
The drawRect method for the first column is being called and as I
said, the first column is printing fine but the drawRect: method for
the second text view is never being called. Interestingly, the
drawRect: method for the super view (the JPSPrintView) is being
called with a rect which matches where the second column should be.
Also I note that the layout manager for the first text view shows
that it contains two containers just as it should. (I can't tell if
this is because this is the only portion of the page rect which is
not covered by the first text view or whether it is because this
where the second text view is supposed to be.)
Because I keep thinking I've set up my frames or some such
incorrectly, for what it's worth, some of the relevant rects are as
follows: (Note I'm placing the first page at the top of the super
view; because the super view will never be displayed on the screen
and I print the pages individually, I could have and probably should
have started laying them out at 0,0 but when I started writing this,
I thought it might make a difference to the layout manager):
First text view (i.e. column 1): Frame = {{0.00, 31388.00}, {234.00,
612.00}}, Bounds = {{0.00, 0.00}, {234.00, 612.00}}
Second text view (i.e. column2):Frame = {{234.00, 31388.00}, {234.00,
612.00}}, Bounds = {{0.00, 0.00}, {234.00, 612.00}}
Rect for page one being returned by rectForPage:1 : 0.00, 31388.00,
468.00, 612.00
The rect passed to drawRect: for the super view: 234.00, 31388.00,
234.00, 612.00
The rect passed to drawRect: for the first text view: 0.00, 0.00,
234.00, 612.00
I know its asking a lot but does anyone have any suggestions of even
where to start looking?
Thanks,
Spence
James P. Spencer
5215 52nd Avenue NW
Rochester, MN 55901
(507) 289-7329
email@hidden
"Badges?? We don't need no stinkin badges!"
_______________________________________________
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