1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svtools.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <vcl/svapp.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <ipwin.hxx> 35*cdf0e10cSrcweir #include <hatchwindow.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir /************************************************************************/ 38*cdf0e10cSrcweir /************************************************************************* 39*cdf0e10cSrcweir |* SvResizeHelper::SvResizeHelper() 40*cdf0e10cSrcweir |* 41*cdf0e10cSrcweir |* Beschreibung 42*cdf0e10cSrcweir *************************************************************************/ 43*cdf0e10cSrcweir SvResizeHelper::SvResizeHelper() 44*cdf0e10cSrcweir : aBorder( 5, 5 ) 45*cdf0e10cSrcweir , nGrab( -1 ) 46*cdf0e10cSrcweir , bResizeable( sal_True ) 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir } 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir /************************************************************************* 51*cdf0e10cSrcweir |* SvResizeHelper::FillHandleRects() 52*cdf0e10cSrcweir |* 53*cdf0e10cSrcweir |* Beschreibung: Die acht Handles zum vergroessern 54*cdf0e10cSrcweir *************************************************************************/ 55*cdf0e10cSrcweir void SvResizeHelper::FillHandleRectsPixel( Rectangle aRects[ 8 ] ) const 56*cdf0e10cSrcweir { 57*cdf0e10cSrcweir // nur wegen EMPTY_RECT 58*cdf0e10cSrcweir Point aBottomRight = aOuter.BottomRight(); 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // Links Oben 61*cdf0e10cSrcweir aRects[ 0 ] = Rectangle( aOuter.TopLeft(), aBorder ); 62*cdf0e10cSrcweir // Oben Mitte 63*cdf0e10cSrcweir aRects[ 1 ] = Rectangle( Point( aOuter.Center().X() - aBorder.Width() / 2, 64*cdf0e10cSrcweir aOuter.Top() ), 65*cdf0e10cSrcweir aBorder ); 66*cdf0e10cSrcweir // Oben Rechts 67*cdf0e10cSrcweir aRects[ 2 ] = Rectangle( Point( aBottomRight.X() - aBorder.Width() +1, 68*cdf0e10cSrcweir aOuter.Top() ), 69*cdf0e10cSrcweir aBorder ); 70*cdf0e10cSrcweir // Mitte Rechts 71*cdf0e10cSrcweir aRects[ 3 ] = Rectangle( Point( aBottomRight.X() - aBorder.Width() +1, 72*cdf0e10cSrcweir aOuter.Center().Y() - aBorder.Height() / 2 ), 73*cdf0e10cSrcweir aBorder ); 74*cdf0e10cSrcweir // Unten Rechts 75*cdf0e10cSrcweir aRects[ 4 ] = Rectangle( Point( aBottomRight.X() - aBorder.Width() +1, 76*cdf0e10cSrcweir aBottomRight.Y() - aBorder.Height() +1 ), 77*cdf0e10cSrcweir aBorder ); 78*cdf0e10cSrcweir // Mitte Unten 79*cdf0e10cSrcweir aRects[ 5 ] = Rectangle( Point( aOuter.Center().X() - aBorder.Width() / 2, 80*cdf0e10cSrcweir aBottomRight.Y() - aBorder.Height() +1), 81*cdf0e10cSrcweir aBorder ); 82*cdf0e10cSrcweir // Links Unten 83*cdf0e10cSrcweir aRects[ 6 ] = Rectangle( Point( aOuter.Left(), 84*cdf0e10cSrcweir aBottomRight.Y() - aBorder.Height() +1), 85*cdf0e10cSrcweir aBorder ); 86*cdf0e10cSrcweir // Mitte Links 87*cdf0e10cSrcweir aRects[ 7 ] = Rectangle( Point( aOuter.Left(), 88*cdf0e10cSrcweir aOuter.Center().Y() - aBorder.Height() / 2 ), 89*cdf0e10cSrcweir aBorder ); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir /************************************************************************* 93*cdf0e10cSrcweir |* SvResizeHelper::FillMoveRectsPixel() 94*cdf0e10cSrcweir |* 95*cdf0e10cSrcweir |* Beschreibung: Die vier Kanten werden berechnet 96*cdf0e10cSrcweir *************************************************************************/ 97*cdf0e10cSrcweir void SvResizeHelper::FillMoveRectsPixel( Rectangle aRects[ 4 ] ) const 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir // Oben 100*cdf0e10cSrcweir aRects[ 0 ] = aOuter; 101*cdf0e10cSrcweir aRects[ 0 ].Bottom() = aRects[ 0 ].Top() + aBorder.Height() -1; 102*cdf0e10cSrcweir // Rechts 103*cdf0e10cSrcweir aRects[ 1 ] = aOuter; 104*cdf0e10cSrcweir aRects[ 1 ].Left() = aRects[ 1 ].Right() - aBorder.Width() -1; 105*cdf0e10cSrcweir //Unten 106*cdf0e10cSrcweir aRects[ 2 ] = aOuter; 107*cdf0e10cSrcweir aRects[ 2 ].Top() = aRects[ 2 ].Bottom() - aBorder.Height() -1; 108*cdf0e10cSrcweir //Links 109*cdf0e10cSrcweir aRects[ 3 ] = aOuter; 110*cdf0e10cSrcweir aRects[ 3 ].Right() = aRects[ 3 ].Left() + aBorder.Width() -1; 111*cdf0e10cSrcweir } 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir /************************************************************************* 114*cdf0e10cSrcweir |* SvResizeHelper::Draw() 115*cdf0e10cSrcweir |* 116*cdf0e10cSrcweir |* Beschreibung 117*cdf0e10cSrcweir *************************************************************************/ 118*cdf0e10cSrcweir void SvResizeHelper::Draw( OutputDevice * pDev ) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir pDev->Push(); 121*cdf0e10cSrcweir pDev->SetMapMode( MapMode() ); 122*cdf0e10cSrcweir Color aColBlack; 123*cdf0e10cSrcweir Color aFillColor( COL_LIGHTGRAY ); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir pDev->SetFillColor( aFillColor ); 126*cdf0e10cSrcweir pDev->SetLineColor(); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir Rectangle aMoveRects[ 4 ]; 129*cdf0e10cSrcweir FillMoveRectsPixel( aMoveRects ); 130*cdf0e10cSrcweir sal_uInt16 i; 131*cdf0e10cSrcweir for( i = 0; i < 4; i++ ) 132*cdf0e10cSrcweir pDev->DrawRect( aMoveRects[ i ] ); 133*cdf0e10cSrcweir if( bResizeable ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir // Handles malen 136*cdf0e10cSrcweir pDev->SetFillColor( aColBlack ); 137*cdf0e10cSrcweir Rectangle aRects[ 8 ]; 138*cdf0e10cSrcweir FillHandleRectsPixel( aRects ); 139*cdf0e10cSrcweir for( i = 0; i < 8; i++ ) 140*cdf0e10cSrcweir pDev->DrawRect( aRects[ i ] ); 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir pDev->Pop(); 143*cdf0e10cSrcweir } 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir /************************************************************************* 146*cdf0e10cSrcweir |* SvResizeHelper::InvalidateBorder() 147*cdf0e10cSrcweir |* 148*cdf0e10cSrcweir |* Beschreibung 149*cdf0e10cSrcweir *************************************************************************/ 150*cdf0e10cSrcweir void SvResizeHelper::InvalidateBorder( Window * pWin ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir Rectangle aMoveRects[ 4 ]; 153*cdf0e10cSrcweir FillMoveRectsPixel( aMoveRects ); 154*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 4; i++ ) 155*cdf0e10cSrcweir pWin->Invalidate( aMoveRects[ i ] ); 156*cdf0e10cSrcweir } 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir /************************************************************************* 159*cdf0e10cSrcweir |* SvResizeHelper::SelectBegin() 160*cdf0e10cSrcweir |* 161*cdf0e10cSrcweir |* Beschreibung 162*cdf0e10cSrcweir *************************************************************************/ 163*cdf0e10cSrcweir sal_Bool SvResizeHelper::SelectBegin( Window * pWin, const Point & rPos ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir if( -1 == nGrab ) 166*cdf0e10cSrcweir { 167*cdf0e10cSrcweir nGrab = SelectMove( pWin, rPos ); 168*cdf0e10cSrcweir if( -1 != nGrab ) 169*cdf0e10cSrcweir { 170*cdf0e10cSrcweir aSelPos = rPos; // Start-Position merken 171*cdf0e10cSrcweir pWin->CaptureMouse(); 172*cdf0e10cSrcweir return sal_True; 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir return sal_False; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir /************************************************************************* 179*cdf0e10cSrcweir |* SvResizeHelper::SelectMove() 180*cdf0e10cSrcweir |* 181*cdf0e10cSrcweir |* Beschreibung 182*cdf0e10cSrcweir *************************************************************************/ 183*cdf0e10cSrcweir short SvResizeHelper::SelectMove( Window * pWin, const Point & rPos ) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir if( -1 == nGrab ) 186*cdf0e10cSrcweir { 187*cdf0e10cSrcweir if( bResizeable ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir Rectangle aRects[ 8 ]; 190*cdf0e10cSrcweir FillHandleRectsPixel( aRects ); 191*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 8; i++ ) 192*cdf0e10cSrcweir if( aRects[ i ].IsInside( rPos ) ) 193*cdf0e10cSrcweir return i; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir // Move-Rect ueberlappen Handles 196*cdf0e10cSrcweir Rectangle aMoveRects[ 4 ]; 197*cdf0e10cSrcweir FillMoveRectsPixel( aMoveRects ); 198*cdf0e10cSrcweir for( sal_uInt16 i = 0; i < 4; i++ ) 199*cdf0e10cSrcweir if( aMoveRects[ i ].IsInside( rPos ) ) 200*cdf0e10cSrcweir return 8; 201*cdf0e10cSrcweir } 202*cdf0e10cSrcweir else 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir Rectangle aRect( GetTrackRectPixel( rPos ) ); 205*cdf0e10cSrcweir aRect.SetSize( pWin->PixelToLogic( aRect.GetSize() ) ); 206*cdf0e10cSrcweir aRect.SetPos( pWin->PixelToLogic( aRect.TopLeft() ) ); 207*cdf0e10cSrcweir pWin->ShowTracking( aRect ); 208*cdf0e10cSrcweir } 209*cdf0e10cSrcweir return nGrab; 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir Point SvResizeHelper::GetTrackPosPixel( const Rectangle & rRect ) const 213*cdf0e10cSrcweir { 214*cdf0e10cSrcweir // wie das Rechteck zurueckkommt ist egal, es zaehlt welches Handle 215*cdf0e10cSrcweir // initial angefasst wurde 216*cdf0e10cSrcweir Point aPos; 217*cdf0e10cSrcweir Rectangle aRect( rRect ); 218*cdf0e10cSrcweir aRect.Justify(); 219*cdf0e10cSrcweir // nur wegen EMPTY_RECT 220*cdf0e10cSrcweir Point aBR = aOuter.BottomRight(); 221*cdf0e10cSrcweir Point aTR = aOuter.TopRight(); 222*cdf0e10cSrcweir Point aBL = aOuter.BottomLeft(); 223*cdf0e10cSrcweir switch( nGrab ) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir case 0: 226*cdf0e10cSrcweir aPos = aRect.TopLeft() - aOuter.TopLeft(); 227*cdf0e10cSrcweir break; 228*cdf0e10cSrcweir case 1: 229*cdf0e10cSrcweir aPos.Y() = aRect.Top() - aOuter.Top(); 230*cdf0e10cSrcweir break; 231*cdf0e10cSrcweir case 2: 232*cdf0e10cSrcweir aPos = aRect.TopRight() - aTR; 233*cdf0e10cSrcweir break; 234*cdf0e10cSrcweir case 3: 235*cdf0e10cSrcweir aPos.X() = aRect.Right() - aTR.X(); 236*cdf0e10cSrcweir break; 237*cdf0e10cSrcweir case 4: 238*cdf0e10cSrcweir aPos = aRect.BottomRight() - aBR; 239*cdf0e10cSrcweir break; 240*cdf0e10cSrcweir case 5: 241*cdf0e10cSrcweir aPos.Y() = aRect.Bottom() - aBR.Y(); 242*cdf0e10cSrcweir break; 243*cdf0e10cSrcweir case 6: 244*cdf0e10cSrcweir aPos = aRect.BottomLeft() - aBL; 245*cdf0e10cSrcweir break; 246*cdf0e10cSrcweir case 7: 247*cdf0e10cSrcweir aPos.X() = aRect.Left() - aOuter.Left(); 248*cdf0e10cSrcweir break; 249*cdf0e10cSrcweir case 8: 250*cdf0e10cSrcweir aPos = aRect.TopLeft() - aOuter.TopLeft(); 251*cdf0e10cSrcweir break; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir return aPos += aSelPos; 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir 256*cdf0e10cSrcweir /************************************************************************* 257*cdf0e10cSrcweir |* SvResizeHelper::GetTrackRectPixel() 258*cdf0e10cSrcweir |* 259*cdf0e10cSrcweir |* Beschreibung 260*cdf0e10cSrcweir *************************************************************************/ 261*cdf0e10cSrcweir Rectangle SvResizeHelper::GetTrackRectPixel( const Point & rTrackPos ) const 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir Rectangle aTrackRect; 264*cdf0e10cSrcweir if( -1 != nGrab ) 265*cdf0e10cSrcweir { 266*cdf0e10cSrcweir Point aDiff = rTrackPos - aSelPos; 267*cdf0e10cSrcweir aTrackRect = aOuter; 268*cdf0e10cSrcweir Point aBR = aOuter.BottomRight(); 269*cdf0e10cSrcweir switch( nGrab ) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir case 0: 272*cdf0e10cSrcweir aTrackRect.Top() += aDiff.Y(); 273*cdf0e10cSrcweir aTrackRect.Left() += aDiff.X(); 274*cdf0e10cSrcweir break; 275*cdf0e10cSrcweir case 1: 276*cdf0e10cSrcweir aTrackRect.Top() += aDiff.Y(); 277*cdf0e10cSrcweir break; 278*cdf0e10cSrcweir case 2: 279*cdf0e10cSrcweir aTrackRect.Top() += aDiff.Y(); 280*cdf0e10cSrcweir aTrackRect.Right() = aBR.X() + aDiff.X(); 281*cdf0e10cSrcweir break; 282*cdf0e10cSrcweir case 3: 283*cdf0e10cSrcweir aTrackRect.Right() = aBR.X() + aDiff.X(); 284*cdf0e10cSrcweir break; 285*cdf0e10cSrcweir case 4: 286*cdf0e10cSrcweir aTrackRect.Bottom() = aBR.Y() + aDiff.Y(); 287*cdf0e10cSrcweir aTrackRect.Right() = aBR.X() + aDiff.X(); 288*cdf0e10cSrcweir break; 289*cdf0e10cSrcweir case 5: 290*cdf0e10cSrcweir aTrackRect.Bottom() = aBR.Y() + aDiff.Y(); 291*cdf0e10cSrcweir break; 292*cdf0e10cSrcweir case 6: 293*cdf0e10cSrcweir aTrackRect.Bottom() = aBR.Y() + aDiff.Y(); 294*cdf0e10cSrcweir aTrackRect.Left() += aDiff.X(); 295*cdf0e10cSrcweir break; 296*cdf0e10cSrcweir case 7: 297*cdf0e10cSrcweir aTrackRect.Left() += aDiff.X(); 298*cdf0e10cSrcweir break; 299*cdf0e10cSrcweir case 8: 300*cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 301*cdf0e10cSrcweir aDiff.X() = -aDiff.X(); // workaround for move in RTL mode 302*cdf0e10cSrcweir aTrackRect.SetPos( aTrackRect.TopLeft() + aDiff ); 303*cdf0e10cSrcweir break; 304*cdf0e10cSrcweir /* 305*cdf0e10cSrcweir case 0: 306*cdf0e10cSrcweir aTrackRect = Rectangle( rTrackPos, aOuter.BottomRight() ); 307*cdf0e10cSrcweir break; 308*cdf0e10cSrcweir case 1: 309*cdf0e10cSrcweir aTrackRect = Rectangle( Point( aOuter.Left(), rTrackPos.Y() ), 310*cdf0e10cSrcweir aOuter.BottomRight() ); 311*cdf0e10cSrcweir break; 312*cdf0e10cSrcweir case 2: 313*cdf0e10cSrcweir aTrackRect = Rectangle( rTrackPos, aOuter.BottomLeft() ); 314*cdf0e10cSrcweir break; 315*cdf0e10cSrcweir case 3: 316*cdf0e10cSrcweir aTrackRect = Rectangle( Point( rTrackPos.X(), aOuter.Top() ), 317*cdf0e10cSrcweir aOuter.BottomLeft() ); 318*cdf0e10cSrcweir break; 319*cdf0e10cSrcweir case 4: 320*cdf0e10cSrcweir aTrackRect = Rectangle( rTrackPos, aOuter.TopLeft() ); 321*cdf0e10cSrcweir break; 322*cdf0e10cSrcweir case 5: 323*cdf0e10cSrcweir aTrackRect = Rectangle( aOuter.TopLeft(), 324*cdf0e10cSrcweir Point( aOuter.Right(), rTrackPos.Y() ) ); 325*cdf0e10cSrcweir break; 326*cdf0e10cSrcweir case 6: 327*cdf0e10cSrcweir aTrackRect = Rectangle( aOuter.TopRight(), rTrackPos ); 328*cdf0e10cSrcweir break; 329*cdf0e10cSrcweir case 7: 330*cdf0e10cSrcweir aTrackRect = Rectangle( Point( rTrackPos.X(), aOuter.Top() ), 331*cdf0e10cSrcweir aOuter.BottomRight() ); 332*cdf0e10cSrcweir break; 333*cdf0e10cSrcweir case 8: 334*cdf0e10cSrcweir aTrackRect = Rectangle( aOuter.TopLeft() + rTrackPos - aSelPos, 335*cdf0e10cSrcweir aOuter.GetSize() ); 336*cdf0e10cSrcweir break; 337*cdf0e10cSrcweir */ 338*cdf0e10cSrcweir } 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir return aTrackRect; 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir 343*cdf0e10cSrcweir void SvResizeHelper::ValidateRect( Rectangle & rValidate ) const 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir switch( nGrab ) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir case 0: 348*cdf0e10cSrcweir if( rValidate.Top() > rValidate.Bottom() ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir rValidate.Top() = rValidate.Bottom(); 351*cdf0e10cSrcweir rValidate.Bottom() = RECT_EMPTY; 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir if( rValidate.Left() > rValidate.Right() ) 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir rValidate.Left() = rValidate.Right(); 356*cdf0e10cSrcweir rValidate.Right() = RECT_EMPTY; 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir break; 359*cdf0e10cSrcweir case 1: 360*cdf0e10cSrcweir if( rValidate.Top() > rValidate.Bottom() ) 361*cdf0e10cSrcweir { 362*cdf0e10cSrcweir rValidate.Top() = rValidate.Bottom(); 363*cdf0e10cSrcweir rValidate.Bottom() = RECT_EMPTY; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir break; 366*cdf0e10cSrcweir case 2: 367*cdf0e10cSrcweir if( rValidate.Top() > rValidate.Bottom() ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir rValidate.Top() = rValidate.Bottom(); 370*cdf0e10cSrcweir rValidate.Bottom() = RECT_EMPTY; 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir if( rValidate.Left() > rValidate.Right() ) 373*cdf0e10cSrcweir rValidate.Right() = RECT_EMPTY; 374*cdf0e10cSrcweir break; 375*cdf0e10cSrcweir case 3: 376*cdf0e10cSrcweir if( rValidate.Left() > rValidate.Right() ) 377*cdf0e10cSrcweir rValidate.Right() = RECT_EMPTY; 378*cdf0e10cSrcweir break; 379*cdf0e10cSrcweir case 4: 380*cdf0e10cSrcweir if( rValidate.Top() > rValidate.Bottom() ) 381*cdf0e10cSrcweir rValidate.Bottom() = RECT_EMPTY; 382*cdf0e10cSrcweir if( rValidate.Left() > rValidate.Right() ) 383*cdf0e10cSrcweir rValidate.Right() = RECT_EMPTY; 384*cdf0e10cSrcweir break; 385*cdf0e10cSrcweir case 5: 386*cdf0e10cSrcweir if( rValidate.Top() > rValidate.Bottom() ) 387*cdf0e10cSrcweir rValidate.Bottom() = RECT_EMPTY; 388*cdf0e10cSrcweir break; 389*cdf0e10cSrcweir case 6: 390*cdf0e10cSrcweir if( rValidate.Top() > rValidate.Bottom() ) 391*cdf0e10cSrcweir rValidate.Bottom() = RECT_EMPTY; 392*cdf0e10cSrcweir if( rValidate.Left() > rValidate.Right() ) 393*cdf0e10cSrcweir { 394*cdf0e10cSrcweir rValidate.Left() = rValidate.Right(); 395*cdf0e10cSrcweir rValidate.Right() = RECT_EMPTY; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir break; 398*cdf0e10cSrcweir case 7: 399*cdf0e10cSrcweir if( rValidate.Left() > rValidate.Right() ) 400*cdf0e10cSrcweir { 401*cdf0e10cSrcweir rValidate.Left() = rValidate.Right(); 402*cdf0e10cSrcweir rValidate.Right() = RECT_EMPTY; 403*cdf0e10cSrcweir } 404*cdf0e10cSrcweir break; 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir if( rValidate.Right() == RECT_EMPTY ) 407*cdf0e10cSrcweir rValidate.Right() = rValidate.Left(); 408*cdf0e10cSrcweir if( rValidate.Bottom() == RECT_EMPTY ) 409*cdf0e10cSrcweir rValidate.Bottom() = rValidate.Top(); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir // Mindestgr"osse 5 x 5 412*cdf0e10cSrcweir if( rValidate.Left() + 5 > rValidate.Right() ) 413*cdf0e10cSrcweir rValidate.Right() = rValidate.Left() +5; 414*cdf0e10cSrcweir if( rValidate.Top() + 5 > rValidate.Bottom() ) 415*cdf0e10cSrcweir rValidate.Bottom() = rValidate.Top() +5; 416*cdf0e10cSrcweir } 417*cdf0e10cSrcweir 418*cdf0e10cSrcweir /************************************************************************* 419*cdf0e10cSrcweir |* SvResizeHelper::SelectRelease() 420*cdf0e10cSrcweir |* 421*cdf0e10cSrcweir |* Beschreibung 422*cdf0e10cSrcweir *************************************************************************/ 423*cdf0e10cSrcweir sal_Bool SvResizeHelper::SelectRelease( Window * pWin, const Point & rPos, 424*cdf0e10cSrcweir Rectangle & rOutPosSize ) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir if( -1 != nGrab ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir rOutPosSize = GetTrackRectPixel( rPos ); 429*cdf0e10cSrcweir rOutPosSize.Justify(); 430*cdf0e10cSrcweir nGrab = -1; 431*cdf0e10cSrcweir pWin->ReleaseMouse(); 432*cdf0e10cSrcweir pWin->HideTracking(); 433*cdf0e10cSrcweir return sal_True; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir return sal_False; 436*cdf0e10cSrcweir } 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir /************************************************************************* 439*cdf0e10cSrcweir |* SvResizeHelper::Release() 440*cdf0e10cSrcweir |* 441*cdf0e10cSrcweir |* Beschreibung 442*cdf0e10cSrcweir *************************************************************************/ 443*cdf0e10cSrcweir void SvResizeHelper::Release( Window * pWin ) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir if( nGrab != -1 ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir pWin->ReleaseMouse(); 448*cdf0e10cSrcweir pWin->HideTracking(); 449*cdf0e10cSrcweir nGrab = -1; 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir } 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir /************************************************************************* 454*cdf0e10cSrcweir |* SvResizeWindow::SvResizeWindow() 455*cdf0e10cSrcweir |* 456*cdf0e10cSrcweir |* Beschreibung 457*cdf0e10cSrcweir *************************************************************************/ 458*cdf0e10cSrcweir SvResizeWindow::SvResizeWindow 459*cdf0e10cSrcweir ( 460*cdf0e10cSrcweir Window * pParent, 461*cdf0e10cSrcweir VCLXHatchWindow* pWrapper 462*cdf0e10cSrcweir ) 463*cdf0e10cSrcweir : Window( pParent, WB_CLIPCHILDREN ) 464*cdf0e10cSrcweir , m_nMoveGrab( -1 ) 465*cdf0e10cSrcweir , m_bActive( sal_False ) 466*cdf0e10cSrcweir , m_pWrapper( pWrapper ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir OSL_ENSURE( pParent != NULL && pWrapper != NULL, "Wrong initialization of hatch window!\n" ); 469*cdf0e10cSrcweir SetBackground(); 470*cdf0e10cSrcweir SetAccessibleRole( ::com::sun::star::accessibility::AccessibleRole::EMBEDDED_OBJECT ); 471*cdf0e10cSrcweir m_aResizer.SetOuterRectPixel( Rectangle( Point(), GetOutputSizePixel() ) ); 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir /************************************************************************* 475*cdf0e10cSrcweir |* SvResizeWindow::SetHatchBorderPixel() 476*cdf0e10cSrcweir |* 477*cdf0e10cSrcweir |* Beschreibung 478*cdf0e10cSrcweir *************************************************************************/ 479*cdf0e10cSrcweir void SvResizeWindow::SetHatchBorderPixel( const Size & rSize ) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir m_aResizer.SetBorderPixel( rSize ); 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir 484*cdf0e10cSrcweir /************************************************************************* 485*cdf0e10cSrcweir |* SvResizeWindow::SelectMouse() 486*cdf0e10cSrcweir |* 487*cdf0e10cSrcweir |* Beschreibung 488*cdf0e10cSrcweir *************************************************************************/ 489*cdf0e10cSrcweir void SvResizeWindow::SelectMouse( const Point & rPos ) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir short nGrab = m_aResizer.SelectMove( this, rPos ); 492*cdf0e10cSrcweir if( nGrab >= 4 ) 493*cdf0e10cSrcweir nGrab -= 4; 494*cdf0e10cSrcweir if( m_nMoveGrab != nGrab ) 495*cdf0e10cSrcweir { // Pointer hat sich geaendert 496*cdf0e10cSrcweir if( -1 == nGrab ) 497*cdf0e10cSrcweir SetPointer( m_aOldPointer ); 498*cdf0e10cSrcweir else 499*cdf0e10cSrcweir { 500*cdf0e10cSrcweir PointerStyle aStyle = POINTER_MOVE; 501*cdf0e10cSrcweir if( nGrab == 3 ) 502*cdf0e10cSrcweir aStyle = POINTER_ESIZE; 503*cdf0e10cSrcweir else if( nGrab == 2 ) 504*cdf0e10cSrcweir aStyle = POINTER_NESIZE; 505*cdf0e10cSrcweir else if( nGrab == 1 ) 506*cdf0e10cSrcweir aStyle = POINTER_SSIZE; 507*cdf0e10cSrcweir else if( nGrab == 0 ) 508*cdf0e10cSrcweir aStyle = POINTER_SESIZE; 509*cdf0e10cSrcweir if( m_nMoveGrab == -1 ) // das erste mal 510*cdf0e10cSrcweir { 511*cdf0e10cSrcweir m_aOldPointer = GetPointer(); 512*cdf0e10cSrcweir SetPointer( Pointer( aStyle ) ); 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir else 515*cdf0e10cSrcweir SetPointer( Pointer( aStyle ) ); 516*cdf0e10cSrcweir } 517*cdf0e10cSrcweir m_nMoveGrab = nGrab; 518*cdf0e10cSrcweir } 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir /************************************************************************* 522*cdf0e10cSrcweir |* SvResizeWindow::MouseButtonDown() 523*cdf0e10cSrcweir |* 524*cdf0e10cSrcweir |* Beschreibung 525*cdf0e10cSrcweir *************************************************************************/ 526*cdf0e10cSrcweir void SvResizeWindow::MouseButtonDown( const MouseEvent & rEvt ) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir if( m_aResizer.SelectBegin( this, rEvt.GetPosPixel() ) ) 529*cdf0e10cSrcweir SelectMouse( rEvt.GetPosPixel() ); 530*cdf0e10cSrcweir } 531*cdf0e10cSrcweir 532*cdf0e10cSrcweir /************************************************************************* 533*cdf0e10cSrcweir |* SvResizeWindow::MouseMove() 534*cdf0e10cSrcweir |* 535*cdf0e10cSrcweir |* Beschreibung 536*cdf0e10cSrcweir *************************************************************************/ 537*cdf0e10cSrcweir void SvResizeWindow::MouseMove( const MouseEvent & rEvt ) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir if( m_aResizer.GetGrab() == -1 ) 540*cdf0e10cSrcweir SelectMouse( rEvt.GetPosPixel() ); 541*cdf0e10cSrcweir else 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir Rectangle aRect( m_aResizer.GetTrackRectPixel( rEvt.GetPosPixel() ) ); 544*cdf0e10cSrcweir Point aDiff = GetPosPixel(); 545*cdf0e10cSrcweir aRect.SetPos( aRect.TopLeft() + aDiff ); 546*cdf0e10cSrcweir m_aResizer.ValidateRect( aRect ); 547*cdf0e10cSrcweir 548*cdf0e10cSrcweir m_pWrapper->QueryObjAreaPixel( aRect ); 549*cdf0e10cSrcweir aRect.SetPos( aRect.TopLeft() - aDiff ); 550*cdf0e10cSrcweir Point aPos = m_aResizer.GetTrackPosPixel( aRect ); 551*cdf0e10cSrcweir 552*cdf0e10cSrcweir SelectMouse( aPos ); 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir } 555*cdf0e10cSrcweir 556*cdf0e10cSrcweir /************************************************************************* 557*cdf0e10cSrcweir |* SvResizeWindow::MouseButtonUp() 558*cdf0e10cSrcweir |* 559*cdf0e10cSrcweir |* Beschreibung 560*cdf0e10cSrcweir *************************************************************************/ 561*cdf0e10cSrcweir void SvResizeWindow::MouseButtonUp( const MouseEvent & rEvt ) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir if( m_aResizer.GetGrab() != -1 ) 564*cdf0e10cSrcweir { 565*cdf0e10cSrcweir Rectangle aRect( m_aResizer.GetTrackRectPixel( rEvt.GetPosPixel() ) ); 566*cdf0e10cSrcweir Point aDiff = GetPosPixel(); 567*cdf0e10cSrcweir aRect.SetPos( aRect.TopLeft() + aDiff ); 568*cdf0e10cSrcweir // aRect -= GetAllBorderPixel(); 569*cdf0e10cSrcweir m_aResizer.ValidateRect( aRect ); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir m_pWrapper->QueryObjAreaPixel( aRect ); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir Rectangle aOutRect; 574*cdf0e10cSrcweir if( m_aResizer.SelectRelease( this, rEvt.GetPosPixel(), aOutRect ) ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir m_nMoveGrab = -1; 577*cdf0e10cSrcweir SetPointer( m_aOldPointer ); 578*cdf0e10cSrcweir m_pWrapper->RequestObjAreaPixel( aRect ); 579*cdf0e10cSrcweir } 580*cdf0e10cSrcweir } 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir 583*cdf0e10cSrcweir /************************************************************************* 584*cdf0e10cSrcweir |* SvResizeWindow::KeyEvent() 585*cdf0e10cSrcweir |* 586*cdf0e10cSrcweir |* Beschreibung 587*cdf0e10cSrcweir *************************************************************************/ 588*cdf0e10cSrcweir void SvResizeWindow::KeyInput( const KeyEvent & rEvt ) 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir if( rEvt.GetKeyCode().GetCode() == KEY_ESCAPE ) 591*cdf0e10cSrcweir { 592*cdf0e10cSrcweir m_aResizer.Release( this ); 593*cdf0e10cSrcweir m_pWrapper->InplaceDeactivate(); 594*cdf0e10cSrcweir } 595*cdf0e10cSrcweir } 596*cdf0e10cSrcweir 597*cdf0e10cSrcweir /************************************************************************* 598*cdf0e10cSrcweir |* SvResizeWindow::Resize() 599*cdf0e10cSrcweir |* 600*cdf0e10cSrcweir |* Beschreibung 601*cdf0e10cSrcweir *************************************************************************/ 602*cdf0e10cSrcweir void SvResizeWindow::Resize() 603*cdf0e10cSrcweir { 604*cdf0e10cSrcweir m_aResizer.InvalidateBorder( this ); // alten Bereich 605*cdf0e10cSrcweir m_aResizer.SetOuterRectPixel( Rectangle( Point(), GetOutputSizePixel() ) ); 606*cdf0e10cSrcweir m_aResizer.InvalidateBorder( this ); // neuen Bereich 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir /************************************************************************* 610*cdf0e10cSrcweir |* SvResizeWindow::Paint() 611*cdf0e10cSrcweir |* 612*cdf0e10cSrcweir |* Beschreibung 613*cdf0e10cSrcweir *************************************************************************/ 614*cdf0e10cSrcweir void SvResizeWindow::Paint( const Rectangle & /*rRect*/ ) 615*cdf0e10cSrcweir { 616*cdf0e10cSrcweir m_aResizer.Draw( this ); 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir long SvResizeWindow::PreNotify( NotifyEvent& rEvt ) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir if ( rEvt.GetType() == EVENT_GETFOCUS && !m_bActive ) 622*cdf0e10cSrcweir { 623*cdf0e10cSrcweir m_bActive = sal_True; 624*cdf0e10cSrcweir m_pWrapper->Activated(); 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir return Window::PreNotify(rEvt); 628*cdf0e10cSrcweir } 629*cdf0e10cSrcweir 630*cdf0e10cSrcweir long SvResizeWindow::Notify( NotifyEvent& rEvt ) 631*cdf0e10cSrcweir { 632*cdf0e10cSrcweir if ( rEvt.GetType() == EVENT_LOSEFOCUS && m_bActive ) 633*cdf0e10cSrcweir { 634*cdf0e10cSrcweir sal_Bool bHasFocus = HasChildPathFocus(sal_True); 635*cdf0e10cSrcweir if ( !bHasFocus ) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir m_bActive = sal_False; 638*cdf0e10cSrcweir m_pWrapper->Deactivated(); 639*cdf0e10cSrcweir } 640*cdf0e10cSrcweir } 641*cdf0e10cSrcweir 642*cdf0e10cSrcweir return Window::Notify(rEvt); 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645