Kaydet (Commit) cb0c081d authored tarafından Miklos Vajna's avatar Miklos Vajna

sw lok comments: handle mouse up/down events on the vertical scrollbar

(cherry picked from commit 527190f0)

Conflicts:
	sw/source/uibase/docvw/SidebarWin.cxx

Change-Id: Ib1c334825a6629224fe0c8fba564656d53e67410
üst 2bfd1c7d
...@@ -92,9 +92,19 @@ void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* p ...@@ -92,9 +92,19 @@ void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* p
{ {
// Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones. // Set map mode, so that callback payloads will contain absolute coordinates instead of relative ones.
Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel());
if (!rChild.IsMapModeEnabled())
{
MapMode aMapMode(rChild.GetMapMode());
aMapMode.SetMapUnit(MAP_TWIP);
aMapMode.SetScaleX(rParent.GetMapMode().GetScaleX());
aMapMode.SetScaleY(rParent.GetMapMode().GetScaleY());
rChild.SetMapMode(aMapMode);
rChild.EnableMapMode();
}
aOffset = rChild.PixelToLogic(aOffset); aOffset = rChild.PixelToLogic(aOffset);
MapMode aMapMode(rChild.GetMapMode()); MapMode aMapMode(rChild.GetMapMode());
aMapMode.SetOrigin(aOffset); aMapMode.SetOrigin(aOffset);
aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit());
rChild.SetMapMode(aMapMode); rChild.SetMapMode(aMapMode);
rChild.EnableMapMode(false); rChild.EnableMapMode(false);
...@@ -108,6 +118,31 @@ void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* p ...@@ -108,6 +118,31 @@ void lcl_translateTwips(vcl::Window& rParent, vcl::Window& rChild, MouseEvent* p
} }
} }
/// Decide which one from the children of rParent should get rMouseEvent.
vcl::Window* lcl_getHitWindow(sw::sidebarwindows::SwSidebarWin& rParent, const MouseEvent& rMouseEvent)
{
vcl::Window* pRet = 0;
rParent.EditWin()->Push(PushFlags::MAPMODE);
rParent.EditWin()->EnableMapMode();
for (sal_Int16 i = rParent.GetChildCount() - 1; i >= 0; --i)
{
vcl::Window* pChild = rParent.GetChild(i);
Point aPosition(rParent.GetPosPixel());
aPosition.Move(pChild->GetPosPixel().getX(), pChild->GetPosPixel().getY());
Size aSize(rParent.GetSizePixel());
Rectangle aRectangleLogic(rParent.EditWin()->PixelToLogic(aPosition), rParent.EditWin()->PixelToLogic(aSize));
if (aRectangleLogic.IsInside(rMouseEvent.GetPosPixel()))
{
pRet = pChild;
break;
}
}
rParent.EditWin()->Pop();
return pRet;
}
} }
namespace sw { namespace sidebarwindows { namespace sw { namespace sidebarwindows {
...@@ -441,29 +476,29 @@ void SwSidebarWin::MouseMove(const MouseEvent& rMouseEvent) ...@@ -441,29 +476,29 @@ void SwSidebarWin::MouseMove(const MouseEvent& rMouseEvent)
void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent) void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent)
{ {
if (mpSidebarTextControl) if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent))
{ {
mpSidebarTextControl->Push(PushFlags::MAPMODE); pHit->Push(PushFlags::MAPMODE);
MouseEvent aMouseEvent(rMouseEvent); MouseEvent aMouseEvent(rMouseEvent);
lcl_translateTwips(*EditWin(), *mpSidebarTextControl, &aMouseEvent); lcl_translateTwips(*EditWin(), *pHit, &aMouseEvent);
mpSidebarTextControl->MouseButtonDown(aMouseEvent); pHit->MouseButtonDown(aMouseEvent);
mpSidebarTextControl->Pop(); pHit->Pop();
} }
} }
void SwSidebarWin::MouseButtonUp(const MouseEvent& rMouseEvent) void SwSidebarWin::MouseButtonUp(const MouseEvent& rMouseEvent)
{ {
if (mpSidebarTextControl) if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent))
{ {
mpSidebarTextControl->Push(PushFlags::MAPMODE); pHit->Push(PushFlags::MAPMODE);
MouseEvent aMouseEvent(rMouseEvent); MouseEvent aMouseEvent(rMouseEvent);
lcl_translateTwips(*EditWin(), *mpSidebarTextControl, &aMouseEvent); lcl_translateTwips(*EditWin(), *pHit, &aMouseEvent);
mpSidebarTextControl->MouseButtonUp(aMouseEvent); pHit->MouseButtonUp(aMouseEvent);
mpSidebarTextControl->Pop(); pHit->Pop();
} }
} }
......
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