[NUI] Use new Extents in Tizen.NUI.Compoents (#1116)
[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;
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     [TypeConverter(typeof(ExtentsTypeConverter))]
27     public class Extents : Disposable
28     {
29
30         /// <summary>
31         /// Extents class
32         /// </summary>
33         /// <since_tizen> 4 </since_tizen>
34         protected bool swigCMemOwn;
35
36         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
37
38         /// <summary>
39         /// Constructor.
40         /// </summary>
41         /// <since_tizen> 4 </since_tizen>
42         public Extents() : this(Interop.Extents.new_Extents__SWIG_0(), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         /// <summary>
48         /// Constructor.
49         /// </summary>
50         /// <param name="copy">A reference to the copied Extents.</param>
51         /// <since_tizen> 4 </since_tizen>
52         public Extents(Extents copy) : this(Interop.Extents.new_Extents__SWIG_1(Extents.getCPtr(copy)), true)
53         {
54             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55         }
56
57         /// <summary>
58         /// Constructor.
59         /// <param name="start">Start extent.</param>
60         /// <param name="end">End extent.</param>
61         /// <param name="top">Top extent.</param>
62         /// <param name="bottom">Bottom extent.</param>
63         /// </summary>
64         /// <since_tizen> 4 </since_tizen>
65         public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
66         {
67             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68         }
69
70         internal Extents(global::System.IntPtr cPtr, bool cMemoryOwn)
71         {
72             swigCMemOwn = cMemoryOwn;
73             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
74         }
75
76         /// <summary>
77         /// Constructor
78         /// </summary>
79         /// <param name="cb"></param>
80         /// <param name="start"></param>
81         /// <param name="end"></param>
82         /// <param name="top"></param>
83         /// <param name="bottom"></param>
84         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
85         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
86         public Extents(ExtentsChangedCallback cb, ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
87         {
88             callback = cb;
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90         }
91
92         /// <summary>
93         /// Copy other extents
94         /// </summary>
95         /// <param name="that"></param>
96         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
97         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
98         public void CopyFrom(Extents that)
99         {
100             Interop.Extents.Extents_start_set(swigCPtr, that.Start);
101             Interop.Extents.Extents_end_set(swigCPtr, that.End);
102             Interop.Extents.Extents_top_set(swigCPtr, that.Top);
103             Interop.Extents.Extents_bottom_set(swigCPtr, that.End);
104         }
105
106         /// <summary>
107         /// Constructor
108         /// </summary>
109         /// <param name="cb"></param>
110         /// <param name="start"></param>
111         /// <param name="end"></param>
112         /// <param name="top"></param>
113         /// <param name="bottom"></param>
114         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
115                 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
116         public delegate void ExtentsChangedCallback(ushort start, ushort end, ushort top, ushort bottom);
117         private ExtentsChangedCallback callback = null;
118
119         /// <summary>
120         /// The Start extent.
121         /// </summary>
122         /// <since_tizen> 4 </since_tizen>
123         public ushort Start
124         {
125             set
126             {
127                 Interop.Extents.Extents_start_set(swigCPtr, value);
128                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129
130                 callback?.Invoke(Start, End, Top, Bottom);
131             }
132             get
133             {
134                 ushort ret = Interop.Extents.Extents_start_get(swigCPtr);
135                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136                 return ret;
137             }
138         }
139
140         /// <summary>
141         /// The End extend.
142         /// </summary>
143         /// <since_tizen> 4 </since_tizen>
144         public ushort End
145         {
146             set
147             {
148                 Interop.Extents.Extents_end_set(swigCPtr, value);
149                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150
151                 callback?.Invoke(Start, End, Top, Bottom);
152             }
153             get
154             {
155                 ushort ret = Interop.Extents.Extents_end_get(swigCPtr);
156                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157                 return ret;
158             }
159         }
160
161         /// <summary>
162         /// The Top extend.
163         /// </summary>
164         /// <since_tizen> 4 </since_tizen>
165         public ushort Top
166         {
167             set
168             {
169                 Interop.Extents.Extents_top_set(swigCPtr, value);
170                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171
172                 callback?.Invoke(Start, End, Top, Bottom);
173             }
174             get
175             {
176                 ushort ret = Interop.Extents.Extents_top_get(swigCPtr);
177                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178                 return ret;
179             }
180         }
181
182         /// <summary>
183         /// The Bottom Extend.
184         /// </summary>
185         /// <since_tizen> 4 </since_tizen>
186         public ushort Bottom
187         {
188             set
189             {
190                 Interop.Extents.Extents_bottom_set(swigCPtr, value);
191                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192
193                 callback?.Invoke(Start, End, Top, Bottom);
194             }
195             get
196             {
197                 ushort ret = Interop.Extents.Extents_bottom_get(swigCPtr);
198                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199                 return ret;
200             }
201         }
202
203         /// <summary>
204         /// Equality operator.
205         /// </summary>
206         /// <param name="rhs">The Extents to test against.</param>
207         /// <returns>True if the extents are not equal.</returns>
208         /// <since_tizen> 4 </since_tizen>
209         public bool EqualTo(Extents rhs)
210         {
211             bool ret = Interop.Extents.Extents_EqualTo(swigCPtr, Extents.getCPtr(rhs));
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             return ret;
214         }
215
216         /// <summary>
217         /// Inequality operator.
218         /// </summary>
219         /// <param name="rhs">The Extents to test against.</param>
220         /// <returns>True if the extents are not equal.</returns>
221         /// <since_tizen> 4 </since_tizen>
222         public bool NotEqualTo(Extents rhs)
223         {
224             bool ret = Interop.Extents.Extents_NotEqualTo(swigCPtr, Extents.getCPtr(rhs));
225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226             return ret;
227         }
228
229         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Extents obj)
230         {
231             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
232         }
233
234         internal Extents Assign(SWIGTYPE_p_uint16_t array)
235         {
236             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_1(swigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false);
237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238             return ret;
239         }
240
241         internal Extents Assign(Extents copy)
242         {
243             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_0(swigCPtr, Extents.getCPtr(copy)), false);
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245             return ret;
246         }
247
248         /// <summary>
249         /// To make a Extents instance be disposed.
250         /// </summary>
251         /// <param name="type">Extents type</param>
252         /// <since_tizen> 4 </since_tizen>
253         protected override void Dispose(DisposeTypes type)
254         {
255             if (disposed)
256             {
257                 return;
258             }
259
260             //Release your own unmanaged resources here.
261             //You should not access any managed member here except static instance.
262             //because the execution order of Finalizes is non-deterministic.
263
264             if (swigCPtr.Handle != global::System.IntPtr.Zero)
265             {
266                 if (swigCMemOwn)
267                 {
268                     swigCMemOwn = false;
269                     Interop.Extents.delete_Extents(swigCPtr);
270                 }
271                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
272             }
273             base.Dispose(type);
274         }
275     }
276 }