[NUI] Refactor dispose pattern to reduce duplication (#1112)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / PaddingType.cs
1 /*
2  * Copyright(c) 2019 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 : Disposable
28     {
29
30         /// <summary>
31         /// Creates an uninitialized PaddingType.
32         /// </summary>
33         /// <since_tizen> 3 </since_tizen>
34         public PaddingType() : this(Interop.PaddingType.new_PaddingType__SWIG_0(), true)
35         {
36             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
37         }
38
39         /// <summary>
40         /// PaddingType Constructor.
41         /// </summary>
42         /// <param name="start">Start padding or X coordinate</param>
43         /// <param name="end">End padding or Y coordinate</param>
44         /// <param name="top">Top padding or Height</param>
45         /// <param name="bottom">Bottom padding or Width</param>
46         /// <since_tizen> 3 </since_tizen>
47         public PaddingType(float start, float end, float top, float bottom) : this(Interop.PaddingType.new_PaddingType__SWIG_1(start, end, top, bottom), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         internal PaddingType(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
53         {
54         }
55
56         /// <summary>
57         /// The Start value.
58         /// </summary>
59         /// <since_tizen> 4 </since_tizen>
60         public float Start
61         {
62             set
63             {
64                 start = value;
65             }
66             get
67             {
68                 return start;
69             }
70         }
71
72         /// <summary>
73         /// The End value.
74         /// </summary>
75         /// <since_tizen> 4 </since_tizen>
76         public float End
77         {
78             set
79             {
80                 end = value;
81             }
82             get
83             {
84                 return end;
85             }
86         }
87
88         /// <summary>
89         /// The Top value.
90         /// </summary>
91         /// <since_tizen> 3 </since_tizen>
92         public float Top
93         {
94             set
95             {
96                 top = value;
97             }
98             get
99             {
100                 return top;
101             }
102         }
103
104         /// <summary>
105         /// The Bottom value.
106         /// </summary>
107         /// <since_tizen> 3 </since_tizen>
108         public float Bottom
109         {
110             set
111             {
112                 bottom = value;
113             }
114             get
115             {
116                 return bottom;
117             }
118         }
119
120         private float left
121         {
122             set
123             {
124                 Interop.PaddingType.PaddingType_left_set(swigCPtr, value);
125                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126             }
127             get
128             {
129                 float ret = Interop.PaddingType.PaddingType_left_get(swigCPtr);
130                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131                 return ret;
132             }
133         }
134
135         private float start
136         {
137             set
138             {
139                 Interop.PaddingType.PaddingType_start_set(swigCPtr, value);
140                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141             }
142             get
143             {
144                 float ret = Interop.PaddingType.PaddingType_start_get(swigCPtr);
145                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146                 return ret;
147             }
148         }
149
150         private float right
151         {
152             set
153             {
154                 Interop.PaddingType.PaddingType_right_set(swigCPtr, value);
155                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156             }
157             get
158             {
159                 float ret = Interop.PaddingType.PaddingType_right_get(swigCPtr);
160                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161                 return ret;
162             }
163         }
164
165         private float end
166         {
167             set
168             {
169                 Interop.PaddingType.PaddingType_end_set(swigCPtr, value);
170                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171             }
172             get
173             {
174                 float ret = Interop.PaddingType.PaddingType_end_get(swigCPtr);
175                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176                 return ret;
177             }
178         }
179
180         private float top
181         {
182             set
183             {
184                 Interop.PaddingType.PaddingType_top_set(swigCPtr, value);
185                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186             }
187             get
188             {
189                 float ret = Interop.PaddingType.PaddingType_top_get(swigCPtr);
190                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191                 return ret;
192             }
193         }
194
195         private float bottom
196         {
197             set
198             {
199                 Interop.PaddingType.PaddingType_bottom_set(swigCPtr, value);
200                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201             }
202             get
203             {
204                 float ret = Interop.PaddingType.PaddingType_bottom_get(swigCPtr);
205                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206                 return ret;
207             }
208         }
209
210         /// <summary>
211         /// Equality operator.
212         /// </summary>
213         /// <param name="a">First operand</param>
214         /// <param name="b">Second operand</param>
215         /// <returns>True if the values are identical</returns>
216         /// <since_tizen> 3 </since_tizen>
217         public static bool operator ==(PaddingType a, PaddingType b)
218         {
219             // If both are null, or both are same instance, return true.
220             if (System.Object.ReferenceEquals(a, b))
221             {
222                 return true;
223             }
224
225             // If one is null, but not both, return false.
226             if (((object)a == null) || ((object)b == null))
227             {
228                 return false;
229             }
230
231             // Return true if the fields match:
232             return (System.Math.Abs(a.Start - b.Start) < NDalic.GetRangedEpsilon(a.Start, b.Start)) &&
233                    (System.Math.Abs(a.End - b.End) < NDalic.GetRangedEpsilon(a.End, b.End)) &&
234                    (System.Math.Abs(a.Bottom - b.Bottom) < NDalic.GetRangedEpsilon(a.Bottom, b.Bottom)) &&
235                    (System.Math.Abs(a.Top - b.Top) < NDalic.GetRangedEpsilon(a.Top, b.Top));
236         }
237
238         /// <summary>
239         /// Inequality operator.
240         /// </summary>
241         /// <param name="a">First operand</param>
242         /// <param name="b">Second operand</param>
243         /// <returns>True if the values are not identical</returns>
244         /// <since_tizen> 3 </since_tizen>
245         public static bool operator !=(PaddingType a, PaddingType b)
246         {
247             return !(a == b);
248         }
249
250         /// <summary>
251         /// Equals
252         /// </summary>
253         /// <param name="o">The object should be compared.</param>
254         /// <returns>True if equal.</returns>
255         /// <since_tizen> 4 </since_tizen>
256         public override bool Equals(object o)
257         {
258             if(o == null)
259             {
260                 return false;
261             }
262             if(!(o is PaddingType))
263             {
264                 return false;
265             }
266             PaddingType p = (PaddingType)o;
267
268             // Return true if the fields match:
269             return (System.Math.Abs(Start- p.Start) < NDalic.GetRangedEpsilon(Start, p.Start)) &&
270                    (System.Math.Abs(End - p.End) < NDalic.GetRangedEpsilon(End, p.End)) &&
271                    (System.Math.Abs(Bottom - p.Bottom) < NDalic.GetRangedEpsilon(Bottom, p.Bottom)) &&
272                    (System.Math.Abs(Top - p.Top) < NDalic.GetRangedEpsilon(Top, p.Top));
273         }
274
275         /// <summary>
276         /// Gets the the hash code of this baseHandle.
277         /// </summary>
278         /// <returns>The Hash Code.</returns>
279         /// <since_tizen> 4 </since_tizen>
280         public override int GetHashCode()
281         {
282             return base.GetHashCode();
283         }
284
285         /// <summary>
286         /// Assignment from individual values.
287         /// </summary>
288         /// <param name="newStart">Start padding or X coordinate</param>
289         /// <param name="newEnd">End padding or Y coordinate</param>
290         /// <param name="newTop">Top padding or Height</param>
291         /// <param name="newBottom">Bottom padding or Width</param>
292         /// <since_tizen> 3 </since_tizen>
293         public void Set(float newStart, float newEnd, float newTop, float newBottom)
294         {
295             Interop.PaddingType.PaddingType_Set(swigCPtr, newStart, newEnd, newTop, newBottom);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297         }
298
299         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PaddingType obj)
300         {
301             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
302         }
303
304         /// This will not be public opened.
305         [EditorBrowsable(EditorBrowsableState.Never)]
306         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
307         {
308             Interop.PaddingType.delete_PaddingType(swigCPtr);
309         }
310     }
311 }