Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/window/brdwin.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 <strings.hrc>
21
#include <svdata.hxx>
22
#include <brdwin.hxx>
23
#include <salframe.hxx>
24
#include <window.h>
25
26
#include <vcl/textrectinfo.hxx>
27
#include <vcl/event.hxx>
28
#include <vcl/decoview.hxx>
29
#include <vcl/syswin.hxx>
30
#include <vcl/dockwin.hxx>
31
#include <vcl/toolkit/floatwin.hxx>
32
#include <vcl/help.hxx>
33
#include <vcl/toolkit/edit.hxx>
34
#include <vcl/settings.hxx>
35
#include <vcl/toolbox.hxx>
36
#include <vcl/ptrstyle.hxx>
37
38
using namespace ::com::sun::star::uno;
39
40
// useful caption height for title bar buttons
41
0
#define MIN_CAPTION_HEIGHT 18
42
43
namespace vcl {
44
45
void Window::ImplCalcSymbolRect( tools::Rectangle& rRect )
46
0
{
47
    // Add border, not shown in the non-default representation,
48
    // as we want to use it for small buttons
49
0
    rRect.AdjustLeft( -1 );
50
0
    rRect.AdjustTop( -1 );
51
0
    rRect.AdjustRight( 1 );
52
0
    rRect.AdjustBottom( 1 );
53
54
    // we leave 5% room between the symbol and the button border
55
0
    tools::Long nExtraWidth = ((rRect.GetWidth()*50)+500)/1000;
56
0
    tools::Long nExtraHeight = ((rRect.GetHeight()*50)+500)/1000;
57
0
    rRect.AdjustLeft(nExtraWidth );
58
0
    rRect.AdjustRight( -nExtraWidth );
59
0
    rRect.AdjustTop(nExtraHeight );
60
0
    rRect.AdjustBottom( -nExtraHeight );
61
0
}
62
63
} /* namespace vcl */
64
65
static void ImplDrawBrdWinSymbol( vcl::RenderContext* pDev,
66
                                  const tools::Rectangle& rRect, SymbolType eSymbol )
67
0
{
68
    // we leave 5% room between the symbol and the button border
69
0
    DecorationView  aDecoView( pDev );
70
0
    tools::Rectangle       aTempRect = rRect;
71
0
    vcl::Window::ImplCalcSymbolRect( aTempRect );
72
0
    aDecoView.DrawSymbol( aTempRect, eSymbol,
73
0
                          pDev->GetSettings().GetStyleSettings().GetButtonTextColor() );
74
0
}
75
76
static void ImplDrawBrdWinSymbolButton( vcl::RenderContext* pDev,
77
                                        const tools::Rectangle& rRect,
78
                                        SymbolType eSymbol, DrawButtonFlags nState )
79
0
{
80
0
    bool bMouseOver(nState & DrawButtonFlags::Highlight);
81
0
    nState &= ~DrawButtonFlags::Highlight;
82
83
0
    tools::Rectangle aTempRect;
84
0
    vcl::Window *pWin = pDev->GetOwnerWindow();
85
0
    if( pWin )
86
0
    {
87
0
        if( bMouseOver )
88
0
        {
89
            // provide a bright background for selection effect
90
0
            pDev->SetFillColor( pDev->GetSettings().GetStyleSettings().GetWindowColor() );
91
0
            pDev->SetLineColor();
92
0
            pDev->DrawRect( rRect );
93
0
            pWin->DrawSelectionBackground( rRect, 2, bool(nState & DrawButtonFlags::Pressed),
94
0
                                            true );
95
0
        }
96
0
        aTempRect = rRect;
97
0
        aTempRect.AdjustLeft(3 );
98
0
        aTempRect.AdjustRight( -4 );
99
0
        aTempRect.AdjustTop(3 );
100
0
        aTempRect.AdjustBottom( -4 );
101
0
    }
102
0
    else
103
0
    {
104
0
        DecorationView aDecoView( pDev );
105
0
        aTempRect = aDecoView.DrawButton( rRect, nState|DrawButtonFlags::Flat );
106
0
    }
107
0
    ImplDrawBrdWinSymbol( pDev, aTempRect, eSymbol );
108
0
}
109
110
111
ImplBorderWindowView::~ImplBorderWindowView()
112
9.15k
{
113
9.15k
}
114
115
bool ImplBorderWindowView::MouseMove( const MouseEvent& )
116
0
{
117
0
    return false;
118
0
}
119
120
bool ImplBorderWindowView::MouseButtonDown( const MouseEvent& )
121
0
{
122
0
    return false;
123
0
}
124
125
bool ImplBorderWindowView::Tracking( const TrackingEvent& )
126
0
{
127
0
    return false;
128
0
}
129
130
OUString ImplBorderWindowView::RequestHelp( const Point&, tools::Rectangle& )
131
0
{
132
0
    return OUString();
133
0
}
134
135
tools::Rectangle ImplBorderWindowView::GetMenuRect() const
136
0
{
137
0
    return tools::Rectangle();
138
0
}
139
140
void ImplBorderWindowView::ImplInitTitle(ImplBorderFrameData* pData)
141
0
{
142
0
    ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
143
144
0
    if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) ||
145
0
          (pData->mnTitleType == BorderWindowTitleType::NONE) )
146
0
    {
147
0
        pData->mnTitleType   = BorderWindowTitleType::NONE;
148
0
        pData->mnTitleHeight = 0;
149
0
    }
150
0
    else
151
0
    {
152
0
        const StyleSettings& rStyleSettings = pData->mpOutDev->GetSettings().GetStyleSettings();
153
0
        if (pData->mnTitleType == BorderWindowTitleType::Tearoff)
154
0
            pData->mnTitleHeight = ToolBox::ImplGetDragWidth(*pData->mpBorderWindow, false) + 2;
155
0
        else
156
0
        {
157
0
            if (pData->mnTitleType == BorderWindowTitleType::Small)
158
0
            {
159
0
                pBorderWindow->SetPointFont(*pBorderWindow->GetOutDev(), rStyleSettings.GetFloatTitleFont() );
160
0
                pData->mnTitleHeight = rStyleSettings.GetFloatTitleHeight();
161
0
            }
162
0
            else // pData->mnTitleType == BorderWindowTitleType::Normal
163
0
            {
164
                // FIXME RenderContext
165
0
                pBorderWindow->SetPointFont(*pBorderWindow->GetOutDev(), rStyleSettings.GetTitleFont());
166
0
                pData->mnTitleHeight = rStyleSettings.GetTitleHeight();
167
0
            }
168
0
            tools::Long nTextHeight = pBorderWindow->GetTextHeight();
169
0
            if (nTextHeight > pData->mnTitleHeight)
170
0
                pData->mnTitleHeight = nTextHeight;
171
0
        }
172
0
    }
173
0
}
174
175
BorderWindowHitTest ImplBorderWindowView::ImplHitTest( ImplBorderFrameData const * pData, const Point& rPos )
176
0
{
177
0
    ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
178
179
0
    if ( pData->maTitleRect.Contains( rPos ) )
180
0
    {
181
0
        if ( pData->maCloseRect.Contains( rPos ) )
182
0
            return BorderWindowHitTest::Close;
183
0
        else if ( pData->maMenuRect.Contains( rPos ) )
184
0
            return BorderWindowHitTest::Menu;
185
0
        else if ( pData->maDockRect.Contains( rPos ) )
186
0
            return BorderWindowHitTest::Dock;
187
0
        else if ( pData->maHideRect.Contains( rPos ) )
188
0
            return BorderWindowHitTest::Hide;
189
0
        else if ( pData->maHelpRect.Contains( rPos ) )
190
0
            return BorderWindowHitTest::Help;
191
0
        else
192
0
            return BorderWindowHitTest::Title;
193
0
    }
194
195
0
    if (pBorderWindow->GetStyle() & WB_SIZEABLE)
196
0
    {
197
0
        tools::Long nSizeWidth = pData->mnNoTitleTop+pData->mnTitleHeight;
198
0
        if ( nSizeWidth < 16 )
199
0
            nSizeWidth = 16;
200
201
        // no corner resize for floating toolbars, which would lead to jumps while formatting
202
        // setting nSizeWidth = 0 will only return pure left,top,right,bottom
203
0
        if( pBorderWindow->GetStyle() & (WB_OWNERDRAWDECORATION | WB_POPUP) )
204
0
            nSizeWidth = 0;
205
206
0
        if ( rPos.X() < pData->mnLeftBorder )
207
0
        {
208
0
            if ( rPos.Y() < nSizeWidth )
209
0
                return BorderWindowHitTest::TopLeft;
210
0
            else if ( rPos.Y() >= pData->mnHeight-nSizeWidth )
211
0
                return BorderWindowHitTest::BottomLeft;
212
0
            else
213
0
                return BorderWindowHitTest::Left;
214
0
        }
215
0
        else if ( rPos.X() >= pData->mnWidth-pData->mnRightBorder )
216
0
        {
217
0
            if ( rPos.Y() < nSizeWidth )
218
0
                return BorderWindowHitTest::TopRight;
219
0
            else if ( rPos.Y() >= pData->mnHeight-nSizeWidth )
220
0
                return BorderWindowHitTest::BottomRight;
221
0
            else
222
0
                return BorderWindowHitTest::Right;
223
0
        }
224
0
        else if ( rPos.Y() < pData->mnNoTitleTop )
225
0
        {
226
0
            if ( rPos.X() < nSizeWidth )
227
0
                return BorderWindowHitTest::TopLeft;
228
0
            else if ( rPos.X() >= pData->mnWidth-nSizeWidth )
229
0
                return BorderWindowHitTest::TopRight;
230
0
            else
231
0
                return BorderWindowHitTest::Top;
232
0
        }
233
0
        else if ( rPos.Y() >= pData->mnHeight-pData->mnBottomBorder )
234
0
        {
235
0
            if ( rPos.X() < nSizeWidth )
236
0
                return BorderWindowHitTest::BottomLeft;
237
0
            else if ( rPos.X() >= pData->mnWidth-nSizeWidth )
238
0
                return BorderWindowHitTest::BottomRight;
239
0
            else
240
0
                return BorderWindowHitTest::Bottom;
241
0
        }
242
0
    }
243
244
0
    return BorderWindowHitTest::NONE;
245
0
}
246
247
void ImplBorderWindowView::ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt )
248
0
{
249
0
    DrawButtonFlags oldCloseState = pData->mnCloseState;
250
0
    DrawButtonFlags oldMenuState = pData->mnMenuState;
251
0
    pData->mnCloseState &= ~DrawButtonFlags::Highlight;
252
0
    pData->mnMenuState &= ~DrawButtonFlags::Highlight;
253
254
0
    Point aMousePos = rMEvt.GetPosPixel();
255
0
    BorderWindowHitTest nHitTest = ImplHitTest( pData, aMousePos );
256
0
    PointerStyle ePtrStyle = PointerStyle::Arrow;
257
0
    if ( nHitTest & BorderWindowHitTest::Left )
258
0
        ePtrStyle = PointerStyle::WindowWSize;
259
0
    else if ( nHitTest & BorderWindowHitTest::Right )
260
0
        ePtrStyle = PointerStyle::WindowESize;
261
0
    else if ( nHitTest & BorderWindowHitTest::Top )
262
0
        ePtrStyle = PointerStyle::WindowNSize;
263
0
    else if ( nHitTest & BorderWindowHitTest::Bottom )
264
0
        ePtrStyle = PointerStyle::WindowSSize;
265
0
    else if ( nHitTest & BorderWindowHitTest::TopLeft )
266
0
        ePtrStyle = PointerStyle::WindowNWSize;
267
0
    else if ( nHitTest & BorderWindowHitTest::BottomRight )
268
0
        ePtrStyle = PointerStyle::WindowSESize;
269
0
    else if ( nHitTest & BorderWindowHitTest::TopRight )
270
0
        ePtrStyle = PointerStyle::WindowNESize;
271
0
    else if ( nHitTest & BorderWindowHitTest::BottomLeft )
272
0
        ePtrStyle = PointerStyle::WindowSWSize;
273
0
    else if ( nHitTest & BorderWindowHitTest::Close )
274
0
        pData->mnCloseState |= DrawButtonFlags::Highlight;
275
0
    else if ( nHitTest & BorderWindowHitTest::Menu )
276
0
        pData->mnMenuState |= DrawButtonFlags::Highlight;
277
0
    else if ( nHitTest & BorderWindowHitTest::Title &&
278
0
              pData->mnTitleType == BorderWindowTitleType::Tearoff && !rMEvt.IsLeaveWindow() )
279
0
        ePtrStyle = PointerStyle::Move;
280
0
    pData->mpBorderWindow->SetPointer( ePtrStyle );
281
282
0
    if( pData->mnCloseState != oldCloseState )
283
0
        pData->mpBorderWindow->Invalidate( pData->maCloseRect );
284
0
    if( pData->mnMenuState != oldMenuState )
285
0
        pData->mpBorderWindow->Invalidate( pData->maMenuRect );
286
0
}
287
288
OUString ImplBorderWindowView::ImplRequestHelp( ImplBorderFrameData const * pData,
289
                                              const Point& rPos,
290
                                              tools::Rectangle& rHelpRect )
291
0
{
292
0
    TranslateId pHelpId;
293
0
    OUString aHelpStr;
294
0
    BorderWindowHitTest nHitTest = ImplHitTest( pData, rPos );
295
0
    if ( nHitTest != BorderWindowHitTest::NONE )
296
0
    {
297
0
        if ( nHitTest & BorderWindowHitTest::Close )
298
0
        {
299
0
            pHelpId     = SV_HELPTEXT_CLOSE;
300
0
            rHelpRect   = pData->maCloseRect;
301
0
        }
302
0
        else if ( nHitTest & BorderWindowHitTest::Dock )
303
0
        {
304
0
            pHelpId     = SV_HELPTEXT_MAXIMIZE;
305
0
            rHelpRect   = pData->maDockRect;
306
0
        }
307
0
        else if ( nHitTest & BorderWindowHitTest::Hide )
308
0
        {
309
0
            pHelpId     = SV_HELPTEXT_MINIMIZE;
310
0
            rHelpRect   = pData->maHideRect;
311
0
        }
312
0
        else if ( nHitTest & BorderWindowHitTest::Help )
313
0
        {
314
0
            pHelpId     = SV_HELPTEXT_HELP;
315
0
            rHelpRect   = pData->maHelpRect;
316
0
        }
317
0
        else if ( nHitTest & BorderWindowHitTest::Title )
318
0
        {
319
0
            if( !pData->maTitleRect.IsEmpty() )
320
0
            {
321
                // tooltip only if title truncated
322
0
                if( pData->mbTitleClipped )
323
0
                {
324
0
                    rHelpRect   = pData->maTitleRect;
325
                    // no help id, use window title as help string
326
0
                    aHelpStr    = pData->mpBorderWindow->GetText();
327
0
                }
328
0
            }
329
0
        }
330
0
    }
331
332
0
    if (pHelpId)
333
0
        aHelpStr = VclResId(pHelpId);
334
335
0
    return aHelpStr;
336
0
}
337
338
tools::Long ImplBorderWindowView::ImplCalcTitleWidth( const ImplBorderFrameData* pData )
339
0
{
340
    // title is not visible therefore no width
341
0
    if ( !pData->mnTitleHeight )
342
0
        return 0;
343
344
0
    ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
345
0
    tools::Long nTitleWidth = pBorderWindow->GetTextWidth( pBorderWindow->GetText() )+6;
346
0
    auto nCloseRectWidth = pData->maCloseRect.GetWidth();
347
0
    assert(nCloseRectWidth >= 0 && "coverity 2023.12.2");
348
0
    nTitleWidth += nCloseRectWidth;
349
0
    auto nDockRectWidth = pData->maDockRect.GetWidth();
350
0
    assert(nDockRectWidth >= 0 && "coverity 2023.12.2");
351
0
    nTitleWidth += nDockRectWidth;
352
0
    auto nMenuRectWidth = pData->maMenuRect.GetWidth();
353
0
    assert(nMenuRectWidth >= 0 && "coverity 2023.12.2");
354
0
    nTitleWidth += nMenuRectWidth;
355
0
    auto nHideRectWidth = pData->maHideRect.GetWidth();
356
0
    assert(nHideRectWidth >= 0 && "coverity 2023.12.2");
357
0
    nTitleWidth += nHideRectWidth;
358
0
    auto nHelpRectWidth = pData->maHelpRect.GetWidth();
359
0
    assert(nHelpRectWidth >= 0 && "coverity 2023.12.2");
360
0
    nTitleWidth += nHelpRectWidth;
361
0
    nTitleWidth += pData->mnLeftBorder+pData->mnRightBorder;
362
0
    return nTitleWidth;
363
0
}
364
365
366
ImplNoBorderWindowView::ImplNoBorderWindowView()
367
8.34k
{
368
8.34k
}
369
370
void ImplNoBorderWindowView::Init( OutputDevice*, tools::Long, tools::Long )
371
8.34k
{
372
8.34k
}
373
374
void ImplNoBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
375
                                        sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
376
8.34k
{
377
8.34k
    rLeftBorder     = 0;
378
8.34k
    rTopBorder      = 0;
379
8.34k
    rRightBorder    = 0;
380
8.34k
    rBottomBorder   = 0;
381
8.34k
}
382
383
tools::Long ImplNoBorderWindowView::CalcTitleWidth() const
384
0
{
385
0
    return 0;
386
0
}
387
388
void ImplNoBorderWindowView::DrawWindow(vcl::RenderContext&, const Point*)
389
0
{
390
0
}
391
392
ImplSmallBorderWindowView::ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow )
393
4.57k
    : mpBorderWindow(pBorderWindow)
394
4.57k
    , mpOutDev(nullptr)
395
4.57k
    , mnWidth(0)
396
4.57k
    , mnHeight(0)
397
4.57k
    , mnLeftBorder(0)
398
4.57k
    , mnTopBorder(0)
399
4.57k
    , mnRightBorder(0)
400
4.57k
    , mnBottomBorder(0)
401
4.57k
    , mbNWFBorder(false)
402
4.57k
{
403
4.57k
}
404
405
void ImplSmallBorderWindowView::Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight )
406
13.7k
{
407
13.7k
    mpOutDev    = pDev;
408
13.7k
    mnWidth     = nWidth;
409
13.7k
    mnHeight    = nHeight;
410
13.7k
    mbNWFBorder = false;
411
412
13.7k
    vcl::Window *pWin = mpOutDev->GetOwnerWindow();
413
13.7k
    vcl::Window *pCtrl = nullptr;
414
13.7k
    vcl::Window *pSubEdit = nullptr;
415
13.7k
    if (pWin)
416
13.7k
        pCtrl = mpBorderWindow->GetWindow(GetWindowType::Client);
417
418
13.7k
    tools::Long nOrigLeftBorder = mnLeftBorder;
419
13.7k
    tools::Long nOrigTopBorder = mnTopBorder;
420
13.7k
    tools::Long nOrigRightBorder = mnRightBorder;
421
13.7k
    tools::Long nOrigBottomBorder = mnBottomBorder;
422
423
13.7k
    WindowBorderStyle nBorderStyle = mpBorderWindow->GetBorderStyle();
424
13.7k
    if ( nBorderStyle & WindowBorderStyle::NOBORDER )
425
4.57k
    {
426
4.57k
        mnLeftBorder    = 0;
427
4.57k
        mnTopBorder     = 0;
428
4.57k
        mnRightBorder   = 0;
429
4.57k
        mnBottomBorder  = 0;
430
4.57k
    }
431
9.15k
    else
432
9.15k
    {
433
        // FIXME: this is currently only on macOS, check with other
434
        // platforms
435
9.15k
        if( ImplGetSVData()->maNWFData.mbNoFocusRects && !( nBorderStyle & WindowBorderStyle::NWF ) )
436
0
        {
437
            // for native widget drawing we must find out what
438
            // control this border belongs to
439
0
            ControlType aCtrlType = ControlType::Generic;
440
0
            ControlPart aCtrlPart = ControlPart::Entire;
441
0
            if (pCtrl && !(pCtrl->GetBorderStyle() & WindowBorderStyle::NONATIVEBORDER))
442
0
            {
443
0
                switch( pCtrl->GetType() )
444
0
                {
445
0
                    case WindowType::LISTBOX:
446
0
                        if( pCtrl->GetStyle() & WB_DROPDOWN )
447
0
                        {
448
0
                            aCtrlType = ControlType::Listbox;
449
0
                            mbNWFBorder = true;
450
0
                            pSubEdit = static_cast<Edit*>(pCtrl)->GetSubEdit();
451
0
                        }
452
0
                        break;
453
0
                    case WindowType::LISTBOXWINDOW:
454
0
                        aCtrlType = ControlType::Listbox;
455
0
                        aCtrlPart = ControlPart::ListboxWindow;
456
0
                        mbNWFBorder = true;
457
0
                        break;
458
0
                    case WindowType::COMBOBOX:
459
0
                        if( pCtrl->GetStyle() & WB_DROPDOWN )
460
0
                        {
461
0
                            aCtrlType = ControlType::Combobox;
462
0
                            mbNWFBorder = true;
463
0
                            pSubEdit = static_cast<Edit*>(pCtrl)->GetSubEdit();
464
0
                        }
465
0
                        break;
466
0
                    case WindowType::MULTILINEEDIT:
467
0
                        aCtrlType = ControlType::MultilineEditbox;
468
0
                        mbNWFBorder = true;
469
0
                        break;
470
0
                    case WindowType::EDIT:
471
0
                    case WindowType::PATTERNFIELD:
472
0
                    case WindowType::METRICFIELD:
473
0
                    case WindowType::CURRENCYFIELD:
474
0
                    case WindowType::DATEFIELD:
475
0
                    case WindowType::TIMEFIELD:
476
0
                    case WindowType::SPINFIELD:
477
0
                    case WindowType::FORMATTEDFIELD:
478
0
                        mbNWFBorder = true;
479
0
                        if (pCtrl->GetStyle() & WB_SPIN)
480
0
                            aCtrlType = ControlType::Spinbox;
481
0
                        else
482
0
                            aCtrlType = ControlType::Editbox;
483
0
                        pSubEdit = static_cast<Edit*>(pCtrl)->GetSubEdit();
484
0
                        break;
485
0
                    default:
486
0
                        break;
487
0
                }
488
0
            }
489
0
            if( mbNWFBorder )
490
0
            {
491
0
                ImplControlValue aControlValue;
492
0
                Size aMinSize( mnWidth, mnHeight );
493
0
                if( aMinSize.Width() < 10 ) aMinSize.setWidth( 10 );
494
0
                if( aMinSize.Height() < 10 ) aMinSize.setHeight( 10 );
495
0
                tools::Rectangle aCtrlRegion( Point(), aMinSize );
496
0
                tools::Rectangle aBounds, aContent;
497
0
                if( pWin->GetNativeControlRegion( aCtrlType, aCtrlPart, aCtrlRegion,
498
0
                                                  ControlState::ENABLED, aControlValue,
499
0
                                                  aBounds, aContent ) )
500
0
                {
501
0
                    aBounds.AdjustLeft(mnLeftBorder);
502
0
                    aBounds.AdjustRight(-mnRightBorder);
503
0
                    aBounds.AdjustTop(mnTopBorder);
504
0
                    aBounds.AdjustBottom(-mnBottomBorder);
505
0
                    aContent.AdjustLeft(mnLeftBorder);
506
0
                    aContent.AdjustRight(-mnRightBorder);
507
0
                    aContent.AdjustTop(mnTopBorder);
508
0
                    aContent.AdjustBottom(-mnBottomBorder);
509
0
                    mnLeftBorder    = aContent.Left() - aBounds.Left();
510
0
                    mnRightBorder   = aBounds.Right() - aContent.Right();
511
0
                    mnTopBorder     = aContent.Top() - aBounds.Top();
512
0
                    mnBottomBorder  = aBounds.Bottom() - aContent.Bottom();
513
0
                    if( mnWidth && mnHeight )
514
0
                    {
515
516
0
                        mpBorderWindow->SetPaintTransparent( true );
517
0
                        mpBorderWindow->SetBackground();
518
0
                        if (!pCtrl->IsControlBackground())
519
0
                        {
520
0
                            pCtrl->SetPaintTransparent(true);
521
0
                            if (pSubEdit)
522
0
                                pSubEdit->SetPaintTransparent(true);
523
0
                        }
524
525
0
                        vcl::Window* pCompoundParent = nullptr;
526
0
                        if( pWin->GetParent() && pWin->GetParent()->IsCompoundControl() )
527
0
                            pCompoundParent = pWin->GetParent();
528
529
0
                        if( pCompoundParent )
530
0
                            pCompoundParent->SetPaintTransparent( true );
531
532
0
                        if( mnWidth < aBounds.GetWidth() || mnHeight < aBounds.GetHeight() )
533
0
                        {
534
0
                            if( ! pCompoundParent ) // compound controls have to fix themselves
535
0
                            {
536
0
                                Point aPos( mpBorderWindow->GetPosPixel() );
537
0
                                if( mnWidth < aBounds.GetWidth() )
538
0
                                    aPos.AdjustX( -((aBounds.GetWidth() - mnWidth) / 2) );
539
0
                                if( mnHeight < aBounds.GetHeight() )
540
0
                                    aPos.AdjustY( -((aBounds.GetHeight() - mnHeight) / 2) );
541
0
                                mpBorderWindow->SetPosSizePixel( aPos, aBounds.GetSize() );
542
0
                            }
543
0
                        }
544
0
                    }
545
0
                }
546
0
                else
547
0
                    mbNWFBorder = false;
548
0
            }
549
0
        }
550
551
9.15k
        if( ! mbNWFBorder )
552
9.15k
        {
553
9.15k
            DrawFrameStyle nStyle = DrawFrameStyle::NONE;
554
9.15k
            DrawFrameFlags nFlags = DrawFrameFlags::NoDraw;
555
            // move border outside if border was converted or if the BorderWindow is a frame window,
556
9.15k
            if ( mpBorderWindow->mbSmallOutBorder )
557
0
                nStyle = DrawFrameStyle::DoubleOut;
558
9.15k
            else if ( nBorderStyle & WindowBorderStyle::NWF )
559
0
                nStyle = DrawFrameStyle::NWF;
560
9.15k
            else
561
9.15k
                nStyle = DrawFrameStyle::DoubleIn;
562
9.15k
            if ( nBorderStyle & WindowBorderStyle::MONO )
563
0
                nFlags |= DrawFrameFlags::Mono;
564
565
9.15k
            DecorationView  aDecoView( mpOutDev );
566
9.15k
            tools::Rectangle       aRect( 0, 0, 10, 10 );
567
9.15k
            tools::Rectangle       aCalcRect = aDecoView.DrawFrame( aRect, nStyle, nFlags );
568
9.15k
            mnLeftBorder    = aCalcRect.Left();
569
9.15k
            mnTopBorder     = aCalcRect.Top();
570
9.15k
            mnRightBorder   = aRect.Right()-aCalcRect.Right();
571
9.15k
            mnBottomBorder  = aRect.Bottom()-aCalcRect.Bottom();
572
9.15k
        }
573
9.15k
    }
574
575
13.7k
    if (pCtrl)
576
13.7k
    {
577
        //fdo#57090 If the borders have changed, then trigger a queue_resize on
578
        //the bordered window, which will resync its borders at that point
579
13.7k
        if (nOrigLeftBorder != mnLeftBorder ||
580
4.57k
            nOrigTopBorder != mnTopBorder ||
581
4.57k
            nOrigRightBorder != mnRightBorder ||
582
4.57k
            nOrigBottomBorder != mnBottomBorder)
583
9.15k
        {
584
9.15k
            pCtrl->queue_resize();
585
9.15k
        }
586
13.7k
    }
587
13.7k
}
588
589
void ImplSmallBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
590
                                           sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
591
27.4k
{
592
27.4k
    rLeftBorder     = mnLeftBorder;
593
27.4k
    rTopBorder      = mnTopBorder;
594
27.4k
    rRightBorder    = mnRightBorder;
595
27.4k
    rBottomBorder   = mnBottomBorder;
596
27.4k
}
597
598
tools::Long ImplSmallBorderWindowView::CalcTitleWidth() const
599
0
{
600
0
    return 0;
601
0
}
602
603
void ImplSmallBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, const Point*)
604
0
{
605
0
    WindowBorderStyle nBorderStyle = mpBorderWindow->GetBorderStyle();
606
0
    if (nBorderStyle & WindowBorderStyle::NOBORDER)
607
0
        return;
608
609
0
    bool bNativeOK = false;
610
    // for native widget drawing we must find out what
611
    // control this border belongs to
612
0
    vcl::Window* pCtrl = mpBorderWindow->GetWindow(GetWindowType::Client);
613
614
0
    ControlType aCtrlType = ControlType::Generic;
615
0
    ControlPart aCtrlPart = ControlPart::Entire;
616
0
    if (pCtrl)
617
0
    {
618
0
        switch (pCtrl->GetType())
619
0
        {
620
0
            case WindowType::MULTILINEEDIT:
621
0
                aCtrlType = ControlType::MultilineEditbox;
622
0
                break;
623
0
            case WindowType::EDIT:
624
0
            case WindowType::PATTERNFIELD:
625
0
            case WindowType::METRICFIELD:
626
0
            case WindowType::CURRENCYFIELD:
627
0
            case WindowType::DATEFIELD:
628
0
            case WindowType::TIMEFIELD:
629
0
            case WindowType::SPINFIELD:
630
0
            case WindowType::FORMATTEDFIELD:
631
0
                if (pCtrl->GetStyle() & WB_SPIN)
632
0
                    aCtrlType = ControlType::Spinbox;
633
0
                else
634
0
                    aCtrlType = ControlType::Editbox;
635
0
                break;
636
637
0
            case WindowType::LISTBOX:
638
0
            case WindowType::MULTILISTBOX:
639
0
            case WindowType::TREELISTBOX:
640
0
                aCtrlType = ControlType::Listbox;
641
0
                if (pCtrl->GetStyle() & WB_DROPDOWN)
642
0
                    aCtrlPart = ControlPart::Entire;
643
0
                else
644
0
                    aCtrlPart = ControlPart::ListboxWindow;
645
0
                break;
646
647
0
            case WindowType::LISTBOXWINDOW:
648
0
                aCtrlType = ControlType::Listbox;
649
0
                aCtrlPart = ControlPart::ListboxWindow;
650
0
                break;
651
652
0
            case WindowType::COMBOBOX:
653
0
            case WindowType::PATTERNBOX:
654
0
            case WindowType::NUMERICBOX:
655
0
            case WindowType::METRICBOX:
656
0
            case WindowType::CURRENCYBOX:
657
0
            case WindowType::DATEBOX:
658
0
            case WindowType::TIMEBOX:
659
0
            case WindowType::LONGCURRENCYBOX:
660
0
                if (pCtrl->GetStyle() & WB_DROPDOWN)
661
0
                {
662
0
                    aCtrlType = ControlType::Combobox;
663
0
                    aCtrlPart = ControlPart::Entire;
664
0
                }
665
0
                else
666
0
                {
667
0
                    aCtrlType = ControlType::Listbox;
668
0
                    aCtrlPart = ControlPart::ListboxWindow;
669
0
                }
670
0
                break;
671
672
0
            default:
673
0
                break;
674
0
        }
675
0
    }
676
677
0
    if (aCtrlType != ControlType::Generic && pCtrl->IsNativeControlSupported(aCtrlType, aCtrlPart))
678
0
    {
679
0
        ImplControlValue aControlValue;
680
0
        ControlState nState = ControlState::ENABLED;
681
682
0
        if (!mpBorderWindow->IsEnabled())
683
0
            nState &= ~ControlState::ENABLED;
684
0
        if (mpBorderWindow->HasFocus() || pCtrl->HasFocus() || pCtrl->HasChildPathFocus())
685
0
            nState |= ControlState::FOCUSED;
686
687
0
        bool bMouseOver = pCtrl->IsMouseOver();
688
0
        if (!bMouseOver)
689
0
        {
690
0
            vcl::Window *pCtrlChild = pCtrl->GetWindow(GetWindowType::FirstChild);
691
0
            while(pCtrlChild)
692
0
            {
693
0
                bMouseOver = pCtrlChild->IsMouseOver();
694
0
                if (bMouseOver)
695
0
                    break;
696
0
                pCtrlChild = pCtrlChild->GetWindow(GetWindowType::Next);
697
0
            }
698
0
        }
699
700
0
        if (bMouseOver)
701
0
            nState |= ControlState::ROLLOVER;
702
703
0
        Point aPoint;
704
0
        tools::Rectangle aCtrlRegion(aPoint, Size(mnWidth, mnHeight));
705
706
0
        tools::Rectangle aBoundingRgn(aPoint, Size(mnWidth, mnHeight));
707
0
        tools::Rectangle aContentRgn(aCtrlRegion);
708
0
        if (!ImplGetSVData()->maNWFData.mbCanDrawWidgetAnySize &&
709
0
            rRenderContext.GetNativeControlRegion(aCtrlType, aCtrlPart, aCtrlRegion,
710
0
                                         nState, aControlValue,
711
0
                                         aBoundingRgn, aContentRgn))
712
0
        {
713
0
            aCtrlRegion=aContentRgn;
714
0
        }
715
716
0
        Color aBackgroundColor = COL_AUTO;
717
0
        if (pCtrl->IsControlBackground())
718
0
            aBackgroundColor = pCtrl->GetBackgroundColor();
719
0
        bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, aCtrlPart, aCtrlRegion, nState, aControlValue, OUString(), aBackgroundColor);
720
721
        // if the native theme draws the spinbuttons in one call, make sure the proper settings
722
        // are passed, this might force a redraw though... (TODO: improve)
723
0
        if ((aCtrlType == ControlType::Spinbox) && !pCtrl->IsNativeControlSupported(ControlType::Spinbox, ControlPart::ButtonUp))
724
0
        {
725
0
            Edit* pEdit = static_cast<Edit*>(pCtrl)->GetSubEdit();
726
0
            if (pEdit && !pEdit->SupportsDoubleBuffering())
727
0
                pCtrl->Paint(*pCtrl->GetOutDev(), tools::Rectangle());  // make sure the buttons are also drawn as they might overwrite the border
728
0
        }
729
0
    }
730
731
0
    if (bNativeOK)
732
0
        return;
733
734
0
    DrawFrameStyle nStyle = DrawFrameStyle::NONE;
735
0
    DrawFrameFlags nFlags = DrawFrameFlags::NONE;
736
    // move border outside if border was converted or if the border window is a frame window,
737
0
    if (mpBorderWindow->mbSmallOutBorder)
738
0
        nStyle = DrawFrameStyle::DoubleOut;
739
0
    else if (nBorderStyle & WindowBorderStyle::NWF)
740
0
        nStyle = DrawFrameStyle::NWF;
741
0
    else
742
0
        nStyle = DrawFrameStyle::DoubleIn;
743
0
    if (nBorderStyle & WindowBorderStyle::MONO)
744
0
        nFlags |= DrawFrameFlags::Mono;
745
0
    if (nBorderStyle & WindowBorderStyle::MENU)
746
0
        nFlags |= DrawFrameFlags::Menu;
747
    // tell DrawFrame that we're drawing a window border of a frame window to avoid round corners
748
0
    if (mpBorderWindow == mpBorderWindow->ImplGetFrameWindow())
749
0
        nFlags |= DrawFrameFlags::WindowBorder;
750
751
0
    DecorationView aDecoView(&rRenderContext);
752
0
    tools::Rectangle aInRect(Point(), Size(mnWidth, mnHeight));
753
0
    aDecoView.DrawFrame(aInRect, nStyle, nFlags);
754
0
}
755
756
757
ImplStdBorderWindowView::ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow )
758
0
{
759
0
    maFrameData.mpBorderWindow  = pBorderWindow;
760
0
    maFrameData.mbDragFull      = false;
761
0
    maFrameData.mnHitTest       = BorderWindowHitTest::NONE;
762
0
    maFrameData.mnCloseState    = DrawButtonFlags::NONE;
763
0
    maFrameData.mnDockState     = DrawButtonFlags::NONE;
764
0
    maFrameData.mnMenuState     = DrawButtonFlags::NONE;
765
0
    maFrameData.mnHideState     = DrawButtonFlags::NONE;
766
0
    maFrameData.mnHelpState     = DrawButtonFlags::NONE;
767
0
    maFrameData.mbTitleClipped  = false;
768
0
}
769
770
ImplStdBorderWindowView::~ImplStdBorderWindowView()
771
0
{
772
0
}
773
774
bool ImplStdBorderWindowView::MouseMove( const MouseEvent& rMEvt )
775
0
{
776
0
    ImplMouseMove( &maFrameData, rMEvt );
777
0
    return true;
778
0
}
779
780
bool ImplStdBorderWindowView::MouseButtonDown( const MouseEvent& rMEvt )
781
0
{
782
0
    ImplBorderWindow* pBorderWindow = maFrameData.mpBorderWindow;
783
784
0
    if ( rMEvt.IsLeft() || rMEvt.IsRight() )
785
0
    {
786
0
        maFrameData.maMouseOff = rMEvt.GetPosPixel();
787
0
        maFrameData.mnHitTest = ImplHitTest( &maFrameData, maFrameData.maMouseOff );
788
0
        if ( maFrameData.mnHitTest != BorderWindowHitTest::NONE )
789
0
        {
790
0
            DragFullOptions nDragFullTest = DragFullOptions::NONE;
791
0
            bool bTracking = true;
792
0
            bool bHitTest = true;
793
794
0
            if ( maFrameData.mnHitTest & BorderWindowHitTest::Close )
795
0
            {
796
0
                maFrameData.mnCloseState |= DrawButtonFlags::Pressed;
797
0
                pBorderWindow->InvalidateBorder();
798
0
            }
799
0
            else if ( maFrameData.mnHitTest & BorderWindowHitTest::Dock )
800
0
            {
801
0
                maFrameData.mnDockState |= DrawButtonFlags::Pressed;
802
0
                pBorderWindow->InvalidateBorder();
803
0
            }
804
0
            else if ( maFrameData.mnHitTest & BorderWindowHitTest::Menu )
805
0
            {
806
0
                maFrameData.mnMenuState |= DrawButtonFlags::Pressed;
807
0
                pBorderWindow->InvalidateBorder();
808
809
                // call handler already on mouse down
810
0
                if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
811
0
                {
812
0
                    SystemWindow* pClientWindow = static_cast<SystemWindow*>(pBorderWindow->ImplGetClientWindow());
813
0
                    pClientWindow->TitleButtonClick( TitleButton::Menu );
814
0
                }
815
816
0
                maFrameData.mnMenuState &= ~DrawButtonFlags::Pressed;
817
0
                pBorderWindow->InvalidateBorder();
818
819
0
                bTracking = false;
820
0
            }
821
0
            else if ( maFrameData.mnHitTest & BorderWindowHitTest::Hide )
822
0
            {
823
0
                maFrameData.mnHideState |= DrawButtonFlags::Pressed;
824
0
                pBorderWindow->InvalidateBorder();
825
0
            }
826
0
            else if ( maFrameData.mnHitTest & BorderWindowHitTest::Help )
827
0
            {
828
0
                maFrameData.mnHelpState |= DrawButtonFlags::Pressed;
829
0
                pBorderWindow->InvalidateBorder();
830
0
            }
831
0
            else
832
0
            {
833
0
                if ( rMEvt.GetClicks() == 1 )
834
0
                {
835
0
                    Point aPos  = pBorderWindow->GetPosPixel();
836
0
                    Size  aSize = pBorderWindow->GetOutputSizePixel();
837
0
                    maFrameData.mnTrackX      = aPos.X();
838
0
                    maFrameData.mnTrackY      = aPos.Y();
839
0
                    maFrameData.mnTrackWidth  = aSize.Width();
840
0
                    maFrameData.mnTrackHeight = aSize.Height();
841
842
0
                    if (maFrameData.mnHitTest & BorderWindowHitTest::Title)
843
0
                        nDragFullTest = DragFullOptions::WindowMove;
844
0
                    else
845
0
                        nDragFullTest = DragFullOptions::WindowSize;
846
0
                }
847
0
                else
848
0
                {
849
0
                    bTracking = false;
850
851
0
                    if ( (maFrameData.mnHitTest & BorderWindowHitTest::Title) &&
852
0
                         ((rMEvt.GetClicks() % 2) == 0) )
853
0
                    {
854
0
                        maFrameData.mnHitTest = BorderWindowHitTest::NONE;
855
0
                        bHitTest = false;
856
857
0
                        if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
858
0
                        {
859
0
                            SystemWindow* pClientWindow = static_cast<SystemWindow*>(pBorderWindow->ImplGetClientWindow());
860
                            // always perform docking on double click, no button required
861
0
                            pClientWindow->TitleButtonClick( TitleButton::Docking );
862
0
                        }
863
0
                    }
864
0
                }
865
0
            }
866
867
0
            if ( bTracking )
868
0
            {
869
0
                maFrameData.mbDragFull = false;
870
0
                if ( nDragFullTest != DragFullOptions::NONE )
871
0
                    maFrameData.mbDragFull = true;   // always fulldrag for proper docking, ignore system settings
872
0
                pBorderWindow->StartTracking();
873
0
            }
874
0
            else if ( bHitTest )
875
0
                maFrameData.mnHitTest = BorderWindowHitTest::NONE;
876
0
        }
877
0
    }
878
879
0
    return true;
880
0
}
881
882
bool ImplStdBorderWindowView::Tracking( const TrackingEvent& rTEvt )
883
0
{
884
0
    ImplBorderWindow* pBorderWindow = maFrameData.mpBorderWindow;
885
886
0
    if ( rTEvt.IsTrackingEnded() )
887
0
    {
888
0
        BorderWindowHitTest nHitTest = maFrameData.mnHitTest;
889
0
        maFrameData.mnHitTest = BorderWindowHitTest::NONE;
890
891
0
        if ( nHitTest & BorderWindowHitTest::Close )
892
0
        {
893
0
            if ( maFrameData.mnCloseState & DrawButtonFlags::Pressed )
894
0
            {
895
0
                maFrameData.mnCloseState &= ~DrawButtonFlags::Pressed;
896
0
                pBorderWindow->InvalidateBorder();
897
898
                // do not call a Click-Handler when aborting
899
0
                if ( !rTEvt.IsTrackingCanceled() )
900
0
                {
901
                    // dispatch to correct window type (why is Close() not virtual ??? )
902
                    // TODO: make Close() virtual
903
0
                    VclPtr<vcl::Window> pWin = pBorderWindow->ImplGetClientWindow()->ImplGetWindow();
904
0
                    SystemWindow  *pSysWin  = dynamic_cast<SystemWindow* >(pWin.get());
905
0
                    DockingWindow *pDockWin = dynamic_cast<DockingWindow*>(pWin.get());
906
0
                    if ( pSysWin )
907
0
                        pSysWin->Close();
908
0
                    else if ( pDockWin )
909
0
                        pDockWin->Close();
910
0
                }
911
0
            }
912
0
        }
913
0
        else if ( nHitTest & BorderWindowHitTest::Dock )
914
0
        {
915
0
            if ( maFrameData.mnDockState & DrawButtonFlags::Pressed )
916
0
            {
917
0
                maFrameData.mnDockState &= ~DrawButtonFlags::Pressed;
918
0
                pBorderWindow->InvalidateBorder();
919
920
                // do not call a Click-Handler when aborting
921
0
                if ( !rTEvt.IsTrackingCanceled() )
922
0
                {
923
0
                    if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
924
0
                    {
925
0
                        SystemWindow* pClientWindow = static_cast<SystemWindow*>(pBorderWindow->ImplGetClientWindow());
926
0
                        pClientWindow->TitleButtonClick( TitleButton::Docking );
927
0
                    }
928
0
                }
929
0
            }
930
0
        }
931
0
        else if ( nHitTest & BorderWindowHitTest::Menu )
932
0
        {
933
0
            if ( maFrameData.mnMenuState & DrawButtonFlags::Pressed )
934
0
            {
935
0
                maFrameData.mnMenuState &= ~DrawButtonFlags::Pressed;
936
0
                pBorderWindow->InvalidateBorder();
937
938
                // handler already called on mouse down
939
0
            }
940
0
        }
941
0
        else if ( nHitTest & BorderWindowHitTest::Hide )
942
0
        {
943
0
            if ( maFrameData.mnHideState & DrawButtonFlags::Pressed )
944
0
            {
945
0
                maFrameData.mnHideState &= ~DrawButtonFlags::Pressed;
946
0
                pBorderWindow->InvalidateBorder();
947
948
                // do not call a Click-Handler when aborting
949
0
                if ( !rTEvt.IsTrackingCanceled() )
950
0
                {
951
0
                    if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
952
0
                    {
953
0
                        SystemWindow* pClientWindow = static_cast<SystemWindow*>(pBorderWindow->ImplGetClientWindow());
954
0
                        pClientWindow->TitleButtonClick( TitleButton::Hide );
955
0
                    }
956
0
                }
957
0
            }
958
0
        }
959
0
        else if ( nHitTest & BorderWindowHitTest::Help )
960
0
        {
961
0
            if ( maFrameData.mnHelpState & DrawButtonFlags::Pressed )
962
0
            {
963
0
                maFrameData.mnHelpState &= ~DrawButtonFlags::Pressed;
964
0
                pBorderWindow->InvalidateBorder();
965
0
            }
966
0
        }
967
0
        else
968
0
        {
969
0
            if ( maFrameData.mbDragFull )
970
0
            {
971
                // restore old state when aborting
972
0
                if ( rTEvt.IsTrackingCanceled() )
973
0
                    pBorderWindow->SetPosSizePixel( Point( maFrameData.mnTrackX, maFrameData.mnTrackY ), Size( maFrameData.mnTrackWidth, maFrameData.mnTrackHeight ) );
974
0
            }
975
0
            else
976
0
            {
977
0
                pBorderWindow->HideTracking();
978
0
                if ( !rTEvt.IsTrackingCanceled() )
979
0
                    pBorderWindow->SetPosSizePixel( Point( maFrameData.mnTrackX, maFrameData.mnTrackY ), Size( maFrameData.mnTrackWidth, maFrameData.mnTrackHeight ) );
980
0
            }
981
982
0
            if ( !rTEvt.IsTrackingCanceled() )
983
0
            {
984
0
                if ( pBorderWindow->ImplGetClientWindow()->ImplIsFloatingWindow() )
985
0
                {
986
0
                    if ( static_cast<FloatingWindow*>(pBorderWindow->ImplGetClientWindow())->IsInPopupMode() )
987
0
                        static_cast<FloatingWindow*>(pBorderWindow->ImplGetClientWindow())->EndPopupMode( FloatWinPopupEndFlags::TearOff );
988
0
                }
989
0
            }
990
0
        }
991
0
    }
992
0
    else if ( !rTEvt.GetMouseEvent().IsSynthetic() )
993
0
    {
994
0
        Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
995
996
0
        if ( maFrameData.mnHitTest & BorderWindowHitTest::Close )
997
0
        {
998
0
            if ( maFrameData.maCloseRect.Contains( aMousePos ) )
999
0
            {
1000
0
                if ( !(maFrameData.mnCloseState & DrawButtonFlags::Pressed) )
1001
0
                {
1002
0
                    maFrameData.mnCloseState |= DrawButtonFlags::Pressed;
1003
0
                    pBorderWindow->InvalidateBorder();
1004
0
                }
1005
0
            }
1006
0
            else
1007
0
            {
1008
0
                if ( maFrameData.mnCloseState & DrawButtonFlags::Pressed )
1009
0
                {
1010
0
                    maFrameData.mnCloseState &= ~DrawButtonFlags::Pressed;
1011
0
                    pBorderWindow->InvalidateBorder();
1012
0
                }
1013
0
            }
1014
0
        }
1015
0
        else if ( maFrameData.mnHitTest & BorderWindowHitTest::Dock )
1016
0
        {
1017
0
            if ( maFrameData.maDockRect.Contains( aMousePos ) )
1018
0
            {
1019
0
                if ( !(maFrameData.mnDockState & DrawButtonFlags::Pressed) )
1020
0
                {
1021
0
                    maFrameData.mnDockState |= DrawButtonFlags::Pressed;
1022
0
                    pBorderWindow->InvalidateBorder();
1023
0
                }
1024
0
            }
1025
0
            else
1026
0
            {
1027
0
                if ( maFrameData.mnDockState & DrawButtonFlags::Pressed )
1028
0
                {
1029
0
                    maFrameData.mnDockState &= ~DrawButtonFlags::Pressed;
1030
0
                    pBorderWindow->InvalidateBorder();
1031
0
                }
1032
0
            }
1033
0
        }
1034
0
        else if ( maFrameData.mnHitTest & BorderWindowHitTest::Menu )
1035
0
        {
1036
0
            if ( maFrameData.maMenuRect.Contains( aMousePos ) )
1037
0
            {
1038
0
                if ( !(maFrameData.mnMenuState & DrawButtonFlags::Pressed) )
1039
0
                {
1040
0
                    maFrameData.mnMenuState |= DrawButtonFlags::Pressed;
1041
0
                    pBorderWindow->InvalidateBorder();
1042
0
                }
1043
0
            }
1044
0
            else
1045
0
            {
1046
0
                if ( maFrameData.mnMenuState & DrawButtonFlags::Pressed )
1047
0
                {
1048
0
                    maFrameData.mnMenuState &= ~DrawButtonFlags::Pressed;
1049
0
                    pBorderWindow->InvalidateBorder();
1050
0
                }
1051
0
            }
1052
0
        }
1053
0
        else if ( maFrameData.mnHitTest & BorderWindowHitTest::Hide )
1054
0
        {
1055
0
            if ( maFrameData.maHideRect.Contains( aMousePos ) )
1056
0
            {
1057
0
                if ( !(maFrameData.mnHideState & DrawButtonFlags::Pressed) )
1058
0
                {
1059
0
                    maFrameData.mnHideState |= DrawButtonFlags::Pressed;
1060
0
                    pBorderWindow->InvalidateBorder();
1061
0
                }
1062
0
            }
1063
0
            else
1064
0
            {
1065
0
                if ( maFrameData.mnHideState & DrawButtonFlags::Pressed )
1066
0
                {
1067
0
                    maFrameData.mnHideState &= ~DrawButtonFlags::Pressed;
1068
0
                    pBorderWindow->InvalidateBorder();
1069
0
                }
1070
0
            }
1071
0
        }
1072
0
        else if ( maFrameData.mnHitTest & BorderWindowHitTest::Help )
1073
0
        {
1074
0
            if ( maFrameData.maHelpRect.Contains( aMousePos ) )
1075
0
            {
1076
0
                if ( !(maFrameData.mnHelpState & DrawButtonFlags::Pressed) )
1077
0
                {
1078
0
                    maFrameData.mnHelpState |= DrawButtonFlags::Pressed;
1079
0
                    pBorderWindow->InvalidateBorder();
1080
0
                }
1081
0
            }
1082
0
            else
1083
0
            {
1084
0
                if ( maFrameData.mnHelpState & DrawButtonFlags::Pressed )
1085
0
                {
1086
0
                    maFrameData.mnHelpState &= ~DrawButtonFlags::Pressed;
1087
0
                    pBorderWindow->InvalidateBorder();
1088
0
                }
1089
0
            }
1090
0
        }
1091
0
        else
1092
0
        {
1093
0
            aMousePos.AdjustX( -(maFrameData.maMouseOff.X()) );
1094
0
            aMousePos.AdjustY( -(maFrameData.maMouseOff.Y()) );
1095
1096
0
            if ( maFrameData.mnHitTest & BorderWindowHitTest::Title )
1097
0
            {
1098
0
                maFrameData.mpBorderWindow->SetPointer( PointerStyle::Move );
1099
1100
0
                Point aPos = pBorderWindow->GetPosPixel();
1101
0
                aPos.AdjustX(aMousePos.X() );
1102
0
                aPos.AdjustY(aMousePos.Y() );
1103
0
                if ( maFrameData.mbDragFull )
1104
0
                {
1105
0
                    pBorderWindow->SetPosPixel( aPos );
1106
0
                    pBorderWindow->ImplUpdateAll();
1107
0
                    pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
1108
0
                }
1109
0
                else
1110
0
                {
1111
0
                    maFrameData.mnTrackX = aPos.X();
1112
0
                    maFrameData.mnTrackY = aPos.Y();
1113
0
                    pBorderWindow->ShowTracking( tools::Rectangle( pBorderWindow->ScreenToOutputPixel( aPos ), pBorderWindow->GetOutputSizePixel() ), ShowTrackFlags::Big );
1114
0
                }
1115
0
            }
1116
0
            else
1117
0
            {
1118
0
                Point       aOldPos         = pBorderWindow->GetPosPixel();
1119
0
                Size        aSize           = pBorderWindow->GetSizePixel();
1120
0
                tools::Rectangle   aNewRect( aOldPos, aSize );
1121
0
                tools::Long        nOldWidth       = aSize.Width();
1122
0
                tools::Long        nOldHeight      = aSize.Height();
1123
0
                tools::Long        nBorderWidth    = maFrameData.mnLeftBorder+maFrameData.mnRightBorder;
1124
0
                tools::Long        nBorderHeight   = maFrameData.mnTopBorder+maFrameData.mnBottomBorder;
1125
0
                tools::Long        nMinWidth       = pBorderWindow->mnMinWidth+nBorderWidth;
1126
0
                tools::Long        nMinHeight      = pBorderWindow->mnMinHeight+nBorderHeight;
1127
0
                tools::Long        nMinWidth2      = nBorderWidth;
1128
0
                tools::Long        nMaxWidth       = pBorderWindow->mnMaxWidth+nBorderWidth;
1129
0
                tools::Long        nMaxHeight      = pBorderWindow->mnMaxHeight+nBorderHeight;
1130
1131
0
                if ( maFrameData.mnTitleHeight )
1132
0
                {
1133
0
                    nMinWidth2 += 4;
1134
1135
0
                    if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
1136
0
                        nMinWidth2 += maFrameData.maCloseRect.GetWidth();
1137
0
                }
1138
0
                if ( nMinWidth2 > nMinWidth )
1139
0
                    nMinWidth = nMinWidth2;
1140
0
                if ( maFrameData.mnHitTest & (BorderWindowHitTest::Left | BorderWindowHitTest::TopLeft | BorderWindowHitTest::BottomLeft) )
1141
0
                {
1142
0
                    aNewRect.AdjustLeft(aMousePos.X() );
1143
0
                    if ( aNewRect.GetWidth() < nMinWidth )
1144
0
                        aNewRect.SetLeft( aNewRect.Right()-nMinWidth+1 );
1145
0
                    else if ( aNewRect.GetWidth() > nMaxWidth )
1146
0
                        aNewRect.SetLeft( aNewRect.Right()-nMaxWidth+1 );
1147
0
                }
1148
0
                else if ( maFrameData.mnHitTest & (BorderWindowHitTest::Right | BorderWindowHitTest::TopRight | BorderWindowHitTest::BottomRight) )
1149
0
                {
1150
0
                    aNewRect.AdjustRight(aMousePos.X() );
1151
0
                    if ( aNewRect.GetWidth() < nMinWidth )
1152
0
                        aNewRect.SetRight( aNewRect.Left()+nMinWidth+1 );
1153
0
                    else if ( aNewRect.GetWidth() > nMaxWidth )
1154
0
                        aNewRect.SetRight( aNewRect.Left()+nMaxWidth+1 );
1155
0
                }
1156
0
                if ( maFrameData.mnHitTest & (BorderWindowHitTest::Top | BorderWindowHitTest::TopLeft | BorderWindowHitTest::TopRight) )
1157
0
                {
1158
0
                    aNewRect.AdjustTop(aMousePos.Y() );
1159
0
                    if ( aNewRect.GetHeight() < nMinHeight )
1160
0
                        aNewRect.SetTop( aNewRect.Bottom()-nMinHeight+1 );
1161
0
                    else if ( aNewRect.GetHeight() > nMaxHeight )
1162
0
                        aNewRect.SetTop( aNewRect.Bottom()-nMaxHeight+1 );
1163
0
                }
1164
0
                else if ( maFrameData.mnHitTest & (BorderWindowHitTest::Bottom | BorderWindowHitTest::BottomLeft | BorderWindowHitTest::BottomRight) )
1165
0
                {
1166
0
                    aNewRect.AdjustBottom(aMousePos.Y() );
1167
0
                    if ( aNewRect.GetHeight() < nMinHeight )
1168
0
                        aNewRect.SetBottom( aNewRect.Top()+nMinHeight+1 );
1169
0
                    else if ( aNewRect.GetHeight() > nMaxHeight )
1170
0
                        aNewRect.SetBottom( aNewRect.Top()+nMaxHeight+1 );
1171
0
                }
1172
1173
                // call Resizing-Handler for SystemWindows
1174
0
                if ( pBorderWindow->ImplGetClientWindow()->IsSystemWindow() )
1175
0
                {
1176
                    // adjust size for Resizing-call
1177
0
                    aSize = aNewRect.GetSize();
1178
0
                    aSize.AdjustWidth( -nBorderWidth );
1179
0
                    aSize.AdjustHeight( -nBorderHeight );
1180
0
                    static_cast<SystemWindow*>(pBorderWindow->ImplGetClientWindow())->Resizing( aSize );
1181
0
                    aSize.AdjustWidth(nBorderWidth );
1182
0
                    aSize.AdjustHeight(nBorderHeight );
1183
0
                    if ( aSize.Width() < nMinWidth )
1184
0
                        aSize.setWidth( nMinWidth );
1185
0
                    if ( aSize.Height() < nMinHeight )
1186
0
                        aSize.setHeight( nMinHeight );
1187
0
                    if ( aSize.Width() > nMaxWidth )
1188
0
                        aSize.setWidth( nMaxWidth );
1189
0
                    if ( aSize.Height() > nMaxHeight )
1190
0
                        aSize.setHeight( nMaxHeight );
1191
0
                    if ( maFrameData.mnHitTest & (BorderWindowHitTest::Left | BorderWindowHitTest::TopLeft | BorderWindowHitTest::BottomLeft) )
1192
0
                        aNewRect.SetLeft( aNewRect.Right()-aSize.Width()+1 );
1193
0
                    else
1194
0
                        aNewRect.SetRight( aNewRect.Left()+aSize.Width()-1 );
1195
0
                    if ( maFrameData.mnHitTest & (BorderWindowHitTest::Top | BorderWindowHitTest::TopLeft | BorderWindowHitTest::TopRight) )
1196
0
                        aNewRect.SetTop( aNewRect.Bottom()-aSize.Height()+1 );
1197
0
                    else
1198
0
                        aNewRect.SetBottom( aNewRect.Top()+aSize.Height()-1 );
1199
0
                }
1200
1201
0
                if ( maFrameData.mbDragFull )
1202
0
                {
1203
                    // no move (only resize) if position did not change
1204
0
                    if( aOldPos != aNewRect.TopLeft() )
1205
0
                        pBorderWindow->setPosSizePixel( aNewRect.Left(), aNewRect.Top(),
1206
0
                                                    aNewRect.GetWidth(), aNewRect.GetHeight() );
1207
0
                    else
1208
0
                        pBorderWindow->setPosSizePixel( aNewRect.Left(), aNewRect.Top(),
1209
0
                                                    aNewRect.GetWidth(), aNewRect.GetHeight(), PosSizeFlags::Size );
1210
1211
0
                    pBorderWindow->ImplUpdateAll();
1212
0
                    pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
1213
0
                    if ( maFrameData.mnHitTest & (BorderWindowHitTest::Right | BorderWindowHitTest::TopRight | BorderWindowHitTest::BottomRight) )
1214
0
                        maFrameData.maMouseOff.AdjustX(aNewRect.GetWidth()-nOldWidth );
1215
0
                    if ( maFrameData.mnHitTest & (BorderWindowHitTest::Bottom | BorderWindowHitTest::BottomLeft | BorderWindowHitTest::BottomRight) )
1216
0
                        maFrameData.maMouseOff.AdjustY(aNewRect.GetHeight()-nOldHeight );
1217
0
                }
1218
0
                else
1219
0
                {
1220
0
                    maFrameData.mnTrackX        = aNewRect.Left();
1221
0
                    maFrameData.mnTrackY        = aNewRect.Top();
1222
0
                    maFrameData.mnTrackWidth    = aNewRect.GetWidth();
1223
0
                    maFrameData.mnTrackHeight   = aNewRect.GetHeight();
1224
0
                    pBorderWindow->ShowTracking( tools::Rectangle( pBorderWindow->ScreenToOutputPixel( aNewRect.TopLeft() ), aNewRect.GetSize() ), ShowTrackFlags::Big );
1225
0
                }
1226
0
            }
1227
0
        }
1228
0
    }
1229
1230
0
    return true;
1231
0
}
1232
1233
OUString ImplStdBorderWindowView::RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect )
1234
0
{
1235
0
    return ImplRequestHelp( &maFrameData, rPos, rHelpRect );
1236
0
}
1237
1238
tools::Rectangle ImplStdBorderWindowView::GetMenuRect() const
1239
0
{
1240
0
    return maFrameData.maMenuRect;
1241
0
}
1242
1243
void ImplStdBorderWindowView::Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight )
1244
0
{
1245
0
    ImplBorderFrameData*    pData = &maFrameData;
1246
0
    ImplBorderWindow*       pBorderWindow = maFrameData.mpBorderWindow;
1247
0
    const StyleSettings&    rStyleSettings = pDev->GetSettings().GetStyleSettings();
1248
0
    DecorationView          aDecoView( pDev );
1249
0
    tools::Rectangle               aRect( 0, 0, 10, 10 );
1250
0
    tools::Rectangle               aCalcRect = aDecoView.DrawFrame( aRect, DrawFrameStyle::DoubleOut, DrawFrameFlags::NoDraw );
1251
1252
0
    pData->mpOutDev         = pDev;
1253
0
    pData->mnWidth          = nWidth;
1254
0
    pData->mnHeight         = nHeight;
1255
1256
0
    pData->mnTitleType      = pBorderWindow->mnTitleType;
1257
1258
0
    if ( !(pBorderWindow->GetStyle() & (WB_MOVEABLE | WB_POPUP)) || (pData->mnTitleType == BorderWindowTitleType::NONE) )
1259
0
        pData->mnBorderSize = 0;
1260
0
    else if ( pData->mnTitleType == BorderWindowTitleType::Tearoff )
1261
0
        pData->mnBorderSize = 0;
1262
0
    else
1263
0
        pData->mnBorderSize = StyleSettings::GetBorderSize();
1264
0
    pData->mnLeftBorder     = aCalcRect.Left();
1265
0
    pData->mnTopBorder      = aCalcRect.Top();
1266
0
    pData->mnRightBorder    = aRect.Right()-aCalcRect.Right();
1267
0
    pData->mnBottomBorder   = aRect.Bottom()-aCalcRect.Bottom();
1268
0
    pData->mnLeftBorder    += pData->mnBorderSize;
1269
0
    pData->mnTopBorder     += pData->mnBorderSize;
1270
0
    pData->mnRightBorder   += pData->mnBorderSize;
1271
0
    pData->mnBottomBorder  += pData->mnBorderSize;
1272
0
    pData->mnNoTitleTop     = pData->mnTopBorder;
1273
1274
0
    ImplInitTitle(&maFrameData);
1275
0
    if (pData->mnTitleHeight)
1276
0
    {
1277
        // to improve symbol display force a minimum title height
1278
0
        if (pData->mnTitleType != BorderWindowTitleType::Tearoff &&
1279
0
            pData->mnTitleHeight < MIN_CAPTION_HEIGHT)
1280
0
            pData->mnTitleHeight = MIN_CAPTION_HEIGHT;
1281
1282
        // set a proper background for drawing
1283
        // highlighted buttons in the title
1284
0
        pBorderWindow->SetBackground( rStyleSettings.GetFaceColor() );
1285
1286
0
        pData->maTitleRect.SetLeft( pData->mnLeftBorder );
1287
0
        pData->maTitleRect.SetRight( nWidth-pData->mnRightBorder-1 );
1288
0
        pData->maTitleRect.SetTop( pData->mnTopBorder );
1289
0
        pData->maTitleRect.SetBottom( pData->maTitleRect.Top()+pData->mnTitleHeight-1 );
1290
1291
0
        if ( pData->mnTitleType & (BorderWindowTitleType::Normal | BorderWindowTitleType::Small) )
1292
0
        {
1293
0
            tools::Long nRight         = pData->maTitleRect.Right() - 3;
1294
0
            tools::Long const nItemTop = pData->maTitleRect.Top() + 2;
1295
0
            tools::Long const nItemBottom = pData->maTitleRect.Bottom() - 2;
1296
1297
0
            auto addSquareOnRight = [&nRight, nItemTop, nItemBottom](
1298
0
                tools::Rectangle & rect, tools::Long gap)
1299
0
            {
1300
0
                rect.SetTop( nItemTop );
1301
0
                rect.SetBottom( nItemBottom );
1302
0
                rect.SetRight( nRight );
1303
0
                rect.SetLeft( rect.Right() - rect.GetHeight() + 1 );
1304
0
                nRight -= rect.GetWidth() + gap;
1305
0
            };
1306
1307
0
            if ( pBorderWindow->GetStyle() & WB_CLOSEABLE )
1308
0
            {
1309
0
                addSquareOnRight(pData->maCloseRect, 3);
1310
0
            }
1311
1312
0
            if ( pBorderWindow->mbMenuBtn )
1313
0
            {
1314
0
                addSquareOnRight(pData->maMenuRect, 0);
1315
0
            }
1316
1317
0
            if ( pBorderWindow->mbDockBtn )
1318
0
            {
1319
0
                addSquareOnRight(pData->maDockRect, 0);
1320
0
            }
1321
1322
0
            if ( pBorderWindow->mbHideBtn )
1323
0
            {
1324
0
                addSquareOnRight(pData->maHideRect, 0);
1325
0
            }
1326
0
        }
1327
0
        else
1328
0
        {
1329
0
            pData->maCloseRect.SetEmpty();
1330
0
            pData->maDockRect.SetEmpty();
1331
0
            pData->maMenuRect.SetEmpty();
1332
0
            pData->maHideRect.SetEmpty();
1333
0
            pData->maHelpRect.SetEmpty();
1334
0
        }
1335
1336
0
        pData->mnTopBorder  += pData->mnTitleHeight;
1337
0
    }
1338
0
    else
1339
0
    {
1340
0
        pData->maTitleRect.SetEmpty();
1341
0
        pData->maCloseRect.SetEmpty();
1342
0
        pData->maDockRect.SetEmpty();
1343
0
        pData->maMenuRect.SetEmpty();
1344
0
        pData->maHideRect.SetEmpty();
1345
0
        pData->maHelpRect.SetEmpty();
1346
0
    }
1347
0
}
1348
1349
void ImplStdBorderWindowView::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1350
                                         sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1351
0
{
1352
0
    rLeftBorder     = maFrameData.mnLeftBorder;
1353
0
    rTopBorder      = maFrameData.mnTopBorder;
1354
0
    rRightBorder    = maFrameData.mnRightBorder;
1355
0
    rBottomBorder   = maFrameData.mnBottomBorder;
1356
0
}
1357
1358
tools::Long ImplStdBorderWindowView::CalcTitleWidth() const
1359
0
{
1360
0
    return ImplCalcTitleWidth( &maFrameData );
1361
0
}
1362
1363
void ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset)
1364
0
{
1365
0
    ImplBorderFrameData* pData = &maFrameData;
1366
0
    ImplBorderWindow* pBorderWindow = pData->mpBorderWindow;
1367
0
    Point aTmpPoint = pOffset ? *pOffset : Point();
1368
0
    tools::Rectangle aInRect( aTmpPoint, Size( pData->mnWidth, pData->mnHeight ) );
1369
0
    const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1370
0
    Color aFaceColor(rStyleSettings.GetFaceColor());
1371
0
    Color aFrameColor(aFaceColor);
1372
1373
0
    aFrameColor.DecreaseContrast(sal_uInt8(0.5 * 255));
1374
1375
    // Draw Frame
1376
0
    vcl::Region oldClipRgn(rRenderContext.GetClipRegion());
1377
1378
    // for popups, don't draw part of the frame
1379
0
    const bool bShowJunctionToLauncher = !(pData->mnTitleType & (BorderWindowTitleType::Normal | BorderWindowTitleType::Small));
1380
0
    if (bShowJunctionToLauncher && !ImplGetSVData()->maNWFData.mbNoFrameJunctionForPopups)
1381
0
    {
1382
0
        FloatingWindow* pWin = dynamic_cast<FloatingWindow*>(pData->mpBorderWindow->GetWindow(GetWindowType::Client));
1383
0
        if (pWin)
1384
0
        {
1385
0
            vcl::Region aClipRgn(aInRect);
1386
0
            AbsoluteScreenPixelRectangle aItemClipRect(pWin->ImplGetItemEdgeClipRect());
1387
0
            if (!aItemClipRect.IsEmpty())
1388
0
            {
1389
0
                tools::Rectangle aTmp(pData->mpBorderWindow->AbsoluteScreenToOutputPixel(aItemClipRect.TopLeft()), aItemClipRect.GetSize());
1390
0
                aClipRgn.Exclude(aTmp);
1391
0
                rRenderContext.SetClipRegion(aClipRgn);
1392
0
            }
1393
0
        }
1394
0
    }
1395
1396
    // single line frame
1397
0
    rRenderContext.SetLineColor(aFrameColor);
1398
0
    rRenderContext.SetFillColor();
1399
0
    rRenderContext.DrawRect(aInRect);
1400
0
    aInRect.AdjustLeft( 1 );
1401
0
    aInRect.AdjustRight( -1 );
1402
0
    aInRect.AdjustTop( 1 );
1403
0
    aInRect.AdjustBottom( -1 );
1404
1405
    // restore
1406
0
    if (!(pData->mnTitleType & (BorderWindowTitleType::Normal | BorderWindowTitleType::Small)))
1407
0
        rRenderContext.SetClipRegion(oldClipRgn);
1408
1409
    // Draw Border
1410
0
    rRenderContext.SetLineColor();
1411
0
    tools::Long nBorderSize = pData->mnBorderSize;
1412
0
    if (nBorderSize)
1413
0
    {
1414
0
        rRenderContext.SetFillColor(rStyleSettings.GetFaceColor());
1415
0
        rRenderContext.DrawRect(tools::Rectangle(Point(aInRect.Left(), aInRect.Top()),
1416
0
                                 Size(aInRect.GetWidth(), nBorderSize)));
1417
0
        rRenderContext.DrawRect(tools::Rectangle(Point(aInRect.Left(), aInRect.Top() + nBorderSize),
1418
0
                                 Size(nBorderSize, aInRect.GetHeight() - nBorderSize)));
1419
0
        rRenderContext.DrawRect(tools::Rectangle(Point(aInRect.Left(), aInRect.Bottom() - nBorderSize + 1),
1420
0
                                 Size(aInRect.GetWidth(), nBorderSize)));
1421
0
        rRenderContext.DrawRect(tools::Rectangle(Point(aInRect.Right()-nBorderSize + 1, aInRect.Top() + nBorderSize),
1422
0
                                 Size(nBorderSize, aInRect.GetHeight() - nBorderSize)));
1423
0
    }
1424
1425
    // Draw Title
1426
0
    if (!pData->maTitleRect.IsEmpty())
1427
0
    {
1428
0
        aInRect = pData->maTitleRect;
1429
1430
        // use no gradient anymore, just a static titlecolor
1431
0
        if (pData->mnTitleType == BorderWindowTitleType::Tearoff)
1432
0
            rRenderContext.SetFillColor(rStyleSettings.GetFaceGradientColor());
1433
0
        else if (pData->mnTitleType == BorderWindowTitleType::Popup)
1434
0
            rRenderContext.SetFillColor(aFaceColor);
1435
0
        else
1436
0
            rRenderContext.SetFillColor(aFrameColor);
1437
1438
0
        rRenderContext.SetTextColor(rStyleSettings.GetButtonTextColor());
1439
0
        tools::Rectangle aTitleRect(pData->maTitleRect);
1440
0
        if(pOffset)
1441
0
            aTitleRect.Move(pOffset->X(), pOffset->Y());
1442
0
        rRenderContext.DrawRect(aTitleRect);
1443
1444
0
        if (pData->mnTitleType != BorderWindowTitleType::Tearoff)
1445
0
        {
1446
0
            aInRect.AdjustLeft(2 );
1447
0
            aInRect.AdjustRight( -2 );
1448
1449
0
            if (!pData->maHelpRect.IsEmpty())
1450
0
                aInRect.SetRight( pData->maHelpRect.Left() - 2 );
1451
0
            else if (!pData->maHideRect.IsEmpty())
1452
0
                aInRect.SetRight( pData->maHideRect.Left() - 2 );
1453
0
            else if (!pData->maDockRect.IsEmpty())
1454
0
                aInRect.SetRight( pData->maDockRect.Left() - 2 );
1455
0
            else if (!pData->maMenuRect.IsEmpty())
1456
0
                aInRect.SetRight( pData->maMenuRect.Left() - 2 );
1457
0
            else if (!pData->maCloseRect.IsEmpty())
1458
0
                aInRect.SetRight( pData->maCloseRect.Left() - 2 );
1459
1460
0
            if (pOffset)
1461
0
                aInRect.Move(pOffset->X(), pOffset->Y());
1462
1463
0
            DrawTextFlags nTextStyle = DrawTextFlags::Left | DrawTextFlags::VCenter | DrawTextFlags::EndEllipsis | DrawTextFlags::Clip;
1464
1465
            // must show tooltip ?
1466
0
            TextRectInfo aInfo;
1467
0
            rRenderContext.GetTextRect(aInRect, pBorderWindow->GetText(), nTextStyle, &aInfo);
1468
0
            pData->mbTitleClipped = aInfo.IsEllipses();
1469
1470
0
            rRenderContext.DrawText(aInRect, pBorderWindow->GetText(), nTextStyle);
1471
0
        }
1472
0
        else
1473
0
        {
1474
0
            ToolBox::ImplDrawGrip(rRenderContext, aTitleRect, ToolBox::ImplGetDragWidth(rRenderContext, false),
1475
0
                                  WindowAlign::Left, false);
1476
0
        }
1477
0
    }
1478
1479
0
    if (!pData->maCloseRect.IsEmpty())
1480
0
    {
1481
0
        tools::Rectangle aSymbolRect(pData->maCloseRect);
1482
0
        if (pOffset)
1483
0
            aSymbolRect.Move(pOffset->X(), pOffset->Y());
1484
0
        ImplDrawBrdWinSymbolButton(&rRenderContext, aSymbolRect, SymbolType::CLOSE, pData->mnCloseState);
1485
0
    }
1486
0
    if (!pData->maDockRect.IsEmpty())
1487
0
    {
1488
0
        tools::Rectangle aSymbolRect(pData->maDockRect);
1489
0
        if (pOffset)
1490
0
            aSymbolRect.Move(pOffset->X(), pOffset->Y());
1491
0
        ImplDrawBrdWinSymbolButton(&rRenderContext, aSymbolRect, SymbolType::DOCK, pData->mnDockState);
1492
0
    }
1493
0
    if (!pData->maMenuRect.IsEmpty())
1494
0
    {
1495
0
        tools::Rectangle aSymbolRect(pData->maMenuRect);
1496
0
        if (pOffset)
1497
0
            aSymbolRect.Move(pOffset->X(), pOffset->Y());
1498
0
        ImplDrawBrdWinSymbolButton(&rRenderContext, aSymbolRect, SymbolType::MENU, pData->mnMenuState);
1499
0
    }
1500
0
    if (!pData->maHideRect.IsEmpty())
1501
0
    {
1502
0
        tools::Rectangle aSymbolRect(pData->maHideRect);
1503
0
        if (pOffset)
1504
0
            aSymbolRect.Move(pOffset->X(), pOffset->Y());
1505
0
        ImplDrawBrdWinSymbolButton(&rRenderContext, aSymbolRect, SymbolType::HIDE, pData->mnHideState);
1506
0
    }
1507
1508
0
    if (!pData->maHelpRect.IsEmpty())
1509
0
    {
1510
0
        tools::Rectangle aSymbolRect(pData->maHelpRect);
1511
0
        if (pOffset)
1512
0
            aSymbolRect.Move(pOffset->X(), pOffset->Y());
1513
0
        ImplDrawBrdWinSymbolButton(&rRenderContext, aSymbolRect, SymbolType::HELP, pData->mnHelpState);
1514
0
    }
1515
0
}
1516
1517
void ImplBorderWindow::ImplInit( vcl::Window* pParent,
1518
                                 WinBits nStyle, BorderWindowStyle nTypeStyle,
1519
                                 SystemParentData* pSystemParentData
1520
                                 )
1521
12.9k
{
1522
    // remove all unwanted WindowBits
1523
12.9k
    WinBits nOrgStyle = nStyle;
1524
12.9k
    WinBits nTestStyle = (WB_MOVEABLE | WB_SIZEABLE | WB_CLOSEABLE | WB_STANDALONE | WB_DIALOGCONTROL | WB_NODIALOGCONTROL | WB_SYSTEMFLOATWIN | WB_INTROWIN | WB_DEFAULTWIN | WB_TOOLTIPWIN | WB_NOSHADOW | WB_OWNERDRAWDECORATION | WB_SYSTEMCHILDWINDOW  | WB_POPUP);
1525
12.9k
    if ( nTypeStyle & BorderWindowStyle::App )
1526
0
        nTestStyle |= WB_APP;
1527
12.9k
    nStyle &= nTestStyle;
1528
1529
12.9k
    mpWindowImpl->mbBorderWin       = true;
1530
12.9k
    mbSmallOutBorder    = false;
1531
12.9k
    if ( nTypeStyle & BorderWindowStyle::Frame )
1532
8.34k
    {
1533
8.34k
        mpWindowImpl->mbOverlapWin = true;
1534
8.34k
        mpWindowImpl->mbFrame = true;
1535
1536
8.34k
        if( nStyle & WB_SYSTEMCHILDWINDOW )
1537
0
        {
1538
0
            mbFrameBorder               = false;
1539
0
        }
1540
8.34k
        else if( nStyle & (WB_OWNERDRAWDECORATION | WB_POPUP) )
1541
0
        {
1542
0
            mbFrameBorder   = (nOrgStyle & WB_NOBORDER) == 0;
1543
0
        }
1544
8.34k
        else
1545
8.34k
        {
1546
8.34k
            mbFrameBorder   = false;
1547
            // closeable windows may have a border as well, eg. system floating windows without caption
1548
8.34k
            if ( (nOrgStyle & (WB_BORDER | WB_NOBORDER | WB_MOVEABLE | WB_SIZEABLE/* | WB_CLOSEABLE*/)) == WB_BORDER )
1549
0
                mbSmallOutBorder = true;
1550
8.34k
        }
1551
8.34k
    }
1552
4.57k
    else if ( nTypeStyle & BorderWindowStyle::Overlap )
1553
0
    {
1554
0
        mpWindowImpl->mbOverlapWin  = true;
1555
0
        mbFrameBorder   = true;
1556
0
    }
1557
4.57k
    else
1558
4.57k
        mbFrameBorder   = false;
1559
1560
12.9k
    if ( nTypeStyle & BorderWindowStyle::Float )
1561
0
        mbFloatWindow = true;
1562
12.9k
    else
1563
12.9k
        mbFloatWindow = false;
1564
1565
12.9k
    Window::ImplInit( pParent, nStyle, pSystemParentData );
1566
12.9k
    SetBackground();
1567
12.9k
    SetTextFillColor();
1568
1569
12.9k
    mpMenuBarWindow = nullptr;
1570
12.9k
    mnMinWidth      = 0;
1571
12.9k
    mnMinHeight     = 0;
1572
12.9k
    mnMaxWidth      = SHRT_MAX;
1573
12.9k
    mnMaxHeight     = SHRT_MAX;
1574
12.9k
    mnOrgMenuHeight = 0;
1575
12.9k
    mbMenuHide      = false;
1576
12.9k
    mbDockBtn       = false;
1577
12.9k
    mbMenuBtn       = false;
1578
12.9k
    mbHideBtn       = false;
1579
12.9k
    mbDisplayActive = IsActive();
1580
1581
12.9k
    if ( nTypeStyle & BorderWindowStyle::Float )
1582
0
        mnTitleType = BorderWindowTitleType::Small;
1583
12.9k
    else
1584
12.9k
        mnTitleType = BorderWindowTitleType::Normal;
1585
12.9k
    mnBorderStyle   = WindowBorderStyle::NORMAL;
1586
12.9k
    InitView();
1587
12.9k
}
1588
1589
ImplBorderWindow::ImplBorderWindow( vcl::Window* pParent,
1590
                                    SystemParentData* pSystemParentData,
1591
                                    WinBits nStyle, BorderWindowStyle nTypeStyle
1592
8.34k
                                    ) : Window( WindowType::BORDERWINDOW )
1593
8.34k
{
1594
8.34k
    ImplInit( pParent, nStyle, nTypeStyle, pSystemParentData );
1595
8.34k
}
Unexecuted instantiation: ImplBorderWindow::ImplBorderWindow(vcl::Window*, SystemParentData*, long, BorderWindowStyle)
ImplBorderWindow::ImplBorderWindow(vcl::Window*, SystemParentData*, long, BorderWindowStyle)
Line
Count
Source
1592
8.34k
                                    ) : Window( WindowType::BORDERWINDOW )
1593
8.34k
{
1594
8.34k
    ImplInit( pParent, nStyle, nTypeStyle, pSystemParentData );
1595
8.34k
}
1596
1597
ImplBorderWindow::ImplBorderWindow( vcl::Window* pParent, WinBits nStyle ,
1598
                                    BorderWindowStyle nTypeStyle ) :
1599
4.57k
    Window( WindowType::BORDERWINDOW )
1600
4.57k
{
1601
4.57k
    ImplInit( pParent, nStyle, nTypeStyle, nullptr );
1602
4.57k
}
Unexecuted instantiation: ImplBorderWindow::ImplBorderWindow(vcl::Window*, long, BorderWindowStyle)
ImplBorderWindow::ImplBorderWindow(vcl::Window*, long, BorderWindowStyle)
Line
Count
Source
1599
4.57k
    Window( WindowType::BORDERWINDOW )
1600
4.57k
{
1601
4.57k
    ImplInit( pParent, nStyle, nTypeStyle, nullptr );
1602
4.57k
}
1603
1604
ImplBorderWindow::~ImplBorderWindow()
1605
9.15k
{
1606
9.15k
    disposeOnce();
1607
9.15k
}
1608
1609
void ImplBorderWindow::dispose()
1610
9.15k
{
1611
9.15k
    mpBorderView.reset();
1612
9.15k
    mpMenuBarWindow.reset();
1613
9.15k
    mpNotebookBar.disposeAndClear();
1614
9.15k
    vcl::Window::dispose();
1615
9.15k
}
1616
1617
void ImplBorderWindow::MouseMove( const MouseEvent& rMEvt )
1618
0
{
1619
0
    if (mpBorderView)
1620
0
        mpBorderView->MouseMove( rMEvt );
1621
0
}
1622
1623
void ImplBorderWindow::MouseButtonDown( const MouseEvent& rMEvt )
1624
0
{
1625
0
    if (mpBorderView)
1626
0
        mpBorderView->MouseButtonDown( rMEvt );
1627
0
}
1628
1629
void ImplBorderWindow::Tracking( const TrackingEvent& rTEvt )
1630
0
{
1631
0
    if (mpBorderView)
1632
0
        mpBorderView->Tracking( rTEvt );
1633
0
}
1634
1635
void ImplBorderWindow::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& )
1636
0
{
1637
0
    if (mpBorderView)
1638
0
        mpBorderView->DrawWindow(rRenderContext);
1639
0
}
1640
1641
void ImplBorderWindow::Draw( OutputDevice* pOutDev, const Point& rPos )
1642
0
{
1643
0
    if (mpBorderView)
1644
0
        mpBorderView->DrawWindow(*pOutDev, &rPos);
1645
0
}
1646
1647
void ImplBorderWindow::Activate()
1648
0
{
1649
0
    SetDisplayActive( true );
1650
0
    Window::Activate();
1651
0
}
1652
1653
void ImplBorderWindow::Deactivate()
1654
8.34k
{
1655
    // remove active windows from the ruler, also ignore the Deactivate
1656
    // if a menu becomes active
1657
8.34k
    if (GetActivateMode() != ActivateModeFlags::NONE && !ImplGetSVData()->mpWinData->mbNoDeactivate)
1658
8.34k
        SetDisplayActive( false );
1659
8.34k
    Window::Deactivate();
1660
8.34k
}
1661
1662
void ImplBorderWindow::RequestHelp( const HelpEvent& rHEvt )
1663
0
{
1664
    // no keyboard help for border window
1665
0
    if ( rHEvt.GetMode() & (HelpEventMode::BALLOON | HelpEventMode::QUICK) && !rHEvt.KeyboardActivated() )
1666
0
    {
1667
0
        Point       aMousePosPixel = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
1668
0
        tools::Rectangle   aHelpRect;
1669
0
        OUString    aHelpStr( mpBorderView->RequestHelp( aMousePosPixel, aHelpRect ) );
1670
1671
        // retrieve rectangle
1672
0
        if ( !aHelpStr.isEmpty() )
1673
0
        {
1674
0
            aHelpRect.SetPos( OutputToScreenPixel( aHelpRect.TopLeft() ) );
1675
0
            if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
1676
0
                Help::ShowBalloon( this, aHelpRect.Center(), aHelpRect, aHelpStr );
1677
0
            else
1678
0
                Help::ShowQuickHelp( this, aHelpRect, aHelpStr );
1679
0
            return;
1680
0
        }
1681
0
    }
1682
1683
0
    Window::RequestHelp( rHEvt );
1684
0
}
1685
1686
void ImplBorderWindow::Resize()
1687
4.57k
{
1688
4.57k
    Size aSize = GetOutputSizePixel();
1689
1690
4.57k
    vcl::Window* pClientWindow = ImplGetClientWindow();
1691
1692
4.57k
    sal_Int32 nLeftBorder;
1693
4.57k
    sal_Int32 nTopBorder;
1694
4.57k
    sal_Int32 nRightBorder;
1695
4.57k
    sal_Int32 nBottomBorder;
1696
4.57k
    mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
1697
1698
4.57k
    if (mpMenuBarWindow)
1699
0
    {
1700
0
        tools::Long nMenuHeight = mpMenuBarWindow->GetSizePixel().Height();
1701
0
        if ( mbMenuHide )
1702
0
        {
1703
0
            if ( nMenuHeight )
1704
0
                mnOrgMenuHeight = nMenuHeight;
1705
0
            nMenuHeight = 0;
1706
0
        }
1707
0
        else
1708
0
        {
1709
0
            if ( !nMenuHeight )
1710
0
                nMenuHeight = mnOrgMenuHeight;
1711
0
        }
1712
0
        mpMenuBarWindow->setPosSizePixel(
1713
0
                nLeftBorder, nTopBorder,
1714
0
                aSize.Width()-nLeftBorder-nRightBorder,
1715
0
                nMenuHeight);
1716
1717
        // shift the notebookbar down accordingly
1718
0
        nTopBorder += nMenuHeight;
1719
0
    }
1720
1721
4.57k
    if (mpNotebookBar)
1722
0
    {
1723
0
        tools::Long nNotebookBarHeight = mpNotebookBar->GetSizePixel().Height();
1724
0
        mpNotebookBar->setPosSizePixel(
1725
0
                nLeftBorder, nTopBorder,
1726
0
                aSize.Width() - nLeftBorder - nRightBorder,
1727
0
                nNotebookBarHeight);
1728
0
    }
1729
1730
4.57k
    GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
1731
4.57k
               pClientWindow->mpWindowImpl->mnRightBorder, pClientWindow->mpWindowImpl->mnBottomBorder );
1732
4.57k
    pClientWindow->ImplPosSizeWindow( pClientWindow->mpWindowImpl->mnLeftBorder,
1733
4.57k
                                      pClientWindow->mpWindowImpl->mnTopBorder,
1734
4.57k
                                      aSize.Width()-pClientWindow->mpWindowImpl->mnLeftBorder-pClientWindow->mpWindowImpl->mnRightBorder,
1735
4.57k
                                      aSize.Height()-pClientWindow->mpWindowImpl->mnTopBorder-pClientWindow->mpWindowImpl->mnBottomBorder,
1736
4.57k
                                      PosSizeFlags::X | PosSizeFlags::Y |
1737
4.57k
                                      PosSizeFlags::Width | PosSizeFlags::Height );
1738
1739
    // UpdateView
1740
4.57k
    mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1741
4.57k
    InvalidateBorder();
1742
1743
4.57k
    Window::Resize();
1744
4.57k
}
1745
1746
void ImplBorderWindow::StateChanged( StateChangedType nType )
1747
13.7k
{
1748
13.7k
    if ( (nType == StateChangedType::Text) ||
1749
9.15k
         (nType == StateChangedType::Data) )
1750
4.60k
    {
1751
4.60k
        if (IsReallyVisible() && mbFrameBorder)
1752
0
            InvalidateBorder();
1753
4.60k
    }
1754
1755
13.7k
    Window::StateChanged( nType );
1756
13.7k
}
1757
1758
void ImplBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
1759
2
{
1760
2
    if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1761
2
         (rDCEvt.GetType() == DataChangedEventType::FONTSUBSTITUTION) ||
1762
2
         ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1763
2
          (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1764
2
    {
1765
2
        if ( !mpWindowImpl->mbFrame || (GetStyle() & (WB_OWNERDRAWDECORATION | WB_POPUP)) )
1766
0
            UpdateView( true, ImplGetWindow()->GetOutputSizePixel() );
1767
2
    }
1768
1769
2
    Window::DataChanged( rDCEvt );
1770
2
}
1771
1772
void ImplBorderWindow::InitView()
1773
12.9k
{
1774
12.9k
    if ( mbSmallOutBorder )
1775
0
        mpBorderView.reset(new ImplSmallBorderWindowView( this ));
1776
12.9k
    else if ( mpWindowImpl->mbFrame )
1777
8.34k
    {
1778
8.34k
        if( mbFrameBorder )
1779
0
            mpBorderView.reset(new ImplStdBorderWindowView( this ));
1780
8.34k
        else
1781
8.34k
            mpBorderView.reset(new ImplNoBorderWindowView);
1782
8.34k
    }
1783
4.57k
    else if ( !mbFrameBorder )
1784
4.57k
        mpBorderView.reset(new ImplSmallBorderWindowView( this ));
1785
0
    else
1786
0
        mpBorderView.reset(new ImplStdBorderWindowView( this ));
1787
12.9k
    Size aSize = GetOutputSizePixel();
1788
12.9k
    mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1789
12.9k
}
1790
1791
void ImplBorderWindow::UpdateView( bool bNewView, const Size& rNewOutSize )
1792
4.57k
{
1793
4.57k
    sal_Int32 nLeftBorder;
1794
4.57k
    sal_Int32 nTopBorder;
1795
4.57k
    sal_Int32 nRightBorder;
1796
4.57k
    sal_Int32 nBottomBorder;
1797
4.57k
    Size aOldSize = GetSizePixel();
1798
4.57k
    Size aOutputSize = rNewOutSize;
1799
1800
4.57k
    if ( bNewView )
1801
0
    {
1802
0
        mpBorderView.reset();
1803
0
        InitView();
1804
0
    }
1805
4.57k
    else
1806
4.57k
    {
1807
4.57k
        Size aSize = aOutputSize;
1808
4.57k
        mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
1809
4.57k
        aSize.AdjustWidth(nLeftBorder+nRightBorder );
1810
4.57k
        aSize.AdjustHeight(nTopBorder+nBottomBorder );
1811
4.57k
        mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1812
4.57k
    }
1813
1814
4.57k
    vcl::Window* pClientWindow = ImplGetClientWindow();
1815
4.57k
    if ( pClientWindow )
1816
4.57k
    {
1817
4.57k
        GetBorder( pClientWindow->mpWindowImpl->mnLeftBorder, pClientWindow->mpWindowImpl->mnTopBorder,
1818
4.57k
                   pClientWindow->mpWindowImpl->mnRightBorder, pClientWindow->mpWindowImpl->mnBottomBorder );
1819
4.57k
    }
1820
4.57k
    GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
1821
4.57k
    if ( aOldSize.Width() || aOldSize.Height() )
1822
0
    {
1823
0
        aOutputSize.AdjustWidth(nLeftBorder+nRightBorder );
1824
0
        aOutputSize.AdjustHeight(nTopBorder+nBottomBorder );
1825
0
        if ( aOutputSize == GetSizePixel() )
1826
0
            InvalidateBorder();
1827
0
        else
1828
0
            SetSizePixel( aOutputSize );
1829
0
    }
1830
4.57k
}
1831
1832
void ImplBorderWindow::InvalidateBorder()
1833
4.57k
{
1834
4.57k
    if ( !IsReallyVisible() )
1835
4.57k
        return;
1836
1837
    // invalidate only if we have a border
1838
0
    sal_Int32 nLeftBorder;
1839
0
    sal_Int32 nTopBorder;
1840
0
    sal_Int32 nRightBorder;
1841
0
    sal_Int32 nBottomBorder;
1842
0
    mpBorderView->GetBorder( nLeftBorder, nTopBorder, nRightBorder, nBottomBorder );
1843
0
    if ( !(nLeftBorder || nTopBorder || nRightBorder || nBottomBorder) )
1844
0
        return;
1845
1846
0
    tools::Rectangle   aWinRect( Point( 0, 0 ), GetOutputSizePixel() );
1847
0
    vcl::Region      aRegion( aWinRect );
1848
0
    aWinRect.AdjustLeft(nLeftBorder );
1849
0
    aWinRect.AdjustTop(nTopBorder );
1850
0
    aWinRect.AdjustRight( -nRightBorder );
1851
0
    aWinRect.AdjustBottom( -nBottomBorder );
1852
    // no output area anymore, now invalidate all
1853
0
    if ( (aWinRect.Right() < aWinRect.Left()) ||
1854
0
         (aWinRect.Bottom() < aWinRect.Top()) )
1855
0
        Invalidate( InvalidateFlags::NoChildren );
1856
0
    else
1857
0
    {
1858
0
        aRegion.Exclude( aWinRect );
1859
0
        Invalidate( aRegion, InvalidateFlags::NoChildren );
1860
0
    }
1861
0
}
1862
1863
void ImplBorderWindow::SetDisplayActive( bool bActive )
1864
8.34k
{
1865
8.34k
    if ( mbDisplayActive != bActive )
1866
0
    {
1867
0
        mbDisplayActive = bActive;
1868
0
        if ( mbFrameBorder )
1869
0
            InvalidateBorder();
1870
0
    }
1871
8.34k
}
1872
1873
void ImplBorderWindow::SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize )
1874
0
{
1875
0
    mnTitleType = nTitleType;
1876
0
    UpdateView( false, rSize );
1877
0
}
1878
1879
void ImplBorderWindow::SetBorderStyle( WindowBorderStyle nStyle )
1880
4.57k
{
1881
4.57k
    if ( !mbFrameBorder && (mnBorderStyle != nStyle) )
1882
4.57k
    {
1883
4.57k
        mnBorderStyle = nStyle;
1884
4.57k
        UpdateView( false, ImplGetWindow()->GetOutputSizePixel() );
1885
4.57k
    }
1886
4.57k
}
1887
1888
void ImplBorderWindow::SetCloseButton()
1889
0
{
1890
0
    SetStyle( GetStyle() | WB_CLOSEABLE );
1891
0
    Size aSize = GetOutputSizePixel();
1892
0
    mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1893
0
    InvalidateBorder();
1894
0
}
1895
1896
void ImplBorderWindow::SetDockButton( bool bDockButton )
1897
0
{
1898
0
    mbDockBtn = bDockButton;
1899
0
    Size aSize = GetOutputSizePixel();
1900
0
    mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1901
0
    InvalidateBorder();
1902
0
}
1903
1904
void ImplBorderWindow::SetHideButton( bool bHideButton )
1905
0
{
1906
0
    mbHideBtn = bHideButton;
1907
0
    Size aSize = GetOutputSizePixel();
1908
0
    mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1909
0
    InvalidateBorder();
1910
0
}
1911
1912
void ImplBorderWindow::SetMenuButton( bool bMenuButton )
1913
0
{
1914
0
    mbMenuBtn = bMenuButton;
1915
0
    Size aSize = GetOutputSizePixel();
1916
0
    mpBorderView->Init( GetOutDev(), aSize.Width(), aSize.Height() );
1917
0
    InvalidateBorder();
1918
0
}
1919
1920
void ImplBorderWindow::UpdateMenuHeight()
1921
0
{
1922
0
    Resize();
1923
0
}
1924
1925
void ImplBorderWindow::SetMenuBarWindow( vcl::Window* pWindow )
1926
0
{
1927
0
    mpMenuBarWindow = pWindow;
1928
0
    UpdateMenuHeight();
1929
0
    if ( pWindow )
1930
0
        pWindow->Show();
1931
0
}
1932
1933
void ImplBorderWindow::SetMenuBarMode( bool bHide )
1934
0
{
1935
0
    mbMenuHide = bHide;
1936
0
    UpdateMenuHeight();
1937
0
}
1938
1939
void ImplBorderWindow::SetNotebookBar(const OUString& rUIXMLDescription,
1940
                                      const css::uno::Reference<css::frame::XFrame>& rFrame,
1941
                                      std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem)
1942
0
{
1943
0
    if (mpNotebookBar)
1944
0
        mpNotebookBar.disposeAndClear();
1945
0
    mpNotebookBar = VclPtr<NotebookBar>::Create(this, "NotebookBar", rUIXMLDescription, rFrame,
1946
0
                                                std::move(pNotebookBarAddonsItem));
1947
0
    Resize();
1948
0
}
1949
1950
void ImplBorderWindow::CloseNotebookBar()
1951
0
{
1952
0
    if (mpNotebookBar)
1953
0
        mpNotebookBar.disposeAndClear();
1954
0
    mpNotebookBar = nullptr;
1955
0
    Resize();
1956
0
}
1957
1958
void ImplBorderWindow::GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
1959
                                  sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const
1960
26.6k
{
1961
26.6k
    mpBorderView->GetBorder(rLeftBorder, rTopBorder, rRightBorder, rBottomBorder);
1962
1963
26.6k
    if (mpMenuBarWindow && !mbMenuHide)
1964
0
        rTopBorder += mpMenuBarWindow->GetSizePixel().Height();
1965
1966
26.6k
    if (mpNotebookBar && mpNotebookBar->IsVisible())
1967
0
        rTopBorder += mpNotebookBar->GetSizePixel().Height();
1968
26.6k
}
1969
1970
tools::Long ImplBorderWindow::CalcTitleWidth() const
1971
0
{
1972
0
    return mpBorderView->CalcTitleWidth();
1973
0
}
1974
1975
tools::Rectangle ImplBorderWindow::GetMenuRect() const
1976
0
{
1977
0
    return mpBorderView->GetMenuRect();
1978
0
}
1979
1980
Size ImplBorderWindow::GetOptimalSize() const
1981
0
{
1982
0
    const vcl::Window* pClientWindow = ImplGetClientWindow();
1983
0
    if (pClientWindow)
1984
0
        return pClientWindow->GetOptimalSize();
1985
0
    return Size(mnMinWidth, mnMinHeight);
1986
0
}
1987
1988
void ImplBorderWindow::queue_resize(StateChangedType eReason)
1989
18.3k
{
1990
    //if we are floating, then we don't want to inform our parent that it needs
1991
    //to calculate a new layout allocation. Because while we are a child
1992
    //of our parent we are not embedded into the parent so it doesn't care
1993
    //about us.
1994
18.3k
    if (mbFloatWindow)
1995
0
        return;
1996
18.3k
    vcl::Window::queue_resize(eReason);
1997
18.3k
}
1998
1999
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */