CheckBoxGroup.hpp
1 /*
2  * Copyright © 2013 mathdu07
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef CHECKBOXGROUP_H_
19 #define CHECKBOXGROUP_H_
20 
21 #include <SFML/UI/ComponentObserver.hpp>
22 #include <SFML/UI/CheckBox.hpp>
23 #include <set>
24 
25 namespace sf
26 {
27 namespace ui
28 {
29 
31 {
32 //CONSTRUCTORS - DESTRUCTOR -----------------------------------------------------------
33 public:
41  CheckBoxGroup();
42 
43  virtual ~CheckBoxGroup();
44 //-------------------------------------------------------------------------------------
45 
46 //METHODS -----------------------------------------------------------------------------
47 public:
55  void addCheckBox(CheckBox &checkbox);
56 
62  std::set<CheckBox*>::const_iterator getCheckboxBegin() const;
63 
69  std::set<CheckBox*>::const_iterator getCheckboxEnd() const;
70 
79  void removeCheckbox(CheckBox& checkbox);
80 
86  unsigned int countCheckbox() const;
87 
95  bool isCheckBoxInGroup(CheckBox *checkbox) const;
96 
102  virtual void onComponentEvent(const ComponentEvent &event);
103 
104 private:
113  CheckBox* firstSelected(CheckBox* excluded = 0) const;
114 //-------------------------------------------------------------------------------------
115 
116 //GETTERS - SETTERS -------------------------------------------------------------------
117 
118 //-------------------------------------------------------------------------------------
119 
120 //FIELDS ------------------------------------------------------------------------------
121 private:
122  std::set<CheckBox*> m_checkBox;
123 //-------------------------------------------------------------------------------------
124 };
125 
126 } /* namespace ui */
127 } /* namespace sf */
128 #endif /* CHECKBOXGROUP_H_ */
129 
void removeCheckbox(CheckBox &checkbox)
Remove a checkbox to this group; This function does NOT delete the checkbox.
void addCheckBox(CheckBox &checkbox)
Add a checkbox to this group.
std::set< CheckBox * >::const_iterator getCheckboxBegin() const
A box which can be checked or not.
Definition: CheckBox.hpp:29
bool isCheckBoxInGroup(CheckBox *checkbox) const
virtual void onComponentEvent(const ComponentEvent &event)
Called each time a component change.
An event generate by a component.
unsigned int countCheckbox() const
A object updated each time a ComponentObservable change.
CheckBoxGroup()
A group of check box.
A group that allow only one check box selected in the same time.
std::set< CheckBox * >::const_iterator getCheckboxEnd() const