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