[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / controls / buttons / radio-button.h
1 #ifndef DALI_TOOLKIT_RADIO_BUTTON_H
2 #define DALI_TOOLKIT_RADIO_BUTTON_H
3
4 /*
5  * Copyright (c) 2029 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include "button.h"
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 // Forward declarations
29
30 namespace Internal DALI_INTERNAL
31 {
32 // Forward declarations
33
34 class RadioButton;
35 } // namespace DALI_INTERNAL
36 /**
37  * @addtogroup dali_toolkit_controls_buttons
38  * @{
39  */
40
41 /**
42  * @brief A RadioButton provides a radio button which two states \e selected or \e unselected.
43  *
44  * Radio buttons are designed to select one of many option at the same time.
45  *
46  * Every button have its own \e label and \e state, which can be modified by Button::Property::LABEL and Button::Property::SELECTED.
47  *
48  * RadioButton can change its current state using Button::SetSelected.
49  *
50  * RadioButtons can be grouped.
51  * Two or more RadioButtons are in one group when they have this same parent.
52  * In each groups only one RadioButton can be \e selected at a given time.
53  * So when RadioButton is set to \e selected, other RadioButtons in its group are set to \e unselected.
54  * When \e selected RadioButton is set to \e unselected no other RadioButtons in his group is set to \e selected.
55  *
56  * A Button::StateChangedSignal() is emitted when the RadioButton change its state to \e selected or \e unselected.
57  *
58  * Usage example: -
59  *
60  * @code
61  * // In Creating a DALi Application
62  *
63  * // Create a group to bind two or more RadioButtons together
64  * Actor radioGroup = Actor::New();
65  * radioGroup.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
66  * Stage::GetCurrent().Add( radioGroup );
67  *
68  * // Make the first RadioButton and add it to its parent
69  * RadioButton button1 = RadioButton::New();
70  * button1.SetProperty( Button::Property::LABEL, "button1" );
71  * button1.SetBackgroundColor( Color::WHITE );
72  * button1.SetProperty( Actor::Property::POSITION, Vector2( 0, -40 ) );
73  * radioGroup.Add( button1 );
74  *
75  * // Make more RadioButtons and add them to their parent
76  * RadioButton button2 = RadioButton::New();
77  * button2.SetProperty( Toolkit::Button::Property::LABEL, "button2" );
78  * button2.SetBackgroundColor( Color::WHITE );
79  * button2.SetProperty( Actor::Property::POSITION, Vector2( 0, 40 ) );
80  * radioGroup.Add( button2 );
81  *
82  * @endcode
83  * @SINCE_1_0.0
84  */
85 class DALI_TOOLKIT_API RadioButton : public Button
86 {
87 public:
88   /**
89    * @brief Creates an uninitialized RadioButton; this can be initialized with RadioButton::New().
90    *
91    * Calling member functions with an uninitialized Dali::Object is not allowed.
92    * @SINCE_1_0.0
93    */
94   RadioButton();
95
96   /**
97    * @brief Copy constructor.
98    * @SINCE_1_0.0
99    * @param[in] radioButton Handle to an object
100    */
101   RadioButton(const RadioButton& radioButton);
102
103   /**
104    * @brief Move constructor
105    * @SINCE_1_9.23
106    *
107    * @param[in] rhs A reference to the moved handle
108    */
109   RadioButton(RadioButton&& rhs) noexcept;
110
111   /**
112    * @brief Assignment operator.
113    * @SINCE_1_0.0
114    * @param[in] radioButton Handle to an object
115    * @return A reference to this
116    */
117   RadioButton& operator=(const RadioButton& radioButton);
118
119   /**
120    * @brief Move assignment
121    * @SINCE_1_9.23
122    *
123    * @param[in] rhs A reference to the moved handle
124    * @return A reference to this
125    */
126   RadioButton& operator=(RadioButton&& rhs) noexcept;
127
128   /**
129    * @brief Destructor.
130    *
131    * This is non-virtual since derived Handle types must not contain data or virtual methods.
132    * @SINCE_1_0.0
133    */
134   ~RadioButton();
135
136   /**
137    * @brief Creates an initialized RadioButton.
138    *
139    * @SINCE_1_0.0
140    * @return A handle to a newly allocated Dali resource
141    */
142   static RadioButton New();
143
144   /**
145    * @brief Creates an initialized RadioButton with given label.
146    *
147    * @SINCE_1_0.0
148    * @param[in] label The button label
149    * @return A handle to a newly allocated Dali resource
150    */
151   static RadioButton New(const std::string& label);
152
153   /**
154    * @brief Downcasts a handle to RadioButton handle.
155    *
156    * If handle points to a RadioButton, the downcast produces valid handle.
157    * If not, the returned handle is left uninitialized.
158    *
159    * @SINCE_1_0.0
160    * @param[in] handle Handle to an object
161    * @return A handle to a RadioButton or an uninitialized handle
162    */
163   static RadioButton DownCast(BaseHandle handle);
164
165 public: // Not intended for application developers
166   /// @cond internal
167   /**
168    * @brief Creates a handle using the Toolkit::Internal implementation.
169    *
170    * @SINCE_1_0.0
171    * @param[in] implementation The Control implementation
172    */
173   DALI_INTERNAL RadioButton(Internal::RadioButton& implementation);
174
175   /**
176    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
177    *
178    * @SINCE_1_0.0
179    * @param[in] internal A pointer to the internal CustomActor
180    */
181   DALI_INTERNAL RadioButton(Dali::Internal::CustomActor* internal);
182   /// @endcond
183 };
184
185 /**
186  * @}
187  */
188 } // namespace Toolkit
189
190 } // namespace Dali
191
192 #endif // DALI_TOOLKIT_RADIO_BUTTON_H