include/vcl/fixedhyper.hxx | 8 ++++---- vcl/source/control/fixedhyper.cxx | 29 ++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 7 deletions(-)
New commits: commit 7c860af19bd8e0cf22a13e3987ec87555ebb5824 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Tue Apr 1 10:56:31 2014 +0200 vcl: FixedHyper - take into account text alignment Change-Id: Icc9b4d73cd2e4945299cbaaa1b55eebc3e1e3922 diff --git a/include/vcl/fixedhyper.hxx b/include/vcl/fixedhyper.hxx index 1b8fcd5..a2bc891 100644 --- a/include/vcl/fixedhyper.hxx +++ b/include/vcl/fixedhyper.hxx @@ -23,10 +23,7 @@ #include <vcl/dllapi.h> #include <vcl/fixed.hxx> - - //= FixedHyperlink - - class VCL_DLLPUBLIC FixedHyperlink : public FixedText +class VCL_DLLPUBLIC FixedHyperlink : public FixedText { private: long m_nTextLen; @@ -40,6 +37,9 @@ */ void Initialize(); + /** is position X positon hitting text */ + SAL_DLLPRIVATE bool ImplIsOverText(Point rPosition); + protected: /** overwrites Window::MouseMove(). diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx index 36d055b..6208374 100644 --- a/vcl/source/control/fixedhyper.cxx +++ b/vcl/source/control/fixedhyper.cxx @@ -52,10 +52,33 @@ void FixedHyperlink::Initialize() m_nTextLen = GetCtrlTextWidth( GetText() ); } +bool FixedHyperlink::ImplIsOverText(Point aPosition) +{ + Size aSize = GetOutputSizePixel(); + + bool bIsOver = false; + + if (GetStyle() & WB_RIGHT) + { + return aPosition.X() > (aSize.Width() - m_nTextLen); + } + else if (GetStyle() & WB_CENTER) + { + bIsOver = aPosition.X() > (aSize.Width() / 2 - m_nTextLen / 2) && + aPosition.X() < (aSize.Width() / 2 + m_nTextLen / 2); + } + else + { + bIsOver = aPosition.X() < m_nTextLen; + } + + return bIsOver; +} + void FixedHyperlink::MouseMove( const MouseEvent& rMEvt ) { // changes the pointer if the control is enabled and the mouse is over the text. - if ( !rMEvt.IsLeaveWindow() && IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) + if ( !rMEvt.IsLeaveWindow() && IsEnabled() && ImplIsOverText(GetPointerPosPixel()) ) SetPointer( POINTER_REFHAND ); else SetPointer( m_aOldPointer ); @@ -64,13 +87,13 @@ void FixedHyperlink::MouseMove( const MouseEvent& rMEvt ) void FixedHyperlink::MouseButtonUp( const MouseEvent& ) { // calls the link if the control is enabled and the mouse is over the text. - if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) + if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) ) ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, m_aClickHdl, this ); } void FixedHyperlink::RequestHelp( const HelpEvent& rHEvt ) { - if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) + if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) ) FixedText::RequestHelp( rHEvt ); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits