Kaydet (Commit) 7c860af1 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

vcl: FixedHyper - take into account text alignment

Change-Id: Icc9b4d73cd2e4945299cbaaa1b55eebc3e1e3922
üst e93a84d4
...@@ -23,10 +23,7 @@ ...@@ -23,10 +23,7 @@
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/fixed.hxx> #include <vcl/fixed.hxx>
class VCL_DLLPUBLIC FixedHyperlink : public FixedText
//= FixedHyperlink
class VCL_DLLPUBLIC FixedHyperlink : public FixedText
{ {
private: private:
long m_nTextLen; long m_nTextLen;
...@@ -40,6 +37,9 @@ ...@@ -40,6 +37,9 @@
*/ */
void Initialize(); void Initialize();
/** is position X positon hitting text */
SAL_DLLPRIVATE bool ImplIsOverText(Point rPosition);
protected: protected:
/** overwrites Window::MouseMove(). /** overwrites Window::MouseMove().
......
...@@ -52,10 +52,33 @@ void FixedHyperlink::Initialize() ...@@ -52,10 +52,33 @@ void FixedHyperlink::Initialize()
m_nTextLen = GetCtrlTextWidth( GetText() ); 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 ) void FixedHyperlink::MouseMove( const MouseEvent& rMEvt )
{ {
// changes the pointer if the control is enabled and the mouse is over the text. // 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 ); SetPointer( POINTER_REFHAND );
else else
SetPointer( m_aOldPointer ); SetPointer( m_aOldPointer );
...@@ -64,13 +87,13 @@ void FixedHyperlink::MouseMove( const MouseEvent& rMEvt ) ...@@ -64,13 +87,13 @@ void FixedHyperlink::MouseMove( const MouseEvent& rMEvt )
void FixedHyperlink::MouseButtonUp( const MouseEvent& ) void FixedHyperlink::MouseButtonUp( const MouseEvent& )
{ {
// calls the link if the control is enabled and the mouse is over the text. // 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 ); ImplCallEventListenersAndHandler( VCLEVENT_BUTTON_CLICK, m_aClickHdl, this );
} }
void FixedHyperlink::RequestHelp( const HelpEvent& rHEvt ) void FixedHyperlink::RequestHelp( const HelpEvent& rHEvt )
{ {
if ( IsEnabled() && GetPointerPosPixel().X() < m_nTextLen ) if ( IsEnabled() && ImplIsOverText(GetPointerPosPixel()) )
FixedText::RequestHelp( rHEvt ); FixedText::RequestHelp( rHEvt );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment