Release 4.0.0-preview1-00301
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PaddingType.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 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// The gesture state.
22     /// </summary>
23     public class PaddingType : global::System.IDisposable
24     {
25         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26         /// <summary>
27         /// swigCMemOwn
28         /// </summary>
29         protected bool swigCMemOwn;
30
31         internal PaddingType(global::System.IntPtr cPtr, bool cMemoryOwn)
32         {
33             swigCMemOwn = cMemoryOwn;
34             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35         }
36
37         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PaddingType obj)
38         {
39             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40         }
41
42         //A Flag to check who called Dispose(). (By User or DisposeQueue)
43         private bool isDisposeQueued = false;
44         /// <summary>
45         /// A Flat to check if it is already disposed.
46         /// </summary>
47         protected bool disposed = false;
48
49         /// <summary>
50         /// Dispose.
51         /// </summary>
52         /// <since_tizen> 3 </since_tizen>
53         ~PaddingType()
54         {
55             if (!isDisposeQueued)
56             {
57                 isDisposeQueued = true;
58                 DisposeQueue.Instance.Add(this);
59             }
60         }
61
62         /// <summary>
63         /// Dispose.
64         /// </summary>
65         /// <since_tizen> 3 </since_tizen>
66         public void Dispose()
67         {
68             //Throw excpetion if Dispose() is called in separate thread.
69             if (!Window.IsInstalled())
70             {
71                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
72             }
73
74             if (isDisposeQueued)
75             {
76                 Dispose(DisposeTypes.Implicit);
77             }
78             else
79             {
80                 Dispose(DisposeTypes.Explicit);
81                 System.GC.SuppressFinalize(this);
82             }
83         }
84
85         /// <summary>
86         /// Dispose.
87         /// </summary>
88         /// <since_tizen> 3 </since_tizen>
89         protected virtual void Dispose(DisposeTypes type)
90         {
91             if (disposed)
92             {
93                 return;
94             }
95
96             if (type == DisposeTypes.Explicit)
97             {
98                 //Called by User
99                 //Release your own managed resources here.
100                 //You should release all of your own disposable objects here.
101
102             }
103
104             //Release your own unmanaged resources here.
105             //You should not access any managed member here except static instance.
106             //because the execution order of Finalizes is non-deterministic.
107
108             if (swigCPtr.Handle != global::System.IntPtr.Zero)
109             {
110                 if (swigCMemOwn)
111                 {
112                     swigCMemOwn = false;
113                     NDalicPINVOKE.delete_PaddingType(swigCPtr);
114                 }
115                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
116             }
117
118             disposed = true;
119         }
120
121         /// <summary>
122         /// Equality operator
123         /// </summary>
124         /// <since_tizen> 3 </since_tizen>
125         public static bool operator ==(PaddingType a, PaddingType b)
126         {
127             // If both are null, or both are same instance, return true.
128             if (System.Object.ReferenceEquals(a, b))
129             {
130                 return true;
131             }
132
133             // If one is null, but not both, return false.
134             if (((object)a == null) || ((object)b == null))
135             {
136                 return false;
137             }
138
139             // Return true if the fields match:
140             return (System.Math.Abs(a.Left - b.Left) < NDalic.GetRangedEpsilon(a.Left, b.Left)) &&
141                    (System.Math.Abs(a.Right - b.Right) < NDalic.GetRangedEpsilon(a.Right, b.Right)) &&
142                    (System.Math.Abs(a.Bottom - b.Bottom) < NDalic.GetRangedEpsilon(a.Bottom, b.Bottom)) &&
143                    (System.Math.Abs(a.Top - b.Top) < NDalic.GetRangedEpsilon(a.Top, b.Top));
144         }
145
146         /// <summary>
147         /// Inequality operator. Returns Null if either operand is Null
148         /// </summary>
149         /// <since_tizen> 3 </since_tizen>
150         public static bool operator !=(PaddingType a, PaddingType b)
151         {
152             return !(a == b);
153         }
154
155
156         /// <summary>
157         /// Equals
158         /// </summary>
159         /// <param name="o">The object should be compared.</param>
160         /// <returns>True if equal.</returns>
161         /// <since_tizen> 4 </since_tizen>
162         public override bool Equals(object o)
163         {
164             if(o == null)
165             {
166                 return false;
167             }
168             if(!(o is PaddingType))
169             {
170                 return false;
171             }
172             PaddingType p = (PaddingType)o;
173
174             // Return true if the fields match:
175             return (System.Math.Abs(Left - p.Left) < NDalic.GetRangedEpsilon(Left, p.Left)) &&
176                    (System.Math.Abs(Right - p.Right) < NDalic.GetRangedEpsilon(Right, p.Right)) &&
177                    (System.Math.Abs(Bottom - p.Bottom) < NDalic.GetRangedEpsilon(Bottom, p.Bottom)) &&
178                    (System.Math.Abs(Top - p.Top) < NDalic.GetRangedEpsilon(Top, p.Top));
179         }
180
181         /// <summary>
182         /// Gets the the hash code of this baseHandle.
183         /// </summary>
184         /// <returns>The Hash Code.</returns>
185         /// <since_tizen> 4 </since_tizen>
186         public override int GetHashCode()
187         {
188             return base.GetHashCode();
189         }
190
191         /// <summary>
192         /// The Left value.
193         /// </summary>
194         /// <since_tizen> 3 </since_tizen>
195         public float Left
196         {
197             set
198             {
199                 left = value;
200             }
201             get
202             {
203                 return left;
204             }
205         }
206
207         /// <summary>
208         /// The Right value.
209         /// </summary>
210         /// <since_tizen> 3 </since_tizen>
211         public float Right
212         {
213             set
214             {
215                 right = value;
216             }
217             get
218             {
219                 return right;
220             }
221         }
222
223         /// <summary>
224         /// The Bottom value.
225         /// </summary>
226         /// <since_tizen> 3 </since_tizen>
227         public float Bottom
228         {
229             set
230             {
231                 bottom = value;
232             }
233             get
234             {
235                 return bottom;
236             }
237         }
238
239         /// <summary>
240         /// The Top value.
241         /// </summary>
242         /// <since_tizen> 3 </since_tizen>
243         public float Top
244         {
245             set
246             {
247                 top = value;
248             }
249             get
250             {
251                 return top;
252             }
253         }
254
255         /// <summary>
256         /// Create an instance of paddingType.
257         /// </summary>
258         /// <since_tizen> 3 </since_tizen>
259         public PaddingType() : this(NDalicPINVOKE.new_PaddingType__SWIG_0(), true)
260         {
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262         }
263
264         /// <summary>
265         /// Create an instance of BaseHandle.
266         /// </summary>
267         /// <param name="x">The x value.</param>
268         /// <param name="y">The y value.</param>
269         /// <param name="width">The width value.</param>
270         /// <param name="height">The height value.</param>
271         /// <since_tizen> 3 </since_tizen>
272         public PaddingType(float x, float y, float width, float height) : this(NDalicPINVOKE.new_PaddingType__SWIG_1(x, y, width, height), true)
273         {
274             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275         }
276
277         /// <summary>
278         /// Set the x, y, width, height of this paddingtype.
279         /// </summary>
280         /// <param name="newX">The x value.</param>
281         /// <param name="newY">The y value.</param>
282         /// <param name="newWidth">The width value.</param>
283         /// <param name="newHeight">The height value.</param>
284         /// <since_tizen> 3 </since_tizen>
285         public void Set(float newX, float newY, float newWidth, float newHeight)
286         {
287             NDalicPINVOKE.PaddingType_Set(swigCPtr, newX, newY, newWidth, newHeight);
288             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289         }
290
291         private float x
292         {
293             set
294             {
295                 NDalicPINVOKE.PaddingType_x_set(swigCPtr, value);
296                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             }
298             get
299             {
300                 float ret = NDalicPINVOKE.PaddingType_x_get(swigCPtr);
301                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302                 return ret;
303             }
304         }
305
306         private float left
307         {
308             set
309             {
310                 NDalicPINVOKE.PaddingType_left_set(swigCPtr, value);
311                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312             }
313             get
314             {
315                 float ret = NDalicPINVOKE.PaddingType_left_get(swigCPtr);
316                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317                 return ret;
318             }
319         }
320
321         private float y
322         {
323             set
324             {
325                 NDalicPINVOKE.PaddingType_y_set(swigCPtr, value);
326                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
327             }
328             get
329             {
330                 float ret = NDalicPINVOKE.PaddingType_y_get(swigCPtr);
331                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332                 return ret;
333             }
334         }
335
336         private float right
337         {
338             set
339             {
340                 NDalicPINVOKE.PaddingType_right_set(swigCPtr, value);
341                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342             }
343             get
344             {
345                 float ret = NDalicPINVOKE.PaddingType_right_get(swigCPtr);
346                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347                 return ret;
348             }
349         }
350
351         private float width
352         {
353             set
354             {
355                 NDalicPINVOKE.PaddingType_width_set(swigCPtr, value);
356                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357             }
358             get
359             {
360                 float ret = NDalicPINVOKE.PaddingType_width_get(swigCPtr);
361                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362                 return ret;
363             }
364         }
365
366         private float bottom
367         {
368             set
369             {
370                 NDalicPINVOKE.PaddingType_bottom_set(swigCPtr, value);
371                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372             }
373             get
374             {
375                 float ret = NDalicPINVOKE.PaddingType_bottom_get(swigCPtr);
376                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377                 return ret;
378             }
379         }
380
381         private float height
382         {
383             set
384             {
385                 NDalicPINVOKE.PaddingType_height_set(swigCPtr, value);
386                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387             }
388             get
389             {
390                 float ret = NDalicPINVOKE.PaddingType_height_get(swigCPtr);
391                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392                 return ret;
393             }
394         }
395
396         private float top
397         {
398             set
399             {
400                 NDalicPINVOKE.PaddingType_top_set(swigCPtr, value);
401                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402             }
403             get
404             {
405                 float ret = NDalicPINVOKE.PaddingType_top_get(swigCPtr);
406                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
407                 return ret;
408             }
409         }
410
411     }
412
413 }