Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/toolkit/source/hatchwindow/ipwin.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/*
3
 * This file is part of the LibreOffice project.
4
 *
5
 * This Source Code Form is subject to the terms of the Mozilla Public
6
 * License, v. 2.0. If a copy of the MPL was not distributed with this
7
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
 *
9
 * This file incorporates work covered by the following license notice:
10
 *
11
 *   Licensed to the Apache Software Foundation (ASF) under one or more
12
 *   contributor license agreements. See the NOTICE file distributed
13
 *   with this work for additional information regarding copyright
14
 *   ownership. The ASF licenses this file to you under the Apache
15
 *   License, Version 2.0 (the "License"); you may not use this file
16
 *   except in compliance with the License. You may obtain a copy of
17
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18
 */
19
20
#include <com/sun/star/accessibility/AccessibleRole.hpp>
21
22
#include <osl/diagnose.h>
23
#include <vcl/event.hxx>
24
#include <vcl/settings.hxx>
25
#include <vcl/ptrstyle.hxx>
26
27
#include "ipwin.hxx"
28
#include "hatchwindow.hxx"
29
30
/************************************************************************/
31
/*************************************************************************
32
|*    SvResizeHelper::SvResizeHelper()
33
|*
34
|*    Description
35
*************************************************************************/
36
SvResizeHelper::SvResizeHelper()
37
0
    : aBorder( 5, 5 )
38
0
    , nGrab( -1 )
39
0
    , mofStartingRatio( std::nullopt )
40
0
{
41
0
}
42
43
/*************************************************************************
44
|*    SvResizeHelper::FillHandleRects()
45
|*
46
|*    Description: the eight handles to magnify
47
*************************************************************************/
48
std::array<tools::Rectangle,8> SvResizeHelper::FillHandleRectsPixel() const
49
0
{
50
0
    std::array<tools::Rectangle,8> aRects;
51
52
    // only because of EMPTY_RECT
53
0
    Point aBottomRight = aOuter.BottomRight();
54
55
    // upper left
56
0
    aRects[ 0 ] = tools::Rectangle( aOuter.TopLeft(), aBorder );
57
    // upper middle
58
0
    aRects[ 1 ] = tools::Rectangle( Point( aOuter.Center().X() - aBorder.Width() / 2,
59
0
                                    aOuter.Top() ),
60
0
                            aBorder );
61
    // upper right
62
0
    aRects[ 2 ] = tools::Rectangle( Point( aBottomRight.X() - aBorder.Width() +1,
63
0
                                    aOuter.Top() ),
64
0
                            aBorder );
65
    // middle right
66
0
    aRects[ 3 ] = tools::Rectangle( Point( aBottomRight.X() - aBorder.Width() +1,
67
0
                                    aOuter.Center().Y() - aBorder.Height() / 2 ),
68
0
                            aBorder );
69
    // lower right
70
0
    aRects[ 4 ] = tools::Rectangle( Point( aBottomRight.X() - aBorder.Width() +1,
71
0
                                    aBottomRight.Y() - aBorder.Height() +1 ),
72
0
                            aBorder );
73
    // lower middle
74
0
    aRects[ 5 ] = tools::Rectangle( Point( aOuter.Center().X() - aBorder.Width() / 2,
75
0
                                    aBottomRight.Y() - aBorder.Height() +1),
76
0
                            aBorder );
77
    // lower left
78
0
    aRects[ 6 ] = tools::Rectangle( Point( aOuter.Left(),
79
0
                                    aBottomRight.Y() - aBorder.Height() +1),
80
0
                            aBorder );
81
    // middle left
82
0
    aRects[ 7 ] = tools::Rectangle( Point( aOuter.Left(),
83
0
                                    aOuter.Center().Y() - aBorder.Height() / 2 ),
84
0
                            aBorder );
85
0
    return aRects;
86
0
}
87
88
/*************************************************************************
89
|*    SvResizeHelper::FillMoveRectsPixel()
90
|*
91
|*    Description: the four edges are calculated
92
*************************************************************************/
93
std::array<tools::Rectangle,4> SvResizeHelper::FillMoveRectsPixel() const
94
0
{
95
0
    std::array<tools::Rectangle,4> aRects;
96
97
    // upper
98
0
    aRects[ 0 ] = aOuter;
99
0
    aRects[ 0 ].SetBottom( aRects[ 0 ].Top() + aBorder.Height() -1 );
100
    // right
101
0
    aRects[ 1 ] = aOuter;
102
0
    if (!aOuter.IsWidthEmpty())
103
0
        aRects[ 1 ].SetLeft( aRects[ 1 ].Right() - aBorder.Width() -1 );
104
    // lower
105
0
    aRects[ 2 ] = aOuter;
106
0
    if (!aOuter.IsHeightEmpty())
107
0
        aRects[ 2 ].SetTop( aRects[ 2 ].Bottom() - aBorder.Height() -1 );
108
    // left
109
0
    aRects[ 3 ] = aOuter;
110
0
    aRects[ 3 ].SetRight( aRects[ 3 ].Left() + aBorder.Width() -1 );
111
112
0
    return aRects;
113
0
}
114
115
/*************************************************************************
116
|*    SvResizeHelper::Draw()
117
|*
118
|*    Description
119
*************************************************************************/
120
void SvResizeHelper::Draw(vcl::RenderContext& rRenderContext)
121
0
{
122
0
    auto popIt = rRenderContext.ScopedPush();
123
0
    rRenderContext.SetMapMode( MapMode() );
124
125
0
    rRenderContext.SetFillColor( COL_LIGHTGRAY );
126
0
    rRenderContext.SetLineColor();
127
128
0
    std::array<tools::Rectangle,4> aMoveRects = FillMoveRectsPixel();
129
0
    sal_uInt16 i;
130
0
    for (i = 0; i < 4; i++)
131
0
        rRenderContext.DrawRect(aMoveRects[i]);
132
    // draw handles
133
0
    rRenderContext.SetFillColor(Color()); // black
134
0
    std::array<tools::Rectangle,8> aRects = FillHandleRectsPixel();
135
0
    for (i = 0; i < 8; i++)
136
0
        rRenderContext.DrawRect( aRects[ i ] );
137
0
}
138
139
/*************************************************************************
140
|*    SvResizeHelper::InvalidateBorder()
141
|*
142
|*    Description
143
*************************************************************************/
144
void SvResizeHelper::InvalidateBorder( vcl::Window * pWin )
145
0
{
146
0
    std::array<tools::Rectangle,4> aMoveRects = FillMoveRectsPixel();
147
0
    for(const auto & rMoveRect : aMoveRects)
148
0
        pWin->Invalidate( rMoveRect );
149
0
}
150
151
/*************************************************************************
152
|*    SvResizeHelper::SelectBegin()
153
|*
154
|*    Description
155
*************************************************************************/
156
bool SvResizeHelper::SelectBegin( vcl::Window * pWin, const Point & rPos, const bool bShiftPressed )
157
0
{
158
0
    if( -1 == nGrab && pWin )
159
0
    {
160
0
        nGrab = SelectMove( pWin, rPos, bShiftPressed );
161
0
        if( -1 != nGrab )
162
0
        {
163
0
            aSelPos = rPos; // store start position
164
0
            mofStartingRatio = std::nullopt;
165
0
            const auto aWinSize = pWin->GetSizePixel();
166
0
            if( aWinSize.Height() )
167
0
                mofStartingRatio  = aWinSize.Width() / static_cast<double>( aWinSize.Height() );
168
0
            pWin->CaptureMouse();
169
0
            return true;
170
0
        }
171
0
    }
172
0
    return false;
173
0
}
174
175
/*************************************************************************
176
|*    SvResizeHelper::SelectMove()
177
|*
178
|*    Description
179
*************************************************************************/
180
short SvResizeHelper::SelectMove( vcl::Window * pWin, const Point & rPos, const bool bShiftPressed )
181
0
{
182
0
    if( -1 == nGrab )
183
0
    {
184
0
        std::array<tools::Rectangle,8> aRects = FillHandleRectsPixel();
185
0
        for( sal_uInt16 i = 0; i < 8; i++ )
186
0
            if( aRects[ i ].Contains( rPos ) )
187
0
                return i;
188
        // Move-Rect overlaps Handles
189
0
        std::array<tools::Rectangle,4> aMoveRects = FillMoveRectsPixel();
190
0
        for(const auto & rMoveRect : aMoveRects)
191
0
            if( rMoveRect.Contains( rPos ) )
192
0
                return 8;
193
0
    }
194
0
    else
195
0
    {
196
0
        tools::Rectangle aRect = pWin->PixelToLogic(GetTrackRectPixel( rPos, bShiftPressed ));
197
0
        pWin->ShowTracking( aRect );
198
0
    }
199
0
    return nGrab;
200
0
}
201
202
Point SvResizeHelper::GetTrackPosPixel( const tools::Rectangle & rRect ) const
203
0
{
204
    // not important how the rectangle is returned, it is important
205
    // which handle has been touched
206
0
    Point aPos;
207
0
    tools::Rectangle aRect( rRect );
208
0
    aRect.Normalize();
209
    // only because of EMPTY_RECT
210
0
    Point aBR = aOuter.BottomRight();
211
0
    Point aTR = aOuter.TopRight();
212
0
    Point aBL = aOuter.BottomLeft();
213
0
    bool bRTL = AllSettings::GetLayoutRTL();
214
0
    switch( nGrab )
215
0
    {
216
0
        case 0:
217
            // FIXME: disable it for RTL because it's wrong calculations
218
0
            if( bRTL )
219
0
                break;
220
0
            aPos = aRect.TopLeft() - aOuter.TopLeft();
221
0
            break;
222
0
        case 1:
223
0
            aPos.setY(  aRect.Top() - aOuter.Top() );
224
0
            break;
225
0
        case 2:
226
            // FIXME: disable it for RTL because it's wrong calculations
227
0
            if( bRTL )
228
0
                break;
229
0
            aPos =  aRect.TopRight() - aTR;
230
0
            break;
231
0
        case 3:
232
0
            if( bRTL )
233
0
                aPos.setX( aRect.Left() - aTR.X() );
234
0
            else
235
0
                aPos.setX( aRect.Right() - aTR.X() );
236
0
            break;
237
0
        case 4:
238
            // FIXME: disable it for RTL because it's wrong calculations
239
0
            if( bRTL )
240
0
                break;
241
0
            aPos =  aRect.BottomRight() - aBR;
242
0
            break;
243
0
        case 5:
244
0
            aPos.setY( aRect.Bottom() - aBR.Y() );
245
0
            break;
246
0
        case 6:
247
            // FIXME: disable it for RTL because it's wrong calculations
248
0
            if( bRTL )
249
0
                break;
250
0
            aPos =  aRect.BottomLeft() - aBL;
251
0
            break;
252
0
        case 7:
253
0
            if( bRTL )
254
0
                aPos.setX( aRect.Right() + aOuter.Right() - aOuter.Right() );
255
0
            else
256
0
                aPos.setX( aRect.Left() - aOuter.Left() );
257
0
            break;
258
0
        case 8:
259
0
            aPos = aRect.TopLeft() - aOuter.TopLeft();
260
0
            break;
261
0
    }
262
0
    return aPos + aSelPos;
263
0
}
264
265
/*************************************************************************
266
|*    SvResizeHelper::GetTrackRectPixel()
267
|*
268
|*    Description
269
*************************************************************************/
270
tools::Rectangle SvResizeHelper::GetTrackRectPixel( const Point & rTrackPos, const bool bShiftPressed ) const
271
0
{
272
0
    tools::Rectangle aTrackRect;
273
0
    if( -1 == nGrab )
274
0
        return aTrackRect;
275
0
    Point aDiff = rTrackPos - aSelPos;
276
0
    aTrackRect = aOuter;
277
0
    Point aBR = aOuter.BottomRight();
278
0
    bool bRTL = AllSettings::GetLayoutRTL();
279
0
    switch( nGrab )
280
0
    {
281
0
        case 0:
282
0
            aTrackRect.AdjustTop(aDiff.Y() );
283
            // ugly solution for resizing OLE objects in RTL
284
0
            if( bRTL )
285
0
                aTrackRect.SetRight( aBR.X() - aDiff.X() );
286
0
            else
287
0
                aTrackRect.AdjustLeft(aDiff.X() );
288
0
            break;
289
0
        case 1:
290
0
            aTrackRect.AdjustTop(aDiff.Y() );
291
0
            break;
292
0
        case 2:
293
0
            aTrackRect.AdjustTop(aDiff.Y() );
294
            // ugly solution for resizing OLE objects in RTL
295
0
            if( bRTL )
296
0
                aTrackRect.AdjustLeft( -(aDiff.X()) );
297
0
            else
298
0
                aTrackRect.SetRight( aBR.X() + aDiff.X() );
299
0
            break;
300
0
        case 3:
301
            // ugly solution for resizing OLE objects in RTL
302
0
            if( bRTL )
303
0
                aTrackRect.AdjustLeft( -(aDiff.X()) );
304
0
            else
305
0
                aTrackRect.SetRight( aBR.X() + aDiff.X() );
306
0
            break;
307
0
        case 4:
308
0
            aTrackRect.SetBottom( aBR.Y() + aDiff.Y() );
309
            // ugly solution for resizing OLE objects in RTL
310
0
            if( bRTL )
311
0
                aTrackRect.AdjustLeft( -(aDiff.X()) );
312
0
            else
313
0
                aTrackRect.SetRight( aBR.X() + aDiff.X() );
314
0
            break;
315
0
        case 5:
316
0
            aTrackRect.SetBottom( aBR.Y() + aDiff.Y() );
317
0
            break;
318
0
        case 6:
319
0
            aTrackRect.SetBottom( aBR.Y() + aDiff.Y() );
320
            // ugly solution for resizing OLE objects in RTL
321
0
            if( bRTL )
322
0
                aTrackRect.SetRight( aBR.X() - aDiff.X() );
323
0
            else
324
0
                aTrackRect.AdjustLeft(aDiff.X() );
325
0
            break;
326
0
        case 7:
327
            // ugly solution for resizing OLE objects in RTL
328
0
            if( bRTL )
329
0
                aTrackRect.SetRight( aBR.X() - aDiff.X() );
330
0
            else
331
0
                aTrackRect.AdjustLeft(aDiff.X() );
332
0
            break;
333
0
        case 8:
334
0
            if( bRTL )
335
0
                aDiff.setX( -aDiff.X() ); // workaround for move in RTL mode
336
0
            if( bShiftPressed )
337
0
            {
338
0
                const Point aDiffAbs( std::abs( aDiff.X() ), std::abs( aDiff.Y() ) );
339
0
                if( 2 * aDiffAbs.X() < aDiffAbs.Y() ) // vertical move
340
0
                    aDiff.setX( 0L );
341
0
                else if( aDiffAbs.X() > 2 * aDiffAbs.Y() ) // horizontal move
342
0
                    aDiff.setY( 0L );
343
0
                else if( aDiffAbs.X() != aDiffAbs.Y() ) // 45° move
344
0
                {
345
0
                    if( aDiffAbs.X() > aDiffAbs.Y() )
346
0
                        aDiff.setY( aDiff.Y() / aDiffAbs.Y() * aDiffAbs.X() );
347
0
                    else
348
0
                        aDiff.setX( aDiff.X() / aDiffAbs.X() * aDiffAbs.Y() );
349
0
                }
350
0
            }
351
0
            aTrackRect.SetPos( aTrackRect.TopLeft() + aDiff );
352
0
            break;
353
0
    }
354
    // TODO: should use same code as other objects. See SdrTextObj::ImpDragCalcRect() and SdrObject::ImpDragCalcRect()
355
    // uneven values are for edges
356
0
    const bool bIsEdge = ( nGrab != (( nGrab / 2 ) * 2) );
357
    // tdf#163816: Resizing OLE object in edited mode should behave like in not-edited mode
358
    // Corner handles are proportional by default, whereas edge handles are not proportional
359
    // pressed Shift toggles behavior
360
0
    const bool bProportional = ( bIsEdge == bShiftPressed );
361
0
    if( bProportional && nGrab != 8 && mofStartingRatio )
362
0
    {
363
0
        bool bChangeWidth = false;
364
0
        if( nGrab == 1 ||  nGrab == 5 ) // top and bottom handles
365
0
        {
366
0
            bChangeWidth = true;
367
0
        }
368
0
        else if ( nGrab != 3 &&  nGrab != 7 )
369
0
        {   // handles in corners: keep the largest size
370
0
            bChangeWidth = aTrackRect.GetWidth() < aTrackRect.GetHeight() * mofStartingRatio.value();
371
0
        }
372
0
        if( bChangeWidth )
373
0
        {
374
0
            const tools::Long nNewWidth =  aTrackRect.GetHeight() * mofStartingRatio.value();
375
0
            if ( nGrab == 6 ||  nGrab == 0 ) // corners on left side
376
                // move left with right as reference
377
0
                aTrackRect.SetLeft( aTrackRect.Right() - nNewWidth );
378
0
            else if ( nGrab == 1 ||  nGrab == 5 ) // top and bottom handles
379
                // move left half of the change of width to keep the handle in the middle
380
0
                aTrackRect.SetLeft( aTrackRect.Left() + ( aTrackRect.GetWidth() - nNewWidth ) / 2 );
381
                // other handles use left as reference, then no change needed
382
0
            aTrackRect.SetWidth( nNewWidth );
383
0
        }
384
0
        else
385
0
        {
386
0
            const tools::Long nNewHeight =  aTrackRect.GetWidth() / mofStartingRatio.value();
387
0
            if ( nGrab == 2 ||  nGrab == 0 )  // corners on top
388
                // move top with bottom as reference
389
0
                aTrackRect.SetTop( aTrackRect.Bottom() - nNewHeight );
390
0
            else if ( nGrab == 3 ||  nGrab == 7 )  // right and left handles
391
                // move top half of the change of height to keep the handle in the middle
392
0
                aTrackRect.SetTop( aTrackRect.Top() + ( aTrackRect.GetHeight() - nNewHeight ) / 2 );
393
                // other handles use top as reference, then no change needed
394
0
            aTrackRect.SetHeight( nNewHeight );
395
0
        }
396
0
    }
397
0
    return aTrackRect;
398
0
}
399
400
void SvResizeHelper::ValidateRect( tools::Rectangle & rValidate ) const
401
0
{
402
0
    switch( nGrab )
403
0
    {
404
0
        case 0:
405
0
            if( rValidate.Top() > rValidate.Bottom() )
406
0
                rValidate.SetTop( rValidate.Bottom() );
407
0
            if( rValidate.Left() > rValidate.Right() )
408
0
                rValidate.SetLeft( rValidate.Right() );
409
0
            break;
410
0
        case 1:
411
0
            if( rValidate.Top() > rValidate.Bottom() )
412
0
                rValidate.SetTop( rValidate.Bottom() );
413
0
            break;
414
0
        case 2:
415
0
            if( rValidate.Top() > rValidate.Bottom() )
416
0
                rValidate.SetTop( rValidate.Bottom() );
417
0
            if( rValidate.Left() > rValidate.Right() )
418
0
                rValidate.SetRight( rValidate.Left() );
419
0
            break;
420
0
        case 3:
421
0
            if( rValidate.Left() > rValidate.Right() )
422
0
                rValidate.SetRight( rValidate.Left() );
423
0
            break;
424
0
        case 4:
425
0
            if( rValidate.Top() > rValidate.Bottom() )
426
0
                rValidate.SetBottom( rValidate.Top() );
427
0
            if( rValidate.Left() > rValidate.Right() )
428
0
                rValidate.SetRight( rValidate.Left() );
429
0
            break;
430
0
        case 5:
431
0
            if( rValidate.Top() > rValidate.Bottom() )
432
0
                rValidate.SetBottom( rValidate.Top() );
433
0
            break;
434
0
        case 6:
435
0
            if( rValidate.Top() > rValidate.Bottom() )
436
0
                rValidate.SetBottom( rValidate.Top() );
437
0
            if( rValidate.Left() > rValidate.Right() )
438
0
                rValidate.SetLeft( rValidate.Right() );
439
0
            break;
440
0
        case 7:
441
0
            if( rValidate.Left() > rValidate.Right() )
442
0
                rValidate.SetLeft( rValidate.Right() );
443
0
            break;
444
0
    }
445
446
    // Minimum size 5 x 5
447
0
    if( rValidate.Left() + 5 > rValidate.Right() )
448
0
        rValidate.SetRight( rValidate.Left() + 5 );
449
0
    if( rValidate.Top() + 5 > rValidate.Bottom() )
450
0
        rValidate.SetBottom( rValidate.Top() + 5 );
451
0
}
452
453
/*************************************************************************
454
|*    SvResizeHelper::SelectRelease()
455
|*
456
|*    Description
457
*************************************************************************/
458
bool SvResizeHelper::SelectRelease( vcl::Window * pWin, const Point & rPos,
459
                                    tools::Rectangle & rOutPosSize, const bool bShiftPressed )
460
0
{
461
0
    if( -1 != nGrab )
462
0
    {
463
0
        rOutPosSize = GetTrackRectPixel( rPos, bShiftPressed );
464
0
        rOutPosSize.Normalize();
465
0
        nGrab = -1;
466
0
        pWin->ReleaseMouse();
467
0
        pWin->HideTracking();
468
0
        return true;
469
0
    }
470
0
    return false;
471
0
}
472
473
/*************************************************************************
474
|*    SvResizeHelper::Release()
475
|*
476
|*    Description
477
*************************************************************************/
478
void SvResizeHelper::Release( vcl::Window * pWin )
479
0
{
480
0
    if( nGrab != -1 )
481
0
    {
482
0
        pWin->ReleaseMouse();
483
0
        pWin->HideTracking();
484
0
        nGrab = -1;
485
0
    }
486
0
}
487
488
/*************************************************************************
489
|*    SvResizeWindow::SvResizeWindow()
490
|*
491
|*    Description
492
*************************************************************************/
493
SvResizeWindow::SvResizeWindow
494
(
495
    vcl::Window * pParent,
496
    VCLXHatchWindow* pWrapper
497
)
498
0
    : Window( pParent, WB_CLIPCHILDREN )
499
0
    , m_aOldPointer(PointerStyle::Arrow)
500
0
    , m_nMoveGrab( -1 )
501
0
    , m_bActive( false )
502
0
    , m_pWrapper( pWrapper )
503
0
{
504
0
    OSL_ENSURE( pParent != nullptr && pWrapper != nullptr, "Wrong initialization of hatch window!" );
505
0
    SetBackground();
506
0
    SetAccessibleRole( css::accessibility::AccessibleRole::EMBEDDED_OBJECT );
507
0
    m_aResizer.SetOuterRectPixel( tools::Rectangle( Point(), GetOutputSizePixel() ) );
508
0
}
Unexecuted instantiation: SvResizeWindow::SvResizeWindow(vcl::Window*, VCLXHatchWindow*)
Unexecuted instantiation: SvResizeWindow::SvResizeWindow(vcl::Window*, VCLXHatchWindow*)
509
510
/*************************************************************************
511
|*    SvResizeWindow::SetHatchBorderPixel()
512
|*
513
|*    Description
514
*************************************************************************/
515
void SvResizeWindow::SetHatchBorderPixel( const Size & rSize )
516
0
{
517
0
     m_aResizer.SetBorderPixel( rSize );
518
0
}
519
520
/*************************************************************************
521
|*    SvResizeWindow::SelectMouse()
522
|*
523
|*    Description
524
*************************************************************************/
525
void SvResizeWindow::SelectMouse( const Point & rPos, const bool bShiftPressed )
526
0
{
527
0
    short nGrab = m_aResizer.SelectMove( this, rPos, bShiftPressed );
528
0
    if( nGrab >= 4 )
529
0
        nGrab -= 4;
530
0
    if( m_nMoveGrab == nGrab )
531
0
        return;
532
533
    // Pointer did change
534
0
    if( -1 == nGrab )
535
0
        SetPointer( m_aOldPointer );
536
0
    else
537
0
    {
538
0
        PointerStyle aStyle = PointerStyle::Move;
539
0
        if( nGrab == 3 )
540
0
            aStyle = PointerStyle::ESize;
541
0
        else if( nGrab == 2 )
542
0
            aStyle = PointerStyle::NESize;
543
0
        else if( nGrab == 1 )
544
0
            aStyle = PointerStyle::SSize;
545
0
        else if( nGrab == 0 )
546
0
            aStyle = PointerStyle::SESize;
547
0
        if( m_nMoveGrab == -1 ) // the first time
548
0
        {
549
0
            m_aOldPointer = GetPointer();
550
0
            SetPointer( aStyle );
551
0
        }
552
0
        else
553
0
            SetPointer( aStyle );
554
0
    }
555
0
    m_nMoveGrab = nGrab;
556
0
}
557
558
/*************************************************************************
559
|*    SvResizeWindow::MouseButtonDown()
560
|*
561
|*    Description
562
*************************************************************************/
563
void SvResizeWindow::MouseButtonDown( const MouseEvent & rEvt )
564
0
{
565
0
    if( m_aResizer.SelectBegin( this, rEvt.GetPosPixel(), rEvt.IsShift() ) )
566
0
        SelectMouse( rEvt.GetPosPixel(), rEvt.IsShift() );
567
0
}
568
569
/*************************************************************************
570
|*    SvResizeWindow::MouseMove()
571
|*
572
|*    Description
573
*************************************************************************/
574
void SvResizeWindow::MouseMove( const MouseEvent & rEvt )
575
0
{
576
0
    if( m_aResizer.GetGrab() == -1 )
577
0
        SelectMouse( rEvt.GetPosPixel(), rEvt.IsShift() );
578
0
    else
579
0
    {
580
0
        tools::Rectangle aRect( m_aResizer.GetTrackRectPixel( rEvt.GetPosPixel(), rEvt.IsShift() ) );
581
0
        Point aDiff = GetPosPixel();
582
0
        aRect.SetPos( aRect.TopLeft() + aDiff );
583
0
        m_aResizer.ValidateRect( aRect );
584
585
0
        m_pWrapper->QueryObjAreaPixel( aRect );
586
0
        aRect.SetPos( aRect.TopLeft() - aDiff );
587
0
        Point aPos = m_aResizer.GetTrackPosPixel( aRect );
588
589
0
        SelectMouse( aPos, rEvt.IsShift() );
590
0
    }
591
0
}
592
593
/*************************************************************************
594
|*    SvResizeWindow::MouseButtonUp()
595
|*
596
|*    Description
597
*************************************************************************/
598
void SvResizeWindow::MouseButtonUp( const MouseEvent & rEvt )
599
0
{
600
0
    if( m_aResizer.GetGrab() == -1 )
601
0
        return;
602
603
0
    tools::Rectangle aRect( m_aResizer.GetTrackRectPixel( rEvt.GetPosPixel(), rEvt.IsShift() ) );
604
0
    Point aDiff = GetPosPixel();
605
0
    aRect.SetPos( aRect.TopLeft() + aDiff );
606
    // aRect -= GetAllBorderPixel();
607
0
    m_aResizer.ValidateRect( aRect );
608
609
0
    m_pWrapper->QueryObjAreaPixel( aRect );
610
611
0
    tools::Rectangle aOutRect;
612
0
    if( m_aResizer.SelectRelease( this, rEvt.GetPosPixel(), aOutRect, rEvt.IsShift() ) )
613
0
    {
614
0
        m_nMoveGrab = -1;
615
0
        SetPointer( m_aOldPointer );
616
0
        m_pWrapper->RequestObjAreaPixel( aRect );
617
0
    }
618
0
}
619
620
/*************************************************************************
621
|*    SvResizeWindow::KeyEvent()
622
|*
623
|*    Description
624
*************************************************************************/
625
void SvResizeWindow::KeyInput( const KeyEvent & rEvt )
626
0
{
627
0
    if( rEvt.GetKeyCode().GetCode() == KEY_ESCAPE )
628
0
    {
629
0
        m_aResizer.Release( this );
630
0
        m_pWrapper->InplaceDeactivate();
631
0
    }
632
0
}
633
634
/*************************************************************************
635
|*    SvResizeWindow::Resize()
636
|*
637
|*    Description
638
*************************************************************************/
639
void SvResizeWindow::Resize()
640
0
{
641
0
    m_aResizer.InvalidateBorder( this ); // old area
642
0
    m_aResizer.SetOuterRectPixel( tools::Rectangle( Point(), GetOutputSizePixel() ) );
643
0
    m_aResizer.InvalidateBorder( this ); // new area
644
0
}
645
646
/*************************************************************************
647
|*    SvResizeWindow::Paint()
648
|*
649
|*    Description
650
*************************************************************************/
651
void SvResizeWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle & /*rRect*/ )
652
0
{
653
0
    m_aResizer.Draw(rRenderContext);
654
0
}
655
656
bool SvResizeWindow::PreNotify( NotifyEvent& rEvt )
657
0
{
658
0
    if ( rEvt.GetType() == NotifyEventType::GETFOCUS && !m_bActive )
659
0
    {
660
0
        m_bActive = true;
661
0
        m_pWrapper->Activated();
662
0
    }
663
664
0
    return Window::PreNotify(rEvt);
665
0
}
666
667
bool SvResizeWindow::EventNotify( NotifyEvent& rEvt )
668
0
{
669
0
    if ( rEvt.GetType() == NotifyEventType::LOSEFOCUS && m_bActive )
670
0
    {
671
0
        bool bHasFocus = HasChildPathFocus(true);
672
0
        if ( !bHasFocus )
673
0
        {
674
0
            m_bActive = false;
675
0
            m_pWrapper->Deactivated();
676
0
        }
677
0
    }
678
679
0
    return Window::EventNotify(rEvt);
680
0
}
681
682
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */