[NUI.Components] Fix build warnings (#1233)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / RadioButtonGroup.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.ComponentModel;
18
19 namespace Tizen.NUI.Components
20 {
21     /// <summary>
22     /// The RadioButtonGroup class is used to group together a set of RadioButton control
23     /// It enables the user to select exclusively single radio button of group.
24     /// </summary>
25     /// <code>
26     /// RadioButtonGroup radioGroup = new RadioButtonGroup();
27     /// RadioButton radio1 = new RadioButton();
28     /// RadioButton radio2 = new RadioButton();
29     /// radioGroup.Add(radio1);
30     /// radioGroup.Add(radio2);
31     /// </code>
32     /// <since_tizen> 6 </since_tizen>
33     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
34     [EditorBrowsable(EditorBrowsableState.Never)]
35     public class RadioButtonGroup : SelectGroup
36     {
37         /// <summary>
38         /// Construct RadioButtonGroup
39         /// </summary>
40         /// <since_tizen> 6 </since_tizen>
41         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         public RadioButtonGroup() : base()
44         {
45         }
46
47         /// <summary>
48         /// Get the RadioButton object at the specified index.
49         /// </summary>
50         /// <param name="index">item index</param>
51         /// <returns>RadioButton</returns>
52         /// <since_tizen> 6 </since_tizen>
53         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
54         [EditorBrowsable(EditorBrowsableState.Never)]
55         public RadioButton GetItem(int index)
56         {
57             return itemGroup[index] as RadioButton;
58         }
59
60         /// <summary>
61         /// Add RadioButton to the end of RadioButtonGroup.
62         /// </summary>
63         /// <param name="radio">The RadioButton to be added to the RadioButtonGroup</param>
64         /// <since_tizen> 6 </since_tizen>
65         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public void Add(RadioButton radio)
68         {
69             if (null == radio) return;
70             base.AddSelection(radio);
71             radio.ItemGroup = this;
72         }
73
74         /// <summary>
75         /// Remove RadioButton from the RadioButtonGroup.
76         /// </summary>
77         /// <param name="radio">The RadioButton to remove from the RadioButtonGroup</param>
78         /// <since_tizen> 6 </since_tizen>
79         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
80         [EditorBrowsable(EditorBrowsableState.Never)]
81         public void Remove(RadioButton radio)
82         {
83             if (null == radio) return;
84             base.RemoveSelection(radio);
85             radio.ItemGroup = null;
86         }
87
88         /// <summary>
89         /// Handle user's select action. Turn on check state of selected RadioButton,
90         /// and turn out check state of other RadioButtons in RadioButtonGroup
91         /// </summary>
92         /// <param name="selection">The selection selected by user</param>
93         /// <since_tizen> 6 </since_tizen>
94         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
95         [EditorBrowsable(EditorBrowsableState.Never)]
96         protected override void SelectionHandler(SelectButton selection)
97         {
98             RadioButton radio = selection as RadioButton;
99             if (!itemGroup.Contains(radio))
100             {
101                 return;
102             }
103
104             foreach (RadioButton btn in itemGroup)
105             {
106                 if (btn != null && btn != radio && btn.IsEnabled == true)
107                 {
108                     btn.IsSelected = false;
109                 }
110             }
111         }
112     }
113 }