Added/Modified comments for API reference of part4
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / Size.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
21     /// <summary>
22     /// Three dimensional size
23     /// </summary>
24     public class Size : global::System.IDisposable
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27         protected bool swigCMemOwn;
28
29         internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
30         {
31             swigCMemOwn = cMemoryOwn;
32             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33         }
34
35         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         ~Size()
41         {
42             DisposeQueue.Instance.Add(this);
43         }
44
45         /// <summary>
46         /// Dispose
47         /// </summary>
48         public virtual void Dispose()
49         {
50             if (!Stage.IsInstalled())
51             {
52                 DisposeQueue.Instance.Add(this);
53                 return;
54             }
55
56             lock (this)
57             {
58                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
59                 {
60                     if (swigCMemOwn)
61                     {
62                         swigCMemOwn = false;
63                         NDalicPINVOKE.delete_Vector3(swigCPtr);
64                     }
65                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
66                 }
67                 global::System.GC.SuppressFinalize(this);
68             }
69         }
70
71         /// <summary>
72         /// Addition operator for A+B
73         /// </summary>
74         /// <param name="arg1">Size, A</param>
75         /// <param name="arg2">Size to assign, B</param>
76         /// <returns>A Size containing the result of the addition</returns>
77         public static Size operator +(Size arg1, Size arg2)
78         {
79             return arg1.Add(arg2);
80         }
81
82         /// <summary>
83         /// Subtraction operator for A-B
84         /// </summary>
85         /// <param name="arg1">Size, A</param>
86         /// <param name="arg2">Size to subtract, B</param>
87         /// <returns>A Size containing the result of the subtraction</returns>
88         public static Size operator -(Size arg1, Size arg2)
89         {
90             return arg1.Subtract(arg2);
91         }
92
93         /// <summary>
94         /// Unary negation operator.
95         /// </summary>
96         /// <param name="arg1">Size for unary negation</param>
97         /// <returns>A Size containg the negation</returns>
98         public static Size operator -(Size arg1)
99         {
100             return arg1.Subtract();
101         }
102
103         /// <summary>
104         /// Multiplication operator.
105         /// </summary>
106         /// <param name="arg1">Size for multiplication</param>
107         /// <param name="arg2">The Size to multipl</param>
108         /// <returns>A Size containing the result of the multiplication</returns>
109         public static Size operator *(Size arg1, Size arg2)
110         {
111             return arg1.Multiply(arg2);
112         }
113
114         /// <summary>
115         /// Multiplication operator.
116         /// </summary>
117         /// <param name="arg1">Size for multiplication</param>
118         /// <param name="arg2">The float value to scale the Size</param>
119         /// <returns>A Size containing the result of the scaling</returns>
120         public static Size operator *(Size arg1, float arg2)
121         {
122             return arg1.Multiply(arg2);
123         }
124
125         /// <summary>
126         /// Division operator.
127         /// </summary>
128         /// <param name="arg1">Size for division</param>
129         /// <param name="arg2">The Size to divide</param>
130         /// <returns>A Size containing the result of the division></returns>
131         public static Size operator /(Size arg1, Size arg2)
132         {
133             return arg1.Divide(arg2);
134         }
135
136         /// <summary>
137         /// Division operator.
138         /// </summary>
139         /// <param name="arg1">Size for division</param>
140         /// <param name="arg2">The float value to scale the Size by</param>
141         /// <returns>A Size containing the result of the scaling</returns>
142         public static Size operator /(Size arg1, float arg2)
143         {
144             return arg1.Divide(arg2);
145         }
146
147         /// <summary>
148         /// Array subscript operator.
149         /// </summary>
150         /// <param name="index">Subscript index</param>
151         /// <returns>The float at the given index</returns>
152         public float this[uint index]
153         {
154             get
155             {
156                 return ValueOfIndex(index);
157             }
158         }
159
160         /// <summary>
161         /// Get Size from pointer.
162         /// </summary>
163         /// <param name="cPtr">Pointer of the Size</param>
164         /// <returns>Size</returns>
165         public static Size GetSizeFromPtr(global::System.IntPtr cPtr)
166         {
167             Size ret = new Size(cPtr, false);
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169             return ret;
170         }
171
172         /// <summary>
173         /// Constructor.
174         /// </summary>
175         public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
176         {
177             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178         }
179
180         /// <summary>
181         /// Constructor.
182         /// </summary>
183         /// <param name="x">x (or width) component</param>
184         /// <param name="y">y (or height) component</param>
185         /// <param name="z">z (or depth) component</param>
186         public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
187         {
188             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189         }
190
191         /// <summary>
192         /// Constructor.
193         /// </summary>
194         /// <param name="size2d">Size2D with x (width) and y (height)</param>
195         public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
196         {
197             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198         }
199
200         /// <summary>
201         /// Zero constant, (0.0f, 0.0f, 0.0f).
202         /// </summary>
203         public static Size Zero
204         {
205             get
206             {
207                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
208                 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
209                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210                 return ret;
211             }
212         }
213
214         private Size Add(Size rhs)
215         {
216             Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
217             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218             return ret;
219         }
220
221         private Size Subtract(Size rhs)
222         {
223             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225             return ret;
226         }
227
228         private Size Multiply(Size rhs)
229         {
230             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232             return ret;
233         }
234
235         private Size Multiply(float rhs)
236         {
237             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239             return ret;
240         }
241
242         private Size Divide(Size rhs)
243         {
244             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
245             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246             return ret;
247         }
248
249         private Size Divide(float rhs)
250         {
251             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
252             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253             return ret;
254         }
255
256         private Size Subtract()
257         {
258             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
259             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260             return ret;
261         }
262
263         private float ValueOfIndex(uint index)
264         {
265             float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267             return ret;
268         }
269
270         /// <summary>
271         /// Check equality.
272         /// Utilizes appropriate machine epsilon values.
273         /// </summary>
274         /// <param name="rhs">The Size to test against</param>
275         /// <returns>True if the Sizes are equal</returns>
276         public bool EqualTo(Size rhs)
277         {
278             bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280             return ret;
281         }
282
283         /// <summary>
284         /// Check inequality.
285         /// Utilizes appropriate machine epsilon values.
286         /// </summary>
287         /// <param name="rhs">The Size to test against</param>
288         /// <returns>True if the Sizes are not equal</returns>
289         public bool NotEqualTo(Size rhs)
290         {
291             bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
292             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293             return ret;
294         }
295
296         /// <summary>
297         /// Width property for width component of Siz
298         /// </summary>
299         public float Width
300         {
301             set
302             {
303                 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
304                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305             }
306             get
307             {
308                 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
309                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310                 return ret;
311             }
312         }
313
314         /// <summary>
315         /// Height property for height component of Size
316         /// </summary>
317         public float Height
318         {
319             set
320             {
321                 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
322                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323             }
324             get
325             {
326                 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
327                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328                 return ret;
329             }
330         }
331
332         /// <summary>
333         /// Depth property for depth component of Size
334         /// </summary>
335         public float Depth
336         {
337             set
338             {
339                 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
340                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341             }
342             get
343             {
344                 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
345                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346                 return ret;
347             }
348         }
349
350         /// <summary>
351         /// Type cast operator, Size to Vector3.
352         /// </summary>
353         /// <param name="size">Object of Size type</param>
354         public static implicit operator Vector3(Size size)
355         {
356             return new Vector3(size.Width, size.Height, size.Depth);
357         }
358
359         /// <summary>
360         /// Type cast operator, Vector3 to Size type.
361         /// </summary>
362         /// <param name="vec">Object of Vector3 type</param>
363         public static implicit operator Size(Vector3 vec)
364         {
365             return new Size(vec.Width, vec.Height, vec.Depth);
366         }
367
368     }
369
370 }
371