[comp.sys.mac.programmer] questions, questions, questions....

rob@cs.mu.oz.au (Robert Wallen) (07/16/89)

A few questions for the programming intelligentsia:

First, has anyone else noticed the weirdness thats displayed when using CNTL
resources within a DITL.  After a week of hair-pulling over a custom CDEF, I 
find that using FindControl() on a normal window returned clicks in my control
fine, but using ModalDialog() ignored it.  Turns out that ModalDialog() seems
to look through the rectangles in the DITL; the CDEF gets fed the rectangle in
the CNTL resource.  If these two are not the same, it gets real hard to work.
And ResEdit doesnt make it easy to fix things either.  Does anyone have a quick
way of ensuring that both rectangles are the same?  Should I code around it?

Second:  In this silly world of Multifinder opening my desk accessories in their
own application layer (that of DA Handler), is there any programmatic way that
I can force them to be in the current applications layer? (Short of fiddling
the low memory KeyMap to pretend the option-key is down)

Third: I am allowed to pass messages 128 and up to MDEFs.  Would there be any
problem sending csCodes of 128 and up to DRVRs?  At the moment, I am using a 
silly call back scheme using _Status which works fine but it would be nicer to
just use _Control.

Fourth: Recently, I tried a program on a guy and was thoroughly disillusioned 
when it bombed badly -- he still used System 3.2 on his MacPlus and had no
intention of upgrading until he got a new hardware platform.  So I need to build
in my own support for PopUpMenuSelect() for him.  And GetMenuCmd(). And God
knows what others.  My question: Does anyone have a definitive list of what
traps appeared at each System rev?  I figure I am going to write a 'PACK' style
resource which will contain each of the traps that the old Mac is missing and
it may end up being implemented the same way that 'PTCH' resources are, only
based on System rev instead of machine.  Any comments?

Thanx in advance,   Rob  (rob@murtoa)

--------------
"I meant," said Ipslore, bitterly, "what is there in this world that makes
living worth while?"  Death thought about it. CATS, he said eventually, CATS
ARE NICE.   -- Sourcery,  Terry Pratchett

rmiller@sbcs.sunysb.edu (Robert Miller) (07/26/90)

I'm working on my first Macintosh application, and I'm unclear about
several things.  There will be two windows, one of them with a TextEdit
record and another one with graphics.

1.  I would like to store the graphics in a PicHandle for easy updating.
What is the effect of calling DrawPicture when there is a picture definition
open?  Will it transfer the code of one picture to another picture?  Or
will the call of DrawPicture be encoded into the picture?  

2.  I would like to keep the viewRect in the TextEdit record large 
enough so that no lines wrap to the next line.  That is, each line ends
with an end-of-line character.  Would calculating the length of the longest
line be a problem?

3.  Is there a straightforward way of printing a Picture or a TextEdit 
record?

I apologize if these questions are too simple, but sometimes it is
very hard to know where to look, even if supposedly everything is spelled
out in Inside Macintosh.

Thanks,

Robert
rmiller@sbcs.sunysb.edu

minow@mountn.dec.com (Martin Minow) (07/27/90)

In article <1990Jul25.192329.11315@sbcs.sunysb.edu> rmiller@sbcs.sunysb.edu
(Robert Miller) writes:

>1.  I would like to store the graphics in a PicHandle for easy updating.
>What is the effect of calling DrawPicture when there is a picture definition
>open? 

Dunno.  You might consider keeping an offscreen GrafPort with a shadow
of the graphics.  Then, you code would be, roughly,
	draw into the offscreen grafport.
	Inval[Rect/Region] the boundaries of the drawing on the screen.
Now, your update event handles all the drawing.  The update event is
trivial: CopyBits from the offscreen port onto the screen port.  (You
do roughly the same thing for color.)

>2.  I would like to keep the viewRect in the TextEdit record large 
>enough so that no lines wrap to the next line.  That is, each line ends
>with an end-of-line character.  Would calculating the length of the longest
>line be a problem?

Look at the definition of crOnly in the TextEdit record.

Calculating the width of a piece of text is messy, since you need to
deal with styles and international (text direction) issues.  Look at
the TextEdit stuff in Inside Mac V for a start.  Also, look at the
Script Manager documentation (in the Sumex or apple.com archives?).
If you "know" the text is old-style, you can just get pointers to
the start and finish and call the Quickdraw measure routine TextWidth.

>3.  Is there a straightforward way of printing a Picture or a TextEdit 
>record?

Yes.  Rich Siegel posted a generic print manager handler a few months
ago.  Try to find it in the archives.  It is very nice.  Basically,
you have to create a print task (straightforward: just follow the code
in Inside Mac) and, for each page, just draw the page as if you were
responding to an update event.  I.e. your updateEvt handler is, more or less:
	GetPort(&savePort);
	SetPort(theWindow);
	BeginUpdate(theWindow);
	EraseRect(&theWindow->portRect);
	draw_everything(theWindow);
	EndUpdate(theWindow);
	SetPort(savePort);

To print the drawing, just call draw_everything() with the print port.

>I apologize if these questions are too simple, but sometimes it is
>very hard to know where to look, even if supposedly everything is spelled
>out in Inside Macintosh.

No problem, and they're not quite as simple as you might imagine.
(Besides, I didn't really answer them. :-)

Martin Minow
minow@bolt.enet.dec.com