[Libreoffice-commits] .: vcl/inc vcl/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Dec 20 22:07:59 PST 2010
vcl/inc/vcl/seleng.hxx | 8 +++++++-
vcl/source/window/seleng.cxx | 34 ++++++++++++++++++++++++++++++----
2 files changed, 37 insertions(+), 5 deletions(-)
New commits:
commit 85c4c716082f25556a9b1ab3fe633f40269ac902
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Dec 21 01:06:22 2010 -0500
Allow selection update interval to be variable.
We use this to dynamically adjust scroll speed in Calc.
diff --git a/vcl/inc/vcl/seleng.hxx b/vcl/inc/vcl/seleng.hxx
index bcbe3a2..35b3270 100644
--- a/vcl/inc/vcl/seleng.hxx
+++ b/vcl/inc/vcl/seleng.hxx
@@ -39,6 +39,8 @@ class CommandEvent;
// Timerticks
#define SELENG_DRAGDROP_TIMEOUT 400
#define SELENG_AUTOREPEAT_INTERVAL 50
+#define SELENG_AUTOREPEAT_INTERVAL_MIN 25
+#define SELENG_AUTOREPEAT_INTERVAL_MAX 300
enum SelectionMode { NO_SELECTION, SINGLE_SELECTION, RANGE_SELECTION, MULTIPLE_SELECTION };
@@ -88,6 +90,7 @@ private:
Timer aWTimer; // erzeugt kuenstliche Mouse-Moves
MouseEvent aLastMove;
SelectionMode eSelMode;
+ ULONG nUpdateInterval;
// Stufigkeit fuer Mausbewegungen waehrend einer Selektion
USHORT nMouseSensitivity;
USHORT nLockedMods;
@@ -99,7 +102,8 @@ private:
public:
SelectionEngine( Window* pWindow,
- FunctionSet* pFunctions = NULL );
+ FunctionSet* pFunctions = NULL,
+ ULONG nAutoRepeatInterval = SELENG_AUTOREPEAT_INTERVAL );
~SelectionEngine();
// TRUE: Event wurde von Selection-Engine verarbeitet.
@@ -158,6 +162,8 @@ public:
BOOL HasAnchor() const;
void SetAnchor( BOOL bAnchor );
+ void SetUpdateInterval( ULONG nInterval );
+
// wird im Ctor eingeschaltet
void ExpandSelectionOnMouseMove( BOOL bExpand = TRUE )
{
diff --git a/vcl/source/window/seleng.cxx b/vcl/source/window/seleng.cxx
index 46f6faf..39e3362 100644
--- a/vcl/source/window/seleng.cxx
+++ b/vcl/source/window/seleng.cxx
@@ -56,8 +56,10 @@ inline BOOL SelectionEngine::ShouldDeselect( BOOL bModifierKey1 ) const
|*
*************************************************************************/
-SelectionEngine::SelectionEngine( Window* pWindow, FunctionSet* pFuncSet ) :
- pWin( pWindow )
+SelectionEngine::SelectionEngine( Window* pWindow, FunctionSet* pFuncSet,
+ ULONG nAutoRepeatInterval ) :
+ pWin( pWindow ),
+ nUpdateInterval( nAutoRepeatInterval )
{
eSelMode = SINGLE_SELECTION;
pFunctionSet = pFuncSet;
@@ -65,7 +67,7 @@ SelectionEngine::SelectionEngine( Window* pWindow, FunctionSet* pFuncSet ) :
nLockedMods = 0;
aWTimer.SetTimeoutHdl( LINK( this, SelectionEngine, ImpWatchDog ) );
- aWTimer.SetTimeout( SELENG_AUTOREPEAT_INTERVAL );
+ aWTimer.SetTimeout( nUpdateInterval );
}
/*************************************************************************
@@ -405,7 +407,7 @@ BOOL SelectionEngine::SelMouseMove( const MouseEvent& rMEvt )
if( aWTimer.IsActive() && !aArea.IsInside( rMEvt.GetPosPixel() ))
return TRUE;
-
+ aWTimer.SetTimeout( nUpdateInterval );
aWTimer.Start();
if ( eSelMode != SINGLE_SELECTION )
{
@@ -502,4 +504,28 @@ void SelectionEngine::Command( const CommandEvent& rCEvt )
}
}
+void SelectionEngine::SetUpdateInterval( ULONG nInterval )
+{
+ if (nInterval < SELENG_AUTOREPEAT_INTERVAL_MIN)
+ // Set a lower threshold. On Windows, setting this value too low
+ // would cause selection to get updated indefinitely.
+ nInterval = SELENG_AUTOREPEAT_INTERVAL_MIN;
+
+ if (nUpdateInterval == nInterval)
+ // no update needed.
+ return;
+
+ if (aWTimer.IsActive())
+ {
+ // reset the timer right away on interval change.
+ aWTimer.Stop();
+ aWTimer.SetTimeout(nInterval);
+ aWTimer.Start();
+ }
+ else
+ aWTimer.SetTimeout(nInterval);
+
+ nUpdateInterval = nInterval;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list