From 7c860af19bd8e0cf22a13e3987ec87555ebb5824 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Tue, 1 Apr 2014 10:56:31 +0200 Subject: vcl: FixedHyper - take into account text alignment Change-Id: Icc9b4d73cd2e4945299cbaaa1b55eebc3e1e3922 --- vcl/source/control/fixedhyper.cxx | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'vcl/source') diff --git a/vcl/source/control/fixedhyper.cxx b/vcl/source/control/fixedhyper.cxx index 36d055bf847e..62083747c4bb 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 ); } -- cgit