graphics in panels--event procedure

Raymond Kreisel mond at sun.com
Thu Mar 23 19:22:41 AEST 1989


>I am trying to draw into a panel, and am having some difficulties.
>But, the panel package sucks up the WIN_REPAINT
>event before I can get to it...  So, it never gets to my event procedure
>with a WIN_REPAINT event

If you set a event procedure for the panel it will NOT get called when a
WIN_REPAINT happens because of a bug in the panel package. In order to put
graphics on a panel and have them repainted, you MUST set up a REPAINT
interposer. The following code shows how to do this.

	ray

 Ray Kreisel
 UUCP: sun!mond                               ARPA-Internet: mond at sun.com
__________

/*
 * Compile: cc -g -o zzz zzz.c -lsuntool -lsunwindow -lpixrect 
 */

#include <suntool/sunview.h>
#include <suntool/panel.h>

Frame           base_frame0;
Panel           panel0;

Initialize_Windows(argcp, argv)
int *argcp;
char **argv;
{

   base_frame0 = window_create(NULL, FRAME,
        WIN_X, 525,
        WIN_Y, 0,
        WIN_WIDTH, 500,
        WIN_HEIGHT, 160,
        FRAME_LABEL, "Tool",
        FRAME_ARGC_PTR_ARGV, argcp, argv,
        0);

   panel0 = window_create(base_frame0, PANEL,
        WIN_X, 0,
        WIN_Y, 0,
        WIN_WIDTH, 490,
        WIN_HEIGHT, 138,
        0);

}

my_inter(panel,event,arg,type)
Panel                   panel;
Event                   *event;
Notify_arg              arg;
Notify_event_type       type;
{
Notify_value    value;
Pixwin          *panel_pw;

        value = notify_next_event_func(panel,event,arg,type);
        if (event_action(event) == WIN_REPAINT)
            {
                printf("got a repaint!!!\n");
                panel_pw = (Pixwin *)window_get(panel,WIN_PIXWIN);
                pw_vector(panel_pw,0,0,300,300,PIX_SRC,1);
            }
        return(value);
}

main(argc, argv)
int             argc;
char            **argv;
{
        Initialize_Windows(&argc,argv);
        notify_interpose_event_func(panel0, my_inter,NOTIFY_SAFE);
        window_main_loop(base_frame0);
}



More information about the Comp.sys.sun mailing list