From 12a2f6dfefb13cfcb75f191f835601357fbc7538 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 21 Sep 2016 16:04:12 +0200 Subject: convert SIZING constants to scoped typed_flags Change-Id: Ibd504cd7059bcaae0a37c0df25d805efff573b99 --- dbaccess/source/ui/inc/TableWindow.hxx | 30 ++++++++++------ dbaccess/source/ui/querydesign/TableWindow.cxx | 50 +++++++++++--------------- 2 files changed, 39 insertions(+), 41 deletions(-) (limited to 'dbaccess') diff --git a/dbaccess/source/ui/inc/TableWindow.hxx b/dbaccess/source/ui/inc/TableWindow.hxx index 181cd66c4be9..aa9aa6ce9ee0 100644 --- a/dbaccess/source/ui/inc/TableWindow.hxx +++ b/dbaccess/source/ui/inc/TableWindow.hxx @@ -30,17 +30,25 @@ #include #include "cppuhelper/basemutex.hxx" +#include class SvTreeListEntry; + +// Flags for the size adjustment of SbaJoinTabWins +enum class SizingFlags { + NONE = 0x0000, + Top = 0x0001, + Bottom = 0x0002, + Left = 0x0004, + Right = 0x0008, +}; +namespace o3tl { + template<> struct typed_flags : is_typed_flags {}; +} + + namespace dbaui { - // Flags for the size adjustment of SbaJoinTabWins - const sal_uInt16 SIZING_NONE = 0x0000; - const sal_uInt16 SIZING_TOP = 0x0001; - const sal_uInt16 SIZING_BOTTOM = 0x0002; - const sal_uInt16 SIZING_LEFT = 0x0004; - const sal_uInt16 SIZING_RIGHT = 0x0008; - class OJoinDesignView; class OJoinTableView; class OTableWindowAccess; @@ -65,8 +73,8 @@ namespace dbaui m_pContainerListener; sal_Int32 m_nMoveCount; // how often the arrow keys was pressed sal_Int32 m_nMoveIncrement; // how many pixel we should move - sal_uInt16 m_nSizingFlags; - bool m_bActive; + SizingFlags m_nSizingFlags; + bool m_bActive; // OContainerListener virtual void _elementInserted( const css::container::ContainerEvent& _rEvent ) throw(css::uno::RuntimeException, std::exception) override; @@ -157,7 +165,7 @@ namespace dbaui inline css::uno::Reference< css::container::XNameAccess > GetOriginalColumns() const { return m_pData->getColumns(); } inline css::uno::Reference< css::beans::XPropertySet > GetTable() const { return m_pData->getTable(); } - sal_uInt16 GetSizingFlags() const { return m_nSizingFlags; } + SizingFlags GetSizingFlags() const { return m_nSizingFlags; } /** set the sizing flag to the direction @param _rPos The EndPosition after resizing. @@ -165,7 +173,7 @@ namespace dbaui void setSizingFlag(const Point& _rPos); /** set the resizing flag to NONE. */ - void resetSizingFlag() { m_nSizingFlags = SIZING_NONE; } + void resetSizingFlag() { m_nSizingFlags = SizingFlags::NONE; } /** returns the new sizing */ diff --git a/dbaccess/source/ui/querydesign/TableWindow.cxx b/dbaccess/source/ui/querydesign/TableWindow.cxx index b699f0d6d20d..9e879064ba99 100644 --- a/dbaccess/source/ui/querydesign/TableWindow.cxx +++ b/dbaccess/source/ui/querydesign/TableWindow.cxx @@ -99,7 +99,7 @@ OTableWindow::OTableWindow( vcl::Window* pParent, const TTableWindowData::value_ ,m_pData( pTabWinData ) ,m_nMoveCount(0) ,m_nMoveIncrement(1) - ,m_nSizingFlags( SIZING_NONE ) + ,m_nSizingFlags( SizingFlags::NONE ) ,m_bActive( false ) { @@ -345,9 +345,9 @@ void OTableWindow::Paint(vcl::RenderContext& rRenderContext, const Rectangle& rR Rectangle OTableWindow::getSizingRect(const Point& _rPos,const Size& _rOutputSize) const { Rectangle aSizingRect = Rectangle( GetPosPixel(), GetSizePixel() ); - sal_uInt16 nSizingFlags = GetSizingFlags(); + SizingFlags nSizingFlags = GetSizingFlags(); - if( nSizingFlags & SIZING_TOP ) + if( nSizingFlags & SizingFlags::Top ) { if( _rPos.Y() < 0 ) aSizingRect.Top() = 0; @@ -355,7 +355,7 @@ Rectangle OTableWindow::getSizingRect(const Point& _rPos,const Size& _rOutputSiz aSizingRect.Top() = _rPos.Y(); } - if( nSizingFlags & SIZING_BOTTOM ) + if( nSizingFlags & SizingFlags::Bottom ) { if( _rPos.Y() > _rOutputSize.Height() ) aSizingRect.Bottom() = _rOutputSize.Height(); @@ -363,7 +363,7 @@ Rectangle OTableWindow::getSizingRect(const Point& _rPos,const Size& _rOutputSiz aSizingRect.Bottom() = _rPos.Y(); } - if( nSizingFlags & SIZING_RIGHT ) + if( nSizingFlags & SizingFlags::Right ) { if( _rPos.X() > _rOutputSize.Width() ) aSizingRect.Right() = _rOutputSize.Width(); @@ -371,7 +371,7 @@ Rectangle OTableWindow::getSizingRect(const Point& _rPos,const Size& _rOutputSiz aSizingRect.Right() = _rPos.X(); } - if( nSizingFlags & SIZING_LEFT ) + if( nSizingFlags & SizingFlags::Left ) { if( _rPos.X() < 0 ) aSizingRect.Left() = 0; @@ -385,19 +385,19 @@ void OTableWindow::setSizingFlag(const Point& _rPos) { Size aOutSize = GetOutputSizePixel(); // Set the flags when the mouse cursor is in the sizing area - m_nSizingFlags = SIZING_NONE; + m_nSizingFlags = SizingFlags::NONE; if( _rPos.X() < TABWIN_SIZING_AREA ) - m_nSizingFlags |= SIZING_LEFT; + m_nSizingFlags |= SizingFlags::Left; if( _rPos.Y() < TABWIN_SIZING_AREA ) - m_nSizingFlags |= SIZING_TOP; + m_nSizingFlags |= SizingFlags::Top; if( _rPos.X() > aOutSize.Width()-TABWIN_SIZING_AREA ) - m_nSizingFlags |= SIZING_RIGHT; + m_nSizingFlags |= SizingFlags::Right; if( _rPos.Y() > aOutSize.Height()-TABWIN_SIZING_AREA ) - m_nSizingFlags |= SIZING_BOTTOM; + m_nSizingFlags |= SizingFlags::Bottom; } void OTableWindow::MouseMove( const MouseEvent& rEvt ) @@ -413,28 +413,18 @@ void OTableWindow::MouseMove( const MouseEvent& rEvt ) Pointer aPointer; // Set the mouse cursor when it is in the sizing area - switch( m_nSizingFlags ) - { - case SIZING_TOP: - case SIZING_BOTTOM: + if ( m_nSizingFlags == SizingFlags::Top || + m_nSizingFlags == SizingFlags::Bottom ) aPointer = Pointer( PointerStyle::SSize ); - break; - - case SIZING_LEFT: - case SIZING_RIGHT: + else if ( m_nSizingFlags == SizingFlags::Left || + m_nSizingFlags ==SizingFlags::Right ) aPointer = Pointer( PointerStyle::ESize ); - break; - - case SIZING_LEFT+SIZING_TOP: - case SIZING_RIGHT+SIZING_BOTTOM: + else if ( m_nSizingFlags == (SizingFlags::Left | SizingFlags::Top) || + m_nSizingFlags == (SizingFlags::Right | SizingFlags::Bottom) ) aPointer = Pointer( PointerStyle::SESize ); - break; - - case SIZING_RIGHT+SIZING_TOP: - case SIZING_LEFT+SIZING_BOTTOM: + else if ( m_nSizingFlags == (SizingFlags::Right | SizingFlags::Top) || + m_nSizingFlags == (SizingFlags::Left | SizingFlags::Bottom) ) aPointer = Pointer( PointerStyle::NESize ); - break; - } SetPointer( aPointer ); } @@ -443,7 +433,7 @@ void OTableWindow::MouseButtonDown( const MouseEvent& rEvt ) { // When resizing, the parent must be informed that // the window size of its child has changed - if( m_nSizingFlags ) + if( m_nSizingFlags != SizingFlags::NONE ) getTableView()->BeginChildSizing( this, GetPointer() ); Window::MouseButtonDown( rEvt ); -- cgit