mousetrap v0.2.0
Loading...
Searching...
No Matches
switch.hpp
1//
2// Copyright 2022 Clemens Cords
3// Created on 10/26/22 by clem (mail@clemens-cords.com)
4//
5
6#pragma once
7
8#include <mousetrap/widget.hpp>
9#include <mousetrap/signal_component.hpp>
10
11#ifdef DOXYGEN
12 #include "../../docs/doxygen.inl"
13#endif
14
15namespace mousetrap
16{
17 #ifndef DOXYGEN
18 class Switch;
19 namespace detail
20 {
21 using SwitchInternal = GtkSwitch;
22 DEFINE_INTERNAL_MAPPING(Switch);
23 }
24 #endif
25
26 /// @brief switch, can be click dragged or clicked to change a binary state
27 /// \signals
28 /// \signal_switched{Switch}
29 /// \widget_signals{Switch}
30 class Switch : public detail::notify_if_gtk_uninitialized,
31 public Widget,
32 HAS_SIGNAL(Switch, switched),
33 HAS_SIGNAL(Switch, realize),
34 HAS_SIGNAL(Switch, unrealize),
35 HAS_SIGNAL(Switch, destroy),
36 HAS_SIGNAL(Switch, hide),
37 HAS_SIGNAL(Switch, show),
38 HAS_SIGNAL(Switch, map),
39 HAS_SIGNAL(Switch, unmap)
40 {
41 public:
42 /// @brief construct
43 Switch();
44
45 /// @brief create from internal
46 Switch(detail::SwitchInternal*);
47
48 /// @brief destructor
49 ~Switch();
50
51 /// @brief expose internal
52 NativeObject get_internal() const override;
53
54 /// @brief get whether the switch is in the "on" position
55 /// @return true if "on", false otherwise
56 bool get_is_active() const;
57
58 /// @brief set whether the switch is in the "on" position
59 /// @param b true if "on", false otherwise
60 void set_is_active(bool);
61
62 private:
63 detail::SwitchInternal* _internal = nullptr;
64 };
65}
66
67
switch, can be click dragged or clicked to change a binary state
Definition: switch.hpp:40
void set_is_active(bool)
set whether the switch is in the "on" position
Definition: switch.cpp:53
~Switch()
destructor
Definition: switch.cpp:38
Switch()
construct
Definition: switch.cpp:9
bool get_is_active() const
get whether the switch is in the "on" position
Definition: switch.cpp:48
NativeObject get_internal() const override
expose internal
Definition: switch.cpp:43
Widget, super class of all renderable entities.
Definition: widget.hpp:67