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.
204 * @return An error code
205 * @param[in] checkButton The %CheckButton instance to be added
206 * @exception E_SUCCESS The method is successful.
207 * @exception E_INVALID_ARG The specified input parameter is invalid.
208 * @exception E_SYSTEM A system error has occurred.
209 * @remarks Only CheckButtons whose style is CHECK_BUTTON_STYLE_RADIO or CHECK_BUTTON_STYLE_RADIO_WITH_DIVIDER can be added to %RadioGroup.
211 result Add(const CheckButton& checkButton);
214 * Removes the check button from the radio group.
218 * @return An error code
219 * @param[in] checkButton The %CheckButton instance to be removed
220 * @exception E_SUCCESS The method is successful.
221 * @exception E_OBJ_NOT_FOUND The object is not found.
222 * @exception E_SYSTEM A system error has occurred.
223 * @remarks Before removing %CheckButton from its parent container, it must be removed from %RadioGroup.
225 result Remove(const CheckButton& checkButton);
229 * Gets the number of check buttons in the radio group.
233 * @return The number of check buttons in the radio group
235 int GetItemCount(void) const;
238 * Selects the specified check button in the radio group.
242 * @param[in] checkButton The check button to be selected
244 void SetSelectedItem(const CheckButton& checkButton);
247 * Gets the selected check button in the radio group.
251 * @return The pointer to the selected check button, @n
252 * else @c null if an error occurs or no check button in the radio group is selected
255 const CheckButton* GetSelectedItem(void) const;
258 // This method is for internal use only.
259 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
261 // This method is prohibited. If this method is used
262 // in an application, the application can get rejected during the certification
265 // (Blocked) Draws the control.
269 // @return An error code
270 // @exception E_UNSUPPORTED_OPERATION This operation is not supported.
272 virtual result Draw(void);
275 // This method is for internal use only.
276 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
278 // This method is prohibited. If this method is used
279 // in an application, the application can get rejected during the certification
282 // (Blocked) Shows this control.
286 // @return An error code
287 // @exception E_UNSUPPORTED_OPERATION This operation is not supported.
289 virtual result Show(void);
292 // This method is for internal use only.
293 // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
295 // This method is prohibited. If this method is used
296 // in an application, the application can get rejected during the certification
299 // (Blocked) Gives the input focus to the control. @n
300 // One must call this method if the control needs to listen to the user input events such as key pressed.
304 // @return An error code
305 // @exception E_UNSUPPORTED_OPERATION This operation is not supported.
307 virtual result SetFocus(void);
310 friend class _RadioGroupImpl;
314 // This is the copy constructor for the %RadioGroup class.
316 RadioGroup(const RadioGroup& rhs);
319 // Assigns the value of the specified instance to the current instance of %RadioGroup.
321 RadioGroup& operator =(const RadioGroup& rhs);
325 }}} //Tizen::Ui::Controls
327 #endif // _FUI_CTRL_RADIO_GROUP_H_