summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorLuke Dixon <6b8b4567@gmail.com>2010-11-14 21:56:24 +0000
committerJonas Finnemann Jensen <jopsen@gmail.com>2010-11-15 17:35:11 +0100
commitba00765e6bbcbca6bb53a705e6cb041c04502bda (patch)
tree35b5d0fe68b3cbfc1918c8a8e5c7ef9f540c9496 /starmath
parent829beed1564e4da2be034fbf58204b0c32311712 (diff)
Blinking caret for visual formula editor.
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/view.hxx8
-rw-r--r--starmath/source/view.cxx44
2 files changed, 50 insertions, 2 deletions
diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx
index 063d6b08dd11..ff2b6b226ba9 100644
--- a/starmath/inc/view.hxx
+++ b/starmath/inc/view.hxx
@@ -35,6 +35,7 @@
#include <sfx2/shell.hxx>
#include <sfx2/viewfac.hxx>
#include <sfx2/viewfrm.hxx>
+#include <vcl/timer.hxx>
#include <svtools/colorcfg.hxx>
#include "edit.hxx"
#include "node.hxx"
@@ -56,6 +57,8 @@ class SmGraphicWindow : public ScrollableWindow
// old style editing pieces
Rectangle aCursorRect;
bool bIsCursorVisible;
+
+ AutoTimer aCaretBlinkTimer;
public:
bool IsCursorVisible() const { return bIsCursorVisible; }
void ShowCursor(bool bShow);
@@ -88,7 +91,10 @@ protected:
private:
void RepaintViewShellDoc();
-
+ DECL_LINK(CaretBlinkTimerHdl, AutoTimer *);
+ void CaretBlinkInit();
+ void CaretBlinkStart();
+ void CaretBlinkStop();
public:
SmGraphicWindow(SmViewShell* pShell);
~SmGraphicWindow();
diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx
index 8e4068e6ebc5..87edffcbcedc 100644
--- a/starmath/source/view.cxx
+++ b/starmath/source/view.cxx
@@ -115,6 +115,8 @@ SmGraphicWindow::SmGraphicWindow(SmViewShell* pShell):
SetHelpId(HID_SMA_WIN_DOCUMENT);
SetUniqueId(HID_SMA_WIN_DOCUMENT);
+
+ CaretBlinkInit();
}
SmGraphicWindow::~SmGraphicWindow()
@@ -123,6 +125,7 @@ SmGraphicWindow::~SmGraphicWindow()
pAccessible->ClearWin(); // make Accessible defunctional
// Note: memory for pAccessible will be freed when the reference
// xAccessible is released.
+ CaretBlinkStop();
}
void SmGraphicWindow::StateChanged( StateChangedType eType )
@@ -221,6 +224,7 @@ void SmGraphicWindow::GetFocus()
//Let view shell know what insertions should be done in visual editor
pViewShell->SetInsertIntoEditWindow(false);
SetIsCursorVisible(true);
+ CaretBlinkStart();
RepaintViewShellDoc();
}
@@ -237,7 +241,8 @@ void SmGraphicWindow::LoseFocus()
}
if (!IsInlineEditEnabled())
return;
- SetIsCursorVisible(FALSE);
+ SetIsCursorVisible(false);
+ CaretBlinkStop();
RepaintViewShellDoc();
}
@@ -247,6 +252,39 @@ void SmGraphicWindow::RepaintViewShellDoc()
rDoc.Repaint();
}
+IMPL_LINK( SmGraphicWindow, CaretBlinkTimerHdl, AutoTimer *, EMPTYARG )
+{
+ if (IsCursorVisible())
+ SetIsCursorVisible(false);
+ else
+ SetIsCursorVisible(true);
+
+ RepaintViewShellDoc();
+
+ return 0;
+}
+
+void SmGraphicWindow::CaretBlinkInit()
+{
+ aCaretBlinkTimer.SetTimeoutHdl(LINK(this, SmGraphicWindow, CaretBlinkTimerHdl));
+ aCaretBlinkTimer.SetTimeout( ScrollableWindow::GetSettings().GetStyleSettings().GetCursorBlinkTime() );
+}
+
+void SmGraphicWindow::CaretBlinkStart()
+{
+ if (!IsInlineEditEnabled())
+ return;
+ if ( aCaretBlinkTimer.GetTimeout() != STYLE_CURSOR_NOBLINKTIME )
+ aCaretBlinkTimer.Start();
+}
+
+void SmGraphicWindow::CaretBlinkStop()
+{
+ if (!IsInlineEditEnabled())
+ return;
+ aCaretBlinkTimer.Stop();
+}
+
void SmGraphicWindow::ShowCursor(bool bShow)
// shows or hides the formula-cursor depending on 'bShow' is true or not
{
@@ -475,6 +513,10 @@ void SmGraphicWindow::KeyInput(const KeyEvent& rKEvt)
}
}
}
+ CaretBlinkStop();
+ CaretBlinkStart();
+ SetIsCursorVisible(true);
+ RepaintViewShellDoc();
}