1 #ifndef DALI_TOOLKIT_RADIO_BUTTON_H
2 #define DALI_TOOLKIT_RADIO_BUTTON_H
5 * Copyright (c) 2029 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
28 // Forward declarations
30 namespace Internal DALI_INTERNAL
32 // Forward declarations
35 } // namespace DALI_INTERNAL
37 * @addtogroup dali_toolkit_controls_buttons
42 * @brief A RadioButton provides a radio button which two states \e selected or \e unselected.
44 * Radio buttons are designed to select one of many option at the same time.
46 * Every button have its own \e label and \e state, which can be modified by Button::Property::LABEL and Button::Property::SELECTED.
48 * RadioButton can change its current state using Button::SetSelected.
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.
56 * A Button::StateChangedSignal() is emitted when the RadioButton change its state to \e selected or \e unselected.
61 * // In Creating a DALi Application
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 );
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 );
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 );
85 class DALI_TOOLKIT_API RadioButton : public Button
89 * @brief Creates an uninitialized RadioButton; this can be initialized with RadioButton::New().
91 * Calling member functions with an uninitialized Dali::Object is not allowed.
97 * @brief Copy constructor.
99 * @param[in] radioButton Handle to an object
101 RadioButton(const RadioButton& radioButton);
104 * @brief Move constructor
107 * @param[in] rhs A reference to the moved handle
109 RadioButton(RadioButton&& rhs);
112 * @brief Assignment operator.
114 * @param[in] radioButton Handle to an object
115 * @return A reference to this
117 RadioButton& operator=(const RadioButton& radioButton);
120 * @brief Move assignment
123 * @param[in] rhs A reference to the moved handle
124 * @return A reference to this
126 RadioButton& operator=(RadioButton&& rhs);
131 * This is non-virtual since derived Handle types must not contain data or virtual methods.
137 * @brief Creates an initialized RadioButton.
140 * @return A handle to a newly allocated Dali resource
142 static RadioButton New();
145 * @brief Creates an initialized RadioButton with given label.
148 * @param[in] label The button label
149 * @return A handle to a newly allocated Dali resource
151 static RadioButton New(const std::string& label);
154 * @brief Downcasts a handle to RadioButton handle.
156 * If handle points to a RadioButton, the downcast produces valid handle.
157 * If not, the returned handle is left uninitialized.
160 * @param[in] handle Handle to an object
161 * @return A handle to a RadioButton or an uninitialized handle
163 static RadioButton DownCast(BaseHandle handle);
165 public: // Not intended for application developers
168 * @brief Creates a handle using the Toolkit::Internal implementation.
171 * @param[in] implementation The Control implementation
173 DALI_INTERNAL RadioButton(Internal::RadioButton& implementation);
176 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
179 * @param[in] internal A pointer to the internal CustomActor
181 DALI_INTERNAL RadioButton(Dali::Internal::CustomActor* internal);
188 } // namespace Toolkit
192 #endif // DALI_TOOLKIT_RADIO_BUTTON_H