diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-10 16:54:47 +1100 |
---|---|---|
committer | Chris Sherlock <chris.sherlock79@gmail.com> | 2016-02-10 21:03:34 +1100 |
commit | 3ff9dd6ff36f21d9bea1851cea05a4ed4228722d (patch) | |
tree | bc68900860674e3e648b1e34060068106c5bd181 | |
parent | 574482123b0fcd7deed9345fd524e9fc1d8bfb5e (diff) |
vcl: move CommandEvent functions from header to cxx file
Moving functions from commandevent.hxx to commandevent.cxx, this means
they are no longer inline, but there was no clear reason as to why they
were inline in the first place!
I've also reordered the header to ensure that CommandEvent is the first
fully declared class, the data classes get declared after this (hence the
forward declarations). This makes reading this header much easier.
One more small thing: a few if statements had braces in the primary if
block, but not in the else block, which is IMO bad style and can possibly
lead to errors. I've made the else block use braces.
Change-Id: I79b010bd66d3c9f4a74d4fa470f62d0263c811f4
-rw-r--r-- | avmedia/source/viewer/mediawindow_impl.cxx | 2 | ||||
-rw-r--r-- | include/vcl/commandevent.hxx | 259 | ||||
-rw-r--r-- | svx/source/sdr/contact/sdrmediawindow.cxx | 2 | ||||
-rw-r--r-- | vcl/source/window/commandevent.cxx | 162 |
4 files changed, 203 insertions, 222 deletions
diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index dbf34150187b..6206abb73300 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -117,7 +117,7 @@ void MediaChildWindow::KeyUp( const KeyEvent& rKEvt ) void MediaChildWindow::Command( const CommandEvent& rCEvt ) { const CommandEvent aTransformedEvent( GetParent()->ScreenToOutputPixel( OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), - rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() ); + rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() ); SystemChildWindow::Command( rCEvt ); GetParent()->Command( aTransformedEvent ); diff --git a/include/vcl/commandevent.hxx b/include/vcl/commandevent.hxx index a9fef5849a43..9670aeae0ad3 100644 --- a/include/vcl/commandevent.hxx +++ b/include/vcl/commandevent.hxx @@ -38,6 +38,45 @@ #define EXTTEXTINPUT_CURSOR_INVISIBLE ((sal_uInt16)0x0001) #define EXTTEXTINPUT_CURSOR_OVERWRITE ((sal_uInt16)0x0002) +class CommandExtTextInputData; +class CommandWheelData; +class CommandScrollData; +class CommandModKeyData; +class CommandDialogData; +class CommandMediaData; +class CommandSelectionChangeData; +class CommandSwipeData; +class CommandLongPressData; +enum class CommandEventId; + +class VCL_DLLPUBLIC CommandEvent +{ +private: + Point maPos; + void* mpData; + CommandEventId mnCommand; + bool mbMouseEvent; + +public: + CommandEvent(); + CommandEvent( const Point& rMousePos, CommandEventId nCmd, + bool bMEvt = false, const void* pCmdData = nullptr ); + + CommandEventId GetCommand() const { return mnCommand; } + const Point& GetMousePosPixel() const { return maPos; } + bool IsMouseEvent() const { return mbMouseEvent; } + void* GetEventData() const { return mpData; } + + const CommandExtTextInputData* GetExtTextInputData() const; + const CommandWheelData* GetWheelData() const; + const CommandScrollData* GetAutoScrollData() const; + const CommandModKeyData* GetModKeyData() const; + const CommandDialogData* GetDialogData() const; + CommandMediaData* GetMediaData() const; + const CommandSelectionChangeData* GetSelectionChangeData() const; + const CommandSwipeData* GetSwipeData() const; + const CommandLongPressData* GetLongPressData() const; +}; class VCL_DLLPUBLIC CommandExtTextInputData { @@ -66,7 +105,6 @@ public: bool IsOnlyCursorChanged() const { return mbOnlyCursor; } }; - class VCL_DLLPUBLIC CommandInputContextData { private: @@ -77,19 +115,6 @@ public: CommandInputContextData( LanguageType eLang ); }; - -inline CommandInputContextData::CommandInputContextData() -{ - meLanguage = LANGUAGE_DONTKNOW; -} - - -inline CommandInputContextData::CommandInputContextData( LanguageType eLang ) -{ - meLanguage = eLang; -} - - enum class CommandWheelMode { NONE = 0, @@ -99,7 +124,6 @@ enum class CommandWheelMode DATAZOOM = 4 }; - // Magic value used in mnLines field in CommandWheelData #define COMMAND_WHEEL_PAGESCROLL ((sal_uLong)0xFFFFFFFF) @@ -139,34 +163,6 @@ public: { return ((mnCode & KEY_MOD2) != 0); } }; - -inline CommandWheelData::CommandWheelData() -{ - mnDelta = 0; - mnNotchDelta = 0; - mnLines = 0; - mnWheelMode = CommandWheelMode::NONE; - mnCode = 0; - mbHorz = false; - mbDeltaIsPixel = false; -} - - -inline CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta, - sal_uLong nScrollLines, - CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier, - bool bHorz, bool bDeltaIsPixel ) -{ - mnDelta = nWheelDelta; - mnNotchDelta = nWheelNotchDelta; - mnLines = nScrollLines; - mnWheelMode = nWheelMode; - mnCode = nKeyModifier; - mbHorz = bHorz; - mbDeltaIsPixel = bDeltaIsPixel; -} - - class VCL_DLLPUBLIC CommandScrollData { private: @@ -181,21 +177,6 @@ public: long GetDeltaY() const { return mnDeltaY; } }; - -inline CommandScrollData::CommandScrollData() -{ - mnDeltaX = 0; - mnDeltaY = 0; -} - - -inline CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY ) -{ - mnDeltaX = nDeltaX; - mnDeltaY = nDeltaY; -} - - class VCL_DLLPUBLIC CommandModKeyData { private: @@ -211,26 +192,12 @@ public: bool IsRightShift() const { return (mnCode & MODKEY_RSHIFT) != 0; } }; - -inline CommandModKeyData::CommandModKeyData() -{ - mnCode = 0L; -} - - -inline CommandModKeyData::CommandModKeyData( sal_uInt16 nCode ) -{ - mnCode = nCode; -} - - enum class ShowDialogId { Preferences = 1, About = 2, }; - class VCL_DLLPUBLIC CommandDialogData { ShowDialogId m_nDialogId; @@ -242,7 +209,6 @@ public: ShowDialogId GetDialogId() const { return m_nDialogId; } }; - // Media Commands enum class MediaCommand { @@ -270,7 +236,6 @@ enum class MediaCommand PreviousTrackHold = 22,// Button Left holding pressed. }; - class VCL_DLLPUBLIC CommandMediaData { MediaCommand m_nMediaId; @@ -286,7 +251,6 @@ public: bool GetPassThroughToOS() const { return m_bPassThroughToOS; } }; - class VCL_DLLPUBLIC CommandSelectionChangeData { private: @@ -301,21 +265,6 @@ public: sal_uLong GetEnd() const { return mnEnd; } }; - -inline CommandSelectionChangeData::CommandSelectionChangeData() -{ - mnStart = mnEnd = 0; -} - - -inline CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, - sal_uLong nEnd ) -{ - mnStart = nStart; - mnEnd = nEnd; -} - - class VCL_DLLPUBLIC CommandSwipeData { double mnVelocityX; @@ -351,7 +300,6 @@ public: double getY() const { return mnY; } }; - enum class CommandEventId { NONE = 0, @@ -378,135 +326,6 @@ enum class CommandEventId LongPress = 22, }; - -class VCL_DLLPUBLIC CommandEvent -{ -private: - Point maPos; - void* mpData; - CommandEventId mnCommand; - bool mbMouseEvent; - -public: - CommandEvent(); - CommandEvent( const Point& rMousePos, CommandEventId nCmd, - bool bMEvt = false, const void* pCmdData = nullptr ); - - CommandEventId GetCommand() const { return mnCommand; } - const Point& GetMousePosPixel() const { return maPos; } - bool IsMouseEvent() const { return mbMouseEvent; } - void* GetEventData() const { return mpData; } - - const CommandExtTextInputData* GetExtTextInputData() const; - const CommandWheelData* GetWheelData() const; - const CommandScrollData* GetAutoScrollData() const; - const CommandModKeyData* GetModKeyData() const; - const CommandDialogData* GetDialogData() const; - CommandMediaData* GetMediaData() const; - const CommandSelectionChangeData* GetSelectionChangeData() const; - const CommandSwipeData* GetSwipeData() const; - const CommandLongPressData* GetLongPressData() const; -}; - - -inline CommandEvent::CommandEvent() -{ - mpData = nullptr; - mnCommand = CommandEventId::NONE; - mbMouseEvent = false; -} - - -inline CommandEvent::CommandEvent( const Point& rMousePos, - CommandEventId nCmd, bool bMEvt, const void* pCmdData ) : - maPos( rMousePos ) -{ - mpData = const_cast<void*>(pCmdData); - mnCommand = nCmd; - mbMouseEvent = bMEvt; -} - - -inline const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const -{ - if ( mnCommand == CommandEventId::ExtTextInput ) - return static_cast<const CommandExtTextInputData*>(mpData); - else - return nullptr; -} - - -inline const CommandWheelData* CommandEvent::GetWheelData() const -{ - if ( mnCommand == CommandEventId::Wheel ) - return static_cast<const CommandWheelData*>(mpData); - else - return nullptr; -} - - -inline const CommandScrollData* CommandEvent::GetAutoScrollData() const -{ - if ( mnCommand == CommandEventId::AutoScroll ) - return static_cast<const CommandScrollData*>(mpData); - else - return nullptr; -} - - -inline const CommandModKeyData* CommandEvent::GetModKeyData() const -{ - if( mnCommand == CommandEventId::ModKeyChange ) - return static_cast<const CommandModKeyData*>(mpData); - else - return nullptr; -} - - -inline const CommandDialogData* CommandEvent::GetDialogData() const -{ - if( mnCommand == CommandEventId::ShowDialog ) - return static_cast<const CommandDialogData*>(mpData); - else - return nullptr; -} - - -inline CommandMediaData* CommandEvent::GetMediaData() const -{ - if( mnCommand == CommandEventId::Media ) - return static_cast<CommandMediaData*>(mpData); - else - return nullptr; -} - - -inline const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const -{ - if( mnCommand == CommandEventId::SelectionChange ) - return static_cast<const CommandSelectionChangeData*>(mpData); - else - return nullptr; -} - - -inline const CommandSwipeData* CommandEvent::GetSwipeData() const -{ - if( mnCommand == CommandEventId::Swipe ) - return static_cast<const CommandSwipeData*>(mpData); - else - return nullptr; -} - - -inline const CommandLongPressData* CommandEvent::GetLongPressData() const -{ - if( mnCommand == CommandEventId::LongPress ) - return static_cast<const CommandLongPressData*>(mpData); - else - return nullptr; -} - #endif // INCLUDED_VCL_COMMANDEVENT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/sdr/contact/sdrmediawindow.cxx b/svx/source/sdr/contact/sdrmediawindow.cxx index d5f07348f078..1292d3205bdf 100644 --- a/svx/source/sdr/contact/sdrmediawindow.cxx +++ b/svx/source/sdr/contact/sdrmediawindow.cxx @@ -107,7 +107,7 @@ void SdrMediaWindow::Command( const CommandEvent& rCEvt ) if( pWindow && getWindow() ) { const CommandEvent aTransformedEvent( pWindow->ScreenToOutputPixel( getWindow()->OutputToScreenPixel( rCEvt.GetMousePosPixel() ) ), - rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() ); + rCEvt.GetCommand(), rCEvt.IsMouseEvent(), rCEvt.GetEventData() ); pWindow->Command( aTransformedEvent ); } diff --git a/vcl/source/window/commandevent.cxx b/vcl/source/window/commandevent.cxx index 143628b83fa3..5fa8e4c26730 100644 --- a/vcl/source/window/commandevent.cxx +++ b/vcl/source/window/commandevent.cxx @@ -32,7 +32,10 @@ CommandExtTextInputData::CommandExtTextInputData( const OUString& rText, memcpy( mpTextAttr, pTextAttr, maText.getLength()*sizeof(sal_uInt16) ); } else + { mpTextAttr = nullptr; + } + mnCursorPos = nCursorPos; mnCursorFlags = nCursorFlags; mbOnlyCursor = bOnlyCursor; @@ -47,7 +50,10 @@ CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData& memcpy( mpTextAttr, rData.mpTextAttr, maText.getLength()*sizeof(sal_uInt16) ); } else + { mpTextAttr = nullptr; + } + mnCursorPos = rData.mnCursorPos; mnCursorFlags = rData.mnCursorFlags; mbOnlyCursor = rData.mbOnlyCursor; @@ -58,4 +64,160 @@ CommandExtTextInputData::~CommandExtTextInputData() delete [] mpTextAttr; } +CommandInputContextData::CommandInputContextData() +{ + meLanguage = LANGUAGE_DONTKNOW; +} + +CommandInputContextData::CommandInputContextData( LanguageType eLang ) +{ + meLanguage = eLang; +} + +CommandWheelData::CommandWheelData() +{ + mnDelta = 0; + mnNotchDelta = 0; + mnLines = 0; + mnWheelMode = CommandWheelMode::NONE; + mnCode = 0; + mbHorz = false; + mbDeltaIsPixel = false; +} + +CommandWheelData::CommandWheelData( long nWheelDelta, long nWheelNotchDelta, + sal_uLong nScrollLines, + CommandWheelMode nWheelMode, sal_uInt16 nKeyModifier, + bool bHorz, bool bDeltaIsPixel ) +{ + mnDelta = nWheelDelta; + mnNotchDelta = nWheelNotchDelta; + mnLines = nScrollLines; + mnWheelMode = nWheelMode; + mnCode = nKeyModifier; + mbHorz = bHorz; + mbDeltaIsPixel = bDeltaIsPixel; +} + +CommandScrollData::CommandScrollData() +{ + mnDeltaX = 0; + mnDeltaY = 0; +} + +CommandScrollData::CommandScrollData( long nDeltaX, long nDeltaY ) +{ + mnDeltaX = nDeltaX; + mnDeltaY = nDeltaY; +} + +CommandModKeyData::CommandModKeyData() +{ + mnCode = 0L; +} + +CommandModKeyData::CommandModKeyData( sal_uInt16 nCode ) +{ + mnCode = nCode; +} + +CommandSelectionChangeData::CommandSelectionChangeData() +{ + mnStart = mnEnd = 0; +} + +CommandSelectionChangeData::CommandSelectionChangeData( sal_uLong nStart, sal_uLong nEnd ) +{ + mnStart = nStart; + mnEnd = nEnd; +} + +CommandEvent::CommandEvent() +{ + mpData = nullptr; + mnCommand = CommandEventId::NONE; + mbMouseEvent = false; +} + +CommandEvent::CommandEvent( const Point& rMousePos, + CommandEventId nCmd, bool bMEvt, const void* pCmdData ) : + maPos( rMousePos ) +{ + mpData = const_cast<void*>(pCmdData); + mnCommand = nCmd; + mbMouseEvent = bMEvt; +} + +const CommandExtTextInputData* CommandEvent::GetExtTextInputData() const +{ + if ( mnCommand == CommandEventId::ExtTextInput ) + return static_cast<const CommandExtTextInputData*>(mpData); + else + return nullptr; +} + +const CommandWheelData* CommandEvent::GetWheelData() const +{ + if ( mnCommand == CommandEventId::Wheel ) + return static_cast<const CommandWheelData*>(mpData); + else + return nullptr; +} + +const CommandScrollData* CommandEvent::GetAutoScrollData() const +{ + if ( mnCommand == CommandEventId::AutoScroll ) + return static_cast<const CommandScrollData*>(mpData); + else + return nullptr; +} + +const CommandModKeyData* CommandEvent::GetModKeyData() const +{ + if( mnCommand == CommandEventId::ModKeyChange ) + return static_cast<const CommandModKeyData*>(mpData); + else + return nullptr; +} + +const CommandDialogData* CommandEvent::GetDialogData() const +{ + if( mnCommand == CommandEventId::ShowDialog ) + return static_cast<const CommandDialogData*>(mpData); + else + return nullptr; +} + +CommandMediaData* CommandEvent::GetMediaData() const +{ + if( mnCommand == CommandEventId::Media ) + return static_cast<CommandMediaData*>(mpData); + else + return nullptr; +} + +const CommandSelectionChangeData* CommandEvent::GetSelectionChangeData() const +{ + if( mnCommand == CommandEventId::SelectionChange ) + return static_cast<const CommandSelectionChangeData*>(mpData); + else + return nullptr; +} + +const CommandSwipeData* CommandEvent::GetSwipeData() const +{ + if( mnCommand == CommandEventId::Swipe ) + return static_cast<const CommandSwipeData*>(mpData); + else + return nullptr; +} + +const CommandLongPressData* CommandEvent::GetLongPressData() const +{ + if( mnCommand == CommandEventId::LongPress ) + return static_cast<const CommandLongPressData*>(mpData); + else + return nullptr; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |