diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-23 16:21:43 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-23 16:46:26 +0100 |
commit | 527190f0c0284a9a4f5a021d0a9163ef9a63a67f (patch) | |
tree | 04cbb1cdc10677a1acd14ddee55f4dcc0c4f91ac /sw/source/uibase/docvw/SidebarWin.cxx | |
parent | 439765480695975e10c92f39aa6a4cb6f2ee7646 (diff) |
sw lok comments: handle mouse up/down events on the vertical scrollbar
Change-Id: Ib1c334825a6629224fe0c8fba564656d53e67410
Diffstat (limited to 'sw/source/uibase/docvw/SidebarWin.cxx')
-rw-r--r-- | sw/source/uibase/docvw/SidebarWin.cxx | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 0891a2af5abd..8d4079d03602 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -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. 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); MapMode aMapMode(rChild.GetMapMode()); aMapMode.SetOrigin(aOffset); + aMapMode.SetMapUnit(rParent.GetMapMode().GetMapUnit()); rChild.SetMapMode(aMapMode); rChild.EnableMapMode(false); @@ -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 { @@ -441,29 +476,29 @@ void SwSidebarWin::MouseMove(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); - 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) { - if (mpSidebarTextControl) + if (vcl::Window* pHit = lcl_getHitWindow(*this, rMouseEvent)) { - mpSidebarTextControl->Push(PushFlags::MAPMODE); + pHit->Push(PushFlags::MAPMODE); MouseEvent aMouseEvent(rMouseEvent); - lcl_translateTwips(EditWin(), *mpSidebarTextControl, &aMouseEvent); + lcl_translateTwips(EditWin(), *pHit, &aMouseEvent); - mpSidebarTextControl->MouseButtonUp(aMouseEvent); + pHit->MouseButtonUp(aMouseEvent); - mpSidebarTextControl->Pop(); + pHit->Pop(); } } |