Oberon Community Platform Forum

General => General Discussion => Topic started by: Pat on March 27, 2009, 02:36:47 PM



Title: How to update BufferWindow display
Post by: Pat on March 27, 2009, 02:36:47 PM
Hi
I have a problem in updating a bufferWindow:

TYPE Window*= OBJECT (WMWindowManager.BufferWindow)
   
   PROCEDURE &Initialize*(img:Raster.Image; CONST title:ARRAY OF CHAR);
   BEGIN
      Init(img.width,img.height, TRUE);
      SELF.img:=img;
      SetTitle(Strings.NewString(title));
      manager:=WM.GetDefaultManager();
      Draw(canvas,img.width,img.height,0);
   END Initialize;
   
   PROCEDURE ModifyImage*;
   BEGIN
      RandomPaint(img); (*do some painting in image after it has appeared on-screen. Each call paints differently*)
      Draw(canvas,img.width,img.height,0);
      Invalidate(bounds);
   END ModifyImage;

   PROCEDURE ToScreen*;
   BEGIN
      WM.ExtAddWindow(SELF, InsertPosX, InsertPosY,
            {WM.FlagFrame,WM.FlagClose,WM.FlagMinimize});
   END ToScreen;
END Window;

Call:
...
NEW(w,someimage,"demoimage");
w.ToScreen;
FOR i:=0 TO something DO
      w.ModifyImage;
      WaitALittle;
END;
...

Why don't I see the modifications I perform in the loop - have I omitted a call to an "update" procedure ?
Thanks for a hint...
Pat


Title: Re: How to update BufferWindow display
Post by: BohdanT on March 27, 2009, 04:03:55 PM
Call Swap(); method.
Before Invalidate.
Example http://www.ocp.inf.ethz.ch/forum/index.php?action=dlattach;topic=88.0;attach=127 (http://www.ocp.inf.ethz.ch/forum/index.php?action=dlattach;topic=88.0;attach=127)


Title: Re: How to update BufferWindow display
Post by: tfrey on March 27, 2009, 05:10:45 PM
Swap is only needed for double buffered windows. Did you override Draw ? (Should not be needed for BufferWindow). Draw is called by the window manager after the application called Invalidate. Maybe you just need to remove the calls to draw. If it does not work then, please attach the whole example.


Title: Re: How to update BufferWindow display
Post by: Pat on March 27, 2009, 06:01:30 PM
In my program, I am almost mirroring what is done in WMScribble.Mod .
The difference is that I do not paint using the mouse, but by program command; thus, the window does not get mouse events.
In addition, I am painting by program on several windows concurrently - thus, windows do not necessarily have the focus.
However, as soon as I move the mouse over the windows, updating of the are touched by the mouse are updated. Thus, I conclude that some "update" message is missing when drawing in a BufferWindow by program.
How does the mouse trigger the update of a window region ?


Title: Re: How to update BufferWindow display
Post by: tfrey on March 27, 2009, 06:29:34 PM
In WM Scribble the touched area is updated by the line :
Invalidate(WMRectangles.MakeRect(Utilities.Min(lx, x), Utilities.Min(ly, y), Utilities.Max(lx, x) + 1, Utilities.Max(ly, y) + 1))

For a buffered window the refreshing of the mouse cursor image causes the update. (This does not happen in the double-buffered case)

I missed that you use bounds for the invalidation. Bounds is in WindowManager coordinates, but Invalidate needs window coordinates.

Replace Invalidate(bounds) by Invalidate(WMRectangles.MakeRect(0, 0, GetWidth(), GetHeight())); in your code and remove the calls to Draw. That should fix it.


Title: Re: How to update BufferWindow display
Post by: Pat on March 29, 2009, 08:27:49 PM
Invalidate(WMRectangles.MakeRect(0, 0, GetWidth(), GetHeight()));
instead of
Invalidate(bounds);

that helped - thanks Thomas
Pat