diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-13 13:33:32 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-11-16 11:38:25 +0100 |
commit | a792468f017fcd7fc040affe288bd058c1ba6523 (patch) | |
tree | 14d36b6ce2ab1ef85d3090d3a032f9102d383223 /sw | |
parent | 739dad1e67468a256c1d0e15e4e99d055668a1b1 (diff) |
sw lok: fix blinking cursor position of comments
With this, it is possible to click inside a comment (and get a blinking
cursor inside a comment), and also possible to use the arrow keys to
native around and still get correct blinking cursor position.
(cherry picked from commit 5fb91dfd804cd6f3d585bb4113b9a68083ac71ee)
Conflicts:
sw/inc/SidebarWin.hxx
sw/source/uibase/docvw/SidebarTxtControl.hxx
sw/source/uibase/docvw/SidebarWin.cxx
Change-Id: I29eb1e60e4e571151f0b18bec8cf765ea09af09f
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/SidebarWin.hxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/docvw/PostItMgr.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarTxtControl.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/docvw/SidebarWin.cxx | 36 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 7 |
5 files changed, 38 insertions, 16 deletions
diff --git a/sw/inc/SidebarWin.hxx b/sw/inc/SidebarWin.hxx index bb1a44af069d..6fdf77db1d18 100644 --- a/sw/inc/SidebarWin.hxx +++ b/sw/inc/SidebarWin.hxx @@ -179,9 +179,10 @@ class SwSidebarWin : public vcl::Window virtual void Draw(OutputDevice* pDev, const Point&, const Size&, sal_uLong) SAL_OVERRIDE; virtual void KeyInput(const KeyEvent& rKeyEvt) SAL_OVERRIDE; + virtual void MouseButtonDown(const MouseEvent& rMouseEvent) SAL_OVERRIDE; void PaintTile(vcl::RenderContext& rRenderContext, const Rectangle& rRect); - /// Get the matching sub-widget inside this sidebar widget for rPointLogic, if any. - vcl::Window* IsHitWindow(const Point& rPointLogic); + /// Is there a matching sub-widget inside this sidebar widget for rPointLogic? + bool IsHitWindow(const Point& rPointLogic); protected: virtual void DataChanged( const DataChangedEvent& aEvent) SAL_OVERRIDE; diff --git a/sw/source/uibase/docvw/PostItMgr.cxx b/sw/source/uibase/docvw/PostItMgr.cxx index 703a433a44ee..871a642d24da 100644 --- a/sw/source/uibase/docvw/PostItMgr.cxx +++ b/sw/source/uibase/docvw/PostItMgr.cxx @@ -1736,9 +1736,9 @@ vcl::Window* SwPostItMgr::IsHitSidebarWindow(const Point& rPointLogic) if (!pPostIt) continue; - if (vcl::Window* pWindow = pPostIt->IsHitWindow(rPointLogic)) + if (pPostIt->IsHitWindow(rPointLogic)) { - pRet = pWindow; + pRet = pPostIt; break; } } diff --git a/sw/source/uibase/docvw/SidebarTxtControl.hxx b/sw/source/uibase/docvw/SidebarTxtControl.hxx index 02d52ebae049..c42839530830 100644 --- a/sw/source/uibase/docvw/SidebarTxtControl.hxx +++ b/sw/source/uibase/docvw/SidebarTxtControl.hxx @@ -41,7 +41,6 @@ class SidebarTextControl : public Control protected: virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE; virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE; virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE; virtual void LoseFocus() SAL_OVERRIDE; @@ -61,6 +60,7 @@ class SidebarTextControl : public Control virtual void GetFocus() SAL_OVERRIDE; virtual void KeyInput( const KeyEvent& rKeyEvt ) SAL_OVERRIDE; + virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE; OutlinerView* GetTextView() const; diff --git a/sw/source/uibase/docvw/SidebarWin.cxx b/sw/source/uibase/docvw/SidebarWin.cxx index 3fe2953b8269..31993ea145cc 100644 --- a/sw/source/uibase/docvw/SidebarWin.cxx +++ b/sw/source/uibase/docvw/SidebarWin.cxx @@ -279,12 +279,10 @@ void SwSidebarWin::PaintTile(vcl::RenderContext& rRenderContext, const Rectangle rRenderContext.Push(PushFlags::NONE); } -vcl::Window* SwSidebarWin::IsHitWindow(const Point& rPointLogic) +bool SwSidebarWin::IsHitWindow(const Point& rPointLogic) { Rectangle aRectangleLogic(EditWin()->PixelToLogic(GetPosPixel()), EditWin()->PixelToLogic(GetSizePixel())); - if (aRectangleLogic.IsInside(rPointLogic)) - return mpSidebarTextControl; - return 0; + return aRectangleLogic.IsInside(rPointLogic); } void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, sal_uLong nInFlags) @@ -355,10 +353,40 @@ void SwSidebarWin::Draw(OutputDevice* pDev, const Point& rPt, const Size& rSz, s } } +/// We want to work in absolute twips: so set delta between rChild and rParent as origin on rChild, then disable map mode on rChild. +static void lcl_setAbsoluteTwips(vcl::Window& rParent, vcl::Window& rChild) +{ + Point aOffset(rChild.GetOutOffXPixel() - rParent.GetOutOffXPixel(), rChild.GetOutOffYPixel() - rParent.GetOutOffYPixel()); + MapMode aMapMode(rChild.GetMapMode()); + aMapMode.SetOrigin(rChild.PixelToLogic(aOffset)); + rChild.SetMapMode(aMapMode); + rChild.EnableMapMode(false); +} + void SwSidebarWin::KeyInput(const KeyEvent& rKeyEvent) { if (mpSidebarTextControl) + { + mpSidebarTextControl->Push(PushFlags::MAPMODE); + lcl_setAbsoluteTwips(*EditWin(), *mpSidebarTextControl); + mpSidebarTextControl->KeyInput(rKeyEvent); + + mpSidebarTextControl->Pop(); + } +} + +void SwSidebarWin::MouseButtonDown(const MouseEvent& rMouseEvent) +{ + if (mpSidebarTextControl) + { + mpSidebarTextControl->Push(PushFlags::MAPMODE); + lcl_setAbsoluteTwips(*EditWin(), *mpSidebarTextControl); + + mpSidebarTextControl->MouseButtonDown(rMouseEvent); + + mpSidebarTextControl->Pop(); + } } void SwSidebarWin::SetPosSizePixelRect(long nX, long nY, long nWidth, long nHeight, diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 92768524f647..e2a13fef554e 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -2770,14 +2770,7 @@ void SwEditWin::MouseButtonDown(const MouseEvent& _rMEvt) { if (vcl::Window* pWindow = m_rView.GetPostItMgr()->IsHitSidebarWindow(rMEvt.GetPosPixel())) { - bool bDisableMapMode = pWindow->IsMapModeEnabled(); - if (bDisableMapMode) - pWindow->EnableMapMode(false); - pWindow->MouseButtonDown(rMEvt); - - if (bDisableMapMode) - pWindow->EnableMapMode(); return; } } |