2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FUiCtrlRadioGroup.h
19 * @brief This is the header file for the %RadioGroup class.
21 * This header file contains the declarations of the %RadioGroup class and its helper classes.
24 #ifndef _FUI_CTRL_RADIO_GROUP_H_
25 #define _FUI_CTRL_RADIO_GROUP_H_
27 #include <FBaseObject.h>
28 #include <FBaseTypes.h>
29 #include <FUiControl.h>
30 #include <FUiContainer.h>
31 #include <FUiCtrlCheckButton.h>
33 namespace Tizen { namespace Ui { namespace Controls
37 * @brief This class is an implementation of a %RadioGroup control.
41 * The %RadioGroup class displays a set of CheckButtons with radio style together in a group, allowing the user to select only
42 * one of the predefined set of buttons.
44 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_button.htm">Buttons</a>.
46 * The following example demonstrates how to use the %RadioGroup class.
49 // Sample code for RadioGroupSample.h
52 class RadioGroupSample
53 : public Tizen::Ui::Controls::Form
54 , public Tizen::Ui::IActionEventListener
57 RadioGroupSample(void)
58 : __pRadioGroup(null){}
60 bool Initialize(void);
61 virtual result OnInitializing(void);
62 virtual result OnTerminating(void);
63 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
66 static const int ID_BUTTON1_CHECKED = 101;
67 static const int ID_BUTTON1_UNCHECKED = 102;
68 static const int ID_BUTTON2_CHECKED = 103;
69 static const int ID_BUTTON2_UNCHECKED = 104;
71 Tizen::Ui::Controls::RadioGroup* __pRadioGroup;
76 // Sample code for RadioGroupSample.cpp
77 #include <FGraphics.h>
79 #include "RadioGroupSample.h"
81 using namespace Tizen::Graphics;
82 using namespace Tizen::Ui::Controls;
85 RadioGroupSample::Initialize(void)
87 Construct(FORM_STYLE_NORMAL);
92 RadioGroupSample::OnInitializing(void)
96 // Creates instances of CheckButton
97 CheckButton *pCheckButton1 = new CheckButton();
98 pCheckButton1->Construct(Rectangle(50, 50, GetClientAreaBounds().width - 100, 100),
99 CHECK_BUTTON_STYLE_RADIO, BACKGROUND_STYLE_DEFAULT, false, L"Radio1");
100 pCheckButton1->SetActionId(ID_BUTTON1_CHECKED, ID_BUTTON1_UNCHECKED);
101 pCheckButton1->AddActionEventListener(*this);
103 CheckButton *pCheckButton2 = new CheckButton();
104 pCheckButton2->Construct(Rectangle(50, 160, GetClientAreaBounds().width - 100, 100),
105 CHECK_BUTTON_STYLE_RADIO,BACKGROUND_STYLE_DEFAULT, false, L"Radio2");
106 pCheckButton2->SetActionId(ID_BUTTON2_CHECKED, ID_BUTTON2_UNCHECKED);
107 pCheckButton2->AddActionEventListener(*this);
109 // Adds check buttons to the form
110 AddControl(*pCheckButton1);
111 AddControl(*pCheckButton2);
113 // Creates an instance of RadioGroup
114 __pRadioGroup = new RadioGroup();
115 __pRadioGroup->Construct();
117 // Adds the check buttons to the radio group
118 __pRadioGroup->Add(*pCheckButton1);
119 __pRadioGroup->Add(*pCheckButton2);
125 RadioGroupSample::OnTerminating(void)
127 result r = E_SUCCESS;
129 // Deallocates the __pRadioGroup
130 delete __pRadioGroup;
135 // IActionEventListener implementation
137 RadioGroupSample::OnActionPerformed(const Control& source, int actionId)
141 case ID_BUTTON1_CHECKED:
146 case ID_BUTTON1_UNCHECKED:
151 case ID_BUTTON2_CHECKED:
156 case ID_BUTTON2_UNCHECKED:
168 class _OSP_EXPORT_ RadioGroup
169 : public Tizen::Ui::Control
173 * This is the default constructor for this class.
180 * This is the destructor for this class.
184 virtual ~RadioGroup(void);
188 * Initializes this instance of %RadioGroup.
192 * @return An error code
193 * @exception E_SUCCESS The method is successful.
194 * @exception E_SYSTEM A system error has occurred.
196 result Construct(void);
200 * Adds the check button to the radio group.
202 * @brief <i> [Deprecated] </i>
203 * @deprecated This API is deprecated.
206 * @return An error code
207 * @param[in] checkButton The %CheckButton instance to add
208 * @exception E_SUCCESS The method is successful.
209 * @exception E_INVALID_ARG The specified input parameter is invalid.
210 * @exception E_SYSTEM A system error has occurred.
211 * @remarks Only CheckButtons whose style is @c CHECK_BUTTON_STYLE_RADIO or @c CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER can be added to %RadioGroup.
213 result Add(const CheckButton& checkButton);
216 * Adds the check button to the radio group.
220 * @return An error code
221 * @param[in] pCheckButton The %CheckButton instance to add
222 * @exception E_SUCCESS The method is successful.
223 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
224 * The specified @c pCheckButton is @c null.
225 * @exception E_SYSTEM A system error has occurred.
226 * @remarks Only CheckButtons whose style is @c CHECK_BUTTON_STYLE_RADIO or @c CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER can be added to %RadioGroup.
228 result Add(CheckButton* pCheckButton);
231 * Removes the check button from the radio group.
233 * @brief <i> [Deprecated] </i>
234 * @deprecated This API is deprecated.
237 * @return An error code
238 * @param[in] checkButton The %CheckButton instance to remove
239 * @exception E_SUCCESS The method is successful.
240 * @exception E_OBJ_NOT_FOUND The object is not found.
241 * @exception E_SYSTEM A system error has occurred.
242 * @remarks Before removing %CheckButton from its parent container, it must be removed from %RadioGroup.
244 result Remove(const CheckButton& checkButton);
247 * Removes the check button from the radio group.
251 * @return An error code
252 * @param[in] pCheckButton The %CheckButton instance to remove
253 * @exception E_SUCCESS The method is successful.
254 * @exception E_OBJ_NOT_FOUND The object is not found.
255 * @exception E_SYSTEM A system error has occurred.
256 * @remarks Before removing %CheckButton from its parent container, it must be removed from %RadioGroup.
258 result Remove(CheckButton* pCheckButton);
262 * Gets the number of check buttons in the radio group.
266 * @return The number of check buttons in the radio group
268 int GetItemCount(void) const;
271 * Selects the specified check button in the radio group.
273 * @brief <i> [Deprecated] </i>
274 * @deprecated This API is deprecated.
277 * @param[in] checkButton The check button to select
279 void SetSelectedItem(const CheckButton& checkButton);
282 * Selects the specified check button in the radio group.
286 * @param[in] pCheckButton The check button to select
287 * @exception E_INVALID_ARG The specified @c pCheckButton is @c null.
289 void SetSelectedItem(CheckButton* pCheckButton);
292 * Gets the selected check button in the radio group.
296 * @return The pointer to the selected check button, @n
297 * else @c null if an error occurs or no check button in the radio group is selected
300 const CheckButton* GetSelectedItem(void) const;
304 // This method is for internal use only.
305 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
307 // This method is reserved and may change its name at any time without
312 virtual void RadioGroup_Reserved1(void){}
315 // This method is for internal use only.
316 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
318 // This method is reserved and may change its name at any time without
323 virtual void RadioGroup_Reserved2(void){}
326 // This method is for internal use only.
327 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
329 // This method is reserved and may change its name at any time without
334 virtual void RadioGroup_Reserved3(void){}
337 friend class _RadioGroupImpl;
341 // This is the copy constructor for the %RadioGroup class.
343 RadioGroup(const RadioGroup& rhs);
346 // Assigns the value of the specified instance to the current instance of %RadioGroup.
348 RadioGroup& operator =(const RadioGroup& rhs);
352 }}} //Tizen::Ui::Controls
354 #endif // _FUI_CTRL_RADIO_GROUP_H_