2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiCtrlRadioGroup.h
20 * @brief This is the header file for the %RadioGroup class.
22 * This header file contains the declarations of the %RadioGroup class and its helper classes.
25 #ifndef _FUI_CTRL_RADIO_GROUP_H_
26 #define _FUI_CTRL_RADIO_GROUP_H_
28 #include <FBaseObject.h>
29 #include <FBaseTypes.h>
30 #include <FUiControl.h>
31 #include <FUiContainer.h>
32 #include <FUiCtrlCheckButton.h>
34 namespace Tizen { namespace Ui { namespace Controls
38 * @brief This class is an implementation of a %RadioGroup control.
42 * The %RadioGroup class displays a set of CheckButtons with radio style together in a group, allowing the user to select only
43 * one of the predefined set of buttons.
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_button.htm">Buttons</a>.
47 * The following example demonstrates how to use the %RadioGroup class.
50 // Sample code for RadioGroupSample.h
53 class RadioGroupSample
54 : public Tizen::Ui::Controls::Form
55 , public Tizen::Ui::IActionEventListener
58 RadioGroupSample(void)
59 : __pRadioGroup(null){}
61 bool Initialize(void);
62 virtual result OnInitializing(void);
63 virtual result OnTerminating(void);
64 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
67 static const int ID_BUTTON1_CHECKED = 101;
68 static const int ID_BUTTON1_UNCHECKED = 102;
69 static const int ID_BUTTON2_CHECKED = 103;
70 static const int ID_BUTTON2_UNCHECKED = 104;
72 Tizen::Ui::Controls::RadioGroup* __pRadioGroup;
77 // Sample code for RadioGroupSample.cpp
78 #include <FGraphics.h>
80 #include "RadioGroupSample.h"
82 using namespace Tizen::Graphics;
83 using namespace Tizen::Ui::Controls;
86 RadioGroupSample::Initialize(void)
88 Construct(FORM_STYLE_NORMAL);
93 RadioGroupSample::OnInitializing(void)
97 // Creates instances of CheckButton
98 CheckButton *pCheckButton1 = new CheckButton();
99 pCheckButton1->Construct(Rectangle(50, 50, GetClientAreaBounds().width - 100, 100),
100 CHECK_BUTTON_STYLE_RADIO, BACKGROUND_STYLE_DEFAULT, false, L"Radio1");
101 pCheckButton1->SetActionId(ID_BUTTON1_CHECKED, ID_BUTTON1_UNCHECKED);
102 pCheckButton1->AddActionEventListener(*this);
104 CheckButton *pCheckButton2 = new CheckButton();
105 pCheckButton2->Construct(Rectangle(50, 160, GetClientAreaBounds().width - 100, 100),
106 CHECK_BUTTON_STYLE_RADIO,BACKGROUND_STYLE_DEFAULT, false, L"Radio2");
107 pCheckButton2->SetActionId(ID_BUTTON2_CHECKED, ID_BUTTON2_UNCHECKED);
108 pCheckButton2->AddActionEventListener(*this);
110 // Adds check buttons to the form
111 AddControl(pCheckButton1);
112 AddControl(pCheckButton2);
114 // Creates an instance of RadioGroup
115 __pRadioGroup = new RadioGroup();
116 __pRadioGroup->Construct();
118 // Adds the check buttons to the radio group
119 __pRadioGroup->Add(pCheckButton1);
120 __pRadioGroup->Add(pCheckButton2);
126 RadioGroupSample::OnTerminating(void)
128 result r = E_SUCCESS;
130 // Deallocates the __pRadioGroup
131 delete __pRadioGroup;
136 // IActionEventListener implementation
138 RadioGroupSample::OnActionPerformed(const Control& source, int actionId)
142 case ID_BUTTON1_CHECKED:
147 case ID_BUTTON1_UNCHECKED:
152 case ID_BUTTON2_CHECKED:
157 case ID_BUTTON2_UNCHECKED:
169 class _OSP_EXPORT_ RadioGroup
170 : public Tizen::Ui::Control
174 * This is the default constructor for this class.
181 * This is the destructor for this class.
185 virtual ~RadioGroup(void);
189 * Initializes this instance of %RadioGroup.
193 * @return An error code
194 * @exception E_SUCCESS The method is successful.
195 * @exception E_SYSTEM A system error has occurred.
197 result Construct(void);
201 * Adds the check button to the radio group.
203 * @brief <i> [Deprecated] </i>
204 * @deprecated This method is deprecated.
207 * @return An error code
208 * @param[in] checkButton The %CheckButton instance to add
209 * @exception E_SUCCESS The method is successful.
210 * @exception E_INVALID_ARG The specified input parameter is invalid.
211 * @exception E_SYSTEM A system error has occurred.
212 * @remarks Only CheckButtons whose style is @c CHECK_BUTTON_STYLE_RADIO or
213 * @c CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER can be added to %RadioGroup.
215 result Add(const CheckButton& checkButton);
218 * Adds the check button to the radio group.
222 * @return An error code
223 * @param[in] pCheckButton The %CheckButton instance to add
224 * @exception E_SUCCESS The method is successful.
225 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
226 * The specified @c pCheckButton is @c null.
227 * @exception E_SYSTEM A system error has occurred.
228 * @remarks Only CheckButtons whose style is @c CHECK_BUTTON_STYLE_RADIO or
229 * @c CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER can be added to %RadioGroup.
231 result Add(CheckButton* pCheckButton);
234 * Removes the check button from the radio group.
236 * @brief <i> [Deprecated] </i>
237 * @deprecated This method is deprecated.
240 * @return An error code
241 * @param[in] checkButton The %CheckButton instance to remove
242 * @exception E_SUCCESS The method is successful.
243 * @exception E_OBJ_NOT_FOUND The object is not found.
244 * @exception E_SYSTEM A system error has occurred.
245 * @remarks Before removing %CheckButton from its parent container, it must be removed from %RadioGroup.
247 result Remove(const CheckButton& checkButton);
250 * Removes the check button from the radio group.
254 * @return An error code
255 * @param[in] pCheckButton The %CheckButton instance to remove
256 * @exception E_SUCCESS The method is successful.
257 * @exception E_OBJ_NOT_FOUND The object is not found.
258 * @exception E_SYSTEM A system error has occurred.
259 * @remarks Before removing %CheckButton from its parent container, it must be removed from %RadioGroup.
261 result Remove(CheckButton* pCheckButton);
265 * Gets the number of check buttons in the radio group.
269 * @return The number of check buttons in the radio group
271 int GetItemCount(void) const;
274 * Selects the specified check button in the radio group.
276 * @brief <i> [Deprecated] </i>
277 * @deprecated This method is deprecated.
280 * @param[in] checkButton The check button to select
282 void SetSelectedItem(const CheckButton& checkButton);
285 * Selects the specified check button in the radio group.
289 * @param[in] pCheckButton The check button to select
290 * @exception E_INVALID_ARG The specified @c pCheckButton is @c null.
292 void SetSelectedItem(CheckButton* pCheckButton);
295 * Gets the selected check button in the radio group.
299 * @return The pointer to the selected check button, @n
300 * else @c null if an error occurs or no check button in the radio group is selected
303 const CheckButton* GetSelectedItem(void) const;
307 // This method is for internal use only.
308 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
310 // This method is reserved and may change its name at any time without
315 virtual void RadioGroup_Reserved1(void){}
318 // This method is for internal use only.
319 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
321 // This method is reserved and may change its name at any time without
326 virtual void RadioGroup_Reserved2(void){}
329 // This method is for internal use only.
330 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
332 // This method is reserved and may change its name at any time without
337 virtual void RadioGroup_Reserved3(void){}
340 friend class _RadioGroupImpl;
344 // This is the copy constructor for the %RadioGroup class.
346 RadioGroup(const RadioGroup& rhs);
349 // Assigns the value of the specified instance to the current instance of %RadioGroup.
351 RadioGroup& operator =(const RadioGroup& rhs);
355 }}} //Tizen::Ui::Controls
357 #endif // _FUI_CTRL_RADIO_GROUP_H_