[NUI] Refactor dispose pattern to reduce duplication (#1112)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Extents.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 using Tizen.NUI.Binding;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// Extents class describing the a collection of uint16_t.
24     /// </summary>
25     /// <since_tizen> 4 </since_tizen>
26     [Binding.TypeConverter(typeof(ExtentsTypeConverter))]
27     public class Extents : Disposable
28     {
29
30
31         /// <summary>
32         /// Constructor.
33         /// </summary>
34         /// <since_tizen> 4 </since_tizen>
35         public Extents() : this(Interop.Extents.new_Extents__SWIG_0(), true)
36         {
37             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
38         }
39
40         /// <summary>
41         /// Constructor.
42         /// </summary>
43         /// <param name="copy">A reference to the copied Extents.</param>
44         /// <since_tizen> 4 </since_tizen>
45         public Extents(Extents copy) : this(Interop.Extents.new_Extents__SWIG_1(Extents.getCPtr(copy)), true)
46         {
47             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
48         }
49
50         /// <summary>
51         /// Constructor.
52         /// <param name="start">Start extent.</param>
53         /// <param name="end">End extent.</param>
54         /// <param name="top">Top extent.</param>
55         /// <param name="bottom">Bottom extent.</param>
56         /// </summary>
57         /// <since_tizen> 4 </since_tizen>
58         public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
59         {
60             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61         }
62
63         internal Extents(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
64         {
65         }
66
67         /// <summary>
68         /// Constructor
69         /// </summary>
70         /// <param name="cb"></param>
71         /// <param name="start"></param>
72         /// <param name="end"></param>
73         /// <param name="top"></param>
74         /// <param name="bottom"></param>
75         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
76         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
77         public Extents(ExtentsChangedCallback cb, ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
78         {
79             callback = cb;
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81         }
82
83         /// <summary>
84         /// Copy other extents
85         /// </summary>
86         /// <param name="that"></param>
87         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
88         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
89         public void CopyFrom(Extents that)
90         {
91             Interop.Extents.Extents_start_set(swigCPtr, that.Start);
92             Interop.Extents.Extents_end_set(swigCPtr, that.End);
93             Interop.Extents.Extents_top_set(swigCPtr, that.Top);
94             Interop.Extents.Extents_bottom_set(swigCPtr, that.End);
95         }
96
97         /// <summary>
98         /// Constructor
99         /// </summary>
100         /// <param name="start"></param>
101         /// <param name="end"></param>
102         /// <param name="top"></param>
103         /// <param name="bottom"></param>
104         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
105                 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
106         public delegate void ExtentsChangedCallback(ushort start, ushort end, ushort top, ushort bottom);
107         private ExtentsChangedCallback callback = null;
108
109         /// <summary>
110         /// The Start extent.
111         /// </summary>
112         /// <since_tizen> 4 </since_tizen>
113         public ushort Start
114         {
115             set
116             {
117                 Interop.Extents.Extents_start_set(swigCPtr, value);
118                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119
120                 callback?.Invoke(Start, End, Top, Bottom);
121             }
122             get
123             {
124                 ushort ret = Interop.Extents.Extents_start_get(swigCPtr);
125                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126                 return ret;
127             }
128         }
129
130         /// <summary>
131         /// The End extend.
132         /// </summary>
133         /// <since_tizen> 4 </since_tizen>
134         public ushort End
135         {
136             set
137             {
138                 Interop.Extents.Extents_end_set(swigCPtr, value);
139                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140
141                 callback?.Invoke(Start, End, Top, Bottom);
142             }
143             get
144             {
145                 ushort ret = Interop.Extents.Extents_end_get(swigCPtr);
146                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147                 return ret;
148             }
149         }
150
151         /// <summary>
152         /// The Top extend.
153         /// </summary>
154         /// <since_tizen> 4 </since_tizen>
155         public ushort Top
156         {
157             set
158             {
159                 Interop.Extents.Extents_top_set(swigCPtr, value);
160                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161
162                 callback?.Invoke(Start, End, Top, Bottom);
163             }
164             get
165             {
166                 ushort ret = Interop.Extents.Extents_top_get(swigCPtr);
167                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168                 return ret;
169             }
170         }
171
172         /// <summary>
173         /// The Bottom Extend.
174         /// </summary>
175         /// <since_tizen> 4 </since_tizen>
176         public ushort Bottom
177         {
178             set
179             {
180                 Interop.Extents.Extents_bottom_set(swigCPtr, value);
181                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182
183                 callback?.Invoke(Start, End, Top, Bottom);
184             }
185             get
186             {
187                 ushort ret = Interop.Extents.Extents_bottom_get(swigCPtr);
188                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189                 return ret;
190             }
191         }
192
193         /// <summary>
194         /// Equality operator.
195         /// </summary>
196         /// <param name="rhs">The Extents to test against.</param>
197         /// <returns>True if the extents are not equal.</returns>
198         /// <since_tizen> 4 </since_tizen>
199         public bool EqualTo(Extents rhs)
200         {
201             bool ret = Interop.Extents.Extents_EqualTo(swigCPtr, Extents.getCPtr(rhs));
202             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203             return ret;
204         }
205
206         /// <summary>
207         /// Inequality operator.
208         /// </summary>
209         /// <param name="rhs">The Extents to test against.</param>
210         /// <returns>True if the extents are not equal.</returns>
211         /// <since_tizen> 4 </since_tizen>
212         public bool NotEqualTo(Extents rhs)
213         {
214             bool ret = Interop.Extents.Extents_NotEqualTo(swigCPtr, Extents.getCPtr(rhs));
215             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216             return ret;
217         }
218
219         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Extents obj)
220         {
221             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
222         }
223
224         internal Extents Assign(SWIGTYPE_p_uint16_t array)
225         {
226             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_1(swigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false);
227             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228             return ret;
229         }
230
231         internal Extents Assign(Extents copy)
232         {
233             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_0(swigCPtr, Extents.getCPtr(copy)), false);
234             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235             return ret;
236         }
237
238         /// This will not be public opened.
239         [EditorBrowsable(EditorBrowsableState.Never)]
240         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
241         {
242             Interop.Extents.delete_Extents(swigCPtr);
243         }
244     }
245 }