[comp.sys.mac.programmer] How to change a printing port's portrect?

cyosta@taux01.UUCP (Yossie Silverman) (07/27/88)

I am trying to print some stuff and I discovered that when I open
a printing port, I get the portrect of the screen.  This is somewhat
of a problem for me, as I would like to use the entire page for
printing.  Anyway, after many games I figured out that I should change
the clipRect with the clipRect call, the viewRgn with a rectRgn call
(directely accessing the grafPort record element), and the
bitmap's bounds variable.  I can envision a few problems with what
I did:  (1) I didn't change the rowBytes or baseAddr in the bitmap,
(2) I directely manipulated the bitmap, and (3) I directely manipulated
the viewRgn.  Can anyone offer some expert critism on what I did, pro
and con?

-- 
Yossie Silverman                                   What did the Caspian sea?
National Semiconductor Ltd. (Israel)				- Saki
UUCP: taux01!yossie@nsc.UUCP
NSA LSD FBI KGB PCP CIA MOSAD NUCLEAR MI5 SPY ASSASSINATE SDI -- OOCLAY ITAY

kaufman@polya.Stanford.EDU (Marc T. Kaufman) (07/27/88)

In article <873@taux01.UUCP> taux01!cyosta@nsc.UUCP (Yossie Silverman) writes:

>        ...Anyway, after many games I figured out that I should change
>the clipRect with the clipRect call, the viewRgn with a rectRgn call
>(directely accessing the grafPort record element), and the
>bitmap's bounds variable.  I can envision a few problems with what
>I did:

Yes, indeed.  First, you have to realize that a Printing Grafport reflects
(in portRect) the page size you set up in Page Setup.  It may, or may not, even
HAVE a bitmap (much less a bitmap.bounds -- in the Printing Grafports I set up
for spooling, bitmap.bounds is (0,0,0,0)).  Yes, you should set the clipRect to
portRect, and the visRgn to clipRgn.  However... if the printing area is not
right, try setting the desired size in your print record and then do a
Validate on it.  What comes back should be somehow related to the best
approximation the printer can give you.

Marc Kaufman (kaufman@polya.stanford.edu)

earleh@eleazar.dartmouth.edu (Earle R. Horton) (07/28/88)

In article <873@taux01.UUCP> taux01!cyosta@nsc.UUCP (Yossie Silverman) writes:
>I am trying to print some stuff and I discovered that when I open
>a printing port, I get the portrect of the screen...

> Anyway, after many games I figured out that I should change
>the clipRect with the clipRect call, the viewRgn with a rectRgn call
>(directely accessing the grafPort record element), and the
>bitmap's bounds variable.

What is in the Print Record whose Handle you pass to PrOpenDoc?  You
shouldn't have to change this stuff, but rather should negotiate with
the Printing Manager to set up a Print Record first.  Then when you
open the printing port you should get a portRect which corresponds to
the prInfo.rPage Rect in the Print Record.  Are you calling
PrintDefault and/or the Printing Dialog routines before opening the
port?

Sorry to answer a question with another question, but it appears to
need it.

What games were you playing?


Earle R. Horton.  H.B. 8000, Dartmouth College, Hanover, NH 03755

cyosta@taux01.UUCP (Yossie Silverman) (07/28/88)

In article <9566@dartvax.Dartmouth.EDU> earleh@eleazar.dartmouth.edu (Earle R. Horton) writes:
>
>What is in the Print Record whose Handle you pass to PrOpenDoc?  You
>shouldn't have to change this stuff, but rather should negotiate with
>the Printing Manager to set up a Print Record first.  Then when you
>open the printing port you should get a portRect which corresponds to
>the prInfo.rPage Rect in the Print Record.  Are you calling
>PrintDefault and/or the Printing Dialog routines before opening the
>port?
>
Well, I am doing all that, i think.  I am calling the page setup routine
in response to the page setup menu item.  I am calling the printer job
routine in response to the print... command.  I call the default routine
as the first thing i do in the program to intialize the print record.
And then I open the port and get the screenbits port.  I also get the
screenbits port when I start a new page.  I am sorry I can't remember
the names of the routines.  Can you or someone post a skeleton print
procedure(s)  I.e. what to do when I start my program, what to do
when the page setup is chosen, what to do when the print... is chosen
and what to do at the end of the program (well, I don't do anything, but
maybe that is wrong too).  I also figured out that I should bracket all
non-interruptible (by menu's etc..) procedures which deal with printing
with PrOpen and PrClose so that a new resource file could be opened by
chooser should the user desire to do so.  The IM I use (phonebook) says
that the calls should only be called at the begining and end of program.
-- 
Yossie Silverman                                   What did the Caspian sea?
National Semiconductor Ltd. (Israel)				- Saki
UUCP: taux01!yossie@nsc.UUCP
NSA LSD FBI KGB PCP CIA MOSAD NUCLEAR MI5 SPY ASSASSINATE SDI -- OOCLAY ITAY