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