Ensuring that Registry.Unregister is called from the most derived class before the...
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / RadioButton.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI.UIComponents
18 {
19
20     /// <summary>
21     /// A RadioButton provides a radio button which two states \e selected or \e unselected.<br>
22     /// Radio buttons are designed to select one of many option at the same time.<br>
23     /// RadioButton can change its current state using Selected.<br>
24     /// <br>
25     /// RadioButtons can be grouped.<br>
26     /// Two or more RadioButtons are in one group when they have this same parent.<br>
27     /// In each groups only one RadioButton can be \e selected at a given time.<br>
28     /// So when RadioButton is set to \e selected, other RadioButtons in its group are set to \e unselected.<br>
29     /// When \e selected RadioButton is set to \e unselected no other RadioButtons in his group is set to \e selected.<br>
30     /// <br>
31     ///  A StateChanged Event is emitted when the RadioButton change its state to \e selected or \e unselected.<br>
32     /// </summary>
33     public class RadioButton : Button
34     {
35         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36
37         internal RadioButton(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.RadioButton_SWIGUpcast(cPtr), cMemoryOwn)
38         {
39             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
40         }
41
42         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RadioButton obj)
43         {
44             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45         }
46
47         /// <summary>
48         /// To make RadioButton instance be disposed.
49         /// </summary>
50         protected override void Dispose(DisposeTypes type)
51         {
52             if (disposed)
53             {
54                 return;
55             }
56
57             if (type == DisposeTypes.Explicit)
58             {
59                 //Called by User
60                 //Release your own managed resources here.
61                 //You should release all of your own disposable objects here.
62
63             }
64
65             //Release your own unmanaged resources here.
66             //You should not access any managed member here except static instance.
67             //because the execution order of Finalizes is non-deterministic.
68
69             if (swigCPtr.Handle != global::System.IntPtr.Zero)
70             {
71                 if (swigCMemOwn)
72                 {
73                     swigCMemOwn = false;
74
75                     //Unreference this instance from Registry.
76                     Registry.Unregister(this);
77
78                     NDalicPINVOKE.delete_RadioButton(swigCPtr);
79                 }
80                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
81             }
82
83             base.Dispose(type);
84         }
85         /// <summary>
86         /// Creates an uninitialized RadioButton
87         /// </summary>
88         public RadioButton() : this(NDalicPINVOKE.RadioButton_New__SWIG_0(), true)
89         {
90             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91
92         }
93
94         /// <summary>
95         /// Creates an uninitialized RadioButton with Label
96         /// </summary>
97         /// <param name="label">Label text</param>
98         public RadioButton(string label) : this(NDalicPINVOKE.RadioButton_New__SWIG_1(label), true)
99         {
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101
102         }
103     }
104 }