FifeGUI 0.2.0
A C++ GUI library designed for games.
radiobutton.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_WIDGETS_RADIOBUTTON_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_RADIOBUTTON_HPP_
7
8#include <map>
9#include <string>
10
11#include "fifechan/platform.hpp"
12#include "fifechan/widgets/checkbox.hpp"
13
14namespace fcn
15{
26 class FIFEGUI_API RadioButton : public fcn::CheckBox
27 {
28 public:
29 RadioButton();
30
39 RadioButton(std::string const & caption, std::string const & group, bool selected = false);
40
41 ~RadioButton() override;
42
43 RadioButton(RadioButton const &) = delete;
44 RadioButton& operator=(RadioButton const &) = delete;
45 RadioButton(RadioButton&&) = delete;
46 RadioButton& operator=(RadioButton&&) = delete;
47
56 void setGroup(std::string const & group);
57
64 std::string const & getGroup() const;
65
66 // Inherited from CheckBox
67
68 void setSelected(bool selected) override;
69 void toggleSelected() override;
70
71 protected:
75 std::string mGroup;
76
80 using GroupMap = std::multimap<std::string, RadioButton*>;
81
85 using GroupIterator = GroupMap::iterator;
86
91 };
92} // namespace fcn
93
94#endif // INCLUDE_FIFECHAN_WIDGETS_RADIOBUTTON_HPP_
An implementation of a check box where a user can select or deselect the check box and where the stat...
Definition checkbox.hpp:27
GroupMap::iterator GroupIterator
Typdef.
std::string const & getGroup() const
Gets the group the radio button belongs to.
void toggleSelected() override
Toggles the check box between being selected and not being selected.
std::multimap< std::string, RadioButton * > GroupMap
Typdef.
static GroupMap mGroupMap
Holds all available radio button groups.
void setSelected(bool selected) override
Sets the check box to be selected or not.
std::string mGroup
Holds the group of the radio button.
void setGroup(std::string const &group)
Sets the group the radio button should belong to.