[NUI] Fix comments according to document review
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / 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
18 using System;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
21
22 namespace Tizen.NUI
23 {
24     /// <summary>
25     /// Extents class describing the a collection of uint16_t.
26     /// </summary>
27     /// <since_tizen> 4 </since_tizen>
28     [Binding.TypeConverter(typeof(ExtentsTypeConverter))]
29     public class Extents : Disposable, ICloneable
30     {
31
32
33         /// <summary>
34         /// Constructor.
35         /// </summary>
36         /// <since_tizen> 4 </since_tizen>
37         public Extents() : this(Interop.Extents.NewExtents(), true)
38         {
39             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
40         }
41
42         /// <summary>
43         /// Constructor.
44         /// </summary>
45         /// <param name="copy">A reference to the copied Extents.</param>
46         /// <since_tizen> 4 </since_tizen>
47         public Extents(Extents copy) : this(Interop.Extents.NewExtents(Extents.getCPtr(copy)), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         /// <summary>
53         /// The type cast operator, ushort to Extents.
54         /// </summary>
55         /// <param name="value">A value of ushort type.</param>
56         /// <returns>return a Extents instance</returns>
57         [EditorBrowsable(EditorBrowsableState.Never)]
58         public static implicit operator Extents(ushort value)
59         {
60             return new Extents(value, value, value, value);
61         }
62
63         /// <summary>
64         /// Constructor.
65         /// <param name="start">Start extent.</param>
66         /// <param name="end">End extent.</param>
67         /// <param name="top">Top extent.</param>
68         /// <param name="bottom">Bottom extent.</param>
69         /// </summary>
70         /// <since_tizen> 4 </since_tizen>
71         public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.NewExtents(start, end, top, bottom), true)
72         {
73             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
74         }
75
76         internal Extents(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
77         {
78         }
79
80         /// <summary>
81         /// Constructor
82         /// </summary>
83         /// <param name="cb"></param>
84         /// <param name="start"></param>
85         /// <param name="end"></param>
86         /// <param name="top"></param>
87         /// <param name="bottom"></param>
88         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
89         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
90         public Extents(ExtentsChangedCallback cb, ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.NewExtents(start, end, top, bottom), true)
91         {
92             callback = cb;
93             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94         }
95
96         /// <summary>
97         /// Copy other extents
98         /// </summary>
99         /// <param name="that"></param>
100         /// <exception cref="ArgumentNullException"> Thrown when that is null. </exception>
101         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
102         [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
103         public void CopyFrom(Extents that)
104         {
105             if (null == that)
106             {
107                 throw new ArgumentNullException(nameof(that));
108             }
109             Interop.Extents.StartSet(SwigCPtr, that.Start);
110             Interop.Extents.EndSet(SwigCPtr, that.End);
111             Interop.Extents.TopSet(SwigCPtr, that.Top);
112             Interop.Extents.BottomSet(SwigCPtr, that.Bottom);
113         }
114
115         /// <summary>
116         /// Constructor
117         /// </summary>
118         /// <param name="start"></param>
119         /// <param name="end"></param>
120         /// <param name="top"></param>
121         /// <param name="bottom"></param>
122         /// <since_tizen> Only used by Tizen.NUI.Components, will not be opened </since_tizen>
123                 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
124         public delegate void ExtentsChangedCallback(ushort start, ushort end, ushort top, ushort bottom);
125         private ExtentsChangedCallback callback = null;
126
127         /// <summary>
128         /// The Start extent.
129         /// </summary>
130         /// <remarks>
131         /// The setter is deprecated in API8 and will be removed in API10. Ue new Extents(...) constructor.
132         /// </remarks>
133         /// <code>
134         /// // DO NOT use like the followings!
135         /// Extents extents = new Extents();
136         /// extents.Start = 1; 
137         /// // USE like this
138         /// ushort start = 1, end = 2, top = 3, bottom = 4;
139         /// Extents extents = new Extents(start, end, top, bottom);
140         /// </code>
141         /// <since_tizen> 4 </since_tizen>
142         public ushort Start
143         {
144             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor")]
145             set
146             {
147                 Interop.Extents.StartSet(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.StartGet(SwigCPtr);
155                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
156                 return ret;
157             }
158         }
159
160         /// <summary>
161         /// The End extend.
162         /// </summary>
163         /// <remarks>
164         /// The setter is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor.
165         /// </remarks>
166         /// <code>
167         /// // DO NOT use like the followings!
168         /// Extents extents = new Extents();
169         /// extents.End = 2; 
170         /// // USE like this
171         /// ushort start = 1, end = 2, top = 3, bottom = 4;
172         /// Extents extents = new Extents(start, end, top, bottom);
173         /// </code>
174         /// <since_tizen> 4 </since_tizen>
175         public ushort End
176         {
177             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor")]
178             set
179             {
180                 Interop.Extents.EndSet(SwigCPtr, value);
181                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182
183                 callback?.Invoke(Start, End, Top, Bottom);
184             }
185             get
186             {
187                 ushort ret = Interop.Extents.EndGet(SwigCPtr);
188                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
189                 return ret;
190             }
191         }
192
193         /// <summary>
194         /// The Top extend.
195         /// </summary>
196         /// <remarks>
197         /// The setter is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor.
198         /// </remarks>
199         /// <code>
200         /// // DO NOT use like the followings!
201         /// Extents extents = new Extents();
202         /// extents.Top = 3; 
203         /// // USE like this
204         /// ushort start = 1, end = 2, top = 3, bottom = 4;
205         /// Extents extents = new Extents(start, end, top, bottom);
206         /// </code>
207         /// <since_tizen> 4 </since_tizen>
208         public ushort Top
209         {
210             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor")]
211             set
212             {
213                 Interop.Extents.TopSet(SwigCPtr, value);
214                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215
216                 callback?.Invoke(Start, End, Top, Bottom);
217             }
218             get
219             {
220                 ushort ret = Interop.Extents.TopGet(SwigCPtr);
221                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
222                 return ret;
223             }
224         }
225
226         /// <summary>
227         /// The Bottom Extend.
228         /// </summary>
229         /// <remarks>
230         /// The setter is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor.
231         /// </remarks>
232         /// <code>
233         /// // DO NOT use like the followings!
234         /// Extents extents = new Extents();
235         /// extents.Bottom = 4; 
236         /// // USE like this
237         /// ushort start = 1, end = 2, top = 3, bottom = 4;
238         /// Extents extents = new Extents(start, end, top, bottom);
239         /// </code>
240         /// <since_tizen> 4 </since_tizen>
241         public ushort Bottom
242         {
243             [Obsolete("Do not use this setter, that is deprecated in API8 and will be removed in API10. Use new Extents(...) constructor")]
244             set
245             {
246                 Interop.Extents.BottomSet(SwigCPtr, value);
247                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248
249                 callback?.Invoke(Start, End, Top, Bottom);
250             }
251             get
252             {
253                 ushort ret = Interop.Extents.BottomGet(SwigCPtr);
254                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
255                 return ret;
256             }
257         }
258
259         /// <summary>
260         /// Equality operator.
261         /// </summary>
262         /// <param name="rhs">The Extents to test against.</param>
263         /// <returns>True if the extents are not equal.</returns>
264         /// <since_tizen> 4 </since_tizen>
265         public bool EqualTo(Extents rhs)
266         {
267             bool ret = Interop.Extents.EqualTo(SwigCPtr, Extents.getCPtr(rhs));
268             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269             return ret;
270         }
271
272         /// <summary>
273         /// Inequality operator.
274         /// </summary>
275         /// <param name="rhs">The Extents to test against.</param>
276         /// <returns>True if the extents are not equal.</returns>
277         /// <since_tizen> 4 </since_tizen>
278         public bool NotEqualTo(Extents rhs)
279         {
280             bool ret = Interop.Extents.NotEqualTo(SwigCPtr, Extents.getCPtr(rhs));
281             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282             return ret;
283         }
284
285         /// <inheritdoc/>
286         [EditorBrowsable(EditorBrowsableState.Never)]
287         public object Clone() => new Extents(this);
288
289         internal Extents Assign(SWIGTYPE_p_uint16_t array)
290         {
291             Extents ret = new Extents(Interop.Extents.AssignUint16(SwigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false);
292             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293             return ret;
294         }
295
296         internal Extents Assign(Extents copy)
297         {
298             Extents ret = new Extents(Interop.Extents.Assign(SwigCPtr, Extents.getCPtr(copy)), false);
299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300             return ret;
301         }
302
303         /// This will not be public opened.
304         [EditorBrowsable(EditorBrowsableState.Never)]
305         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
306         {
307             Interop.Extents.DeleteExtents(swigCPtr);
308         }
309     }
310 }