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