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