summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-12-29 10:08:13 +0200
committerNoel Grandin <noel@peralex.com>2015-01-06 10:59:42 +0200
commita48d8465c3f9f36a02fb3c6a79f5dbb5851174f7 (patch)
treebb73793ff3d7c18ecb6d3140e0010c0df12ccab7
parent64cccf36f26f6398906a0cc6fc48e76defbe057d (diff)
fdo#84938: convert SELENG_ #defines to 'enum class'
Change-Id: I200fc00958984577ced6d2df87c8e9647b43c809
-rw-r--r--include/vcl/seleng.hxx54
-rw-r--r--vcl/source/window/seleng.cxx106
2 files changed, 85 insertions, 75 deletions
diff --git a/include/vcl/seleng.hxx b/include/vcl/seleng.hxx
index d0da0e89148f..141a68690ac0 100644
--- a/include/vcl/seleng.hxx
+++ b/include/vcl/seleng.hxx
@@ -23,6 +23,7 @@
#include <vcl/dllapi.h>
#include <vcl/timer.hxx>
#include <vcl/event.hxx>
+#include <o3tl/typed_flags_set.hxx>
namespace vcl { class Window; }
class CommandEvent;
@@ -63,15 +64,20 @@ public:
// - SelectionEngine -
-
-#define SELENG_DRG_ENAB 0x0001
-#define SELENG_IN_SEL 0x0002
-#define SELENG_IN_ADD 0x0004
-#define SELENG_ADD_ALW 0x0008
-#define SELENG_HAS_ANCH 0x0020
-#define SELENG_CMDEVT 0x0040
-#define SELENG_WAIT_UPEVT 0x0080
-#define SELENG_EXPANDONMOVE 0x0100
+enum class SelectionEngineFlags {
+ DRG_ENAB = 0x0001,
+ IN_SEL = 0x0002,
+ IN_ADD = 0x0004,
+ ADD_ALW = 0x0008,
+ HAS_ANCH = 0x0020,
+ CMDEVT = 0x0040,
+ WAIT_UPEVT = 0x0080,
+ EXPANDONMOVE = 0x0100,
+};
+namespace o3tl
+{
+ template<> struct typed_flags<SelectionEngineFlags> : is_typed_flags<SelectionEngineFlags, 0x01ff> {};
+}
class VCL_DLLPUBLIC SelectionEngine
{
@@ -84,7 +90,7 @@ private:
SelectionMode eSelMode;
sal_uLong nUpdateInterval;
sal_uInt16 nLockedMods;
- sal_uInt16 nFlags;
+ SelectionEngineFlags nFlags;
DECL_DLLPRIVATE_LINK( ImpWatchDog, void* );
inline bool ShouldDeselect( bool bModifierKey1 ) const;
@@ -157,15 +163,15 @@ public:
void ExpandSelectionOnMouseMove( bool bExpand = true )
{
if( bExpand )
- nFlags |= SELENG_EXPANDONMOVE;
+ nFlags |= SelectionEngineFlags::EXPANDONMOVE;
else
- nFlags &= ~SELENG_EXPANDONMOVE;
+ nFlags &= ~SelectionEngineFlags::EXPANDONMOVE;
}
};
inline bool SelectionEngine::IsAddMode() const
{
- if ( nFlags & (SELENG_IN_ADD | SELENG_ADD_ALW) )
+ if ( nFlags & (SelectionEngineFlags::IN_ADD | SelectionEngineFlags::ADD_ALW) )
return true;
else
return false;
@@ -174,30 +180,30 @@ inline bool SelectionEngine::IsAddMode() const
inline void SelectionEngine::SetAddMode( bool bNewMode )
{
if ( bNewMode )
- nFlags |= SELENG_IN_ADD;
+ nFlags |= SelectionEngineFlags::IN_ADD;
else
- nFlags &= (~SELENG_IN_ADD);
+ nFlags &= (~SelectionEngineFlags::IN_ADD);
}
inline void SelectionEngine::EnableDrag( bool bOn )
{
if ( bOn )
- nFlags |= SELENG_DRG_ENAB;
+ nFlags |= SelectionEngineFlags::DRG_ENAB;
else
- nFlags &= (~SELENG_DRG_ENAB);
+ nFlags &= (~SelectionEngineFlags::DRG_ENAB);
}
inline void SelectionEngine::AddAlways( bool bOn )
{
if( bOn )
- nFlags |= SELENG_ADD_ALW;
+ nFlags |= SelectionEngineFlags::ADD_ALW;
else
- nFlags &= (~SELENG_ADD_ALW);
+ nFlags &= (~SelectionEngineFlags::ADD_ALW);
}
inline bool SelectionEngine::IsAlwaysAdding() const
{
- if ( nFlags & SELENG_ADD_ALW )
+ if ( nFlags & SelectionEngineFlags::ADD_ALW )
return true;
else
return false;
@@ -205,7 +211,7 @@ inline bool SelectionEngine::IsAlwaysAdding() const
inline bool SelectionEngine::IsInSelection() const
{
- if ( nFlags & SELENG_IN_SEL )
+ if ( nFlags & SelectionEngineFlags::IN_SEL )
return true;
else
return false;
@@ -213,7 +219,7 @@ inline bool SelectionEngine::IsInSelection() const
inline bool SelectionEngine::HasAnchor() const
{
- if ( nFlags & SELENG_HAS_ANCH )
+ if ( nFlags & SelectionEngineFlags::HAS_ANCH )
return true;
else
return false;
@@ -222,9 +228,9 @@ inline bool SelectionEngine::HasAnchor() const
inline void SelectionEngine::SetAnchor( bool bAnchor )
{
if ( bAnchor )
- nFlags |= SELENG_HAS_ANCH;
+ nFlags |= SelectionEngineFlags::HAS_ANCH;
else
- nFlags &= (~SELENG_HAS_ANCH);
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH);
}
#endif // INCLUDED_VCL_SELENG_HXX
diff --git a/vcl/source/window/seleng.cxx b/vcl/source/window/seleng.cxx
index b9aa184d761a..60567209e81f 100644
--- a/vcl/source/window/seleng.cxx
+++ b/vcl/source/window/seleng.cxx
@@ -39,7 +39,7 @@ SelectionEngine::SelectionEngine( vcl::Window* pWindow, FunctionSet* pFuncSet,
{
eSelMode = SINGLE_SELECTION;
pFunctionSet = pFuncSet;
- nFlags = SELENG_EXPANDONMOVE;
+ nFlags = SelectionEngineFlags::EXPANDONMOVE;
nLockedMods = 0;
aWTimer.SetTimeoutHdl( LINK( this, SelectionEngine, ImpWatchDog ) );
@@ -72,20 +72,20 @@ void SelectionEngine::CursorPosChanging( bool bShift, bool bMod1 )
{
if ( IsAddMode() )
{
- if ( !(nFlags & SELENG_HAS_ANCH) )
+ if ( !(nFlags & SelectionEngineFlags::HAS_ANCH) )
{
pFunctionSet->CreateAnchor();
- nFlags |= SELENG_HAS_ANCH;
+ nFlags |= SelectionEngineFlags::HAS_ANCH;
}
}
else
{
- if ( !(nFlags & SELENG_HAS_ANCH) )
+ if ( !(nFlags & SelectionEngineFlags::HAS_ANCH) )
{
if( ShouldDeselect( bMod1 ) )
pFunctionSet->DeselectAll();
pFunctionSet->CreateAnchor();
- nFlags |= SELENG_HAS_ANCH;
+ nFlags |= SelectionEngineFlags::HAS_ANCH;
}
}
}
@@ -93,11 +93,11 @@ void SelectionEngine::CursorPosChanging( bool bShift, bool bMod1 )
{
if ( IsAddMode() )
{
- if ( nFlags & SELENG_HAS_ANCH )
+ if ( nFlags & SelectionEngineFlags::HAS_ANCH )
{
// pFunctionSet->CreateCursor();
pFunctionSet->DestroyAnchor();
- nFlags &= (~SELENG_HAS_ANCH);
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH);
}
}
else
@@ -106,14 +106,14 @@ void SelectionEngine::CursorPosChanging( bool bShift, bool bMod1 )
pFunctionSet->DeselectAll();
else
pFunctionSet->DestroyAnchor();
- nFlags &= (~SELENG_HAS_ANCH);
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH);
}
}
}
bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
{
- nFlags &= (~SELENG_CMDEVT);
+ nFlags &= (~SelectionEngineFlags::CMDEVT);
if ( !pFunctionSet || !pWin || rMEvt.GetClicks() > 1 || rMEvt.IsRight() )
return false;
@@ -131,7 +131,7 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
if( !rMEvt.IsRight() )
{
pWin->CaptureMouse();
- nFlags |= SELENG_IN_SEL;
+ nFlags |= SelectionEngineFlags::IN_SEL;
}
else
{
@@ -143,11 +143,11 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
case 0: // KEY_NO_KEY
{
bool bSelAtPoint = pFunctionSet->IsSelectionAtPoint( aPos );
- nFlags &= (~SELENG_IN_ADD);
- if ( (nFlags & SELENG_DRG_ENAB) && bSelAtPoint )
+ nFlags &= (~SelectionEngineFlags::IN_ADD);
+ if ( (nFlags & SelectionEngineFlags::DRG_ENAB) && bSelAtPoint )
{
- nFlags |= SELENG_WAIT_UPEVT;
- nFlags &= ~(SELENG_IN_SEL);
+ nFlags |= SelectionEngineFlags::WAIT_UPEVT;
+ nFlags &= ~(SelectionEngineFlags::IN_SEL);
pWin->ReleaseMouse();
return true; // wait for STARTDRAG-Command-Event
}
@@ -157,12 +157,12 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
pFunctionSet->DeselectAll();
else
pFunctionSet->DestroyAnchor();
- nFlags &= (~SELENG_HAS_ANCH); // bHasAnchor = false;
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH); // bHasAnchor = false;
}
pFunctionSet->SetCursorAtPoint( aPos );
// special case Single-Selection, to enable simple Select+Drag
- if (eSelMode == SINGLE_SELECTION && (nFlags & SELENG_DRG_ENAB))
- nFlags |= SELENG_WAIT_UPEVT;
+ if (eSelMode == SINGLE_SELECTION && (nFlags & SelectionEngineFlags::DRG_ENAB))
+ nFlags |= SelectionEngineFlags::WAIT_UPEVT;
return true;
}
@@ -170,20 +170,20 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
if ( eSelMode == SINGLE_SELECTION )
{
pWin->ReleaseMouse();
- nFlags &= (~SELENG_IN_SEL);
+ nFlags &= (~SelectionEngineFlags::IN_SEL);
return false;
}
- if ( nFlags & SELENG_ADD_ALW )
- nFlags |= SELENG_IN_ADD;
+ if ( nFlags & SelectionEngineFlags::ADD_ALW )
+ nFlags |= SelectionEngineFlags::IN_ADD;
else
- nFlags &= (~SELENG_IN_ADD);
+ nFlags &= (~SelectionEngineFlags::IN_ADD);
- if( !(nFlags & SELENG_HAS_ANCH) )
+ if( !(nFlags & SelectionEngineFlags::HAS_ANCH) )
{
- if ( !(nFlags & SELENG_IN_ADD) )
+ if ( !(nFlags & SelectionEngineFlags::IN_ADD) )
pFunctionSet->DeselectAll();
pFunctionSet->CreateAnchor();
- nFlags |= SELENG_HAS_ANCH;
+ nFlags |= SelectionEngineFlags::HAS_ANCH;
}
pFunctionSet->SetCursorAtPoint( aPos );
return true;
@@ -192,15 +192,15 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
// allow Control only for Multi-Select
if ( eSelMode != MULTIPLE_SELECTION )
{
- nFlags &= (~SELENG_IN_SEL);
+ nFlags &= (~SelectionEngineFlags::IN_SEL);
pWin->ReleaseMouse();
return true; // skip Mouse-Click
}
- if ( nFlags & SELENG_HAS_ANCH )
+ if ( nFlags & SelectionEngineFlags::HAS_ANCH )
{
// pFunctionSet->CreateCursor();
pFunctionSet->DestroyAnchor();
- nFlags &= (~SELENG_HAS_ANCH);
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH);
}
if ( pFunctionSet->IsSelectionAtPoint( aPos ) )
{
@@ -217,14 +217,14 @@ bool SelectionEngine::SelMouseButtonDown( const MouseEvent& rMEvt )
if ( eSelMode != MULTIPLE_SELECTION )
{
pWin->ReleaseMouse();
- nFlags &= (~SELENG_IN_SEL);
+ nFlags &= (~SelectionEngineFlags::IN_SEL);
return false;
}
- nFlags |= SELENG_IN_ADD; //bIsInAddMode = true;
- if ( !(nFlags & SELENG_HAS_ANCH) )
+ nFlags |= SelectionEngineFlags::IN_ADD; //bIsInAddMode = true;
+ if ( !(nFlags & SelectionEngineFlags::HAS_ANCH) )
{
pFunctionSet->CreateAnchor();
- nFlags |= SELENG_HAS_ANCH;
+ nFlags |= SelectionEngineFlags::HAS_ANCH;
}
pFunctionSet->SetCursorAtPoint( aPos );
return true;
@@ -238,7 +238,8 @@ bool SelectionEngine::SelMouseButtonUp( const MouseEvent& rMEvt )
aWTimer.Stop();
if( !pFunctionSet || !pWin )
{
- nFlags &= ~(SELENG_CMDEVT | SELENG_WAIT_UPEVT | SELENG_IN_SEL);
+ const SelectionEngineFlags nMask = (SelectionEngineFlags::CMDEVT | SelectionEngineFlags::WAIT_UPEVT | SelectionEngineFlags::IN_SEL);
+ nFlags &= ~nMask;
return false;
}
@@ -247,7 +248,7 @@ bool SelectionEngine::SelMouseButtonUp( const MouseEvent& rMEvt )
ReleaseMouse();
}
- if( (nFlags & SELENG_WAIT_UPEVT) && !(nFlags & SELENG_CMDEVT) &&
+ if( (nFlags & SelectionEngineFlags::WAIT_UPEVT) && !(nFlags & SelectionEngineFlags::CMDEVT) &&
eSelMode != SINGLE_SELECTION)
{
// MouseButtonDown in Sel but no CommandEvent yet
@@ -258,21 +259,22 @@ bool SelectionEngine::SelMouseButtonUp( const MouseEvent& rMEvt )
if( !(nModifier & KEY_SHIFT) )
{
pFunctionSet->DestroyAnchor();
- nFlags &= (~SELENG_HAS_ANCH); // uncheck anchor
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH); // uncheck anchor
}
pFunctionSet->DeselectAtPoint( aLastMove.GetPosPixel() );
- nFlags &= (~SELENG_HAS_ANCH); // uncheck anchor
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH); // uncheck anchor
pFunctionSet->SetCursorAtPoint( aLastMove.GetPosPixel(), true );
}
else
{
pFunctionSet->DeselectAll();
- nFlags &= (~SELENG_HAS_ANCH); // uncheck anchor
+ nFlags &= (~SelectionEngineFlags::HAS_ANCH); // uncheck anchor
pFunctionSet->SetCursorAtPoint( aLastMove.GetPosPixel() );
}
}
- nFlags &= ~(SELENG_CMDEVT | SELENG_WAIT_UPEVT | SELENG_IN_SEL);
+ const SelectionEngineFlags nMask = (SelectionEngineFlags::CMDEVT | SelectionEngineFlags::WAIT_UPEVT | SelectionEngineFlags::IN_SEL);
+ nFlags &= ~nMask;
return true;
}
@@ -286,11 +288,11 @@ void SelectionEngine::ReleaseMouse()
bool SelectionEngine::SelMouseMove( const MouseEvent& rMEvt )
{
- if ( !pFunctionSet || !(nFlags & SELENG_IN_SEL) ||
- (nFlags & (SELENG_CMDEVT | SELENG_WAIT_UPEVT)) )
+ if ( !pFunctionSet || !(nFlags & SelectionEngineFlags::IN_SEL) ||
+ (nFlags & (SelectionEngineFlags::CMDEVT | SelectionEngineFlags::WAIT_UPEVT)) )
return false;
- if( !(nFlags & SELENG_EXPANDONMOVE) )
+ if( !(nFlags & SelectionEngineFlags::EXPANDONMOVE) )
return false; // wait for DragEvent!
aLastMove = rMEvt;
@@ -303,10 +305,10 @@ bool SelectionEngine::SelMouseMove( const MouseEvent& rMEvt )
aWTimer.Start();
if ( eSelMode != SINGLE_SELECTION )
{
- if ( !(nFlags & SELENG_HAS_ANCH) )
+ if ( !(nFlags & SelectionEngineFlags::HAS_ANCH) )
{
pFunctionSet->CreateAnchor();
- nFlags |= SELENG_HAS_ANCH;
+ nFlags |= SelectionEngineFlags::HAS_ANCH;
}
}
@@ -319,10 +321,10 @@ void SelectionEngine::SetWindow( vcl::Window* pNewWin )
{
if( pNewWin != pWin )
{
- if ( pWin && (nFlags & SELENG_IN_SEL) )
+ if ( pWin && (nFlags & SelectionEngineFlags::IN_SEL) )
pWin->ReleaseMouse();
pWin = pNewWin;
- if ( pWin && ( nFlags & SELENG_IN_SEL ) )
+ if ( pWin && ( nFlags & SelectionEngineFlags::IN_SEL ) )
pWin->CaptureMouse();
}
}
@@ -330,9 +332,10 @@ void SelectionEngine::SetWindow( vcl::Window* pNewWin )
void SelectionEngine::Reset()
{
aWTimer.Stop();
- if ( nFlags & SELENG_IN_SEL )
+ if ( nFlags & SelectionEngineFlags::IN_SEL )
pWin->ReleaseMouse();
- nFlags &= ~(SELENG_HAS_ANCH | SELENG_IN_SEL);
+ SelectionEngineFlags nMask = (SelectionEngineFlags::HAS_ANCH | SelectionEngineFlags::IN_SEL);
+ nFlags &= ~nMask;
nLockedMods = 0;
}
@@ -342,10 +345,10 @@ void SelectionEngine::Command( const CommandEvent& rCEvt )
if ( !pFunctionSet || !pWin || aWTimer.IsActive() )
return;
aWTimer.Stop();
- nFlags |= SELENG_CMDEVT;
+ nFlags |= SelectionEngineFlags::CMDEVT;
if ( rCEvt.GetCommand() == COMMAND_STARTDRAG )
{
- if ( nFlags & SELENG_DRG_ENAB )
+ if ( nFlags & SelectionEngineFlags::DRG_ENAB )
{
DBG_ASSERT( rCEvt.IsMouseEvent(), "STARTDRAG: Not a MouseEvent" );
if ( pFunctionSet->IsSelectionAtPoint( rCEvt.GetMousePosPixel() ) )
@@ -354,13 +357,14 @@ void SelectionEngine::Command( const CommandEvent& rCEvt )
aLastMove.GetClicks(), aLastMove.GetMode(),
aLastMove.GetButtons(), aLastMove.GetModifier() );
pFunctionSet->BeginDrag();
- nFlags &= ~(SELENG_CMDEVT|SELENG_WAIT_UPEVT|SELENG_IN_SEL);
+ const SelectionEngineFlags nMask = (SelectionEngineFlags::CMDEVT|SelectionEngineFlags::WAIT_UPEVT|SelectionEngineFlags::IN_SEL);
+ nFlags &= ~nMask;
}
else
- nFlags &= ~SELENG_CMDEVT;
+ nFlags &= ~SelectionEngineFlags::CMDEVT;
}
else
- nFlags &= ~SELENG_CMDEVT;
+ nFlags &= ~SelectionEngineFlags::CMDEVT;
}
}