[comp.windows.open-look] canvas repaint, canvas resize

jung@autarch.acsu.buffalo.edu (alexander w jung) (03/13/91)

Hi!
I recently got into XView programming and tried the program line.c from the
O'Reilly book. The first thing that I had problems with was that the repaint
routine is only called when the window becomes larger after a resizing.
Therefore no redraw is done when parts of the canvas get hidden. This seems
efficiant when another window covers the canvas, but in this case its more or
less kind of a bug (or is there a way to enable this?).
  To get around this I attached a resize callback function to the canvas, which
gets called also when the canvas get smaller after a resize. At the end of
this callback I wanted to call the repaint function indirectly by generating
a repaint event for this canvas. *Can anybody explain me how to do this?*
The only way in which I got it working was to get all the arguments needed
for the repaint callback in the resize callback function and call it directly
from there. (not what I would call a good solution, but it works)

Yours
        Alexander

P.S.: I'm doing this on a SUN SLC, SUN OS 4.1, OpenWindows 2.0


----------------------------------------------------------
Alexander Jung (temporary at Buffalo, N.Y.)
jung@einstein.physics.buffalo.edu
----------------------------------------------------------
Famous last words:
   1) "Don't worry, I can handle it."
   2) "You and what army?"
   3) "If you were as smart as you think you are, you wouldn't be
       a cop." 

dmaustin@vivid.sun.com (Darren Austin) (03/13/91)

In article <64835@eerie.acsu.Buffalo.EDU> jung@autarch.acsu.buffalo.edu (alexander w jung) writes:
> Hi!

Howdy!

> I recently got into XView programming and tried the program line.c from the
> O'Reilly book. The first thing that I had problems with was that the repaint
> routine is only called when the window becomes larger after a resizing.
> Therefore no redraw is done when parts of the canvas get hidden. This seems
> efficiant when another window covers the canvas, but in this case its more or
> less kind of a bug (or is there a way to enable this?).

This is the ever present "canvas bit gravity" problem.  You need
to add CANVAS_FIXED_IMAGE, TRUE to the creation of the canvas.
This will make the canvas package to set the bit gravity of the
paint window(s) to ForgetGravity which will cause repaint events
when the canvas is resized (either smaller or larger).

Hope this helps,
--Darren
--
Darren Austin                         |  Actually, it's a buck and a quarter
Windows and Graphics Software	      |  staff, but I'm not going to tell
Sun Microsystems, Mountain View       |  *him* that.
dmaustin@sun.com	              |