diff options
author | Tomaž Vajngerl <quikee@gmail.com> | 2013-08-08 21:11:54 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2013-08-08 23:03:37 +0200 |
commit | 5f3b4c0eb6905bcff588baaec235dbf726da191b (patch) | |
tree | 4fe6284d9ea368547ea401ff169ca7957fe90988 | |
parent | dfc4ace4278d6c9e77ec150f947a1a6ee454d70d (diff) |
fdo#67592 Resize selection box from all 4 corners
Change-Id: I40c857eb1ed5c784a3911667f685c6450bf7a7c4
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 14 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 109 | ||||
-rw-r--r-- | sc/source/ui/view/output.cxx | 31 |
3 files changed, 121 insertions, 33 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 0909f413c9b5..f32ea5e0141f 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -82,6 +82,16 @@ class ScGridWindow : public Window, public DropTargetHelper, public DragSourceHe friend class ScFilterListBox; private: + + enum RfCorner + { + NONE, + LEFT_UP, + RIGHT_UP, + LEFT_DOWN, + RIGHT_DOWN + }; + // #114409# ::sdr::overlay::OverlayObjectList* mpOOCursors; ::sdr::overlay::OverlayObjectList* mpOOSelection; @@ -171,6 +181,8 @@ private: Rectangle aInvertRect; + RfCorner aRFSelectedCorned; + bool bEEMouse:1; // Edit Engine has mouse bool bDPMouse:1; // DataPilot D&D (new Pivot table) bool bRFMouse:1; // RangeFinder drag @@ -255,7 +267,7 @@ private: bool GetEditUrlOrError( bool bSpellErr, const Point& rPos, String* pName=0, String* pUrl=0, String* pTarget=0 ); - bool HitRangeFinder( const Point& rMouse, bool& rCorner, sal_uInt16* pIndex = NULL, + bool HitRangeFinder( const Point& rMouse, RfCorner& rCorner, sal_uInt16* pIndex = NULL, SCsCOL* pAddX = NULL, SCsROW* pAddY = NULL ); sal_uInt16 HitPageBreak( const Point& rMouse, ScRange* pSource = NULL, diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 7afbab12e41a..29016c2f4140 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -1765,9 +1765,11 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta // Reihenfolge passend zum angezeigten Cursor: // RangeFinder, AutoFill, PageBreak, Drawing - bool bCorner; - bool bFound = HitRangeFinder(rMEvt.GetPosPixel(), bCorner, &nRFIndex, &nRFAddX, &nRFAddY); - bRFSize = bCorner; + RfCorner rCorner = NONE; + bool bFound = HitRangeFinder(rMEvt.GetPosPixel(), rCorner, &nRFIndex, &nRFAddX, &nRFAddY); + bRFSize = (rCorner != NONE); + aRFSelectedCorned = rCorner; + if (bFound) { bRFMouse = true; // die anderen Variablen sind oben initialisiert @@ -2545,10 +2547,10 @@ void ScGridWindow::MouseMove( const MouseEvent& rMEvt ) // Range-Finder - bool bCorner; - if ( HitRangeFinder( rMEvt.GetPosPixel(), bCorner ) ) + RfCorner rCorner = NONE; + if ( HitRangeFinder( rMEvt.GetPosPixel(), rCorner ) ) { - if (bCorner) + if (rCorner != NONE) SetPointer( Pointer( POINTER_CROSS ) ); else SetPointer( Pointer( POINTER_HAND ) ); @@ -4702,8 +4704,8 @@ Point ScGridWindow::GetMousePosPixel() const { return aCurMousePos; } //------------------------------------------------------------------------ -bool ScGridWindow::HitRangeFinder( const Point& rMouse, bool& rCorner, - sal_uInt16* pIndex, SCsCOL* pAddX, SCsROW* pAddY ) +bool ScGridWindow::HitRangeFinder( const Point& rMouse, RfCorner& rCorner, + sal_uInt16* pIndex, SCsCOL* pAddX, SCsROW* pAddY) { bool bFound = false; ScInputHandler* pHdl = SC_MOD()->GetInputHdl( pViewData->GetViewShell() ); @@ -4724,36 +4726,74 @@ bool ScGridWindow::HitRangeFinder( const Point& rMouse, bool& rCorner, // zusammengefasste (einzeln/Bereich) ??? ScAddress aAddr( nPosX, nPosY, nTab ); - Point aNext = pViewData->GetScrPos( nPosX, nPosY, eWhich, true ); + Point aCellStart = pViewData->GetScrPos( nPosX, nPosY, eWhich, true ); + Point aCellEnd = aCellStart; long nSizeXPix; long nSizeYPix; pViewData->GetMergeSizePixel( nPosX, nPosY, nSizeXPix, nSizeYPix ); - aNext.X() += nSizeXPix * nLayoutSign; - aNext.Y() += nSizeYPix; - bool bCornerHor; + aCellEnd.X() += nSizeXPix * nLayoutSign; + aCellEnd.Y() += nSizeYPix; + + bool bCornerHorizontalRight; + bool bCornerHorizontalLeft; if ( bLayoutRTL ) - bCornerHor = ( rMouse.X() >= aNext.X() && rMouse.X() <= aNext.X() + 8 ); + { + bCornerHorizontalRight = ( rMouse.X() >= aCellEnd.X() && rMouse.X() <= aCellEnd.X() + 8 ); + bCornerHorizontalLeft = ( rMouse.X() >= aCellStart.X() - 8 && rMouse.X() <= aCellStart.X() ); + } else - bCornerHor = ( rMouse.X() >= aNext.X() - 8 && rMouse.X() <= aNext.X() ); + { + bCornerHorizontalRight = ( rMouse.X() >= aCellEnd.X() - 8 && rMouse.X() <= aCellEnd.X() ); + bCornerHorizontalLeft = ( rMouse.X() >= aCellStart.X() && rMouse.X() <= aCellStart.X() + 8 ); + } - bool bCellCorner = ( bCornerHor && - rMouse.Y() >= aNext.Y() - 8 && rMouse.Y() <= aNext.Y() ); - // corner is hit only if the mouse is within the cell + bool bCornerVerticalDown = rMouse.Y() >= aCellEnd.Y() - 8 && rMouse.Y() <= aCellEnd.Y(); + bool bCornerVerticalUp = rMouse.Y() >= aCellStart.Y() && rMouse.Y() <= aCellStart.Y() + 8; + // corner is hit only if the mouse is within the cell sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count(); for (sal_uInt16 i=nCount; i;) { - // rueckwaerts suchen, damit der zuletzt gepaintete Rahmen gefunden wird + // search backwards so that the last repainted frame is found --i; ScRangeFindData* pData = pRangeFinder->GetObject(i); if ( pData->aRef.In(aAddr) ) { - if (pIndex) *pIndex = i; - if (pAddX) *pAddX = nPosX - pData->aRef.aStart.Col(); - if (pAddY) *pAddY = nPosY - pData->aRef.aStart.Row(); - bFound = sal_True; - rCorner = ( bCellCorner && aAddr == pData->aRef.aEnd ); + if (pIndex) + *pIndex = i; + if (pAddX) + *pAddX = nPosX - pData->aRef.aStart.Col(); + if (pAddY) + *pAddY = nPosY - pData->aRef.aStart.Row(); + + bFound = true; + + rCorner = NONE; + + ScAddress aEnd = pData->aRef.aEnd; + ScAddress aStart = pData->aRef.aStart; + + if ( bCornerHorizontalLeft && bCornerVerticalUp && + aAddr == aStart) + { + rCorner = LEFT_UP; + } + else if (bCornerHorizontalRight && bCornerVerticalDown && + aAddr == aEnd) + { + rCorner = RIGHT_DOWN; + } + else if (bCornerHorizontalRight && bCornerVerticalUp && + aAddr == ScAddress(aEnd.Col(), aStart.Row(), aStart.Tab())) + { + rCorner = RIGHT_UP; + } + else if (bCornerHorizontalLeft && bCornerVerticalDown && + aAddr == ScAddress(aStart.Col(), aEnd.Row(), aStart.Tab())) + { + rCorner = LEFT_DOWN; + } break; } } @@ -4972,8 +5012,27 @@ void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp ) ScRange aNew = aOld; if ( bRFSize ) { - aNew.aEnd.SetCol((SCCOL)nPosX); - aNew.aEnd.SetRow((SCROW)nPosY); + switch (aRFSelectedCorned) + { + case LEFT_UP: + aNew.aStart.SetCol((SCCOL)nPosX); + aNew.aStart.SetRow((SCROW)nPosY); + break; + case LEFT_DOWN: + aNew.aStart.SetCol((SCCOL)nPosX); + aNew.aEnd.SetRow((SCROW)nPosY); + break; + case RIGHT_UP: + aNew.aEnd.SetCol((SCCOL)nPosX); + aNew.aStart.SetRow((SCROW)nPosY); + break; + case RIGHT_DOWN: + aNew.aEnd.SetCol((SCCOL)nPosX); + aNew.aEnd.SetRow((SCROW)nPosY); + break; + default: + break; + } } else { diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx index 5826efde66dc..a786718f917e 100644 --- a/sc/source/ui/view/output.cxx +++ b/sc/source/ui/view/output.cxx @@ -2013,8 +2013,8 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY, { long nMinX = nScrX; long nMinY = nScrY; - long nMaxX = nScrX+nScrW-1; - long nMaxY = nScrY+nScrH-1; + long nMaxX = nScrX + nScrW - 1; + long nMaxY = nScrY + nScrH - 1; if ( bLayoutRTL ) { long nTemp = nMinX; @@ -2086,19 +2086,36 @@ void ScOutputData::DrawRefMark( SCCOL nRefStartX, SCROW nRefStartY, else { if (bTop) - mpDev->DrawLine( Point( nMinX,nMinY ), Point( nMaxX,nMinY ) ); + mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMaxX, nMinY ) ); if (bBottom) - mpDev->DrawLine( Point( nMinX,nMaxY ), Point( nMaxX,nMaxY ) ); + mpDev->DrawLine( Point( nMinX, nMaxY ), Point( nMaxX, nMaxY ) ); if (bLeft) - mpDev->DrawLine( Point( nMinX,nMinY ), Point( nMinX,nMaxY ) ); + mpDev->DrawLine( Point( nMinX, nMinY ), Point( nMinX, nMaxY ) ); if (bRight) - mpDev->DrawLine( Point( nMaxX,nMinY ), Point( nMaxX,nMaxY ) ); + mpDev->DrawLine( Point( nMaxX, nMinY ), Point( nMaxX, nMaxY ) ); } if ( bHandle && bRight && bBottom ) { mpDev->SetLineColor(); mpDev->SetFillColor( rColor ); - mpDev->DrawRect( Rectangle( nMaxX-3*nLayoutSign, nMaxY-3, nMaxX+nLayoutSign, nMaxY+1 ) ); + + const sal_Int32 aRadius = 4; + + sal_Int32 aRectMaxX1 = nMaxX - nLayoutSign * aRadius; + sal_Int32 aRectMaxX2 = nMaxX + nLayoutSign; + sal_Int32 aRectMinX1 = nMinX - nLayoutSign; + sal_Int32 aRectMinX2 = nMinX + nLayoutSign * aRadius; + + sal_Int32 aRectMaxY1 = nMaxY - aRadius; + sal_Int32 aRectMaxY2 = nMaxY + 1; + sal_Int32 aRectMinY1 = nMinY - 1; + sal_Int32 aRectMinY2 = nMinY + aRadius; + + // Draw corner rectangles + mpDev->DrawRect( Rectangle( aRectMaxX1, aRectMaxY1, aRectMaxX2, aRectMaxY2 ) ); + mpDev->DrawRect( Rectangle( aRectMinX1, aRectMinY1, aRectMinX2, aRectMinY2 ) ); + mpDev->DrawRect( Rectangle( aRectMinX1, aRectMaxY1, aRectMinX2, aRectMaxY2 ) ); + mpDev->DrawRect( Rectangle( aRectMaxX1, aRectMinY1, aRectMaxX2, aRectMinY2 ) ); } } } |