[comp.sys.mac.programmer] Graphic window from MPW tool

mkb@ROVER.RI.CMU.EDU (Mike Blackwell) (04/06/88)

I remember seeing an answer to this once, but I can no longer find it...

I would like to write an MPW tool type program which opens a window and
draws some simple line graphics, something like a plotting program. I'd like
it to be an MPW tool, so I can use stdio, IO redirection, and good things
like that. What I need to know are what toolbox init routines should and
shouldn't be called, and anything else that might be non-obvious. If you
have a code fragment, I'd really appreciate it!

		thanks, Mike Blackwell

		mkb@rover.ri.cmu.edu		412-268-8830

gustav@swanee.OZ (Gustav) (04/09/88)

in article <1330@PT.CS.CMU.EDU>, mkb@ROVER.RI.CMU.EDU (Mike Blackwell) says:
> 
> I would like to write an MPW tool type program which opens a window and
> draws some simple line graphics, something like a plotting program. I'd like
> it to be an MPW tool, so I can use stdio, IO redirection, and good things
> like that. What I need to know are what toolbox init routines should and
> shouldn't be called, and anything else that might be non-obvious. 
>
There is a mention in MPW 2.0 manual to the effect that this aspect is
untested. I tried some simple graphics, but without calling windows
and it was OK. But then trying to combine windows with graphics blew
the whole thing to pieces like supernova. Unless this part of MPW is
polished out and working properly it cannot be called a finished
commercial product.

dan@Apple.COM (Dan Allen) (04/13/88)

As a co-creator of the MPW Shell, I would like to set the graphical tool
controversy to rest.  Here is the scoop:

a)	Graphics instructions in MPW Tools are perfectly harmless.  They
work fine, as long as InitGraf(@thePort) is done right.  Since an MPW
Tool has its own A5 World, it has its own set of QuickDraw globals and
can draw to its heart's content.

b)	Where to draw?  Well, a tool can draw anywhere it likes to I
suppose, but it SHOULD draw in its own window, obviously.

c)	Tools & Windows.  A tool can have its own window.  MPW 2.0 ships
several tools which have their own windows, including Commando,
GetFileName, etc.  MPW Tool windows must be MODAL dialogs, however, to
work right currently.  You can also have nested Modal dialogs.

d)	Tools & Events.  Here is the crux of the problem.  Tools can
have their own MainEventLoop while in a ModalDialog, but tools cannot
currently have their own Modeless windows.  Why?  Well, the MPW Shell
currently does not have a good info passing mechanism for passing events
to tools that the Shell does not understand.  Such a mechanism is needed
in order to put up Modeless windows.

Remember that since MPW Tools are guests in the MPW Shell's heap that
they should not initialize the Window Manager or Menu Manager since they
are already up and working.

The warnings in the MPW 2.0 manual about graphical tools should have
been warnings about tools having Modeless windows.  As long as you can
constrain your tools to one or more Modal dialogs, then everything
should be fine.  To get an idea about what can be done, take a look at
Commando.

If you have more questions about MPW Tools and graphics, just ask.

Dan Allen
Software Explorer
Apple Computer