Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/splitwin.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
#ifndef INCLUDED_VCL_SPLITWIN_HXX
21
#define INCLUDED_VCL_SPLITWIN_HXX
22
23
#include <vcl/dllapi.h>
24
#include <vcl/dockwin.hxx>
25
#include <o3tl/typed_flags_set.hxx>
26
27
class ImplSplitSet;
28
29
enum class SplitWindowItemFlags
30
{
31
    NONE           = 0x0000,
32
    Fixed          = 0x0001,
33
    RelativeSize   = 0x0002,
34
    PercentSize    = 0x0004,
35
    ColSet         = 0x0008,
36
};
37
namespace o3tl
38
{
39
    template<> struct typed_flags<SplitWindowItemFlags> : is_typed_flags<SplitWindowItemFlags, 0x0f> {};
40
}
41
42
#define SPLITWINDOW_APPEND          (sal_uInt16(0xFFFF))
43
0
#define SPLITWINDOW_ITEM_NOTFOUND   (sal_uInt16(0xFFFF))
44
45
65.7k
#define SPLITWIN_SPLITSIZE              4
46
0
#define SPLITWIN_SPLITSIZEEXLN          7
47
48
class VCL_DLLPUBLIC SplitWindow : public DockingWindow
49
{
50
private:
51
    std::unique_ptr<ImplSplitSet> mpMainSet;
52
    ImplSplitSet*       mpBaseSet;
53
    ImplSplitSet*       mpSplitSet;
54
    std::unique_ptr<tools::Long[]> mpLastSizes;
55
    tools::Rectangle           maDragRect;
56
    tools::Long                mnDX;
57
    tools::Long                mnDY;
58
    tools::Long                mnLeftBorder;
59
    tools::Long                mnTopBorder;
60
    tools::Long                mnRightBorder;
61
    tools::Long                mnBottomBorder;
62
    tools::Long                mnMaxSize;
63
    tools::Long                mnMouseOff;
64
    tools::Long                mnMStartPos;
65
    tools::Long                mnMSplitPos;
66
    WinBits             mnWinStyle;
67
    WindowAlign         meAlign;
68
    sal_uInt16          mnSplitTest;
69
    sal_uInt16          mnSplitPos;
70
    sal_uInt16          mnMouseModifier;
71
    bool                mbDragFull:1,
72
                        mbHorz:1,
73
                        mbBottomRight:1,
74
                        mbCalc:1,
75
                        mbRecalc:1,
76
                        mbInvalidate:1,
77
                        mbFadeIn:1,
78
                        mbFadeOut:1,
79
                        mbFadeInDown:1,
80
                        mbFadeOutDown:1,
81
                        mbFadeInPressed:1,
82
                        mbFadeOutPressed:1,
83
                        mbFadeNoButtonMode:1;
84
    Link<SplitWindow*,void>  maSplitHdl;
85
86
    using Window::ImplInit;
87
    SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
88
    SAL_DLLPRIVATE void ImplInitSettings();
89
    SAL_DLLPRIVATE void ImplCalcLayout();
90
    SAL_DLLPRIVATE void ImplUpdate();
91
    SAL_DLLPRIVATE void ImplSetWindowSize( tools::Long nDelta );
92
    SAL_DLLPRIVATE void ImplSplitMousePos( Point& rMousePos );
93
    SAL_DLLPRIVATE void ImplGetButtonRect( tools::Rectangle& rRect, bool bTest ) const;
94
    SAL_DLLPRIVATE void ImplGetFadeInRect( tools::Rectangle& rRect, bool bTest = false ) const;
95
    SAL_DLLPRIVATE void ImplGetFadeOutRect( tools::Rectangle& rRect ) const;
96
    SAL_DLLPRIVATE void ImplDrawFadeIn(vcl::RenderContext& rRenderContext);
97
    SAL_DLLPRIVATE void ImplDrawFadeOut(vcl::RenderContext& rRenderContext);
98
    SAL_DLLPRIVATE void ImplNewAlign();
99
    SAL_DLLPRIVATE void ImplDrawGrip(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, bool bHorz, bool bLeft);
100
    SAL_DLLPRIVATE void ImplStartSplit( const MouseEvent& rMEvt );
101
102
    SAL_DLLPRIVATE void ImplDrawBorder(vcl::RenderContext& rRenderContext);
103
    SAL_DLLPRIVATE void ImplDrawBorderLine(vcl::RenderContext& rRenderContext);
104
    static SAL_DLLPRIVATE void ImplCalcSet2( SplitWindow* pWindow, ImplSplitSet* pSet, bool bHide,
105
                                             bool bRows );
106
    static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( ImplSplitSet* pSet, const Point& rPos,
107
                                                tools::Long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos,
108
                                                bool bRows );
109
    static SAL_DLLPRIVATE sal_uInt16 ImplTestSplit( const SplitWindow* pWindow, const Point& rPos,
110
                                                tools::Long& rMouseOff, ImplSplitSet** ppFoundSet, sal_uInt16& rFoundPos );
111
    SAL_DLLPRIVATE void ImplDrawSplitTracking(const Point& rPos);
112
113
                        SplitWindow (const SplitWindow &) = delete;
114
                        SplitWindow & operator= (const SplitWindow &) = delete;
115
public:
116
                        SplitWindow( vcl::Window* pParent, WinBits nStyle = 0 );
117
    virtual             ~SplitWindow() override;
118
    virtual void        dispose() override;
119
120
    virtual void        StartSplit();
121
    virtual void        Split();
122
    virtual void        SplitResize();
123
    virtual void        FadeIn();
124
    virtual void        FadeOut();
125
126
    virtual void        MouseButtonDown( const MouseEvent& rMEvt ) override;
127
    virtual void        MouseMove( const MouseEvent& rMEvt ) override;
128
    virtual void        Tracking( const TrackingEvent& rTEvt ) override;
129
    virtual void        Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
130
    virtual void        Resize() override;
131
    virtual void        RequestHelp( const HelpEvent& rHEvt ) override;
132
    virtual void        StateChanged( StateChangedType nType ) override;
133
    virtual void        DataChanged( const DataChangedEvent& rDCEvt ) override;
134
    virtual bool        PreNotify( NotifyEvent& rNEvt ) override;
135
136
    void                InsertItem( sal_uInt16 nId, vcl::Window* pWindow, tools::Long nSize,
137
                                    sal_uInt16 nPos, sal_uInt16 nIntoSetId,
138
                                    SplitWindowItemFlags nBits );
139
    void                InsertItem( sal_uInt16 nId, tools::Long nSize,
140
                                    sal_uInt16 nPos, sal_uInt16 nIntoSetId,
141
                                    SplitWindowItemFlags nBits );
142
    void                RemoveItem( sal_uInt16 nId );
143
144
    void                SplitItem( sal_uInt16 nId, tools::Long nNewSize,
145
                                   bool bPropSmall,
146
                                   bool bPropGreat );
147
    void                SetItemSize( sal_uInt16 nId, tools::Long nNewSize );
148
    tools::Long                GetItemSize( sal_uInt16 nId ) const;
149
    /** Set a range that limits the (variable part of the) size with an
150
        upper and a lower bound (both are valid values themselves.)
151
        @param nId
152
            Id of the item for which the size limits are set.
153
        @param rRange
154
            Values of -1 define missing bounds, thus setting a range (-1,-1)
155
            (the default) removes the size limit.
156
    */
157
    void                SetItemSizeRange (sal_uInt16 nId, const Range& rRange);
158
    /** Return the current size limits for the specified item.
159
    */
160
    tools::Long                GetItemSize( sal_uInt16 nId, SplitWindowItemFlags nBits ) const;
161
    sal_uInt16          GetSet( sal_uInt16 nId ) const;
162
    sal_uInt16          GetItemId( vcl::Window* pWindow ) const;
163
    sal_uInt16          GetItemId( const Point& rPos ) const;
164
    sal_uInt16          GetItemPos( sal_uInt16 nId, sal_uInt16 nSetId = 0 ) const;
165
    sal_uInt16          GetItemId( sal_uInt16 nPos ) const;
166
    sal_uInt16          GetItemCount( sal_uInt16 nSetId = 0 ) const;
167
    bool                IsItemValid( sal_uInt16 nId ) const;
168
169
    void                SetAlign( WindowAlign eNewAlign );
170
39.4k
    WindowAlign         GetAlign() const { return meAlign; }
171
0
    bool                IsHorizontal() const { return mbHorz; }
172
173
0
    void                SetMaxSizePixel( tools::Long nNewMaxSize ) { mnMaxSize = nNewMaxSize; }
174
175
    Size                CalcLayoutSizePixel( const Size& aNewSize );
176
177
    void                ShowFadeInHideButton();
178
    void                ShowFadeOutButton();
179
    tools::Long                GetFadeInSize() const;
180
0
    bool                IsFadeNoButtonMode() const { return mbFadeNoButtonMode; }
181
182
0
    void                SetSplitHdl( const Link<SplitWindow*,void>& rLink ) { maSplitHdl = rLink; }
183
};
184
185
#endif // INCLUDED_VCL_SPLITWIN_HXX
186
187
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */