[comp.windows.open-look] Panels and events

kbj@jupiter.risc.com (Ken Johnson) (11/09/90)

I have a base frame that contains a panel and three canvases.  The panel c
contains three buttons and four text items.  Basically everything works,
but, as always, I need improved functionality and I can't figure out how to 
do it. Here's what I have and then what I want.

1) One of the menuitem call back procedures launches a compute intensive 
procedure that calls three canvas repaint procedures every few seconds.
This takes about 100 times.  When in the compute routine the panel items
are dead - except that the 4 text tiems are updated by the compute
routine.

This scenario is OK most of the time.  Sometimes I want to interrupt the
compute routine - this is what the 'pause' button on the panel is supposed
to do.  The problem is that it is dead during the time the compute routine
is busy.  

Questions:

1) Is there a call I can once every few seconds from inside my compute
routine that will service the panel?  This is the approach the
Mac seems to take.

2) What is the story with the panel_repaint_procedure?

3) Do I have to handle events myself?  God, I hope not?

4) Should I fork the compute process and send it signals?

Lions and Tigers and Bears Oh my....  What is most conventional and intelligent
way to do this?

/* ------ Another question ------ */

Ah, for get this.  I'll deal with it later.....

Ken J.

Ken Johnson                             Phone: 805-373-4487
Rockwell International Science Center   Comnet: 273-4487
1049 Camino Dos Rios A-18               e-mail: kbj@risc.com
Thousand Oaks, CA 91360

       If enough data is collected
                     anything may be proven by statistical methods....

toone@Corp.Sun.COM (Nolan C. Toone) (11/10/90)

>  1) Is there a call I can once every few seconds from inside my compute
>  routine that will service the panel?  This is the approach the
>  Mac seems to take.
>
> 4) Should I fork the compute process and send it signals?

I am assuming you are using xview in which case you can use
notify_dispatch routine in you compute routine to handle the
events that come in.  Your Pause/interrupt routine could then
set a flag that could then be checked when you are in the
compute routine.


		Regards,

     /\
    \\ \	Nolan C. Toone, Catalyst Tech Support
   \ \\ /	Sun Microsystems 
  / \/ / / 	MailStop PAL1-316
 / /   \//\ 	2550 Garcia Avenue
 \//\   / / 	Mountain View, California  94043
  / / /\ /  	
   / \\ \	Phone:  415-336-0391
    \ \\ 	EMail:	toone@Corp.Sun.Com
     \/

jmck@Eng.Sun.COM (John McKernan) (11/10/90)

>I am assuming you are using xview in which case you can use
>notify_dispatch routine in you compute routine to handle the
>events that come in.  Your Pause/interrupt routine could then
>set a flag that could then be checked when you are in the
>compute routine.
>    \\ \	Nolan C. Toone, Catalyst Tech Support

Note that if you use notify dispatch, you can't use xv main loop.
Also you can't call notify dispatch from a notify proc. An alternative
is to do your drawing in an itimer function which is called every half
second, or any other interval. Here's some example code for that
approach:

#include <sys/time.h>

struct itimerval delay = {0,0,0,0};

void my_wait( seconds, funcptr )
   int seconds;
   Notify_func (*funcptr) ();
{
   delay.it_interval.tv_sec = seconds;
   delay.it_value.tv_sec = seconds;
   notify_set_itimer_func( frame, funcptr, ITIMER_REAL, &delay, NULL );
}

John McKernan.                                                     
Windows and Graphics Software, Sun Microsystems.                  jmck@sun.com