1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Copyright 2010 Inalogic® Inc.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License, as
* published by the Free Software Foundation; either version 2.1 or 3.0
* of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the applicable version of the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of both the GNU Lesser General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>
*
* Authored by: Jay Taoko <jaytaoko@inalogic.com>
*
*/
#ifndef RADIOBUTTONLOGIC_H
#define RADIOBUTTONLOGIC_H
namespace nux
{
class RadioButton;
//! RadioButtonGroup select one of many radio button in a group.
/*!
RadioButtonGroup does not hold a strong reference on radio buttons.
*/
class RadioButtonGroup: public InitiallyUnownedObject
{
NUX_DECLARE_OBJECT_TYPE(RadioButtonGroup, InitiallyUnownedObject);
public:
RadioButtonGroup(NUX_FILE_LINE_PROTO);
~RadioButtonGroup();
//! Add a radio button to the group.
/*
The first radio button added to the group gets its check state set to true.
When a radio button is added to a group that is not empty, its check state is set to false.
*/
void ConnectButton(RadioButton* radio);
//! Remove a radio button from the group.
/*
When a radio button is removed, the previous button in the group gets its check state set to true;
*/
void DisconnectButton(RadioButton* radio);
//! Set the active radio button.
/*
Set the active radio button in the group. If \i emit_signal is true, all the button in the group
emit their \i state_changed signal.\n
If the parameter \i radio is already active and \i emit_signal is true, the \i state_changed signal will be emitted.\n
The active button is the last one to emit its \i state_changed signal.
@param radio The button to activate.
@param emit_signal If true, emit the state_changed signal of all the buttons in the group.
*/
void SetActiveButton(RadioButton* radio, bool emit_signal = true);
private:
//! Return the number of buttons in the group.
/*!
Return the number of buttons in the group.
@return The number of buttons in the group.
*/
int GetNumButtons();
void NotifyClick(RadioButton* radio);
std::vector<ObjectWeakPtr<RadioButton> > radio_button_array_;
int active_button_index_;
friend class RadioButton;
};
}
#endif // RADIOBUTTONLOGIC_H
|