Release 4.0.0-preview1-00301
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Uint16Pair.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
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23
24     //"Please do not use! this will be deprecated"
25     /// <summary>
26     /// Simple class for passing around pairs of small unsigned integers.<br />
27     /// Use this for integer dimensions and points with limited range such as image
28     /// sizes and pixel coordinates where a pair of floating point numbers is
29     /// inefficient and illogical (i.e.the data is inherently integer).<br />
30     /// One of these can be passed in a single 32 bit integer register on
31     /// common architectures.<br />
32     /// </summary>
33     /// <since_tizen> 3 </since_tizen>
34     [EditorBrowsable(EditorBrowsableState.Never)]
35     public class Uint16Pair : global::System.IDisposable
36     {
37         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
38         /// <summary>swigCMemOwn.</summary>
39         /// <since_tizen> 3 </since_tizen>
40         protected bool swigCMemOwn;
41
42         internal Uint16Pair(global::System.IntPtr cPtr, bool cMemoryOwn)
43         {
44             swigCMemOwn = cMemoryOwn;
45             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
46         }
47
48         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Uint16Pair obj)
49         {
50             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
51         }
52
53         //A Flag to check who called Dispose(). (By User or DisposeQueue)
54         private bool isDisposeQueued = false;
55         /// <summary>
56         /// A Flat to check if it is already disposed.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         protected bool disposed = false;
60
61         /// <summary>
62         /// Dispose.
63         /// </summary>
64         /// <since_tizen> 3 </since_tizen>
65         ~Uint16Pair()
66         {
67             if (!isDisposeQueued)
68             {
69                 isDisposeQueued = true;
70                 DisposeQueue.Instance.Add(this);
71             }
72         }
73
74         /// <summary>
75         /// Dispose.
76         /// </summary>
77         /// <since_tizen> 3 </since_tizen>
78         public void Dispose()
79         {
80             //Throw excpetion if Dispose() is called in separate thread.
81             if (!Window.IsInstalled())
82             {
83                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
84             }
85
86             if (isDisposeQueued)
87             {
88                 Dispose(DisposeTypes.Implicit);
89             }
90             else
91             {
92                 Dispose(DisposeTypes.Explicit);
93                 System.GC.SuppressFinalize(this);
94             }
95         }
96
97         /// <summary>
98         /// Dispose.
99         /// </summary>
100         /// <since_tizen> 3 </since_tizen>
101         protected virtual void Dispose(DisposeTypes type)
102         {
103             if (disposed)
104             {
105                 return;
106             }
107
108             if (type == DisposeTypes.Explicit)
109             {
110                 //Called by User
111                 //Release your own managed resources here.
112                 //You should release all of your own disposable objects here.
113
114             }
115
116             //Release your own unmanaged resources here.
117             //You should not access any managed member here except static instance.
118             //because the execution order of Finalizes is non-deterministic.
119
120             if (swigCPtr.Handle != global::System.IntPtr.Zero)
121             {
122                 if (swigCMemOwn)
123                 {
124                     swigCMemOwn = false;
125                     NDalicPINVOKE.delete_Uint16Pair(swigCPtr);
126                 }
127                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
128             }
129
130             disposed = true;
131         }
132
133         /// <summary>
134         /// Less than comparison operator for storing in collections (not geometrically meaningful).
135         /// </summary>
136         /// <param name="arg1">A reference for comparison.</param>
137         /// <param name="arg2">A reference for comparison</param>
138         /// <return>True if arg1 less than arg2</return>
139         /// <since_tizen> 3 </since_tizen>
140         public static bool operator <(Uint16Pair arg1, Uint16Pair arg2)
141         {
142             return arg1.LessThan(arg2);
143         }
144
145         /// <summary>
146         /// More than comparison operator for storing in collections (not geometrically meaningful).
147         /// </summary>
148         /// <param name="arg1">A reference for comparison.</param>
149         /// <param name="arg2">A reference for comparison</param>
150         /// <return>True if arg1 > arg2</return>
151         /// <since_tizen> 3 </since_tizen>
152         public static bool operator >(Uint16Pair arg1, Uint16Pair arg2)
153         {
154             return arg1.GreaterThan(arg2);
155         }
156
157         /// <summary>
158         /// Default constructor for the(0, 0) tuple.
159         /// </summary>
160         /// <since_tizen> 3 </since_tizen>
161         public Uint16Pair() : this(NDalicPINVOKE.new_Uint16Pair__SWIG_0(), true)
162         {
163             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
164         }
165
166         /// <summary>
167         /// Default constructor for the(0, 0) tuple.
168         /// </summary>
169         /// <param name="width">The width or X dimension of the tuple. Make sure it is less than 65536.</param>
170         /// <param name="height">The height or Y dimension of the tuple.Make sure it is less than 65536.</param>
171         /// <since_tizen> 3 </since_tizen>
172         public Uint16Pair(uint width, uint height) : this(NDalicPINVOKE.new_Uint16Pair__SWIG_1(width, height), true)
173         {
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175         }
176
177         /// <summary>
178         /// Constructor taking separate x and y (width and height) parameters.
179         /// </summary>
180         /// <param name="rhs">A reference to assign.</param>
181         /// <since_tizen> 3 </since_tizen>
182         public Uint16Pair(Uint16Pair rhs) : this(NDalicPINVOKE.new_Uint16Pair__SWIG_2(Uint16Pair.getCPtr(rhs)), true)
183         {
184             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185         }
186
187         /// <summary>
188         /// Sets the width.
189         /// </summary>
190         /// <param name="width">The x dimension to be stored in this 2-tuple.</param>
191         /// <since_tizen> 3 </since_tizen>
192         public void SetWidth(ushort width)
193         {
194             NDalicPINVOKE.Uint16Pair_SetWidth(swigCPtr, width);
195             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196         }
197
198         /// <summary>
199         /// Get the width.
200         /// </summary>
201         /// <return>
202         /// The x dimension stored in this 2-tuple.
203         /// </return>
204         /// <since_tizen> 3 </since_tizen>
205         public ushort GetWidth()
206         {
207             ushort ret = NDalicPINVOKE.Uint16Pair_GetWidth(swigCPtr);
208             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209             return ret;
210         }
211
212         /// <summary>
213         /// Sets the height.
214         /// </summary>
215         /// <param name="height">The y dimension to be stored in this 2-tuple.</param>
216         /// <since_tizen> 3 </since_tizen>
217         public void SetHeight(ushort height)
218         {
219             NDalicPINVOKE.Uint16Pair_SetHeight(swigCPtr, height);
220             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221         }
222
223         /// <summary>
224         /// Get the height.
225         /// </summary>
226         /// <return>
227         /// The y dimension stored in this 2-tuple.
228         /// </return>
229         /// <since_tizen> 3 </since_tizen>
230         public ushort GetHeight()
231         {
232             ushort ret = NDalicPINVOKE.Uint16Pair_GetHeight(swigCPtr);
233             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234             return ret;
235         }
236
237         /// <summary>
238         /// Sets the x dimension.
239         /// </summary>
240         /// <param name="x">The x dimension to be stored in this 2-tuple.</param>
241         /// <since_tizen> 3 </since_tizen>
242         public void SetX(ushort x)
243         {
244             NDalicPINVOKE.Uint16Pair_SetX(swigCPtr, x);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246         }
247
248         /// <summary>
249         /// Get the x dimension.
250         /// </summary>
251         /// <return>
252         /// The x dimension stored in this 2-tuple.
253         /// </return>
254         /// <since_tizen> 3 </since_tizen>
255         public ushort GetX()
256         {
257             ushort ret = NDalicPINVOKE.Uint16Pair_GetX(swigCPtr);
258             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259             return ret;
260         }
261
262         /// <summary>
263         /// Sets the y dimension.
264         /// </summary>
265         /// <param name="y">The y dimension to be stored in this 2-tuple.</param>
266         /// <since_tizen> 3 </since_tizen>
267         public void SetY(ushort y)
268         {
269             NDalicPINVOKE.Uint16Pair_SetY(swigCPtr, y);
270             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271         }
272
273         /// <summary>
274         /// Get the y dimension.
275         /// </summary>
276         /// <return>
277         /// The y dimension stored in this 2-tuple.
278         /// </return>
279         /// <since_tizen> 3 </since_tizen>
280         public ushort GetY()
281         {
282             ushort ret = NDalicPINVOKE.Uint16Pair_GetY(swigCPtr);
283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284             return ret;
285         }
286
287         /// <summary>
288         /// Constructor taking separate x and y (width and height) parameters.
289         /// </summary>
290         /// <param name="rhs">A reference to assign.</param>
291         /// <return>The created object.</return>
292         /// <since_tizen> 3 </since_tizen>
293         public Uint16Pair Assign(Uint16Pair rhs)
294         {
295             Uint16Pair ret = new Uint16Pair(NDalicPINVOKE.Uint16Pair_Assign(swigCPtr, Uint16Pair.getCPtr(rhs)), false);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             return ret;
298         }
299
300         private bool EqualTo(Uint16Pair rhs)
301         {
302             bool ret = NDalicPINVOKE.Uint16Pair_EqualTo(swigCPtr, Uint16Pair.getCPtr(rhs));
303             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304             return ret;
305         }
306
307         private bool NotEqualTo(Uint16Pair rhs)
308         {
309             bool ret = NDalicPINVOKE.Uint16Pair_NotEqualTo(swigCPtr, Uint16Pair.getCPtr(rhs));
310             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311             return ret;
312         }
313
314         private bool LessThan(Uint16Pair rhs)
315         {
316             bool ret = NDalicPINVOKE.Uint16Pair_LessThan(swigCPtr, Uint16Pair.getCPtr(rhs));
317             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318             return ret;
319         }
320
321         private bool GreaterThan(Uint16Pair rhs)
322         {
323             bool ret = NDalicPINVOKE.Uint16Pair_GreaterThan(swigCPtr, Uint16Pair.getCPtr(rhs));
324             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325             return ret;
326         }
327
328     }
329
330 }