Add comments for API reference of part 4
[platform/core/csapi/tizenfx.git] / src / 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         /// </summary>
47         public virtual void Dispose()
48         {
49             if (!Stage.IsInstalled())
50             {
51                 DisposeQueue.Instance.Add(this);
52                 return;
53             }
54
55             lock (this)
56             {
57                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
58                 {
59                     if (swigCMemOwn)
60                     {
61                         swigCMemOwn = false;
62                         NDalicPINVOKE.delete_Vector3(swigCPtr);
63                     }
64                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65                 }
66                 global::System.GC.SuppressFinalize(this);
67             }
68         }
69
70
71         /// <summary>
72         /// Addition operator.
73         /// </summary>
74         public static Size operator +(Size arg1, Size arg2)
75         {
76             return arg1.Add(arg2);
77         }
78
79         /// <summary>
80         /// Subtraction operator.
81         /// </summary>
82         public static Size operator -(Size arg1, Size arg2)
83         {
84             return arg1.Subtract(arg2);
85         }
86
87         /// <summary>
88         /// 
89         /// </summary>
90         public static Size operator -(Size arg1)
91         {
92             return arg1.Subtract();
93         }
94
95         /// <summary>
96         /// Multiplication operator.
97         /// </summary>
98         public static Size operator *(Size arg1, Size arg2)
99         {
100             return arg1.Multiply(arg2);
101         }
102
103         /// <summary>
104         /// Multiplication operator.
105         /// </summary>
106         public static Size operator *(Size arg1, float arg2)
107         {
108             return arg1.Multiply(arg2);
109         }
110
111         /// <summary>
112         /// Division operator.
113         /// </summary>
114         public static Size operator /(Size arg1, Size arg2)
115         {
116             return arg1.Divide(arg2);
117         }
118
119         /// <summary>
120         /// Division operator.
121         /// </summary>
122         public static Size operator /(Size arg1, float arg2)
123         {
124             return arg1.Divide(arg2);
125         }
126
127         /// <summary>
128         /// Array subscript operator.
129         /// </summary>
130         public float this[uint index]
131         {
132             get
133             {
134                 return ValueOfIndex(index);
135             }
136         }
137
138         /// <summary>
139         /// </summary>
140         public static Size GetSizeFromPtr(global::System.IntPtr cPtr)
141         {
142             Size ret = new Size(cPtr, false);
143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144             return ret;
145         }
146
147         /// <summary>
148         /// Constructor.
149         /// </summary>
150         public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
151         {
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153         }
154
155         /// <summary>
156         /// Constructor.
157         /// </summary>
158         public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
159         {
160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161         }
162
163         /// <summary>
164         /// Constructor.
165         /// </summary>
166         public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
167         {
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169         }
170
171         /// <summary>
172         /// </summary>
173         public static Size Zero
174         {
175             get
176             {
177                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
178                 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
179                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180                 return ret;
181             }
182         }
183
184         private Size Add(Size rhs)
185         {
186             Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
187             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188             return ret;
189         }
190
191         private Size Subtract(Size rhs)
192         {
193             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
194             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
195             return ret;
196         }
197
198         private Size Multiply(Size rhs)
199         {
200             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
201             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202             return ret;
203         }
204
205         private Size Multiply(float rhs)
206         {
207             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
208             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209             return ret;
210         }
211
212         private Size Divide(Size rhs)
213         {
214             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
215             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216             return ret;
217         }
218
219         private Size Divide(float rhs)
220         {
221             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
222             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223             return ret;
224         }
225
226         private Size Subtract()
227         {
228             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230             return ret;
231         }
232
233         private float ValueOfIndex(uint index)
234         {
235             float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
236             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237             return ret;
238         }
239
240         /// <summary>
241         /// Check equality.
242         /// Utilizes appropriate machine epsilon values.
243         /// </summary>
244         public bool EqualTo(Size rhs)
245         {
246             bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
247             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248             return ret;
249         }
250
251         /// <summary>
252         /// Check inequality.
253         /// Utilizes appropriate machine epsilon values.
254         /// </summary>
255         public bool NotEqualTo(Size rhs)
256         {
257             bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
258             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259             return ret;
260         }
261
262         /// <summary>
263         /// </summary>
264         public float Width
265         {
266             set
267             {
268                 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
269                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270             }
271             get
272             {
273                 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
274                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275                 return ret;
276             }
277         }
278
279         /// <summary>
280         /// </summary>
281         public float Height
282         {
283             set
284             {
285                 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
286                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287             }
288             get
289             {
290                 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
291                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292                 return ret;
293             }
294         }
295
296         /// <summary>
297         /// </summary>
298         public float Depth
299         {
300             set
301             {
302                 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
303                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304             }
305             get
306             {
307                 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
308                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309                 return ret;
310             }
311         }
312
313         /// <summary>
314         /// </summary>
315         public static implicit operator Vector3(Size size)
316         {
317             return new Vector3(size.Width, size.Height, size.Depth);
318         }
319
320         /// <summary>
321         /// </summary>
322         public static implicit operator Size(Vector3 vec)
323         {
324             return new Size(vec.Width, vec.Height, vec.Depth);
325         }
326
327     }
328
329 }
330