[comp.sys.mac.programmer] writing to a window without selecting it.

jmidili@hub.cs.jmu.edu (jeff midili) (04/09/91)

Lots of programs like MacDraw, MacDraft, etc have a small window
seperate of the main image window that displays the x,y coordinates
of the mouse pointer withen the image.  I have written a program
that displays a pix image, and now I want to add the small window that
will display the x,y coordinates of the mouse when it is in the 
window.  I can do it now, but only by selecting the coordwindow during
each NULL event and drawstringing the coordinates in the coordwindow.
The problem with this is that for each NULL event I Select the coord-
window, draw in it, and then Select my image window.  This creates
unsightly flickering in each window.  

Is there another way to do this without getting into assembly?  I know
that the NIH Image Processing software package does just what I want
to do, but it is writtten in assembly.

I really appreciate any help I can get on this!

jeff midili

jmidili@hub.cs.jmu.edu

gourdol@imag.imag.fr (Gourdol Arnaud) (04/09/91)

In article <1991Apr9.034248.6761@hub.cs.jmu.edu> jmidili@hub.cs.jmu.edu (jeff midili) writes:
>Lots of programs like MacDraw, MacDraft, etc have a small window
>seperate of the main image window that displays the x,y coordinates
>of the mouse pointer withen the image.  I have written a program
>that displays a pix image, and now I want to add the small window that
>will display the x,y coordinates of the mouse when it is in the 
>window.  I can do it now, but only by selecting the coordwindow during
>each NULL event and drawstringing the coordinates in the coordwindow.
>The problem with this is that for each NULL event I Select the coord-
>window, draw in it, and then Select my image window.  This creates
>unsightly flickering in each window.  

Don't select the window, just switch the grafPorts:

SetPort(coordWindow);
DrawString(...);
SetPort(mainWindow);

Arno.

-- 
   /======================//==========================================/
  / Arnaud Gourdol.      // On the Netland:         Gourdol@imag.fr  /
 /                      // Via AppleLink: Gourdol@imag.fr@INTERNET# /
/======================//==========================================/

captkidd@athena.mit.edu (Ivan Cavero Belaunde) (04/10/91)

In article <1991Apr9.034248.6761@hub.cs.jmu.edu> jmidili@hub.cs.jmu.edu (jeff midili) writes:
>Lots of programs like MacDraw, MacDraft, etc have a small window
>seperate of the main image window that displays the x,y coordinates
>of the mouse pointer withen the image.  I have written a program
>that displays a pix image, and now I want to add the small window that
>will display the x,y coordinates of the mouse when it is in the 
>window.  I can do it now, but only by selecting the coordwindow during
>each NULL event and drawstringing the coordinates in the coordwindow.
>The problem with this is that for each NULL event I Select the coord-
>window, draw in it, and then Select my image window.  This creates
>unsightly flickering in each window.  

If what you mean by "selecting" the window is calling SelectWindow on it,
(thereby bringing it to the front) you don't have to do that. You can just do:

	oldPort = GetPort();
	SetPort (myCoordWindow);
	DrawMyStuff ();
	SetPort (oldPort);

QD takes care of all the clipping and stuff for you.

-Ivan Cavero Belaunde
Visualist
Digital Video Applications Corp. (DiVA)
Internet: captkidd@ATHENA.MIT.EDU

chou@steelhead.cs.washington.edu (Pai Hsiang Chou) (04/10/91)

In article <1991Apr9.182240.9074@athena.mit.edu> captkidd@athena.mit.edu (Ivan Cavero Belaunde) writes:

>If what you mean by "selecting" the window is calling SelectWindow on it,
>(thereby bringing it to the front) you don't have to do that. You can just do:
>
>	oldPort = GetPort();

I think GetPort() is a procedure, not a function (i.e. has no return value).
The correct syntax is

	GetPort(&oldPort);

>	SetPort (myCoordWindow);
>	DrawMyStuff ();
>	SetPort (oldPort);
>
>QD takes care of all the clipping and stuff for you.