[NUI] Fix Svace issue (#949)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / WidgetImpl.cs
1 /*
2  * Copyright(c) 2017 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 System.ComponentModel;
19 using System.Runtime.InteropServices;
20
21 namespace Tizen.NUI
22 {
23     internal class WidgetImpl : BaseObject
24     {
25         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26
27         internal WidgetImpl() : this( Interop.WidgetImpl.WidgetImpl_New(), true )
28         {
29             SwigDirectorConnect();
30         }
31
32         internal WidgetImpl(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.WidgetImpl.WidgetImpl_SWIGUpcast(cPtr), cMemoryOwn)
33         {
34             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35         }
36
37         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(WidgetImpl obj)
38         {
39             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40         }
41
42         protected override void Dispose(DisposeTypes type)
43         {
44             if (disposed)
45             {
46                 return;
47             }
48
49             if (type == DisposeTypes.Explicit)
50             {
51                 //Called by User
52                 //Release your own managed resources here.
53                 //You should release all of your own disposable objects here.
54             }
55
56             //Release your own unmanaged resources here.
57             //You should not access any managed member here except static instance.
58             //because the execution order of Finalizes is non-deterministic.
59
60             if (swigCPtr.Handle != global::System.IntPtr.Zero)
61             {
62                 if (swigCMemOwn)
63                 {
64                     swigCMemOwn = false;
65                     //throw new global::System.MethodAccessException("C++ destructor does not have public access");
66                 }
67                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
68             }
69
70             base.Dispose(type);
71         }
72
73         public class WIdgetInstanceOnCreateArgs : EventArgs
74         {
75             private string _contentInfo;
76             private Window _window;
77
78             public string ContentInfo
79             {
80                 get
81                 {
82                     return _contentInfo;
83                 }
84                 set
85                 {
86                     _contentInfo = value;
87                 }
88             }
89
90             public Window Window
91             {
92                 get
93                 {
94                     return _window;
95                 }
96                 set
97                 {
98                     _window = value;
99                 }
100             }
101         }
102
103         private EventHandler<WIdgetInstanceOnCreateArgs> _widgetInstanceOnCreateEventHandler;
104         public event EventHandler<WIdgetInstanceOnCreateArgs> WidgetInstanceCreated
105         {
106             add
107             {
108                 _widgetInstanceOnCreateEventHandler += value;
109             }
110             remove
111             {
112                 _widgetInstanceOnCreateEventHandler -= value;
113             }
114         }
115
116         public class WIdgetInstanceOnDestroyArgs : EventArgs
117         {
118             private string _contentInfo;
119             private Widget.TerminationType _terminateType;
120
121             public string ContentInfo
122             {
123                 get
124                 {
125                     return _contentInfo;
126                 }
127                 set
128                 {
129                     _contentInfo = value;
130                 }
131             }
132
133             public Widget.TerminationType TerminateType
134             {
135                 get
136                 {
137                     return _terminateType;
138                 }
139                 set
140                 {
141                     _terminateType = value;
142                 }
143             }
144         }
145
146         private EventHandler<WIdgetInstanceOnDestroyArgs> _widgetInstanceOnDestroyEventHandler;
147         public event EventHandler<WIdgetInstanceOnDestroyArgs> WidgetInstanceDestroyed
148         {
149             add
150             {
151                 _widgetInstanceOnDestroyEventHandler += value;
152             }
153             remove
154             {
155                 _widgetInstanceOnDestroyEventHandler -= value;
156             }
157         }
158
159         public class WidgetInstanceOnResizeArgs : EventArgs
160         {
161             private Window _window;
162
163             public Window Window
164             {
165                 get
166                 {
167                     return _window;
168                 }
169                 set
170                 {
171                     _window = value;
172                 }
173             }
174         }
175
176         private EventHandler<WidgetInstanceOnResizeArgs> _widgetInstanceOnResizeEventHandler;
177         public event EventHandler<WidgetInstanceOnResizeArgs> WidgetInstanceResized
178         {
179             add
180             {
181                 _widgetInstanceOnResizeEventHandler += value;
182             }
183             remove
184             {
185                 _widgetInstanceOnResizeEventHandler -= value;
186             }
187         }
188
189         private EventHandler _widgetInstanceOnPauseEventHandler;
190         public event EventHandler WidgetInstancePaused
191         {
192             add
193             {
194                 _widgetInstanceOnPauseEventHandler += value;
195             }
196             remove
197             {
198                 _widgetInstanceOnPauseEventHandler -= value;
199             }
200         }
201
202         private EventHandler _widgetInstanceOnResumeEventHandler;
203         public event EventHandler WidgetInstanceResumed
204         {
205             add
206             {
207                 _widgetInstanceOnResumeEventHandler += value;
208             }
209             remove
210             {
211                 _widgetInstanceOnResumeEventHandler -= value;
212             }
213         }
214
215         public class WidgetInstanceOnUpdateArgs : EventArgs
216         {
217             private string _contentInfo;
218             private int _force;
219
220             public string ContentInfo
221             {
222                 get
223                 {
224                     return _contentInfo;
225                 }
226                 set
227                 {
228                     _contentInfo = value;
229                 }
230             }
231
232             public int Force
233             {
234                 get
235                 {
236                     return _force;
237                 }
238                 set
239                 {
240                     _force = value;
241                 }
242             }
243         }
244
245         private EventHandler<WidgetInstanceOnUpdateArgs> _widgetInstanceOnUpdateEventHandler;
246         public event EventHandler<WidgetInstanceOnUpdateArgs> WidgetInstanceUpdated
247         {
248             add
249             {
250                 _widgetInstanceOnUpdateEventHandler += value;
251             }
252             remove
253             {
254                 _widgetInstanceOnUpdateEventHandler -= value;
255             }
256         }
257
258         public virtual void OnCreate(string contentInfo, Window window)
259         {
260             WIdgetInstanceOnCreateArgs args = new WIdgetInstanceOnCreateArgs();
261             args.ContentInfo = contentInfo;
262             args.Window = window;
263             _widgetInstanceOnCreateEventHandler?.Invoke(this, args);
264         }
265
266         public virtual void OnTerminate(string contentInfo, Widget.TerminationType type)
267         {
268             WIdgetInstanceOnDestroyArgs args = new WIdgetInstanceOnDestroyArgs();
269             args.ContentInfo = contentInfo;
270             args.TerminateType = type;
271             _widgetInstanceOnDestroyEventHandler?.Invoke(this,args);
272         }
273
274         public virtual void OnPause()
275         {
276             _widgetInstanceOnPauseEventHandler?.Invoke(this, new EventArgs());
277         }
278
279         public virtual void OnResume()
280         {
281             _widgetInstanceOnResumeEventHandler?.Invoke(this, new EventArgs());
282         }
283
284         public virtual void OnResize(Window window)
285         {
286             WidgetInstanceOnResizeArgs args = new WidgetInstanceOnResizeArgs();
287             args.Window = window;
288             _widgetInstanceOnResizeEventHandler?.Invoke(this, args);
289         }
290
291         public virtual void OnUpdate(string contentInfo, int force)
292         {
293             WidgetInstanceOnUpdateArgs args = new WidgetInstanceOnUpdateArgs();
294             args.ContentInfo = contentInfo;
295             args.Force = force;
296             _widgetInstanceOnUpdateEventHandler?.Invoke(this, args);
297         }
298
299         internal virtual void SignalConnected(SlotObserver slotObserver, SWIGTYPE_p_Dali__CallbackBase callback)
300         {
301         }
302
303         internal virtual void SignalDisconnected(SlotObserver slotObserver, SWIGTYPE_p_Dali__CallbackBase callback)
304         {
305         }
306
307         public void SetContentInfo(string contentInfo)
308         {
309             Interop.WidgetImpl.WidgetImpl_SetContentInfo(swigCPtr, contentInfo);
310             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311         }
312
313         internal void SetImpl(SWIGTYPE_p_Dali__Widget__Impl impl)
314         {
315             Interop.WidgetImpl.WidgetImpl_SetImpl(swigCPtr, SWIGTYPE_p_Dali__Widget__Impl.getCPtr(impl));
316             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317         }
318
319         private void SwigDirectorConnect()
320         {
321             swigDelegate0 = new SwigDelegateWidgetImpl_0(SwigDirectorOnCreate);
322             swigDelegate1 = new SwigDelegateWidgetImpl_1(SwigDirectorOnTerminate);
323             swigDelegate2 = new SwigDelegateWidgetImpl_2(SwigDirectorOnPause);
324             swigDelegate3 = new SwigDelegateWidgetImpl_3(SwigDirectorOnResume);
325             swigDelegate4 = new SwigDelegateWidgetImpl_4(SwigDirectorOnResize);
326             swigDelegate5 = new SwigDelegateWidgetImpl_5(SwigDirectorOnUpdate);
327             swigDelegate6 = new SwigDelegateWidgetImpl_6(SwigDirectorSignalConnected);
328             swigDelegate7 = new SwigDelegateWidgetImpl_7(SwigDirectorSignalDisconnected);
329             Interop.WidgetImpl.WidgetImpl_director_connect(swigCPtr, swigDelegate0, swigDelegate1, swigDelegate2, swigDelegate3, swigDelegate4, swigDelegate5, swigDelegate6, swigDelegate7);
330         }
331
332         private bool SwigDerivedClassHasMethod(string methodName, global::System.Type[] methodTypes)
333         {
334             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);
335             bool hasDerivedMethod = methodInfo.DeclaringType.IsSubclassOf(typeof(WidgetImpl));
336             return hasDerivedMethod;
337         }
338
339         private void SwigDirectorOnCreate(string contentInfo, global::System.IntPtr window)
340         {
341             OnCreate(contentInfo, new Window(window, true));
342         }
343
344         private void SwigDirectorOnTerminate(string contentInfo, int type)
345         {
346             OnTerminate(contentInfo, (Widget.TerminationType)type);
347         }
348
349         private void SwigDirectorOnPause()
350         {
351             OnPause();
352         }
353
354         private void SwigDirectorOnResume()
355         {
356             OnResume();
357         }
358
359         private void SwigDirectorOnResize(global::System.IntPtr window)
360         {
361             OnResize(new Window(window, true));
362         }
363
364         private void SwigDirectorOnUpdate(string contentInfo, int force)
365         {
366             OnUpdate(contentInfo, force);
367         }
368
369         private void SwigDirectorSignalConnected(global::System.IntPtr slotObserver, global::System.IntPtr callback)
370         {
371             SignalConnected((slotObserver == global::System.IntPtr.Zero) ? null : new SlotObserver(slotObserver, false), (callback == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_Dali__CallbackBase(callback, false));
372         }
373
374         private void SwigDirectorSignalDisconnected(global::System.IntPtr slotObserver, global::System.IntPtr callback)
375         {
376             SignalDisconnected((slotObserver == global::System.IntPtr.Zero) ? null : new SlotObserver(slotObserver, false), (callback == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_Dali__CallbackBase(callback, false));
377         }
378
379         public delegate void SwigDelegateWidgetImpl_0(string contentInfo, global::System.IntPtr window);
380         public delegate void SwigDelegateWidgetImpl_1(string contentInfo, int type);
381         public delegate void SwigDelegateWidgetImpl_2();
382         public delegate void SwigDelegateWidgetImpl_3();
383         public delegate void SwigDelegateWidgetImpl_4(global::System.IntPtr window);
384         public delegate void SwigDelegateWidgetImpl_5(string contentInfo, int force);
385         public delegate void SwigDelegateWidgetImpl_6(global::System.IntPtr slotObserver, global::System.IntPtr callback);
386         public delegate void SwigDelegateWidgetImpl_7(global::System.IntPtr slotObserver, global::System.IntPtr callback);
387
388         private SwigDelegateWidgetImpl_0 swigDelegate0;
389         private SwigDelegateWidgetImpl_1 swigDelegate1;
390         private SwigDelegateWidgetImpl_2 swigDelegate2;
391         private SwigDelegateWidgetImpl_3 swigDelegate3;
392         private SwigDelegateWidgetImpl_4 swigDelegate4;
393         private SwigDelegateWidgetImpl_5 swigDelegate5;
394         private SwigDelegateWidgetImpl_6 swigDelegate6;
395         private SwigDelegateWidgetImpl_7 swigDelegate7;
396
397         private static global::System.Type[] swigMethodTypes0 = new global::System.Type[] { typeof(string), typeof(Window) };
398         private static global::System.Type[] swigMethodTypes1 = new global::System.Type[] { typeof(string), typeof(Widget.TerminationType) };
399         private static global::System.Type[] swigMethodTypes2 = new global::System.Type[] { };
400         private static global::System.Type[] swigMethodTypes3 = new global::System.Type[] { };
401         private static global::System.Type[] swigMethodTypes4 = new global::System.Type[] { typeof(Window) };
402         private static global::System.Type[] swigMethodTypes5 = new global::System.Type[] { typeof(string), typeof(int) };
403         private static global::System.Type[] swigMethodTypes6 = new global::System.Type[] { typeof(SlotObserver), typeof(SWIGTYPE_p_Dali__CallbackBase) };
404         private static global::System.Type[] swigMethodTypes7 = new global::System.Type[] { typeof(SlotObserver), typeof(SWIGTYPE_p_Dali__CallbackBase) };
405     }
406 }