[NUI] Fix the crash when setting MinimumSize, MaximumSize (#1124)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Extents.cs
1 /*
2 * Copyright (c) 2019 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 using System;
18 using Tizen.NUI.Binding;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// Extents class describing the a collection of uint16_t.
24     /// </summary>
25     /// <since_tizen> 4 </since_tizen>
26     [TypeConverter(typeof(ExtentsTypeConverter))]
27     public class Extents : Disposable
28     {
29
30         /// <summary>
31         /// Extents class
32         /// </summary>
33         /// <since_tizen> 4 </since_tizen>
34         protected bool swigCMemOwn;
35
36         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
37
38         /// <summary>
39         /// Constructor.
40         /// </summary>
41         /// <since_tizen> 4 </since_tizen>
42         public Extents() : this(Interop.Extents.new_Extents__SWIG_0(), true)
43         {
44             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
45         }
46
47         /// <summary>
48         /// Constructor.
49         /// </summary>
50         /// <param name="copy">A reference to the copied Extents.</param>
51         /// <since_tizen> 4 </since_tizen>
52         public Extents(Extents copy) : this(Interop.Extents.new_Extents__SWIG_1(Extents.getCPtr(copy)), true)
53         {
54             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
55         }
56
57         /// <summary>
58         /// Constructor.
59         /// <param name="start">Start extent.</param>
60         /// <param name="end">End extent.</param>
61         /// <param name="top">Top extent.</param>
62         /// <param name="bottom">Bottom extent.</param>
63         /// </summary>
64         /// <since_tizen> 4 </since_tizen>
65         public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
66         {
67             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68         }
69
70         internal Extents(global::System.IntPtr cPtr, bool cMemoryOwn)
71         {
72             swigCMemOwn = cMemoryOwn;
73             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
74         }
75
76         /// <summary>
77         /// Constructor
78         /// </summary>
79         /// <param name="cb"></param>
80         /// <param name="start"></param>
81         /// <param name="end"></param>
82         /// <param name="top"></param>
83         /// <param name="bottom"></param>
84         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
85         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
86         public Extents(ExtentsChangedCallback cb, ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.new_Extents__SWIG_2(start, end, top, bottom), true)
87         {
88             callback = cb;
89             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90         }
91
92         /// <summary>
93         /// Copy other extents
94         /// </summary>
95         /// <param name="that"></param>
96         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
97         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
98         public void CopyFrom(Extents that)
99         {
100             Interop.Extents.Extents_start_set(swigCPtr, that.Start);
101             Interop.Extents.Extents_end_set(swigCPtr, that.End);
102             Interop.Extents.Extents_top_set(swigCPtr, that.Top);
103             Interop.Extents.Extents_bottom_set(swigCPtr, that.End);
104         }
105
106         /// <summary>
107         /// Constructor
108         /// </summary>
109         /// <param name="start"></param>
110         /// <param name="end"></param>
111         /// <param name="top"></param>
112         /// <param name="bottom"></param>
113         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
114                 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
115         public delegate void ExtentsChangedCallback(ushort start, ushort end, ushort top, ushort bottom);
116         private ExtentsChangedCallback callback = null;
117
118         /// <summary>
119         /// The Start extent.
120         /// </summary>
121         /// <since_tizen> 4 </since_tizen>
122         public ushort Start
123         {
124             set
125             {
126                 Interop.Extents.Extents_start_set(swigCPtr, value);
127                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128
129                 callback?.Invoke(Start, End, Top, Bottom);
130             }
131             get
132             {
133                 ushort ret = Interop.Extents.Extents_start_get(swigCPtr);
134                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135                 return ret;
136             }
137         }
138
139         /// <summary>
140         /// The End extend.
141         /// </summary>
142         /// <since_tizen> 4 </since_tizen>
143         public ushort End
144         {
145             set
146             {
147                 Interop.Extents.Extents_end_set(swigCPtr, value);
148                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149
150                 callback?.Invoke(Start, End, Top, Bottom);
151             }
152             get
153             {
154                 ushort ret = Interop.Extents.Extents_end_get(swigCPtr);
155                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
156                 return ret;
157             }
158         }
159
160         /// <summary>
161         /// The Top extend.
162         /// </summary>
163         /// <since_tizen> 4 </since_tizen>
164         public ushort Top
165         {
166             set
167             {
168                 Interop.Extents.Extents_top_set(swigCPtr, value);
169                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170
171                 callback?.Invoke(Start, End, Top, Bottom);
172             }
173             get
174             {
175                 ushort ret = Interop.Extents.Extents_top_get(swigCPtr);
176                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177                 return ret;
178             }
179         }
180
181         /// <summary>
182         /// The Bottom Extend.
183         /// </summary>
184         /// <since_tizen> 4 </since_tizen>
185         public ushort Bottom
186         {
187             set
188             {
189                 Interop.Extents.Extents_bottom_set(swigCPtr, value);
190                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191
192                 callback?.Invoke(Start, End, Top, Bottom);
193             }
194             get
195             {
196                 ushort ret = Interop.Extents.Extents_bottom_get(swigCPtr);
197                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198                 return ret;
199             }
200         }
201
202         /// <summary>
203         /// Equality operator.
204         /// </summary>
205         /// <param name="rhs">The Extents to test against.</param>
206         /// <returns>True if the extents are not equal.</returns>
207         /// <since_tizen> 4 </since_tizen>
208         public bool EqualTo(Extents rhs)
209         {
210             bool ret = Interop.Extents.Extents_EqualTo(swigCPtr, Extents.getCPtr(rhs));
211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212             return ret;
213         }
214
215         /// <summary>
216         /// Inequality operator.
217         /// </summary>
218         /// <param name="rhs">The Extents to test against.</param>
219         /// <returns>True if the extents are not equal.</returns>
220         /// <since_tizen> 4 </since_tizen>
221         public bool NotEqualTo(Extents rhs)
222         {
223             bool ret = Interop.Extents.Extents_NotEqualTo(swigCPtr, Extents.getCPtr(rhs));
224             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225             return ret;
226         }
227
228         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Extents obj)
229         {
230             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
231         }
232
233         internal Extents Assign(SWIGTYPE_p_uint16_t array)
234         {
235             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_1(swigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false);
236             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237             return ret;
238         }
239
240         internal Extents Assign(Extents copy)
241         {
242             Extents ret = new Extents(Interop.Extents.Extents_Assign__SWIG_0(swigCPtr, Extents.getCPtr(copy)), false);
243             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244             return ret;
245         }
246
247         /// <summary>
248         /// To make a Extents instance be disposed.
249         /// </summary>
250         /// <param name="type">Extents type</param>
251         /// <since_tizen> 4 </since_tizen>
252         protected override void Dispose(DisposeTypes type)
253         {
254             if (disposed)
255             {
256                 return;
257             }
258
259             //Release your own unmanaged resources here.
260             //You should not access any managed member here except static instance.
261             //because the execution order of Finalizes is non-deterministic.
262
263             if (swigCPtr.Handle != global::System.IntPtr.Zero)
264             {
265                 if (swigCMemOwn)
266                 {
267                     swigCMemOwn = false;
268                     Interop.Extents.delete_Extents(swigCPtr);
269                 }
270                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
271             }
272             base.Dispose(type);
273         }
274     }
275 }