* limitations under the License.
*
*/
- using System;
- using Tizen.NUI.Binding;
+using System;
+using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI
{
/// The Rectangle class.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- [TypeConverter(typeof(RectangleTypeConverter))]
- public class Rectangle : Disposable
+ [Binding.TypeConverter(typeof(RectangleTypeConverter))]
+ public class Rectangle : Disposable, ICloneable
{
/// <summary>
- /// swigCMemOwn
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- protected bool swigCMemOwn;
-
- private global::System.Runtime.InteropServices.HandleRef swigCPtr;
-
- /// <summary>
/// The constructor.
/// </summary>
/// <since_tizen> 3 </since_tizen>
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal Rectangle(global::System.IntPtr cPtr, bool cMemoryOwn)
+ internal Rectangle(Rectangle other) : this(other.x, other.y, other.width, other.height)
+ {
+ }
+
+ internal Rectangle(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ internal Rectangle(RectangleChangedCallback cb, int x, int y, int width, int height) : this(Interop.Rectangle.new_Rectangle__SWIG_1(x, y, width, height), true)
+ {
+ callback = cb;
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ internal Rectangle(RectangleChangedCallback cb) : this()
+ {
+ callback = cb;
+ }
+
+ internal Rectangle(RectangleChangedCallback cb, Rectangle other) : this(cb, other.x, other.y, other.width, other.height)
{
- swigCMemOwn = cMemoryOwn;
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
/// <summary>
+ /// The type cast operator, int to Rectangle.
+ /// </summary>
+ /// <param name="value">A value of int type.</param>
+ /// <returns>return a Extents instance</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static implicit operator Rectangle(int value)
+ {
+ return new Rectangle(value, value, value, value);
+ }
+
+ internal delegate void RectangleChangedCallback(int x, int y, int width, int height);
+ private RectangleChangedCallback callback = null;
+
+ /// <summary>
/// The x position of the rectangle.
/// </summary>
+ /// <remarks>
+ /// The setter is deprecated in API8 and will be removed in API10. Please use new Rectangle(...) constructor.
+ /// </remarks>
+ /// <code>
+ /// // DO NOT use like the followings!
+ /// Rectangle rectangle = new Rectangle();
+ /// rectangle.X = 1;
+ /// // Please USE like this
+ /// int x = 1, y = 2, width = 3, height = 4;
+ /// Rectangle rectangle = new Rectangle(x, y, width, height);
+ /// </code>
/// <since_tizen> 3 </since_tizen>
public int X
{
set
{
+ Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Rectangle(...) constructor");
+
x = (value);
+
+ callback?.Invoke(X, Y, Width, Height);
}
get
{
/// <summary>
/// The Y position of the rectangle.
/// </summary>
+ /// <remarks>
+ /// The setter is deprecated in API8 and will be removed in API10. Please use new Rectangle(...) constructor.
+ /// </remarks>
+ /// <code>
+ /// // DO NOT use like the followings!
+ /// Rectangle rectangle = new Rectangle();
+ /// rectangle.Y = 2;
+ /// // Please USE like this
+ /// int x = 1, y = 2, width = 3, height = 4;
+ /// Rectangle rectangle = new Rectangle(x, y, width, height);
+ /// </code>
/// <since_tizen> 3 </since_tizen>
public int Y
{
set
{
+ Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Rectangle(...) constructor");
+
y = (value);
+
+ callback?.Invoke(X, Y, Width, Height);
}
get
{
/// <summary>
/// The width of the rectangle.
/// </summary>
+ /// <remarks>
+ /// The setter is deprecated in API8 and will be removed in API10. Please use new Rectangle(...) constructor.
+ /// </remarks>
+ /// <code>
+ /// // DO NOT use like the followings!
+ /// Rectangle rectangle = new Rectangle();
+ /// rectangle.Width = 3;
+ /// // Please USE like this
+ /// int x = 1, y = 2, width = 3, height = 4;
+ /// Rectangle rectangle = new Rectangle(x, y, width, height);
+ /// </code>
/// <since_tizen> 3 </since_tizen>
public int Width
{
set
{
+ Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Rectangle(...) constructor");
+
width = (value);
+
+ callback?.Invoke(X, Y, Width, Height);
}
get
{
/// <summary>
/// The height of the rectangle.
/// </summary>
+ /// <remarks>
+ /// The setter is deprecated in API8 and will be removed in API10. Please use new Rectangle(...) constructor.
+ /// </remarks>
+ /// <code>
+ /// // DO NOT use like the followings!
+ /// Rectangle rectangle = new Rectangle();
+ /// rectangle.Height = 4;
+ /// // Please USE like this
+ /// int x = 1, y = 2, width = 3, height = 4;
+ /// Rectangle rectangle = new Rectangle(x, y, width, height);
+ /// </code>
/// <since_tizen> 3 </since_tizen>
public int Height
{
set
{
+ Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Rectangle(...) constructor");
+
height = (value);
+
+ callback?.Invoke(X, Y, Width, Height);
}
get
{
/// <since_tizen> 4 </since_tizen>
public override bool Equals(object o)
{
- if(o == null)
+ if (o == null)
{
return false;
}
- if(!(o is Rectangle))
+ if (!(o is Rectangle))
{
return false;
}
return ret;
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public object Clone() => new Rectangle(this);
+
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rectangle obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
- /// <summary>
- /// Dispose.
- /// </summary>
- /// <since_tizen> 3 </since_tizen>
- protected override void Dispose(DisposeTypes type)
+ /// This will not be public opened.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
- if (disposed)
- {
- return;
- }
-
- //Release your own unmanaged resources here.
- //You should not access any managed member here except static instance.
- //because the execution order of Finalizes is non-deterministic.
-
- if (swigCPtr.Handle != global::System.IntPtr.Zero)
- {
- if (swigCMemOwn)
- {
- swigCMemOwn = false;
- Interop.Rectangle.delete_Rectangle(swigCPtr);
- }
- swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
- }
- disposed = true;
+ Interop.Rectangle.delete_Rectangle(swigCPtr);
}
+
+ /// <summary>
+ /// Determines whether the reference is null or the Rectangle has all 0 properties.
+ /// </summary>
+ internal static bool IsNullOrZero(Rectangle rectangle) => (rectangle == null || (rectangle.top == 0 && rectangle.right == 0 && rectangle.bottom == 0 && rectangle.left == 0));
}
}
\ No newline at end of file