Add comments for API reference of part 4
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Size2D.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     /// A two dimensional size
23     /// </summary>
24     public class Size2D : global::System.IDisposable
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27         protected bool swigCMemOwn;
28
29         internal Size2D(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(Size2D obj)
36         {
37             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38         }
39
40         ~Size2D()
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_Vector2(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         /// <summary>
71         /// Addition operator.
72         /// </summary>
73         public static Size2D operator +(Size2D arg1, Size2D arg2)
74         {
75             return arg1.Add(arg2);
76         }
77
78         /// <summary>
79         /// Subtraction operator.
80         /// </summary>
81         public static Size2D operator -(Size2D arg1, Size2D arg2)
82         {
83             return arg1.Subtract(arg2);
84         }
85
86         /// <summary>
87         /// </summary>
88         public static Size2D operator -(Size2D arg1)
89         {
90             return arg1.Subtract();
91         }
92
93         /// <summary>
94         /// Multiplication operator.
95         /// </summary>
96         public static Size2D operator *(Size2D arg1, Size2D arg2)
97         {
98             return arg1.Multiply(arg2);
99         }
100
101         /// <summary>
102         /// Multiplication operator.
103         /// </summary>
104         public static Size2D operator *(Size2D arg1, int arg2)
105         {
106             return arg1.Multiply(arg2);
107         }
108
109         /// <summary>
110         /// Division operator.
111         /// </summary>
112         public static Size2D operator /(Size2D arg1, Size2D arg2)
113         {
114             return arg1.Divide(arg2);
115         }
116
117         /// <summary>
118         /// Division operator.
119         /// </summary>
120         public static Size2D operator /(Size2D arg1, int arg2)
121         {
122             return arg1.Divide(arg2);
123         }
124
125         /// <summary>
126         /// Array subscript operator.
127         /// </summary>
128         public float this[uint index]
129         {
130             get
131             {
132                 return ValueOfIndex(index);
133             }
134         }
135
136         /// <summary>
137         public static Size2D GetSize2DFromPtr(global::System.IntPtr cPtr)
138         {
139             Size2D ret = new Size2D(cPtr, false);
140             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141             return ret;
142         }
143
144         /// <summary>
145         /// Constructor.
146         /// </summary>
147         public Size2D() : this(NDalicPINVOKE.new_Vector2__SWIG_0(), true)
148         {
149             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150         }
151
152         /// <summary>
153         /// Constructor.
154         /// </summary>
155         public Size2D(int x, int y) : this(NDalicPINVOKE.new_Vector2__SWIG_1((float)x, (float)y), true)
156         {
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158         }
159
160         /// <summary>
161         /// Constructor.
162         /// </summary>
163         public Size2D(Size size) : this(NDalicPINVOKE.new_Vector2__SWIG_3(Size.getCPtr(size)), true)
164         {
165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
166         }
167
168         private Size2D Add(Size2D rhs)
169         {
170             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Add(swigCPtr, Size2D.getCPtr(rhs)), true);
171             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172             return ret;
173         }
174
175         private Size2D Subtract(Size2D rhs)
176         {
177             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Subtract__SWIG_0(swigCPtr, Size2D.getCPtr(rhs)), true);
178             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179             return ret;
180         }
181
182
183         private Size2D Multiply(Size2D rhs)
184         {
185             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Multiply__SWIG_0(swigCPtr, Size2D.getCPtr(rhs)), true);
186             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187             return ret;
188         }
189
190         private Size2D Multiply(int rhs)
191         {
192             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Multiply__SWIG_1(swigCPtr, (float)rhs), true);
193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194             return ret;
195         }
196
197
198         private Size2D Divide(Size2D rhs)
199         {
200             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Divide__SWIG_0(swigCPtr, Size2D.getCPtr(rhs)), true);
201             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
202             return ret;
203         }
204
205         private Size2D Divide(int rhs)
206         {
207             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Divide__SWIG_1(swigCPtr, (float)rhs), true);
208             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
209             return ret;
210         }
211
212         private Size2D Subtract()
213         {
214             Size2D ret = new Size2D(NDalicPINVOKE.Vector2_Subtract__SWIG_1(swigCPtr), true);
215             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
216             return ret;
217         }
218
219         /// <summary>
220         /// Check equality.
221         /// Utilizes appropriate machine epsilon values.
222         /// </summary>
223         public bool EqualTo(Size2D rhs)
224         {
225             bool ret = NDalicPINVOKE.Vector2_EqualTo(swigCPtr, Size2D.getCPtr(rhs));
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227             return ret;
228         }
229
230         /// <summary>
231         /// Check inequality.
232         /// Utilizes appropriate machine epsilon values.
233         /// </summary>
234         public bool NotEqualTo(Size2D rhs)
235         {
236             bool ret = NDalicPINVOKE.Vector2_NotEqualTo(swigCPtr, Size2D.getCPtr(rhs));
237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238             return ret;
239         }
240
241         private int ValueOfIndex(uint index)
242         {
243             int ret = (int)NDalicPINVOKE.Vector2_ValueOfIndex__SWIG_0(swigCPtr, index);
244             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245             return ret;
246         }
247
248         /// <summary>
249         /// </summary>
250         public int Width
251         {
252             set
253             {
254                 NDalicPINVOKE.Vector2_Width_set(swigCPtr, (float)value);
255                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256             }
257             get
258             {
259                 float ret = NDalicPINVOKE.Vector2_Width_get(swigCPtr);
260                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261                 return (int)ret;
262             }
263         }
264
265         /// <summary>
266         /// </summary>
267         public int Height
268         {
269             set
270             {
271                 NDalicPINVOKE.Vector2_Height_set(swigCPtr, (float)value);
272                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273             }
274             get
275             {
276                 float ret = NDalicPINVOKE.Vector2_Height_get(swigCPtr);
277                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278                 return (int)ret;
279             }
280         }
281
282         /// <summary>
283         /// </summary>
284         public static implicit operator Vector2(Size2D size)
285         {
286             return new Vector2((float)size.Width, (float)size.Height);
287         }
288
289         /// <summary>
290         /// </summary>
291         public static implicit operator Size2D(Vector2 vec)
292         {
293             return new Size2D((int)vec.X, (int)vec.Y);
294         }
295
296     }
297
298 }
299