1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
23 public class Rectangle : global::System.IDisposable
25 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 protected bool swigCMemOwn;
28 internal Rectangle(global::System.IntPtr cPtr, bool cMemoryOwn)
30 swigCMemOwn = cMemoryOwn;
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rectangle obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 //A Flag to check who called Dispose(). (By User or DisposeQueue)
40 private bool isDisposeQueued = false;
41 //A Flat to check if it is already disposed.
42 protected bool disposed = false;
48 isDisposeQueued = true;
49 DisposeQueue.Instance.Add(this);
55 //Throw excpetion if Dispose() is called in separate thread.
56 if (!Window.IsInstalled())
58 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
63 Dispose(DisposeTypes.Implicit);
67 Dispose(DisposeTypes.Explicit);
68 System.GC.SuppressFinalize(this);
72 protected virtual void Dispose(DisposeTypes type)
79 if(type == DisposeTypes.Explicit)
82 //Release your own managed resources here.
83 //You should release all of your own disposable objects here.
86 //Release your own unmanaged resources here.
87 //You should not access any managed member here except static instance.
88 //because the execution order of Finalizes is non-deterministic.
90 if (swigCPtr.Handle != global::System.IntPtr.Zero)
95 NDalicPINVOKE.delete_Rectangle(swigCPtr);
97 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
103 /// Equality operator.
105 /// <param name="a">First operand</param>
106 /// <param name="b">Second operand</param>
107 /// <returns>True if boxes are exactly same</returns>
108 public static bool operator ==(Rectangle a, Rectangle b)
110 // If both are null, or both are same instance, return true.
111 if (System.Object.ReferenceEquals(a, b))
116 // If one is null, but not both, return false.
117 if (((object)a == null) || ((object)b == null))
122 // Return true if the fields match:
123 return a.X == b.X && a.Y == b.Y && a.Width == b.Width && a.Height == b.Height;
127 /// Inequality operator.
129 /// <param name="a">The first rectangle</param>
130 /// <param name="b">The second rectangle</param>
131 /// <returns>True if rectangles are not identical</returns>
132 public static bool operator !=(Rectangle a, Rectangle b)
138 /// X position of the rectangle
153 /// Y position of the rectangle
168 /// Width of the rectangle
183 /// Height of the rectangle
200 public Rectangle() : this(NDalicPINVOKE.new_Rectangle__SWIG_0(), true)
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 /// <param name="x">X coordinate (or left)</param>
209 /// <param name="y">Y coordinate (or right)</param>
210 /// <param name="width">Width (or bottom)</param>
211 /// <param name="height">Height (or top)</param>
212 public Rectangle(int x, int y, int width, int height) : this(NDalicPINVOKE.new_Rectangle__SWIG_1(x, y, width, height), true)
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 /// Assignment from individual values.
220 /// <param name="newX">X coordinate</param>
221 /// <param name="newY">Y coordinate</param>
222 /// <param name="newWidth">Width</param>
223 /// <param name="newHeight">Height</param>
224 public void Set(int newX, int newY, int newWidth, int newHeight)
226 NDalicPINVOKE.Rectangle_Set(swigCPtr, newX, newY, newWidth, newHeight);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 /// Determines whether or not this Rectangle is empty.
233 /// <returns>True if width or height are zero</returns>
234 public bool IsEmpty()
236 bool ret = NDalicPINVOKE.Rectangle_IsEmpty(swigCPtr);
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// Gets the left of the rectangle.
244 /// <returns>The left edge of the rectangle</returns>
247 int ret = NDalicPINVOKE.Rectangle_Left(swigCPtr);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 /// Gets the right of the rectangle.
255 /// <returns>The right edge of the rectangle</returns>
258 int ret = NDalicPINVOKE.Rectangle_Right(swigCPtr);
259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 /// Gets the top of the rectangle.
266 /// <returns>The top of the rectangle</returns>
269 int ret = NDalicPINVOKE.Rectangle_Top(swigCPtr);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 /// Gets the bottom of the rectangle.
277 /// <returns>The bottom of the rectangle</returns>
280 int ret = NDalicPINVOKE.Rectangle_Bottom(swigCPtr);
281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286 /// Gets the area of the rectangle.
288 /// <returns>The area of the rectangle</returns>
291 int ret = NDalicPINVOKE.Rectangle_Area(swigCPtr);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 /// Determines whether or not this rectangle and the specified rectangle intersect.
299 /// <param name="other">The other rectangle to test against this rectangle</param>
300 /// <returns>True if the rectangles intersect</returns>
301 public bool Intersects(Rectangle other)
303 bool ret = NDalicPINVOKE.Rectangle_Intersects(swigCPtr, Rectangle.getCPtr(other));
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 /// Determines whether or not this Rectangle contains the specified rectangle.
311 /// <param name="other">The other rectangle to test against this rectangle</param>
312 /// <returns>True if the specified rectangle is contained</returns>
313 public bool Contains(Rectangle other)
315 bool ret = NDalicPINVOKE.Rectangle_Contains(swigCPtr, Rectangle.getCPtr(other));
316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 NDalicPINVOKE.Rectangle_x_set(swigCPtr, value);
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 int ret = NDalicPINVOKE.Rectangle_x_get(swigCPtr);
330 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 NDalicPINVOKE.Rectangle_left_set(swigCPtr, value);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344 int ret = NDalicPINVOKE.Rectangle_left_get(swigCPtr);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354 NDalicPINVOKE.Rectangle_y_set(swigCPtr, value);
355 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359 int ret = NDalicPINVOKE.Rectangle_y_get(swigCPtr);
360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369 NDalicPINVOKE.Rectangle_right_set(swigCPtr, value);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 int ret = NDalicPINVOKE.Rectangle_right_get(swigCPtr);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 NDalicPINVOKE.Rectangle_width_set(swigCPtr, value);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 int ret = NDalicPINVOKE.Rectangle_width_get(swigCPtr);
390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 NDalicPINVOKE.Rectangle_bottom_set(swigCPtr, value);
400 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 int ret = NDalicPINVOKE.Rectangle_bottom_get(swigCPtr);
405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
414 NDalicPINVOKE.Rectangle_height_set(swigCPtr, value);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419 int ret = NDalicPINVOKE.Rectangle_height_get(swigCPtr);
420 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429 NDalicPINVOKE.Rectangle_top_set(swigCPtr, value);
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 int ret = NDalicPINVOKE.Rectangle_top_get(swigCPtr);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();