diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-04-01 10:56:31 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-04-01 10:58:24 +0200 |
commit | 7c860af19bd8e0cf22a13e3987ec87555ebb5824 (patch) | |
tree | 71cb4f3d85b133b91e3837b18b747ea096ebeb7c | |
parent | e93a84d4857af442122d54c4d4857fa90d9f22f9 (diff) |
vcl: FixedHyper - take into account text alignment
Change-Id: Icc9b4d73cd2e4945299cbaaa1b55eebc3e1e3922
-rw-r--r-- | include/vcl/fixedhyper.hxx | 8 | ||||
-rw-r--r-- | vcl/source/control/fixedhyper.cxx | 29 |
2 files changed, 30 insertions, 7 deletions
diff --git a/include/vcl/fixedhyper.hxx b/include/vcl/fixedhyper.hxx index 1b8fcd554d32..a2bc891f60fe 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 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 ); } |