Merge base & optional
[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) 2014 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 /**
40  * @brief A RadioButton provides a radio button which two states \e selected or \e unselected.
41  *
42  * Radio buttons are designed to select one of many option at the same time.
43  *
44  * Every button have its own \e label and \e state, which can be modified by RadioButton::SetLabel and RadioButton::SetSelected.
45  *
46  * RadioButton can change its current state using RadioButton::ToggleState.
47  *
48  * RadioButtons can be grouped.
49  * Two or more RadioButtons are in one group when they have this same parent.
50  * In each groups only one RadioButton can be \e selected at a given time.
51  * So when RadioButton is set to \e selected, other RadioButtons in its group are set to \e unselected.
52  * When \e selected RadioButton is set to \e unselected no other RadioButtons in his group is set to \e selected.
53  *
54  * A Button::ClickedSignal() is emitted when the RadioButton change its state to \e selected or \e unselected.
55  */
56 class DALI_IMPORT_API RadioButton: public Button
57 {
58  public:
59   /**
60    * @brief Create an uninitialized RadioButton; this can be initialized with RadioButton::New().
61    *
62    * Calling member functions with an uninitialized Dali::Object is not allowed.
63    */
64   RadioButton();
65
66   /**
67    * @brief Copy constructor.
68    */
69   RadioButton(const RadioButton& radioButton);
70
71   /**
72    * @brief Assignment operator.
73    */
74   RadioButton& operator=(const RadioButton& radioButton);
75
76   /**
77    * @brief Destructor
78    *
79    * This is non-virtual since derived Handle types must not contain data or virtual methods.
80    */
81   ~RadioButton();
82
83   /**
84    * @brief Create an initialized RadioButton.
85    *
86    * @return A handle to a newly allocated Dali resource.
87    */
88   static RadioButton New();
89
90   /**
91    * @brief Create an initialized RadioButton with given label.
92    *
93    * @param[in] label The button label.
94    *
95    * @return A handle to a newly allocated Dali resource.
96    */
97   static RadioButton New(const std::string& label);
98
99   /**
100    * @brief Create an initialized RadioButton with existing Actor.
101    *
102    * @param[in] label An Actor with the label.
103    *
104    * @return A handle to a newly allocated Dali resource.
105    */
106   static RadioButton New(Actor label);
107
108   /**
109    * @brief Downcast an Object handle to RadioButton.
110    *
111    * If handle points to a RadioButton the downcast produces valid
112    * handle. If not the returned handle is left uninitialized.
113    *
114    * @param[in] handle Handle to an object
115    * @return handle to a RadioButton or an uninitialized handle
116    */
117   static RadioButton DownCast(BaseHandle handle);
118
119   /**
120    * @brief Sets the button label.
121    *
122    * @param[in] label The button label.
123    */
124   void SetLabel(const std::string& label);
125
126   /**
127    * @brief Sets the button label using existing Actor.
128    *
129    * @param[in] label An Actor with the label.
130    */
131   void SetLabel(Actor label);
132
133   /**
134    * @brief Gets the label.
135    *
136    * @return An Actor with the label.
137    */
138   Actor GetLabel() const;
139
140   /**
141    * @brief Sets the button as selected or unselected.
142    *
143    * @param[in] selected property
144    */
145   void SetSelected(bool selected);
146
147   /**
148    * @return true if button is selected, false if button is unselected.
149    */
150   bool IsSelected()const;
151
152   /**
153    * @brief Change button state.
154    *
155    * If button is selected unselect it. If button is unselected select it.
156    */
157   void ToggleState();
158
159  public: // Not intended for application developers
160
161   /**
162    * @brief Creates a handle using the Toolkit::Internal implementation.
163    *
164    * @param[in]  implementation  The Control implementation.
165    */
166   DALI_INTERNAL RadioButton(Internal::RadioButton& implementation);
167
168   /**
169    * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
170    *
171    * @param[in]  internal  A pointer to the internal CustomActor.
172    */
173   DALI_INTERNAL RadioButton(Dali::Internal::CustomActor* internal);
174
175 };
176
177 } // namespace Toolkit
178
179 } // namespace Dali
180
181 #endif // __DALI_TOOLKIT_RADIO_BUTTON_H__