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