[NUI] Add NUI-Layout (#293)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Layouting / LayoutItemWrapperImpl.cs
1 /*
2  * Copyright (c) 2018 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 Tizen.NUI.BaseComponents;
19
20 namespace Tizen.NUI
21 {
22     internal class LayoutItemWrapperImpl : BaseObject, ILayoutParent
23     {
24         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
25
26         public delegate void OnUnparentDelegate();
27         public delegate void OnRegisterChildPropertiesDelegate(string containerType);
28         public delegate void OnMeasureDelegate(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec);
29         public delegate void OnLayoutDelegate(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom);
30         public delegate void OnSizeChangedDelegate(LayoutSize newSize, LayoutSize oldSize);
31         public delegate void OnInitializeDelegate();
32
33         public OnUnparentDelegate OnUnparent;
34         public OnRegisterChildPropertiesDelegate OnRegisterChildProperties;
35         public OnMeasureDelegate OnMeasure;
36         public OnLayoutDelegate OnLayout;
37         public OnSizeChangedDelegate OnSizeChanged;
38         public OnInitializeDelegate OnInitialize;
39
40         internal LayoutItemWrapperImpl(global::System.IntPtr cPtr, bool cMemoryOwn) : base(LayoutPINVOKE.LayoutItemWrapperImpl_SWIGUpcast(cPtr), cMemoryOwn)
41         {
42             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43         }
44
45         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LayoutItemWrapperImpl obj)
46         {
47             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
48         }
49
50         protected override void Dispose(DisposeTypes type)
51         {
52             if (disposed)
53             {
54                 return;
55             }
56
57             if (type == DisposeTypes.Explicit)
58             {
59                 //Called by User
60                 //Release your own managed resources here.
61                 //You should release all of your own disposable objects here.
62
63             }
64
65             //Release your own unmanaged resources here.
66             //You should not access any managed member here except static instance.
67             //because the execution order of Finalizes is non-deterministic.
68
69             if (swigCPtr.Handle != global::System.IntPtr.Zero)
70             {
71                 if (swigCMemOwn)
72                 {
73                     swigCMemOwn = false;
74                 }
75                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
76             }
77             base.Dispose();
78         }
79
80         public LayoutItemWrapperImpl() : this(LayoutPINVOKE.new_LayoutItemWrapperImpl(), true)
81         {
82             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83             SwigDirectorConnect();
84         }
85
86         /* public LayoutItemWrapperImpl (Handle owner) : this (NDalicPINVOKE.LayoutItemWrapperImpl_New(Handle.getCPtr(owner)), true)
87         {
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89         }*/
90
91         public void Initialize(View owner, string containerType)
92         {
93             LayoutPINVOKE.LayoutItemWrapperImpl_Initialize(swigCPtr, View.getCPtr(owner), containerType);
94             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
95         }
96
97         public View GetOwner()
98         {
99             global::System.IntPtr cPtr = LayoutPINVOKE.LayoutItemWrapperImpl_GetOwner(swigCPtr);
100             View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
101             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102             return ret;
103         }
104
105         internal void Unparent()
106         {
107             LayoutPINVOKE.LayoutItemWrapperImpl_Unparent(swigCPtr);
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109         }
110
111         internal void SetAnimateLayout(bool animateLayout)
112         {
113             LayoutPINVOKE.LayoutItemWrapperImpl_SetAnimateLayout(swigCPtr, animateLayout);
114             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
115         }
116
117         internal bool IsLayoutAnimated()
118         {
119             bool ret = LayoutPINVOKE.LayoutItemWrapperImpl_IsLayoutAnimated(swigCPtr);
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121             return ret;
122         }
123
124         internal void RegisterChildProperties(string containerType)
125         {
126             LayoutPINVOKE.LayoutItemWrapperImpl_RegisterChildProperties(swigCPtr, containerType);
127             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128         }
129
130         internal void Measure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
131         {
132             LayoutPINVOKE.LayoutItemWrapperImpl_Measure(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec));
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134         }
135
136         internal void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
137         {
138             LayoutPINVOKE.LayoutItemWrapperImpl_Layout(swigCPtr, LayoutLength.getCPtr(left), LayoutLength.getCPtr(top), LayoutLength.getCPtr(right), LayoutLength.getCPtr(bottom));
139             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140         }
141
142         internal static LayoutLength GetDefaultSize(LayoutLength size, LayoutMeasureSpec measureSpec)
143         {
144             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetDefaultSize(LayoutLength.getCPtr(size), LayoutMeasureSpec.getCPtr(measureSpec)), true);
145             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146             return ret;
147         }
148
149         public ILayoutParent GetParent()
150         {
151             global::System.IntPtr cPtr = LayoutPINVOKE.LayoutItemWrapperImpl_GetParent(swigCPtr);
152             //ILayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new ILayoutParent(cPtr, false);
153             ILayoutParent ret = (cPtr == global::System.IntPtr.Zero) ? null : new LayoutItemWrapperImpl(cPtr, false);
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155             return ret;
156         }
157
158         internal void RequestLayout()
159         {
160             LayoutPINVOKE.LayoutItemWrapperImpl_RequestLayout(swigCPtr);
161             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162         }
163
164         internal bool IsLayoutRequested()
165         {
166             bool ret = LayoutPINVOKE.LayoutItemWrapperImpl_IsLayoutRequested(swigCPtr);
167             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168             return ret;
169         }
170
171         internal LayoutLength GetMeasuredWidth()
172         {
173             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetMeasuredWidth(swigCPtr), true);
174             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175             return ret;
176         }
177
178         internal LayoutLength GetMeasuredHeight()
179         {
180             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetMeasuredHeight(swigCPtr), true);
181             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
182             return ret;
183         }
184
185         internal MeasuredSize GetMeasuredWidthAndState()
186         {
187             MeasuredSize ret = new MeasuredSize(LayoutPINVOKE.LayoutItemWrapperImpl_GetMeasuredWidthAndState(swigCPtr), true);
188             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189             return ret;
190         }
191
192         internal MeasuredSize GetMeasuredHeightAndState()
193         {
194             MeasuredSize ret = new MeasuredSize(LayoutPINVOKE.LayoutItemWrapperImpl_GetMeasuredHeightAndState(swigCPtr), true);
195             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196             return ret;
197         }
198
199         internal LayoutLength GetSuggestedMinimumWidth()
200         {
201             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetSuggestedMinimumWidth(swigCPtr), true);
202             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203             return ret;
204         }
205
206         internal LayoutLength GetSuggestedMinimumHeight()
207         {
208             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetSuggestedMinimumHeight(swigCPtr), true);
209             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210             return ret;
211         }
212
213         internal void SetMinimumWidth(LayoutLength minWidth)
214         {
215             LayoutPINVOKE.LayoutItemWrapperImpl_SetMinimumWidth(swigCPtr, LayoutLength.getCPtr(minWidth));
216             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217         }
218
219         internal void SetMinimumHeight(LayoutLength minHeight)
220         {
221             LayoutPINVOKE.LayoutItemWrapperImpl_SetMinimumHeight(swigCPtr, LayoutLength.getCPtr(minHeight));
222             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223         }
224
225         internal LayoutLength GetMinimumWidth()
226         {
227             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetMinimumWidth(swigCPtr), true);
228             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229             return ret;
230         }
231
232         internal LayoutLength GetMinimumHeight()
233         {
234             LayoutLength ret = new LayoutLength(LayoutPINVOKE.LayoutItemWrapperImpl_GetMinimumHeight(swigCPtr), true);
235             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236             return ret;
237         }
238
239         public Extents GetPadding()
240         {
241             Extents ret = new Extents(LayoutPINVOKE.LayoutItemWrapperImpl_GetPadding(swigCPtr), true);
242             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243             return ret;
244         }
245
246         internal void SetMeasuredDimensions(MeasuredSize measuredWidth, MeasuredSize measuredHeight)
247         {
248             LayoutPINVOKE.LayoutItemWrapperImpl_SetMeasuredDimensions(swigCPtr, MeasuredSize.getCPtr(measuredWidth), MeasuredSize.getCPtr(measuredHeight));
249             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250         }
251
252         internal void OnUnparentNative()
253         {
254             LayoutPINVOKE.LayoutItemWrapperImpl_OnUnparent(swigCPtr);
255             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256         }
257
258         internal void OnRegisterChildPropertiesNative(string containerType)
259         {
260             LayoutPINVOKE.LayoutItemWrapperImpl_OnRegisterChildProperties(swigCPtr, containerType);
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262         }
263
264         internal void OnMeasureNative(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec)
265         {
266             LayoutPINVOKE.LayoutItemWrapperImpl_OnMeasure(swigCPtr, LayoutMeasureSpec.getCPtr(widthMeasureSpec), LayoutMeasureSpec.getCPtr(heightMeasureSpec));
267             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268         }
269
270         internal void OnLayoutNative(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom)
271         {
272             LayoutPINVOKE.LayoutItemWrapperImpl_OnLayout(swigCPtr, changed, LayoutLength.getCPtr(left), LayoutLength.getCPtr(top), LayoutLength.getCPtr(right), LayoutLength.getCPtr(bottom));
273             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274         }
275
276         internal void OnSizeChangedNative(LayoutSize newSize, LayoutSize oldSize)
277         {
278             LayoutPINVOKE.LayoutItemWrapperImpl_OnSizeChanged(swigCPtr, LayoutSize.getCPtr(newSize), LayoutSize.getCPtr(oldSize));
279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280         }
281
282         internal void OnInitializeNative()
283         {
284             LayoutPINVOKE.LayoutItemWrapperImpl_OnInitialize(swigCPtr);
285             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286         }
287
288         protected void SwigDirectorConnect()
289         {
290             //swigDelegate0 = new SwigDelegateLayoutItemWrapperImpl_0(SwigDirectorGetParent);
291             swigDelegate1 = new SwigDelegateLayoutItemWrapperImpl_1(SwigDirectorOnUnparent);
292             swigDelegate2 = new SwigDelegateLayoutItemWrapperImpl_2(SwigDirectorOnRegisterChildProperties);
293             swigDelegate3 = new SwigDelegateLayoutItemWrapperImpl_3(SwigDirectorOnMeasure);
294             swigDelegate4 = new SwigDelegateLayoutItemWrapperImpl_4(SwigDirectorOnLayout);
295             swigDelegate5 = new SwigDelegateLayoutItemWrapperImpl_5(SwigDirectorOnSizeChanged);
296             swigDelegate6 = new SwigDelegateLayoutItemWrapperImpl_6(SwigDirectorOnInitialize);
297
298             LayoutPINVOKE.LayoutItemWrapperImpl_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2, swigDelegate3, swigDelegate4, swigDelegate5, swigDelegate6);
299         }
300
301         private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)
302         {
303             global::System.Reflection.MethodInfo methodInfo = this.GetType().GetMethod(methodName, global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.NonPublic | global::System.Reflection.BindingFlags.Instance, null, methodTypes, null);
304             bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(LayoutItemWrapperImpl));
305             return hasDerivedMethod;
306         }
307
308         /*private global::System.IntPtr SwigDirectorGetParent()
309         {
310             return ILayoutParent.getCPtr(GetParent()).Handle;
311         }*/
312
313         private void SwigDirectorOnUnparent()
314         {
315             OnUnparent();
316         }
317
318         private void SwigDirectorOnRegisterChildProperties(string containerType)
319         {
320             OnRegisterChildProperties(containerType);
321         }
322
323         private void SwigDirectorOnMeasure(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec)
324         {
325             OnMeasure(new LayoutMeasureSpec(widthMeasureSpec, true), new LayoutMeasureSpec(heightMeasureSpec, true));
326         }
327
328         private void SwigDirectorOnLayout(bool changed, global::System.IntPtr left, global::System.IntPtr top, global::System.IntPtr right, global::System.IntPtr bottom)
329         {
330             OnLayout(changed, new LayoutLength(left, true), new LayoutLength(top, true), new LayoutLength(right, true), new LayoutLength(bottom, true));
331         }
332
333         private void SwigDirectorOnSizeChanged(global::System.IntPtr newSize, global::System.IntPtr oldSize)
334         {
335             OnSizeChanged(new LayoutSize(newSize, true), new LayoutSize(oldSize, true));
336         }
337
338         private void SwigDirectorOnInitialize()
339         {
340             OnInitialize();
341         }
342
343         public delegate global::System.IntPtr SwigDelegateLayoutItemWrapperImpl_0();
344         public delegate void SwigDelegateLayoutItemWrapperImpl_1();
345         public delegate void SwigDelegateLayoutItemWrapperImpl_2(string containerType);
346         public delegate void SwigDelegateLayoutItemWrapperImpl_3(global::System.IntPtr widthMeasureSpec, global::System.IntPtr heightMeasureSpec);
347         public delegate void SwigDelegateLayoutItemWrapperImpl_4(bool changed, global::System.IntPtr left, global::System.IntPtr top, global::System.IntPtr right, global::System.IntPtr bottom);
348         public delegate void SwigDelegateLayoutItemWrapperImpl_5(global::System.IntPtr newSize, global::System.IntPtr oldSize);
349         public delegate void SwigDelegateLayoutItemWrapperImpl_6();
350
351         private SwigDelegateLayoutItemWrapperImpl_0 swigDelegate0;
352         private SwigDelegateLayoutItemWrapperImpl_1 swigDelegate1;
353         private SwigDelegateLayoutItemWrapperImpl_2 swigDelegate2;
354         private SwigDelegateLayoutItemWrapperImpl_3 swigDelegate3;
355         private SwigDelegateLayoutItemWrapperImpl_4 swigDelegate4;
356         private SwigDelegateLayoutItemWrapperImpl_5 swigDelegate5;
357         private SwigDelegateLayoutItemWrapperImpl_6 swigDelegate6;
358     }
359 } // namespace Tizen.NUI