Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/vcl/weld/Toggleable.hxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 <vcl/dllapi.h>
13
#include <vcl/weld/Widget.hxx>
14
15
namespace weld
16
{
17
class VCL_DLLPUBLIC Toggleable : virtual public Widget
18
{
19
protected:
20
    Link<Toggleable&, void> m_aToggleHdl;
21
    TriState m_eSavedValue = TRISTATE_FALSE;
22
23
    void signal_toggled()
24
0
    {
25
0
        if (notify_events_disabled())
26
0
            return;
27
0
        m_aToggleHdl.Call(*this);
28
0
    }
29
30
    virtual void do_set_active(bool active) = 0;
31
32
public:
33
    void set_active(bool active)
34
0
    {
35
0
        disable_notify_events();
36
0
        do_set_active(active);
37
0
        enable_notify_events();
38
0
    }
39
40
    virtual bool get_active() const = 0;
41
42
    virtual TriState get_state() const
43
0
    {
44
0
        if (get_active())
45
0
            return TRISTATE_TRUE;
46
0
        return TRISTATE_FALSE;
47
0
    }
48
49
0
    void save_state() { m_eSavedValue = get_state(); }
50
0
    TriState get_saved_state() const { return m_eSavedValue; }
51
0
    bool get_state_changed_from_saved() const { return m_eSavedValue != get_state(); }
52
53
0
    virtual void connect_toggled(const Link<Toggleable&, void>& rLink) { m_aToggleHdl = rLink; }
54
};
55
}
56
57
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */