Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/weld/Button.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
10
#pragma once
11
12
#include <rtl/ustring.hxx>
13
#include <tools/gen.hxx>
14
#include <tools/link.hxx>
15
#include <vcl/dllapi.h>
16
#include <vcl/weld/Widget.hxx>
17
18
namespace com::sun::star::graphic
19
{
20
class XGraphic;
21
}
22
class Color;
23
class VirtualDevice;
24
25
namespace vcl
26
{
27
class Font;
28
}
29
30
namespace weld
31
{
32
class VCL_DLLPUBLIC Button : virtual public Widget
33
{
34
protected:
35
    Link<Button&, void> m_aClickHdl;
36
37
0
    void signal_clicked() { m_aClickHdl.Call(*this); }
38
39
public:
40
    virtual void set_label(const OUString& rText) = 0;
41
    // pDevice, the image for the button, or nullptr to unset
42
    virtual void set_image(VirtualDevice* pDevice) = 0;
43
    virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) = 0;
44
    virtual void set_from_icon_name(const OUString& rIconName) = 0;
45
    virtual OUString get_label() const = 0;
46
0
    void clicked() { signal_clicked(); }
47
48
    // font size is in points, not pixels, e.g. see Window::[G]etPointFont
49
    virtual void set_font(const vcl::Font& rFont) = 0;
50
51
    /* Sometimes, a widget should behave like a button (activate on click,
52
       accept keyboard focus, etc), but look entirely different.
53
54
       pDevice, the custom look to use, or nullptr to unset.
55
56
       Typically doing this is ill advised. Consider using
57
       set_accessible_name if you do. */
58
    virtual void set_custom_button(VirtualDevice* pDevice) = 0;
59
60
0
    virtual void connect_clicked(const Link<Button&, void>& rLink) { m_aClickHdl = rLink; }
61
};
62
}
63
64
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */