diff --git starmath/inc/view.hxx starmath/inc/view.hxx index eab2444..b1c30e8 100644 --- starmath/inc/view.hxx +++ starmath/inc/view.hxx @@ -35,6 +35,7 @@ #include #include #include +#include #include "edit.hxx" #include "node.hxx" #include "accessibility.hxx" @@ -60,6 +61,8 @@ class SmGraphicWindow : public ScrollableWindow USHORT nZoom; short nModifyCount; BOOL bIsCursorVisible; + /** Buffer for drawing formula to (For double buffering) */ + VirtualDevice vDev; protected: void SetFormulaDrawPos(const Point &rPos) { aFormulaDrawPos = rPos; } @@ -69,6 +72,8 @@ protected: void SetCursor(const Rectangle &rRect); virtual void DataChanged( const DataChangedEvent& ); + /** Paint formula to pDev */ + virtual void PrePaint(); virtual void Paint(const Rectangle&); virtual void KeyInput(const KeyEvent& rKEvt); virtual void Command(const CommandEvent& rCEvt); diff --git starmath/source/view.cxx starmath/source/view.cxx index f00036f..fd0f770 100644 --- starmath/source/view.cxx +++ starmath/source/view.cxx @@ -99,7 +99,8 @@ SmGraphicWindow::SmGraphicWindow(SmViewShell* pShell): pAccessible(0), pViewShell(pShell), nZoom(100), - bIsCursorVisible(FALSE) + bIsCursorVisible(FALSE), + vDev(*this, 0, 0) { // docking windows are usually hidden (often already done in the // resource) and will be shown by the sfx framework. @@ -211,6 +212,7 @@ void SmGraphicWindow::MouseButtonDown(const MouseEvent& rMEvt) pEdit->GrabFocus(); } } + GrabFocus(); //So that we can get KeyInput } void SmGraphicWindow::GetFocus() @@ -302,17 +304,27 @@ const SmNode * SmGraphicWindow::SetCursorPos(USHORT nRow, USHORT nCol) return pNode; } - -void SmGraphicWindow::Paint(const Rectangle&) +void SmGraphicWindow::PrePaint() { DBG_ASSERT(pViewShell, "Sm : NULL pointer"); + Size size = pViewShell->GetDoc()->GetFormulaTree()->GetSize(); + vDev.SetOutputSize(size); + SmDocShell &rDoc = *pViewShell->GetDoc(); Point aPoint; - rDoc.Draw(*this, aPoint); //! modifies aPoint to be the topleft + rDoc.Draw(vDev, aPoint); //! modifies aPoint to be the topleft //! corner of the formula SetFormulaDrawPos(aPoint); +} + +void SmGraphicWindow::Paint(const Rectangle&) +{ + DBG_ASSERT(pViewShell, "Sm : NULL pointer"); + + Size size = pViewShell->GetDoc()->GetFormulaTree()->GetSize(); + DrawOutDev(Point(0,0), size, Point(0,0), size, vDev); SetIsCursorVisible(FALSE); // (old) cursor must be drawn again @@ -345,6 +357,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. }