2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using Tizen.NUI.Binding;
23 /// The Rectangle class.
25 /// <since_tizen> 3 </since_tizen>
26 [TypeConverter(typeof(RectangleTypeConverter))]
27 public class Rectangle : Disposable
32 /// <since_tizen> 3 </since_tizen>
33 protected bool swigCMemOwn;
35 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
40 /// <since_tizen> 3 </since_tizen>
41 public Rectangle() : this(Interop.Rectangle.new_Rectangle__SWIG_0(), true)
43 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
49 /// <param name="x">The x coordinate (or left).</param>
50 /// <param name="y">The y coordinate (or right).</param>
51 /// <param name="width">The width (or bottom).</param>
52 /// <param name="height">The height (or top).</param>
53 /// <since_tizen> 3 </since_tizen>
54 public Rectangle(int x, int y, int width, int height) : this(Interop.Rectangle.new_Rectangle__SWIG_1(x, y, width, height), true)
56 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59 internal Rectangle(global::System.IntPtr cPtr, bool cMemoryOwn)
61 swigCMemOwn = cMemoryOwn;
62 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
66 /// The x position of the rectangle.
68 /// <since_tizen> 3 </since_tizen>
82 /// The Y position of the rectangle.
84 /// <since_tizen> 3 </since_tizen>
98 /// The width of the rectangle.
100 /// <since_tizen> 3 </since_tizen>
114 /// The height of the rectangle.
116 /// <since_tizen> 3 </since_tizen>
133 Interop.Rectangle.Rectangle_x_set(swigCPtr, value);
134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
138 int ret = Interop.Rectangle.Rectangle_x_get(swigCPtr);
139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148 Interop.Rectangle.Rectangle_left_set(swigCPtr, value);
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153 int ret = Interop.Rectangle.Rectangle_left_get(swigCPtr);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
163 Interop.Rectangle.Rectangle_y_set(swigCPtr, value);
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 int ret = Interop.Rectangle.Rectangle_y_get(swigCPtr);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 Interop.Rectangle.Rectangle_right_set(swigCPtr, value);
179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
183 int ret = Interop.Rectangle.Rectangle_right_get(swigCPtr);
184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193 Interop.Rectangle.Rectangle_width_set(swigCPtr, value);
194 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 int ret = Interop.Rectangle.Rectangle_width_get(swigCPtr);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 Interop.Rectangle.Rectangle_bottom_set(swigCPtr, value);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 int ret = Interop.Rectangle.Rectangle_bottom_get(swigCPtr);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 Interop.Rectangle.Rectangle_height_set(swigCPtr, value);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228 int ret = Interop.Rectangle.Rectangle_height_get(swigCPtr);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 Interop.Rectangle.Rectangle_top_set(swigCPtr, value);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 int ret = Interop.Rectangle.Rectangle_top_get(swigCPtr);
244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250 /// THe Equality operator.
252 /// <param name="a">The first operand.</param>
253 /// <param name="b">The second operand.</param>
254 /// <returns>True if the boxes are exactly the same.</returns>
255 /// <since_tizen> 3 </since_tizen>
256 public static bool operator ==(Rectangle a, Rectangle b)
258 // If both are null, or both are same instance, return true.
259 if (System.Object.ReferenceEquals(a, b))
264 // If one is null, but not both, return false.
265 if (((object)a == null) || ((object)b == null))
270 // Return true if the fields match:
271 return a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height;
275 /// Inequality operator.
277 /// <param name="a">The first rectangle.</param>
278 /// <param name="b">The second rectangle.</param>
279 /// <returns>True if the rectangles are not identical.</returns>
280 /// <since_tizen> 3 </since_tizen>
281 public static bool operator !=(Rectangle a, Rectangle b)
287 /// Equality operator.
289 /// <param name="o">The object to compare with the current object.</param>
290 /// <returns>True if boxes are exactly same.</returns>
291 /// <since_tizen> 4 </since_tizen>
292 public override bool Equals(object o)
298 if(!(o is Rectangle))
302 Rectangle r = (Rectangle)o;
304 // Return true if the fields match:
305 return X == r.X && Y == r.Y && Width == r.Width && Height == r.Height;
309 /// Serves as the default hash function.
311 /// <returns>A hash code for the current object.</returns>
312 /// <since_tizen> 4 </since_tizen>
313 public override int GetHashCode()
315 return base.GetHashCode();
319 /// Assignment from individual values.
321 /// <param name="newX">The x coordinate.</param>
322 /// <param name="newY">The y coordinate.</param>
323 /// <param name="newWidth">The width.</param>
324 /// <param name="newHeight">The height.</param>
325 /// <since_tizen> 3 </since_tizen>
326 public void Set(int newX, int newY, int newWidth, int newHeight)
328 Interop.Rectangle.Rectangle_Set(swigCPtr, newX, newY, newWidth, newHeight);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// Determines whether or not this rectangle is empty.
335 /// <returns>True if width or height are zero.</returns>
336 /// <since_tizen> 3 </since_tizen>
337 public bool IsEmpty()
339 bool ret = Interop.Rectangle.Rectangle_IsEmpty(swigCPtr);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345 /// Gets the left of the rectangle.
347 /// <returns>The left edge of the rectangle.</returns>
348 /// <since_tizen> 3 </since_tizen>
351 int ret = Interop.Rectangle.Rectangle_Left(swigCPtr);
352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 /// Gets the right of the rectangle.
359 /// <returns>The right edge of the rectangle.</returns>
360 /// <since_tizen> 3 </since_tizen>
363 int ret = Interop.Rectangle.Rectangle_Right(swigCPtr);
364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 /// Gets the top of the rectangle.
371 /// <returns>The top of the rectangle.</returns>
372 /// <since_tizen> 3 </since_tizen>
375 int ret = Interop.Rectangle.Rectangle_Top(swigCPtr);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381 /// Gets the bottom of the rectangle.
383 /// <returns>The bottom of the rectangle.</returns>
384 /// <since_tizen> 3 </since_tizen>
387 int ret = Interop.Rectangle.Rectangle_Bottom(swigCPtr);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393 /// Gets the area of the rectangle.
395 /// <returns>The area of the rectangle.</returns>
396 /// <since_tizen> 3 </since_tizen>
399 int ret = Interop.Rectangle.Rectangle_Area(swigCPtr);
400 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
405 /// Determines whether or not this rectangle and the specified rectangle intersect.
407 /// <param name="other">The other rectangle to test against this rectangle.</param>
408 /// <returns>True if the rectangles intersect.</returns>
409 /// <since_tizen> 3 </since_tizen>
410 public bool Intersects(Rectangle other)
412 bool ret = Interop.Rectangle.Rectangle_Intersects(swigCPtr, Rectangle.getCPtr(other));
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 /// Determines whether or not this rectangle contains the specified rectangle.
420 /// <param name="other">The other rectangle to test against this rectangle.</param>
421 /// <returns>True if the specified rectangle is contained.</returns>
422 /// <since_tizen> 3 </since_tizen>
423 public bool Contains(Rectangle other)
425 bool ret = Interop.Rectangle.Rectangle_Contains(swigCPtr, Rectangle.getCPtr(other));
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rectangle obj)
432 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
438 /// <since_tizen> 3 </since_tizen>
439 protected override void Dispose(DisposeTypes type)
446 //Release your own unmanaged resources here.
447 //You should not access any managed member here except static instance.
448 //because the execution order of Finalizes is non-deterministic.
450 if (swigCPtr.Handle != global::System.IntPtr.Zero)
455 Interop.Rectangle.delete_Rectangle(swigCPtr);
457 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);