neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
i_button.hpp
Go to the documentation of this file.
1// i_button.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#pragma once
21
22#include <neogfx/neogfx.hpp>
26
27namespace neogfx
28{
30 {
32 BiState,
34 };
35}
36
42
43namespace neogfx
44{
45 typedef std::optional<bool> button_checked_state;
46
47 struct not_tri_state_checkable : public std::logic_error { not_tri_state_checkable() : std::logic_error("neogfx::not_tri_state_checkable") {} };
48
49 class i_button : public i_widget, public virtual i_skinnable_item
50 {
51 public:
52 declare_event(pressed)
53 declare_event(clicked)
54 declare_event(double_clicked)
55 declare_event(right_clicked)
56 declare_event(released)
57 public:
58 declare_event(toggled)
59 declare_event(checked)
60 declare_event(unchecked)
61 declare_event(indeterminate)
62 public:
63 virtual bool is_pressed() const = 0;
64 virtual button_checkable checkable() const = 0;
65 virtual void set_checkable(button_checkable aCheckable = button_checkable::BiState) = 0;
66 virtual bool is_checked() const = 0;
67 virtual bool is_unchecked() const = 0;
68 virtual bool is_indeterminate() const = 0;
69 virtual void check() = 0;
70 virtual void uncheck() = 0;
71 virtual void set_indeterminate() = 0;
72 virtual void set_checked(bool aChecked) = 0;
73 virtual void toggle() = 0;
74 };
75
76 class i_radio_button : public i_button
77 {
78 public:
79 virtual bool is_on() const = 0;
80 virtual bool is_off() const = 0;
81 virtual void set_on() = 0;
82 public:
83 virtual const i_radio_button* next_button() const = 0;
84 virtual i_radio_button* next_button() = 0;
85 virtual bool any_siblings_on() const = 0;
86 };
87}
#define end_declare_enum(enumName)
Definition i_enum.hpp:62
#define declare_enum_string(enumName, enumEnumerator)
Definition i_enum.hpp:59
#define begin_declare_enum(enumName)
Definition i_enum.hpp:52
button_checkable
Definition i_button.hpp:30
Definition plf_hive.h:79
#define declare_event(declName,...)
Definition i_event.hpp:305