Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/toolkit/fixed.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
#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23
#error "don't use this in new code"
24
#endif
25
26
#include <vcl/dllapi.h>
27
#include <vcl/toolkit/edit.hxx>
28
#include <vcl/ctrl.hxx>
29
#include <vcl/image.hxx>
30
31
class VCL_DLLPUBLIC FixedText : public Control
32
{
33
private:
34
    sal_Int32 m_nMaxWidthChars;
35
    sal_Int32 m_nMinWidthChars;
36
    VclPtr<vcl::Window> m_pMnemonicWindow;
37
38
    using Control::ImplInitSettings;
39
    using Window::ImplInit;
40
    SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle );
41
    SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
42
    SAL_DLLPRIVATE void    ImplDraw( OutputDevice* pDev, SystemTextColorFlags nSystemTextColorFlags,
43
                              const Point& rPos, const Size& rSize, bool bFillLayout = false ) const;
44
public:
45
    SAL_DLLPRIVATE static DrawTextFlags ImplGetTextStyle( WinBits nWinBits );
46
protected:
47
    virtual void    FillLayoutData() const override;
48
    virtual const vcl::Font&
49
                    GetCanonicalFont( const StyleSettings& _rStyle ) const override;
50
    virtual const Color&
51
                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const override;
52
53
    virtual vcl::Window* getAccessibleRelationLabelFor() const override;
54
55
public:
56
    explicit FixedText(vcl::Window* pParent, WinBits nStyle = 0, WindowType eType = WindowType::FIXEDTEXT);
57
    virtual         ~FixedText() override;
58
    virtual void    dispose() override;
59
60
    virtual rtl::Reference<comphelper::OAccessible> CreateAccessible() override;
61
62
    virtual void    ApplySettings(vcl::RenderContext& rRenderContext) override;
63
64
    virtual void    Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
65
    virtual void    Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
66
    virtual void    Resize() override;
67
    virtual void    StateChanged( StateChangedType nType ) override;
68
    virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
69
70
    void            setMaxWidthChars(sal_Int32 nWidth);
71
    void            setMinWidthChars(sal_Int32 nWidth);
72
    static Size     CalcMinimumTextSize(Control const* pControl, tools::Long nMaxWidth = 0x7fffffff);
73
    static Size     getTextDimensions(Control const *pControl, const OUString &rTxt, tools::Long nMaxWidth);
74
    Size            CalcMinimumSize(tools::Long nMaxWidth = 0x7fffffff) const;
75
    virtual Size    GetOptimalSize() const override;
76
    virtual bool    set_property(const OUString &rKey, const OUString &rValue) override;
77
    void            set_mnemonic_widget(vcl::Window *pWindow);
78
0
    vcl::Window*    get_mnemonic_widget() const { return m_pMnemonicWindow; }
79
};
80
81
class SelectableFixedText final : public Edit
82
{
83
public:
84
    explicit SelectableFixedText( vcl::Window* pParent, WinBits nStyle );
85
86
    virtual void    LoseFocus() override;
87
    virtual void    ApplySettings(vcl::RenderContext&) override;
88
    virtual void    DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
89
};
90
91
class UNLESS_MERGELIBS(VCL_DLLPUBLIC) FixedLine final : public Control
92
{
93
private:
94
    using Control::ImplInitSettings;
95
    using Window::ImplInit;
96
    SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle );
97
    SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
98
    SAL_DLLPRIVATE void    ImplDraw(vcl::RenderContext& rRenderContext);
99
100
    virtual void    FillLayoutData() const override;
101
    virtual const vcl::Font&
102
                    GetCanonicalFont( const StyleSettings& _rStyle ) const override;
103
    virtual const Color&
104
                    GetCanonicalTextColor( const StyleSettings& _rStyle ) const override;
105
106
public:
107
    explicit        FixedLine( vcl::Window* pParent, WinBits nStyle = WB_HORZ );
108
109
    virtual void    ApplySettings(vcl::RenderContext&) override;
110
111
    virtual void    Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
112
    virtual void    Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
113
    virtual void    Resize() override;
114
    virtual void    StateChanged( StateChangedType nType ) override;
115
    virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
116
117
    virtual Size    GetOptimalSize() const override;
118
    virtual void    DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
119
};
120
121
class VCL_DLLPUBLIC FixedBitmap final : public Control
122
{
123
private:
124
    Bitmap        maBitmap;
125
126
    using Control::ImplInitSettings;
127
    using Window::ImplInit;
128
    SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle );
129
    SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
130
    SAL_DLLPRIVATE void    ImplDraw( OutputDevice* pDev, const Point& rPos, const Size& rSize );
131
132
public:
133
    explicit        FixedBitmap( vcl::Window* pParent, WinBits nStyle = 0 );
134
135
    SAL_DLLPRIVATE virtual void ApplySettings(vcl::RenderContext&) override;
136
137
    SAL_DLLPRIVATE virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
138
    SAL_DLLPRIVATE virtual void Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
139
    SAL_DLLPRIVATE virtual void Resize() override;
140
    SAL_DLLPRIVATE virtual void StateChanged( StateChangedType nType ) override;
141
    SAL_DLLPRIVATE virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
142
143
    void SetBitmap( const Bitmap& rBitmap );
144
};
145
146
class VCL_DLLPUBLIC FixedImage : public Control
147
{
148
private:
149
    Image           maImage;
150
151
private:
152
    using Control::ImplInitSettings;
153
    using Window::ImplInit;
154
    SAL_DLLPRIVATE void    ImplInit( vcl::Window* pParent, WinBits nStyle );
155
    SAL_DLLPRIVATE static WinBits ImplInitStyle( WinBits nStyle );
156
157
protected:
158
    SAL_DLLPRIVATE void    ImplDraw( OutputDevice* pDev,
159
                              const Point& rPos, const Size& rSize );
160
public:
161
    explicit        FixedImage( vcl::Window* pParent, WinBits nStyle = 0 );
162
163
    SAL_DLLPRIVATE virtual void    ApplySettings(vcl::RenderContext&) override;
164
165
    SAL_DLLPRIVATE virtual void    Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
166
    SAL_DLLPRIVATE virtual void    Draw( OutputDevice* pDev, const Point& rPos, SystemTextColorFlags nFlags ) override;
167
    SAL_DLLPRIVATE virtual void    Resize() override;
168
    SAL_DLLPRIVATE virtual void    StateChanged( StateChangedType nType ) override;
169
    SAL_DLLPRIVATE virtual void    DataChanged( const DataChangedEvent& rDCEvt ) override;
170
    SAL_DLLPRIVATE virtual Size    GetOptimalSize() const override;
171
172
    void            SetImage( const Image& rImage );
173
0
    const Image&    GetImage() const { return maImage; }
174
175
0
    const Image&    GetModeImage( ) const { return maImage;}
176
    SAL_DLLPRIVATE virtual bool    set_property(const OUString &rKey, const OUString &rValue) override;
177
178
    SAL_DLLPRIVATE void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
179
};
180
181
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */