Allow selection update interval to be variable.
We use this to dynamically adjust scroll speed in Calc.
This commit is contained in:
parent
96718f9566
commit
854b014960
2 changed files with 37 additions and 5 deletions
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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: */
|
||||
|
|
Loading…
Reference in a new issue