Hi,

I'm working on creating a visual formula editor in OO.o Math for
Go-OO as part of Google Summer of Code 2010. So far it's going pretty
good, but run into some minor flickering issues when redrawing often,
which is why I'm posting here...

In OO.o Math I need to redraw then entire formula whenever the the
caret moves or the formula is changed. The widget is drawn in
SmGraphicWindow::Paint. To redraw the widget I call Invalidate().

Now I would expect that some kind of double buffering to happen
around the call to SmGraphicWindow::Paint. But as far as I can see
the widget (SmGraphicWindow) is at times completely blank, this is
very brief, but enough to be visible and course flickering.

How is Window::Paint supposed to be implemented to avoid flickering?
Is the drawing in Window::Paint double buffered? If not why? And how
should I implement double buffering?
 - I haven't found much in terms of documentation, so if there's any
please throw it at me...

If anybody wants to try it out (I doubt that's necessary) I've attached a
patch that makes it easy to reproduce the issue by clicking the formula
and hitting some keys.
The patch will make any key course the formula to be redrawn, so it's
easy to make it redraw as fast as it would if the user entered text...

The patch is against ooo320-m17 (with go-oo patches), but it's only
two lines show if it doesn't apply it's easy to copy-paste.

Anyway, I hope you can help me resolve this problem...

--
Regards Jonas Finnemann Jensen.
diff --git starmath/source/view.cxx starmath/source/view.cxx
index f00036f..a4e56ab 100644
--- starmath/source/view.cxx
+++ starmath/source/view.cxx
@@ -211,6 +211,7 @@ void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt)
             pEdit->GrabFocus();
         }
     }
+    GrabFocus();    //So that we can get KeyInput
 }
 
 void SmGraphicWindow::GetFocus()
@@ -345,6 +346,8 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
 {
     if (! (GetView() && GetView()->KeyInput(rKEvt)) )
         ScrollableWindow::KeyInput(rKEvt);
+    Invalidate(); //to simulate the required repaint at each caret movement or repaint 
+                  //that occurs when a character is entered and the formula changes.
 }
 
 
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@gsl.openoffice.org
For additional commands, e-mail: dev-h...@gsl.openoffice.org

Reply via email to