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