Oberon Community Platform Forum
December 12, 2019, 09:47:39 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to update BufferWindow display  (Read 5164 times)
Pat
Jr. Member
**
Posts: 69


« 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
Logged
BohdanT
Sr. Member
****
Posts: 271


Life is difficult, but fortunately is short!


WWW
« Reply #1 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
« Last Edit: March 27, 2009, 04:06:02 PM by BohdanT » Logged
tfrey
Newbie
*
Posts: 13


« Reply #2 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.
Logged
Pat
Jr. Member
**
Posts: 69


« Reply #3 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 ?
Logged
tfrey
Newbie
*
Posts: 13


« Reply #4 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.
Logged
Pat
Jr. Member
**
Posts: 69


« Reply #5 on: March 29, 2009, 08:27:49 PM »

Invalidate(WMRectangles.MakeRect(0, 0, GetWidth(), GetHeight()));
instead of
Invalidate(bounds);

that helped - thanks Thomas
Pat
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!