Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/inc/brdwin.hxx
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
#pragma once
21
22
#include <vcl/notebookbar/notebookbar.hxx>
23
#include <vcl/window.hxx>
24
#include <o3tl/typed_flags_set.hxx>
25
26
#include <com/sun/star/frame/XFrame.hpp>
27
28
class ImplBorderWindowView;
29
struct NotebookBarAddonsItem;
30
enum class DrawButtonFlags;
31
32
enum class BorderWindowStyle {
33
    NONE             = 0x0000,
34
    Overlap          = 0x0001,
35
    Float            = 0x0004,
36
    Frame            = 0x0008,
37
    App              = 0x0010
38
};
39
namespace o3tl {
40
    template<> struct typed_flags<BorderWindowStyle> : is_typed_flags<BorderWindowStyle, 0x001d> {};
41
};
42
43
enum class BorderWindowHitTest {
44
    NONE           = 0x0000,
45
    Title          = 0x0001,
46
    Left           = 0x0002,
47
    Menu           = 0x0004,
48
    Top            = 0x0008,
49
    Right          = 0x0010,
50
    Bottom         = 0x0020,
51
    TopLeft        = 0x0040,
52
    TopRight       = 0x0080,
53
    BottomLeft     = 0x0100,
54
    BottomRight    = 0x0200,
55
    Close          = 0x0400,
56
    Dock           = 0x0800,
57
    Hide           = 0x1000,
58
    Help           = 0x2000,
59
};
60
namespace o3tl {
61
    template<> struct typed_flags<BorderWindowHitTest> : is_typed_flags<BorderWindowHitTest, 0x3fff> {};
62
};
63
64
enum class BorderWindowTitleType {
65
    Normal           = 0x0001,
66
    Small            = 0x0002,
67
    Tearoff          = 0x0004,
68
    Popup            = 0x0008,
69
    NONE             = 0x0010
70
};
71
namespace o3tl {
72
    template<> struct typed_flags<BorderWindowTitleType> : is_typed_flags<BorderWindowTitleType, 0x001f> {};
73
};
74
75
class ImplBorderWindow final : public vcl::Window
76
{
77
    friend class vcl::Window;
78
    friend class vcl::WindowOutputDevice;
79
    friend class ImplBorderWindowView;
80
    friend class ImplSmallBorderWindowView;
81
    friend class ImplStdBorderWindowView;
82
83
private:
84
    std::unique_ptr<ImplBorderWindowView> mpBorderView;
85
    VclPtr<vcl::Window>     mpMenuBarWindow;
86
    VclPtr<NotebookBar>     mpNotebookBar;
87
    tools::Long                    mnMinWidth;
88
    tools::Long                    mnMinHeight;
89
    tools::Long                    mnMaxWidth;
90
    tools::Long                    mnMaxHeight;
91
    tools::Long                    mnOrgMenuHeight;
92
    BorderWindowTitleType   mnTitleType;
93
    WindowBorderStyle       mnBorderStyle;
94
    bool                    mbFloatWindow;
95
    bool                    mbSmallOutBorder;
96
    bool                    mbFrameBorder;
97
    bool                    mbMenuHide;
98
    bool                    mbDockBtn;
99
    bool                    mbHideBtn;
100
    bool                    mbMenuBtn;
101
    bool                    mbDisplayActive;
102
103
    using Window::ImplInit;
104
    void                    ImplInit( vcl::Window* pParent,
105
                                      WinBits nStyle, BorderWindowStyle nTypeStyle,
106
                                      SystemParentData* pParentData );
107
108
                            ImplBorderWindow (const ImplBorderWindow &) = delete;
109
                            ImplBorderWindow& operator= (const ImplBorderWindow &) = delete;
110
111
public:
112
                            ImplBorderWindow( vcl::Window* pParent,
113
                                              SystemParentData* pParentData,
114
                                              WinBits nStyle,
115
                                              BorderWindowStyle nTypeStyle );
116
                            ImplBorderWindow( vcl::Window* pParent, WinBits nStyle,
117
                                              BorderWindowStyle nTypeStyle );
118
    virtual                 ~ImplBorderWindow() override;
119
    virtual void            dispose() override;
120
121
    virtual void            MouseMove( const MouseEvent& rMEvt ) override;
122
    virtual void            MouseButtonDown( const MouseEvent& rMEvt ) override;
123
    virtual void            Tracking( const TrackingEvent& rTEvt ) override;
124
    virtual void            Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
125
    virtual void            Activate() override;
126
    virtual void            Deactivate() override;
127
    virtual void            Resize() override;
128
    virtual void            RequestHelp( const HelpEvent& rHEvt ) override;
129
    virtual void            StateChanged( StateChangedType nType ) override;
130
    virtual void            DataChanged( const DataChangedEvent& rDCEvt ) override;
131
    virtual void            queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
132
133
    void                    InitView();
134
    void                    UpdateView( bool bNewView, const Size& rNewOutSize );
135
    void                    InvalidateBorder();
136
137
    using Window::Draw;
138
    void                    Draw( OutputDevice* pDev, const Point& rPos );
139
140
    void                    SetDisplayActive( bool bActive );
141
    void                    SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
142
    void                    SetBorderStyle( WindowBorderStyle nStyle );
143
11.8k
    WindowBorderStyle       GetBorderStyle() const { return mnBorderStyle; }
144
    void                    SetCloseButton();
145
    void                    SetDockButton( bool bDockButton );
146
    void                    SetHideButton( bool bHideButton );
147
    void                    SetMenuButton( bool bMenuButton );
148
149
    void                    UpdateMenuHeight();
150
    void                    SetMenuBarWindow( vcl::Window* pWindow );
151
    void                    SetMenuBarMode( bool bHide );
152
153
    void SetNotebookBar(const OUString& rUIXMLDescription,
154
                        const css::uno::Reference<css::frame::XFrame>& rFrame,
155
                        std::unique_ptr<NotebookBarAddonsItem> pNotebookBarAddonsItem);
156
    void CloseNotebookBar();
157
3.93k
    const VclPtr<NotebookBar>& GetNotebookBar() const { return mpNotebookBar; }
158
159
    void                    SetMinOutputSize( tools::Long nWidth, tools::Long nHeight )
160
0
                                { mnMinWidth = nWidth; mnMinHeight = nHeight; }
161
    void                    SetMaxOutputSize( tools::Long nWidth, tools::Long nHeight )
162
0
                                { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
163
164
    void                    GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
165
                                       sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
166
    tools::Long                    CalcTitleWidth() const;
167
168
    tools::Rectangle               GetMenuRect() const;
169
170
    virtual Size            GetOptimalSize() const override;
171
};
172
173
struct ImplBorderFrameData
174
{
175
    VclPtr<ImplBorderWindow> mpBorderWindow;
176
    VclPtr<OutputDevice>     mpOutDev;
177
    tools::Rectangle                maTitleRect;
178
    tools::Rectangle                maCloseRect;
179
    tools::Rectangle                maDockRect;
180
    tools::Rectangle                maMenuRect;
181
    tools::Rectangle                maHideRect;
182
    tools::Rectangle                maHelpRect;
183
    Point                    maMouseOff;
184
    tools::Long                     mnWidth;
185
    tools::Long                     mnHeight;
186
    tools::Long                     mnTrackX;
187
    tools::Long                     mnTrackY;
188
    tools::Long                     mnTrackWidth;
189
    tools::Long                     mnTrackHeight;
190
    sal_Int32                mnLeftBorder;
191
    sal_Int32                mnTopBorder;
192
    sal_Int32                mnRightBorder;
193
    sal_Int32                mnBottomBorder;
194
    tools::Long                     mnNoTitleTop;
195
    tools::Long                     mnBorderSize;
196
    tools::Long                     mnTitleHeight;
197
    BorderWindowHitTest      mnHitTest;
198
    DrawButtonFlags          mnCloseState;
199
    DrawButtonFlags          mnDockState;
200
    DrawButtonFlags          mnMenuState;
201
    DrawButtonFlags          mnHideState;
202
    DrawButtonFlags          mnHelpState;
203
    BorderWindowTitleType    mnTitleType;
204
    bool                     mbDragFull;
205
    bool                     mbTitleClipped;
206
};
207
208
class ImplBorderWindowView
209
{
210
public:
211
    virtual                 ~ImplBorderWindowView();
212
213
    virtual bool            MouseMove( const MouseEvent& rMEvt );
214
    virtual bool            MouseButtonDown( const MouseEvent& rMEvt );
215
    virtual bool            Tracking( const TrackingEvent& rTEvt );
216
    virtual OUString        RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect );
217
218
    virtual void            Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) = 0;
219
    virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
220
                                       sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
221
    virtual tools::Long            CalcTitleWidth() const = 0;
222
    virtual void            DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) = 0;
223
    virtual tools::Rectangle       GetMenuRect() const;
224
225
    static void             ImplInitTitle( ImplBorderFrameData* pData );
226
    static BorderWindowHitTest ImplHitTest( ImplBorderFrameData const * pData, const Point& rPos );
227
    static void             ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
228
    static OUString         ImplRequestHelp( ImplBorderFrameData const * pData, const Point& rPos, tools::Rectangle& rHelpRect );
229
    static tools::Long             ImplCalcTitleWidth( const ImplBorderFrameData* pData );
230
};
231
232
class ImplNoBorderWindowView final : public ImplBorderWindowView
233
{
234
public:
235
                            ImplNoBorderWindowView();
236
237
    virtual void            Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
238
    virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
239
                                       sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
240
    virtual tools::Long            CalcTitleWidth() const override;
241
    virtual void            DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
242
};
243
244
class ImplSmallBorderWindowView final : public ImplBorderWindowView
245
{
246
    VclPtr<ImplBorderWindow> mpBorderWindow;
247
    VclPtr<OutputDevice>     mpOutDev;
248
    tools::Long                    mnWidth;
249
    tools::Long                    mnHeight;
250
    sal_Int32               mnLeftBorder;
251
    sal_Int32               mnTopBorder;
252
    sal_Int32               mnRightBorder;
253
    sal_Int32               mnBottomBorder;
254
    bool                    mbNWFBorder;
255
256
public:
257
                            ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow );
258
259
    virtual void            Init( OutputDevice* pOutDev, tools::Long nWidth, tools::Long nHeight ) override;
260
    virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
261
                                       sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
262
    virtual tools::Long            CalcTitleWidth() const override;
263
    virtual void            DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
264
};
265
266
class ImplStdBorderWindowView final : public ImplBorderWindowView
267
{
268
    ImplBorderFrameData     maFrameData;
269
270
public:
271
                            ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
272
                            virtual ~ImplStdBorderWindowView() override;
273
274
    virtual bool        MouseMove( const MouseEvent& rMEvt ) override;
275
    virtual bool        MouseButtonDown( const MouseEvent& rMEvt ) override;
276
    virtual bool        Tracking( const TrackingEvent& rTEvt ) override;
277
    virtual OUString        RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect ) override;
278
    virtual tools::Rectangle       GetMenuRect() const override;
279
280
    virtual void            Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
281
    virtual void            GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
282
                                       sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
283
    virtual tools::Long            CalcTitleWidth() const override;
284
    virtual void            DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
285
};
286
287
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */