nui 0.2.30 release
[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     public class Size : global::System.IDisposable
22     {
23         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
24         protected bool swigCMemOwn;
25
26         internal Size(global::System.IntPtr cPtr, bool cMemoryOwn)
27         {
28             swigCMemOwn = cMemoryOwn;
29             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
30         }
31
32         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size obj)
33         {
34             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
35         }
36
37         ~Size()
38         {
39             DisposeQueue.Instance.Add(this);
40         }
41
42         public virtual void Dispose()
43         {
44             if (!Stage.IsInstalled())
45             {
46                 DisposeQueue.Instance.Add(this);
47                 return;
48             }
49
50             lock (this)
51             {
52                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
53                 {
54                     if (swigCMemOwn)
55                     {
56                         swigCMemOwn = false;
57                         NDalicPINVOKE.delete_Vector3(swigCPtr);
58                     }
59                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
60                 }
61                 global::System.GC.SuppressFinalize(this);
62             }
63         }
64
65
66         public static Size operator +(Size arg1, Size arg2)
67         {
68             return arg1.Add(arg2);
69         }
70
71         public static Size operator -(Size arg1, Size arg2)
72         {
73             return arg1.Subtract(arg2);
74         }
75
76         public static Size operator -(Size arg1)
77         {
78             return arg1.Subtract();
79         }
80
81         public static Size operator *(Size arg1, Size arg2)
82         {
83             return arg1.Multiply(arg2);
84         }
85
86         public static Size operator *(Size arg1, float arg2)
87         {
88             return arg1.Multiply(arg2);
89         }
90
91         public static Size operator /(Size arg1, Size arg2)
92         {
93             return arg1.Divide(arg2);
94         }
95
96         public static Size operator /(Size arg1, float arg2)
97         {
98             return arg1.Divide(arg2);
99         }
100
101         public float this[uint index]
102         {
103             get
104             {
105                 return ValueOfIndex(index);
106             }
107         }
108
109         public static Size GetSizeFromPtr(global::System.IntPtr cPtr)
110         {
111             Size ret = new Size(cPtr, false);
112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113             return ret;
114         }
115
116
117         public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
118         {
119             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120         }
121
122         public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
123         {
124             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
125         }
126
127         public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
128         {
129             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130         }
131
132
133         public static Size Zero
134         {
135             get
136             {
137                 global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
138                 Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
139                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140                 return ret;
141             }
142         }
143
144         private Size Add(Size rhs)
145         {
146             Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148             return ret;
149         }
150
151         private Size Subtract(Size rhs)
152         {
153             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155             return ret;
156         }
157
158         private Size Multiply(Size rhs)
159         {
160             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162             return ret;
163         }
164
165         private Size Multiply(float rhs)
166         {
167             Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
168             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169             return ret;
170         }
171
172         private Size Divide(Size rhs)
173         {
174             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
175             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176             return ret;
177         }
178
179         private Size Divide(float rhs)
180         {
181             Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
182             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183             return ret;
184         }
185
186         private Size Subtract()
187         {
188             Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190             return ret;
191         }
192
193         private float ValueOfIndex(uint index)
194         {
195             float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197             return ret;
198         }
199
200         public bool EqualTo(Size rhs)
201         {
202             bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204             return ret;
205         }
206
207         public bool NotEqualTo(Size rhs)
208         {
209             bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
210             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211             return ret;
212         }
213
214
215         public float Width
216         {
217             set
218             {
219                 NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
220                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221             }
222             get
223             {
224                 float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
225                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226                 return ret;
227             }
228         }
229
230         public float Height
231         {
232             set
233             {
234                 NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
235                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236             }
237             get
238             {
239                 float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
240                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241                 return ret;
242             }
243         }
244
245         public float Depth
246         {
247             set
248             {
249                 NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
250                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251             }
252             get
253             {
254                 float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
255                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256                 return ret;
257             }
258         }
259
260
261         public static implicit operator Vector3(Size size)
262         {
263             return new Vector3(size.Width, size.Height, size.Depth);
264         }
265
266         public static implicit operator Size(Vector3 vec)
267         {
268             return new Size(vec.Width, vec.Height, vec.Depth);
269         }
270
271     }
272
273 }
274