Merge "Fix Ime Rotation" into tizen_2.1
[platform/framework/native/uifw.git] / inc / FUiCtrlRadioGroup.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17 /**
18  * @file        FUiCtrlRadioGroup.h
19  * @brief       This is the header file for the %RadioGroup class.
20  *
21  * This header file contains the declarations of the %RadioGroup class and its helper classes.
22  */
23
24 #ifndef _FUI_CTRL_RADIO_GROUP_H_
25 #define _FUI_CTRL_RADIO_GROUP_H_
26
27 #include <FBaseObject.h>
28 #include <FBaseTypes.h>
29 #include <FUiControl.h>
30 #include <FUiContainer.h>
31 #include <FUiCtrlCheckButton.h>
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35 /**
36  * @class       RadioGroup
37  * @brief       This class is an implementation of a %RadioGroup control.
38  *
39  * @since       2.0
40  *
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.
43  * @n
44  * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_button.htm">Buttons</a>.
45  *
46  * The following example demonstrates how to use the %RadioGroup class.
47  *
48  * @code
49 // Sample code for RadioGroupSample.h
50 #include <FUi.h>
51
52 class RadioGroupSample
53         : public Tizen::Ui::Controls::Form
54         , public Tizen::Ui::IActionEventListener
55 {
56 public:
57         RadioGroupSample(void)
58         : __pRadioGroup(null){}
59
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);
64
65 private:
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;
70
71         Tizen::Ui::Controls::RadioGroup* __pRadioGroup;
72 };
73  *      @endcode
74  *
75  *      @code
76 // Sample code for RadioGroupSample.cpp
77 #include <FGraphics.h>
78
79 #include "RadioGroupSample.h"
80
81 using namespace Tizen::Graphics;
82 using namespace Tizen::Ui::Controls;
83
84 bool
85 RadioGroupSample::Initialize(void)
86 {
87         Construct(FORM_STYLE_NORMAL);
88         return true;
89 }
90
91 result
92 RadioGroupSample::OnInitializing(void)
93 {
94         result r = E_SUCCESS;
95
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);
102
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);
108
109         // Adds check buttons to the form
110         AddControl(*pCheckButton1);
111         AddControl(*pCheckButton2);
112
113         // Creates an instance of RadioGroup
114         __pRadioGroup = new RadioGroup();
115         __pRadioGroup->Construct();
116
117         // Adds the check buttons to the radio group
118         __pRadioGroup->Add(*pCheckButton1);
119         __pRadioGroup->Add(*pCheckButton2);
120
121         return r;
122 }
123
124 result
125 RadioGroupSample::OnTerminating(void)
126 {
127         result r = E_SUCCESS;
128
129         // Deallocates the __pRadioGroup
130         delete __pRadioGroup;
131
132         return r;
133 }
134
135 // IActionEventListener implementation
136 void
137 RadioGroupSample::OnActionPerformed(const Control& source, int actionId)
138 {
139         switch (actionId)
140         {
141         case ID_BUTTON1_CHECKED:
142                 {
143                         // ....
144                 }
145                 break;
146         case ID_BUTTON1_UNCHECKED:
147                 {
148                         // ....
149                 }
150                 break;
151         case ID_BUTTON2_CHECKED:
152                 {
153                         // ....
154                 }
155                 break;
156         case ID_BUTTON2_UNCHECKED:
157                 {
158                         // ....
159                 }
160                 break;
161         default:
162                 break;
163         }
164 }
165    * @endcode
166    *
167    */
168 class _OSP_EXPORT_ RadioGroup
169         : public Tizen::Ui::Control
170 {
171 public:
172         /**
173          * This is the default constructor for this class.
174          *
175          * @since       2.0
176          */
177         RadioGroup(void);
178
179         /**
180         * This is the destructor for this class.
181         *
182         * @since        2.0
183         */
184         virtual ~RadioGroup(void);
185
186
187         /**
188          * Initializes this instance of %RadioGroup.
189          *
190          * @since                       2.0
191          *
192          * @return      An error code
193          * @exception   E_SUCCESS           The method is successful.
194          * @exception   E_SYSTEM            A system error has occurred.
195          */
196         result Construct(void);
197
198 public:
199         /**
200          * Adds the check button to the radio group.
201          *
202          * @brief       <i> [Deprecated] </i>
203          * @deprecated  This API is deprecated.
204          * @since               2.0
205          *
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.
212          */
213         result Add(const CheckButton& checkButton);
214
215         /**
216          * Adds the check button to the radio group.
217          *
218          * @since               2.1
219          *
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.
227          */
228         result Add(CheckButton* pCheckButton);
229
230         /**
231          * Removes the check button from the radio group.
232          *
233          * @brief       <i> [Deprecated] </i>
234          * @deprecated  This API is deprecated.
235          * @since               2.0
236          *
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.
243          */
244         result Remove(const CheckButton& checkButton);
245
246         /**
247          * Removes the check button from the radio group.
248          *
249          * @since               2.1
250          *
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.
257          */
258         result Remove(CheckButton* pCheckButton);
259
260 public:
261         /**
262          * Gets the number of check buttons in the radio group.
263          *
264          * @since       2.0
265          *
266          * @return      The number of check buttons in the radio group
267          */
268         int GetItemCount(void) const;
269
270         /**
271          * Selects the specified check button in the radio group.
272          *
273          * @brief               <i> [Deprecated] </i>
274          * @deprecated          This API is deprecated.
275          * @since                       2.0
276          *
277          * @param[in]           checkButton             The check button to select
278          */
279         void SetSelectedItem(const CheckButton& checkButton);
280
281         /**
282          * Selects the specified check button in the radio group.
283          *
284          * @since                       2.1
285          *
286          * @param[in]           pCheckButton            The check button to select
287          * @exception       E_INVALID_ARG       The specified @c pCheckButton is @c null.
288          */
289         void SetSelectedItem(CheckButton* pCheckButton);
290
291         /**
292          * Gets the selected check button in the radio group.
293          *
294          * @since                       2.0
295          *
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
298          *
299          */
300         const CheckButton* GetSelectedItem(void) const;
301
302 private:
303         //
304         // This method is for internal use only.
305         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
306         //
307         // This method is reserved and may change its name at any time without
308         // prior notice.
309         //
310         // @since 2.1
311         //
312         virtual void RadioGroup_Reserved1(void){}
313
314         //
315         // This method is for internal use only.
316         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
317         //
318         // This method is reserved and may change its name at any time without
319         // prior notice.
320         //
321         // @since 2.1
322         //
323         virtual void RadioGroup_Reserved2(void){}
324
325         //
326         // This method is for internal use only.
327         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
328         //
329         // This method is reserved and may change its name at any time without
330         // prior notice.
331         //
332         // @since 2.1
333         //
334         virtual void RadioGroup_Reserved3(void){}
335
336 protected:
337         friend class _RadioGroupImpl;
338
339 private:
340         //
341         // This is the copy constructor for the %RadioGroup class.
342         //
343         RadioGroup(const RadioGroup& rhs);
344
345         //
346         // Assigns the value of the specified instance to the current instance of %RadioGroup.
347         //
348         RadioGroup& operator =(const RadioGroup& rhs);
349
350 }; // RadioGroup
351
352 }}} //Tizen::Ui::Controls
353
354 #endif // _FUI_CTRL_RADIO_GROUP_H_