summaryrefslogtreecommitdiff
path: root/vcl/source/control
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-01 10:56:31 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-01 10:58:24 +0200
commit7c860af19bd8e0cf22a13e3987ec87555ebb5824 (patch)
tree71cb4f3d85b133b91e3837b18b747ea096ebeb7c /vcl/source/control
parente93a84d4857af442122d54c4d4857fa90d9f22f9 (diff)
vcl: FixedHyper - take into account text alignment
Change-Id: Icc9b4d73cd2e4945299cbaaa1b55eebc3e1e3922
Diffstat (limited to 'vcl/source/control')
-rw-r--r--vcl/source/control/fixedhyper.cxx29
1 files changed, 26 insertions, 3 deletions
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 );
}