Merge "Fixed test cases after changes in ResourceImage" into 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) 2017 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
27 namespace Toolkit
28 {
29
30 // Forward declarations
31
32 namespace Internal DALI_INTERNAL
33 {
34 // Forward declarations
35
36 class RadioButton;
37 }
38 /**
39  * @addtogroup dali_toolkit_controls_buttons
40  * @{
41  */
42
43 /**
44  * @brief A RadioButton provides a radio button which two states \e selected or \e unselected.
45  *
46  * Radio buttons are designed to select one of many option at the same time.
47  *
48  * Every button have its own \e label and \e state, which can be modified by Button::Property::LABEL and Button::Property::SELECTED.
49  *
50  * RadioButton can change its current state using Button::SetSelected.
51  *
52  * RadioButtons can be grouped.
53  * Two or more RadioButtons are in one group when they have this same parent.
54  * In each groups only one RadioButton can be \e selected at a given time.
55  * So when RadioButton is set to \e selected, other RadioButtons in its group are set to \e unselected.
56  * When \e selected RadioButton is set to \e unselected no other RadioButtons in his group is set to \e selected.
57  *
58  * A Button::StateChangedSignal() is emitted when the RadioButton change its state to \e selected or \e unselected.
59  *
60  * Usage example: -
61  *
62  * @code
63  * // in Creating a DALi Application
64  *
65  * // Create a group to bind two or more RadioButtons together
66  * Actor radioGroup = Actor::New();
67  * radioGroup.SetParentOrigin( ParentOrigin::CENTER );
68  * Stage::GetCurrent().Add( radioGroup );
69  *
70  * // Make the first RadioButton and add it to its parent
71  * RadioButton button1 = RadioButton::New();
72  * button1.SetProperty( Button::Property::LABEL, "button1" );
73  * button1.SetBackgroundColor( Color::WHITE );
74  * button1.SetPosition( 0, -40 );
75  * radioGroup.Add( button1 );
76  *
77  * // Make more RadioButtons and add them to their parent
78  * RadioButton button2 = RadioButton::New();
79  * button2.SetProperty( Toolkit::Button::Property::LABEL, "button2" );
80  * button2.SetBackgroundColor( Color::WHITE );
81  * button2.SetPosition( 0, 40 );
82  * radioGroup.Add( button2 );
83  *
84  * @endcode
85  * @SINCE_1_0.0
86  */
87 class DALI_IMPORT_API RadioButton: public Button
88 {
89  public:
90   /**
91    * @brief Create an uninitialized RadioButton; this can be initialized with RadioButton::New().
92    *
93    * Calling member functions with an uninitialized Dali::Object is not allowed.
94    * @SINCE_1_0.0
95    */
96   RadioButton();
97
98   /**
99    * @brief Copy constructor.
100    * @SINCE_1_0.0
101    * @param[in] radioButton Handle to an object
102    */
103   RadioButton( const RadioButton& radioButton );
104
105   /**
106    * @brief Assignment operator.
107    * @SINCE_1_0.0
108    * @param[in] radioButton Handle to an object
109    * @return A reference to this
110    */
111   RadioButton& operator=( const RadioButton& radioButton );
112
113   /**
114    * @brief Destructor
115    *
116    * This is non-virtual since derived Handle types must not contain data or virtual methods.
117    * @SINCE_1_0.0
118    */
119   ~RadioButton();
120
121   /**
122    * @brief Create an initialized RadioButton.
123    *
124    * @SINCE_1_0.0
125    * @return A handle to a newly allocated Dali resource.
126    */
127   static RadioButton New();
128
129   /**
130    * @brief Create an initialized RadioButton with given label.
131    *
132    * @SINCE_1_0.0
133    * @param[in] label The button label.
134    *
135    * @return A handle to a newly allocated Dali resource.
136    */
137   static RadioButton New( const std::string& label );
138
139   /**
140    * @brief Downcast a handle to RadioButton handle.
141    *
142    * If handle points to a RadioButton the downcast produces valid
143    * handle. If not the returned handle is left uninitialized.
144    *
145    * @SINCE_1_0.0
146    * @param[in] handle Handle to an object
147    * @return A handle to a RadioButton or an uninitialized handle
148    */
149   static RadioButton DownCast( BaseHandle handle );
150
151  public: // Not intended for application developers
152
153   /// @cond internal
154   /**
155    * @brief Creates a handle using the Toolkit::Internal implementation.
156    *
157    * @SINCE_1_0.0
158    * @param[in]  implementation  The Control implementation.
159    */
160   DALI_INTERNAL RadioButton( Internal::RadioButton& implementation );
161
162   /**
163    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
164    *
165    * @SINCE_1_0.0
166    * @param[in]  internal  A pointer to the internal CustomActor.
167    */
168   DALI_INTERNAL RadioButton( Dali::Internal::CustomActor* internal );
169   /// @endcond
170 };
171
172 /**
173  * @}
174  */
175 } // namespace Toolkit
176
177 } // namespace Dali
178
179 #endif // __DALI_TOOLKIT_RADIO_BUTTON_H__