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