Coverage Report

Created: 2026-07-10 11:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/status.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_STATUS_HXX
21
#define INCLUDED_VCL_STATUS_HXX
22
23
#include <tools/solar.h>
24
#include <vcl/dllapi.h>
25
#include <vcl/window.hxx>
26
#include <o3tl/typed_flags_set.hxx>
27
#include <memory>
28
#include <vector>
29
30
class UserDrawEvent;
31
struct ImplStatusItem;
32
33
void DrawProgress(vcl::Window* pWindow, vcl::RenderContext& rRenderContext, const Point& rPos,
34
                                tools::Long nOffset, tools::Long nPrgsWidth, tools::Long nPrgsHeight,
35
                                sal_uInt16 nPercent1, sal_uInt16 nPercent2, sal_uInt16 nPercentCount,
36
                                const tools::Rectangle& rFramePosSize, ControlType eControlType);
37
38
39
enum class StatusBarItemBits {
40
    NONE            = 0x0000,
41
    Left            = 0x0001,
42
    Center          = 0x0002,
43
    Right           = 0x0004,
44
    In              = 0x0008,
45
    Out             = 0x0010,
46
    Flat            = 0x0020,
47
    AutoSize        = 0x0040,
48
    UserDraw        = 0x0080,
49
    Mandatory       = 0x0100,
50
};
51
namespace o3tl
52
{
53
    template<> struct typed_flags<StatusBarItemBits> : is_typed_flags<StatusBarItemBits, 0x01ff> {};
54
}
55
56
#define STATUSBAR_APPEND            (sal_uInt16(0xFFFF))
57
0
#define STATUSBAR_ITEM_NOTFOUND     (sal_uInt16(0xFFFF))
58
41.7k
#define STATUSBAR_OFFSET            (tools::Long(5))
59
60
61
class VCL_DLLPUBLIC StatusBar : public vcl::Window
62
{
63
    class SAL_DLLPRIVATE ImplData;
64
private:
65
    std::vector<std::unique_ptr<ImplStatusItem>> mvItemList;
66
    std::unique_ptr<ImplData> mpImplData;
67
    OUString            maPrgsTxt;
68
    Point               maPrgsTxtPos;
69
    tools::Rectangle           maPrgsFrameRect;
70
    tools::Long                mnPrgsSize;
71
    tools::Long                mnItemsWidth;
72
    tools::Long                mnDX;
73
    tools::Long                mnDY;
74
    tools::Long                mnCalcHeight;
75
    tools::Long                mnTextY;
76
    sal_uInt16          mnCurItemId;
77
    sal_uInt16          mnPercent;
78
    sal_uInt16          mnPercentCount;
79
    sal_uInt32          mnLastProgressPaint_ms;
80
    bool                mbFormat;
81
    bool                mbProgressMode;
82
    bool                mbInUserDraw;
83
    bool                mbAdjustHiDPI;
84
    Link<StatusBar*,void>  maClickHdl;
85
    Link<StatusBar*,void>  maDoubleClickHdl;
86
87
    using Window::ImplInit;
88
    SAL_DLLPRIVATE void      ImplInit( vcl::Window* pParent, WinBits nStyle );
89
    SAL_DLLPRIVATE void      ImplInitSettings();
90
    SAL_DLLPRIVATE void      ImplFormat();
91
    SAL_DLLPRIVATE bool      ImplIsItemUpdate() const;
92
93
    SAL_DLLPRIVATE void      ImplDrawText(vcl::RenderContext& rRenderContext);
94
    SAL_DLLPRIVATE void      ImplDrawItem(vcl::RenderContext& rRenderContext, bool bOffScreen,
95
                                          sal_uInt16 nPos);
96
    SAL_DLLPRIVATE void      ImplDrawProgress(vcl::RenderContext& rRenderContext, sal_uInt16 nNewPerc);
97
    SAL_DLLPRIVATE void      ImplCalcProgressRect();
98
    SAL_DLLPRIVATE tools::Rectangle ImplGetItemRectPos( sal_uInt16 nPos ) const;
99
    SAL_DLLPRIVATE sal_uInt16    ImplGetFirstVisiblePos() const;
100
101
    SAL_DLLPRIVATE void      PaintSelfAndChildrenImmediately();
102
103
protected:
104
    virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
105
106
public:
107
                        StatusBar( vcl::Window* pParent,
108
                                   WinBits nWinStyle = WB_BORDER | WB_RIGHT );
109
    virtual             ~StatusBar() override;
110
    virtual void        dispose() override;
111
112
    void                AdjustItemWidthsForHiDPI();
113
114
    virtual void        MouseButtonDown( const MouseEvent& rMEvt ) override;
115
    virtual void        Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
116
    virtual void        Resize() override;
117
    virtual void        RequestHelp( const HelpEvent& rHEvt ) override;
118
    virtual void        StateChanged( StateChangedType nType ) override;
119
    virtual void        DataChanged( const DataChangedEvent& rDCEvt ) override;
120
121
    void                Click();
122
    void                DoubleClick();
123
    virtual void        UserDraw( const UserDrawEvent& rUDEvt );
124
125
    void                InsertItem( sal_uInt16 nItemId, sal_uLong nWidth,
126
                                    StatusBarItemBits nBits = StatusBarItemBits::Center | StatusBarItemBits::In,
127
                                    tools::Long nOffset = STATUSBAR_OFFSET,
128
                                    sal_uInt16 nPos = STATUSBAR_APPEND );
129
    void                RemoveItem( sal_uInt16 nItemId );
130
131
    void                ShowItem( sal_uInt16 nItemId );
132
    void                HideItem( sal_uInt16 nItemId );
133
    bool                IsItemVisible( sal_uInt16 nItemId ) const;
134
135
    void                RedrawItem( sal_uInt16 nItemId );
136
137
    void                Clear();
138
139
    sal_uInt16          GetItemCount() const;
140
    sal_uInt16          GetItemId( sal_uInt16 nPos ) const;
141
    sal_uInt16          GetItemId( const Point& rPos ) const;
142
    sal_uInt16          GetItemPos( sal_uInt16 nItemId ) const;
143
    tools::Rectangle           GetItemRect( sal_uInt16 nItemId ) const;
144
    Point               GetItemTextPos( sal_uInt16 nItemId ) const;
145
0
    sal_uInt16          GetCurItemId() const { return mnCurItemId; }
146
147
    sal_uLong           GetItemWidth( sal_uInt16 nItemId ) const;
148
    StatusBarItemBits   GetItemBits( sal_uInt16 nItemId ) const;
149
150
    tools::Long                GetItemOffset( sal_uInt16 nItemId ) const;
151
152
    /// @param nCharsWidth, if not -1, overrides the normal width calculation
153
    void                SetItemText( sal_uInt16 nItemId, const OUString& rText, int nCharsWidth = -1 );
154
    const OUString&     GetItemText( sal_uInt16 nItemId ) const;
155
156
    void                SetItemData( sal_uInt16 nItemId, void* pNewData );
157
    void*               GetItemData( sal_uInt16 nItemId ) const;
158
159
    void                SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand );
160
    const OUString &    GetItemCommand( sal_uInt16 nItemId );
161
162
    void                SetHelpText( sal_uInt16 nItemId, const OUString& rText );
163
    const OUString&     GetHelpText( sal_uInt16 nItemId ) const;
164
165
    using Window::SetQuickHelpText;
166
    void                SetQuickHelpText( sal_uInt16 nItemId, const OUString& rText );
167
    using Window::GetQuickHelpText;
168
    const OUString&     GetQuickHelpText( sal_uInt16 nItemId ) const;
169
170
    void                SetHelpId( sal_uInt16 nItemId, const OUString& rHelpId );
171
172
    void                StartProgressMode( const OUString& rText );
173
    void                SetProgressValue( sal_uInt16 nPercent );
174
    void                EndProgressMode();
175
40.3k
    bool                IsProgressMode() const { return mbProgressMode; }
176
177
    void                SetText( const OUString& rText ) override;
178
179
    Size                CalcWindowSizePixel() const;
180
181
0
    void                SetClickHdl( const Link<StatusBar*,void>& rLink ) { maClickHdl = rLink; }
182
0
    void                SetDoubleClickHdl( const Link<StatusBar*,void>& rLink ) { maDoubleClickHdl = rLink; }
183
184
    using Window::SetAccessibleName;
185
    void                SetAccessibleName( sal_uInt16 nItemId, const OUString& rName );
186
    using Window::GetAccessibleName;
187
    const OUString&     GetAccessibleName( sal_uInt16 nItemId ) const;
188
};
189
190
#endif // INCLUDED_VCL_STATUS_HXX
191
192
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */