[NUI] Revert "Sync with dalihub & API5 branch (#631)" (#635)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window.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 using System;
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21 using System.Collections.Generic;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// The window class is used internally for drawing.<br />
27     /// The window has an orientation and indicator properties.<br />
28     /// </summary>
29     /// <since_tizen> 3 </since_tizen>
30     public class Window : BaseHandle
31     {
32         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33         private global::System.Runtime.InteropServices.HandleRef stageCPtr;
34         private readonly global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr;
35         private Layer _rootLayer;
36         private string _windowTitle;
37         private readonly LayoutItem rootLayoutItem;
38
39         private List<Layer> _childLayers = new List<Layer>();
40         internal List<Layer> LayersChildren
41         {
42             get
43             {
44                 return _childLayers;
45             }
46         }
47
48         internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn)
49         {
50             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
51             if (NDalicPINVOKE.Stage_IsInstalled())
52             {
53                 global::System.IntPtr rootLayoutIntPtr;
54                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
55                 // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to the Window
56                 // Enables layouts added to the Window to have a parent layout.  As parent layout is needed to store measure spec properties.
57                 // Currently without these measure specs the new layout added will always be the size of the window.
58                 rootLayoutIntPtr = NDalicManualPINVOKE.Window_NewRootLayout();
59                 // Store HandleRef used by Add()
60                 rootLayoutCPtr = new global::System.Runtime.InteropServices.HandleRef(this, rootLayoutIntPtr);
61                 Layer rootLayer = GetRootLayer();
62                 // Add the root layout created above to the root layer.
63                 NDalicPINVOKE.Actor_Add(  Layer.getCPtr(rootLayer), rootLayoutCPtr );
64                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
65
66                 global::System.IntPtr rootControlLayoutIntPtr = Tizen.NUI.NDalicManualPINVOKE.GetLayout__SWIG_1(rootLayoutCPtr);
67                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
68
69                 rootLayoutItem = new LayoutItem(rootControlLayoutIntPtr, true);
70             }
71         }
72
73         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
74         {
75             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
76         }
77
78         internal static Window GetCurrent()
79         {
80             Window ret = new Window(NDalicPINVOKE.Stage_GetCurrent(), true);
81             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82             return ret;
83         }
84
85         internal static bool IsInstalled()
86         {
87             bool ret = NDalicPINVOKE.Stage_IsInstalled();
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             return ret;
90         }
91
92         /// <summary>
93         /// Sets whether the window accepts a focus or not.
94         /// </summary>
95         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
96         /// <since_tizen> 3 </since_tizen>
97         public void SetAcceptFocus(bool accept)
98         {
99             NDalicPINVOKE.SetAcceptFocus(swigCPtr, accept);
100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101         }
102
103         /// <summary>
104         /// Returns whether the window accepts a focus or not.
105         /// </summary>
106         /// <returns>True if the window accepts a focus, false otherwise.</returns>
107         /// <since_tizen> 3 </since_tizen>
108         public bool IsFocusAcceptable()
109         {
110             bool ret = NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
111             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112
113             return ret;
114         }
115
116         /// <summary>
117         /// Shows the window if it is hidden.
118         /// </summary>
119         /// <since_tizen> 3 </since_tizen>
120         public void Show()
121         {
122             NDalicPINVOKE.Show(swigCPtr);
123             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
124         }
125
126         /// <summary>
127         /// Hides the window if it is showing.
128         /// </summary>
129         /// <since_tizen> 3 </since_tizen>
130         public void Hide()
131         {
132             NDalicPINVOKE.Hide(swigCPtr);
133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134         }
135
136         /// <summary>
137         /// Retrieves whether the window is visible or not.
138         /// </summary>
139         /// <returns>True if the window is visible.</returns>
140         /// <since_tizen> 3 </since_tizen>
141         public bool IsVisible()
142         {
143             bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145             return temp;
146         }
147
148         /// <summary>
149         /// Gets the count of supported auxiliary hints of the window.
150         /// </summary>
151         /// <returns>The number of supported auxiliary hints.</returns>
152         /// <since_tizen> 3 </since_tizen>
153         public uint GetSupportedAuxiliaryHintCount()
154         {
155             uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
156             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157             return ret;
158         }
159
160         /// <summary>
161         /// Gets the supported auxiliary hint string of the window.
162         /// </summary>
163         /// <param name="index">The index of the supported auxiliary hint lists.</param>
164         /// <returns>The auxiliary hint string of the index.</returns>
165         /// <since_tizen> 3 </since_tizen>
166         public string GetSupportedAuxiliaryHint(uint index)
167         {
168             string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
169             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170             return ret;
171         }
172
173         /// <summary>
174         /// Creates an auxiliary hint of the window.
175         /// </summary>
176         /// <param name="hint">The auxiliary hint string.</param>
177         /// <param name="value">The value string.</param>
178         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
179         /// <since_tizen> 3 </since_tizen>
180         public uint AddAuxiliaryHint(string hint, string value)
181         {
182             uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
183             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184             return ret;
185         }
186
187         /// <summary>
188         /// Removes an auxiliary hint of the window.
189         /// </summary>
190         /// <param name="id">The ID of the auxiliary hint.</param>
191         /// <returns>True if no error occurred, false otherwise.</returns>
192         /// <since_tizen> 3 </since_tizen>
193         public bool RemoveAuxiliaryHint(uint id)
194         {
195             bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197             return ret;
198         }
199
200         /// <summary>
201         /// Changes a value of the auxiliary hint.
202         /// </summary>
203         /// <param name="id">The auxiliary hint ID.</param>
204         /// <param name="value">The value string to be set.</param>
205         /// <returns>True if no error occurred, false otherwise.</returns>
206         /// <since_tizen> 3 </since_tizen>
207         public bool SetAuxiliaryHintValue(uint id, string value)
208         {
209             bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
210             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211             return ret;
212         }
213
214         /// <summary>
215         /// Gets a value of the auxiliary hint.
216         /// </summary>
217         /// <param name="id">The auxiliary hint ID.</param>
218         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
219         /// <since_tizen> 3 </since_tizen>
220         public string GetAuxiliaryHintValue(uint id)
221         {
222             string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
223             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224             return ret;
225         }
226
227         /// <summary>
228         /// Gets an ID of the auxiliary hint string.
229         /// </summary>
230         /// <param name="hint">The auxiliary hint string.</param>
231         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
232         /// <since_tizen> 3 </since_tizen>
233         public uint GetAuxiliaryHintId(string hint)
234         {
235             uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
236             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237             return ret;
238         }
239
240         /// <summary>
241         /// Sets a region to accept input events.
242         /// </summary>
243         /// <param name="inputRegion">The region to accept input events.</param>
244         /// <since_tizen> 3 </since_tizen>
245         public void SetInputRegion(Rectangle inputRegion)
246         {
247             NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
248             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249         }
250
251         /// <summary>
252         /// Gets or sets a window type.
253         /// </summary>
254         /// <since_tizen> 3 </since_tizen>
255         public WindowType Type
256         {
257             get
258             {
259                 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
260                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261                 return ret;
262             }
263             set
264             {
265                 NDalicPINVOKE.SetType(swigCPtr, (int)value);
266                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267             }
268         }
269
270         /// <summary>
271         /// Sets a priority level for the specified notification window.
272         /// </summary>
273         /// <param name="level">The notification window level.</param>
274         /// <returns>True if no error occurred, false otherwise.</returns>
275         /// <since_tizen> 3 </since_tizen>
276         public bool SetNotificationLevel(NotificationLevel level)
277         {
278             bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280             return ret;
281         }
282
283         /// <summary>
284         /// Gets a priority level for the specified notification window.
285         /// </summary>
286         /// <returns>The notification window level.</returns>
287         /// <since_tizen> 3 </since_tizen>
288         public NotificationLevel GetNotificationLevel()
289         {
290             NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
291             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292             return ret;
293         }
294
295         /// <summary>
296         /// Sets a transparent window's visual state to opaque. <br />
297         /// If a visual state of a transparent window is opaque, <br />
298         /// then the window manager could handle it as an opaque window when calculating visibility.
299         /// </summary>
300         /// <param name="opaque">Whether the window's visual state is opaque.</param>
301         /// <remarks>This will have no effect on an opaque window. <br />
302         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
303         /// </remarks>
304         /// <since_tizen> 3 </since_tizen>
305         public void SetOpaqueState(bool opaque)
306         {
307             NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309         }
310
311         /// <summary>
312         /// Returns whether a transparent window's visual state is opaque or not.
313         /// </summary>
314         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
315         /// <remarks> The return value has no meaning on an opaque window. </remarks>
316         /// <since_tizen> 3 </since_tizen>
317         public bool IsOpaqueState()
318         {
319             bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
320             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321             return ret;
322         }
323
324         /// <summary>
325         /// Sets a window's screen off mode.
326         /// </summary>
327         /// <param name="screenOffMode">The screen mode.</param>
328         /// <returns>True if no error occurred, false otherwise.</returns>
329         /// <since_tizen> 4 </since_tizen>
330         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
331         {
332             bool ret = NDalicPINVOKE.SetScreenOffMode(swigCPtr, (int)screenOffMode);
333             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334             return ret;
335         }
336
337         /// <summary>
338         /// Gets the screen mode of the window.
339         /// </summary>
340         /// <returns>The screen off mode.</returns>
341         /// <since_tizen> 4 </since_tizen>
342         public ScreenOffMode GetScreenOffMode()
343         {
344             ScreenOffMode ret = (ScreenOffMode)NDalicPINVOKE.GetScreenOffMode(swigCPtr);
345             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346             return ret;
347         }
348
349         /// <summary>
350         /// Sets preferred brightness of the window.
351         /// </summary>
352         /// <param name="brightness">The preferred brightness (0 to 100).</param>
353         /// <returns>True if no error occurred, false otherwise.</returns>
354         /// <since_tizen> 3 </since_tizen>
355         public bool SetBrightness(int brightness)
356         {
357             bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
358             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359             return ret;
360         }
361
362         /// <summary>
363         /// Gets the preferred brightness of the window.
364         /// </summary>
365         /// <returns>The preferred brightness.</returns>
366         /// <since_tizen> 3 </since_tizen>
367         public int GetBrightness()
368         {
369             int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
370             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
371             return ret;
372         }
373
374         /// <summary>
375         /// The focus changed event argument.
376         /// </summary>
377         /// <since_tizen> 3 </since_tizen>
378         public class FocusChangedEventArgs : EventArgs
379         {
380             /// <summary>
381             /// FocusGained flag.
382             /// </summary>
383             /// <since_tizen> 3 </since_tizen>
384             public bool FocusGained
385             {
386                 get;
387                 set;
388             }
389         }
390
391         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
392         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
393         private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
394         private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
395
396         /// <summary>
397         /// FocusChanged event.
398         /// </summary>
399         /// <since_tizen> 3 </since_tizen>
400         public event EventHandler<FocusChangedEventArgs> FocusChanged
401         {
402             add
403             {
404                 if (_windowFocusChangedEventHandler == null)
405                 {
406                     _windowFocusChangedEventCallback = OnWindowFocusedChanged;
407                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
408                 }
409
410                 _windowFocusChangedEventHandler += value;
411             }
412             remove
413             {
414                 _windowFocusChangedEventHandler -= value;
415
416                 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
417                 {
418                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
419                 }
420             }
421         }
422
423         private void OnWindowFocusedChanged(bool focusGained)
424         {
425             FocusChangedEventArgs e = new FocusChangedEventArgs();
426
427             e.FocusGained = focusGained;
428
429             if (_windowFocusChangedEventHandler != null)
430             {
431                 _windowFocusChangedEventHandler(this, e);
432             }
433         }
434
435         /// <summary>
436         /// Gets/Sets a window title.
437         /// </summary>
438         /// <since_tizen> 4 </since_tizen>
439         public string Title
440         {
441             get
442             {
443                 return _windowTitle;
444             }
445             set
446             {
447                 _windowTitle = value;
448                 SetClass(_windowTitle, "");
449             }
450         }
451
452         /// <summary>
453         /// The rendering behavior of a Window.
454         /// </summary>
455         /// <since_tizen> 5 </since_tizen>
456         public RenderingBehaviorType RenderingBehavior
457         {
458             get
459             {
460                 return GetRenderingBehavior();
461             }
462             set
463             {
464                 SetRenderingBehavior(value);
465             }
466         }
467
468         internal WindowFocusSignalType WindowFocusChangedSignal()
469         {
470             WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
471             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472             return ret;
473         }
474
475         internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
476         {
477             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478         }
479
480         internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
481         {
482             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
483         }
484
485         internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
486         {
487             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488         }
489
490         internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
491         {
492             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
493         }
494
495         internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
496         {
497             NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
498             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499         }
500
501         internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
502         {
503             NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
504             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
505         }
506
507         internal void RotateIndicator(Window.WindowOrientation orientation)
508         {
509             NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
510             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511         }
512
513         /// <summary>
514         /// Sets the window name and the class string.
515         /// </summary>
516         /// <param name="name">The name of the window.</param>
517         /// <param name="klass">The class of the window.</param>
518         /// <since_tizen> 4 </since_tizen>
519         public void SetClass(string name, string klass)
520         {
521             NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
522             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
523         }
524
525         /// <summary>
526         /// Raises the window to the top of the window stack.
527         /// </summary>
528         /// <since_tizen> 3 </since_tizen>
529         public void Raise()
530         {
531             NDalicPINVOKE.Window_Raise(swigCPtr);
532             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533         }
534
535         /// <summary>
536         /// Lowers the window to the bottom of the window stack.
537         /// </summary>
538         /// <since_tizen> 3 </since_tizen>
539         public void Lower()
540         {
541             NDalicPINVOKE.Window_Lower(swigCPtr);
542             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543         }
544
545         /// <summary>
546         /// Activates the window to the top of the window stack even it is iconified.
547         /// </summary>
548         /// <since_tizen> 3 </since_tizen>
549         public void Activate()
550         {
551             NDalicPINVOKE.Window_Activate(swigCPtr);
552             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553         }
554
555         internal void AddAvailableOrientation(Window.WindowOrientation orientation)
556         {
557             NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
558             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559         }
560
561         internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
562         {
563             NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
564             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
565         }
566
567         internal void SetPreferredOrientation(Window.WindowOrientation orientation)
568         {
569             NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
570             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
571         }
572
573         internal Window.WindowOrientation GetPreferredOrientation()
574         {
575             Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
576             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
577             return ret;
578         }
579
580         internal DragAndDropDetector GetDragAndDropDetector()
581         {
582             DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
583             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584             return ret;
585         }
586
587         internal Any GetNativeHandle()
588         {
589             Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
590             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
591             return ret;
592         }
593
594         internal WindowFocusSignalType FocusChangedSignal()
595         {
596             WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
597             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
598             return ret;
599         }
600
601         /// <summary>
602         /// Gets the default ( root ) layer.
603         /// </summary>
604         /// <returns>The root layer.</returns>
605         /// <since_tizen> 3 </since_tizen>
606         public Layer GetDefaultLayer()
607         {
608             return this.GetRootLayer();
609         }
610
611         internal void Add(Layer layer)
612         {
613             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
614             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615
616             LayersChildren.Add(layer);
617         }
618
619         internal void Remove(Layer layer)
620         {
621             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
622             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623
624             LayersChildren.Remove(layer);
625         }
626
627         /// <summary>
628         /// Add a child view to window.
629         /// </summary>
630         /// <param name="view">the child should be added to the window.</param>
631         /// <since_tizen> 3 </since_tizen>
632         public void Add(View view)
633         {
634             NDalicPINVOKE.Actor_Add( rootLayoutCPtr, View.getCPtr(view) );
635             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636             this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
637             view.InternalParent = this.GetRootLayer();
638         }
639
640         /// <summary>
641         /// Remove a child view from window.
642         /// </summary>
643         /// <param name="view">the child to be removed.</param>
644         /// <since_tizen> 3 </since_tizen>
645         public void Remove(View view)
646         {
647             NDalicPINVOKE.Actor_Remove( rootLayoutCPtr, View.getCPtr(view) );
648             this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
649             view.InternalParent = null;
650         }
651
652         internal Vector2 GetSize()
653         {
654             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
655             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656             return ret;
657         }
658
659         internal RenderTaskList GetRenderTaskList()
660         {
661             RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
662             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663             return ret;
664         }
665
666         /// <summary>
667         /// Queries the number of on-window layers.
668         /// </summary>
669         /// <returns>The number of layers.</returns>
670         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
671         internal uint GetLayerCount()
672         {
673             if (LayersChildren == null || LayersChildren.Count < 0)
674                 return 0;
675
676             return (uint) LayersChildren.Count;
677         }
678
679         /// <summary>
680         /// Retrieves the layer at a specified depth.
681         /// </summary>
682         /// <param name="depth">The layer's depth index.</param>
683         /// <returns>The layer found at the given depth.</returns>
684         /// <since_tizen> 3 </since_tizen>
685         public Layer GetLayer(uint depth)
686         {
687             if (depth < LayersChildren.Count)
688             {
689                 Layer ret = LayersChildren[Convert.ToInt32(depth)];
690                 return ret;
691             }
692             else
693             {
694                 return null;
695             }
696         }
697
698         internal Layer GetRootLayer()
699         {
700             // Window.IsInstalled() is actually true only when called from event thread and
701             // Core has been initialized, not when Stage is ready.
702             if (_rootLayer == null && Window.IsInstalled())
703             {
704                 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
705                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706                 LayersChildren.Add(_rootLayer);
707             }
708             return _rootLayer;
709         }
710
711         internal void SetBackgroundColor(Vector4 color)
712         {
713             NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
714             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715         }
716
717         internal Vector4 GetBackgroundColor()
718         {
719             Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
720             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721             return ret;
722         }
723
724         internal Vector2 GetDpi()
725         {
726             Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
727             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728             return ret;
729         }
730
731         internal ObjectRegistry GetObjectRegistry()
732         {
733             ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
734             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735             return ret;
736         }
737
738         /// <summary>
739         /// Keep rendering for at least the given amount of time.
740         /// </summary>
741         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
742         /// <since_tizen> 3 </since_tizen>
743         public void KeepRendering(float durationSeconds)
744         {
745             NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
746             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
747         }
748
749         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
750         {
751             NDalicPINVOKE.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
752             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
753         }
754
755         internal RenderingBehaviorType GetRenderingBehavior()
756         {
757             RenderingBehaviorType ret = (RenderingBehaviorType)NDalicPINVOKE.Stage_GetRenderingBehavior(stageCPtr);
758             if (NDalicPINVOKE.SWIGPendingException.Pending)
759                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
760             return ret;
761         }
762
763         internal KeyEventSignal KeyEventSignal()
764         {
765             KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
766             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767             return ret;
768         }
769
770         internal VoidSignal EventProcessingFinishedSignal()
771         {
772             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
773             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774             return ret;
775         }
776
777         internal TouchSignal TouchSignal()
778         {
779             TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
780             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781             return ret;
782         }
783
784         internal TouchDataSignal TouchDataSignal()
785         {
786             TouchDataSignal ret = new TouchDataSignal(NDalicPINVOKE.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
787             if (NDalicPINVOKE.SWIGPendingException.Pending)
788                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
789             return ret;
790         }
791
792         private StageWheelSignal WheelEventSignal()
793         {
794             StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
795             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
796             return ret;
797         }
798
799
800         private WheelSignal StageWheelEventSignal()
801         {
802             WheelSignal ret = new WheelSignal(NDalicPINVOKE.Actor_WheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
803             if (NDalicPINVOKE.SWIGPendingException.Pending)
804                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
805             return ret;
806         }
807
808
809         internal VoidSignal ContextLostSignal()
810         {
811             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
812             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
813             return ret;
814         }
815
816         internal VoidSignal ContextRegainedSignal()
817         {
818             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
819             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
820             return ret;
821         }
822
823         internal VoidSignal SceneCreatedSignal()
824         {
825             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
826             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
827             return ret;
828         }
829
830         internal ResizedSignal ResizedSignal()
831         {
832             ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
833             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
834             return ret;
835         }
836
837         internal static Vector4 DEFAULT_BACKGROUND_COLOR
838         {
839             get
840             {
841                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
842                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
843                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844                 return ret;
845             }
846         }
847
848         internal static Vector4 DEBUG_BACKGROUND_COLOR
849         {
850             get
851             {
852                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
853                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
854                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
855                 return ret;
856             }
857         }
858
859         private static readonly Window instance = Application.Instance.GetWindow();
860
861         /// <summary>
862         /// The stage instance property (read-only).<br />
863         /// Gets the current window.<br />
864         /// </summary>
865         /// <since_tizen> 3 </since_tizen>
866         public static Window Instance
867         {
868             get
869             {
870                 return instance;
871             }
872         }
873
874         /// <summary>
875         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
876         /// This function can be used for following example scenarios: <br />
877         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
878         /// </summary>
879         /// <param name="DaliKey">The key code to grab.</param>
880         /// <returns>True if the grab succeeds.</returns>
881         /// <since_tizen> 3 </since_tizen>
882         public bool GrabKeyTopmost(int DaliKey)
883         {
884             bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
885             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
886             return ret;
887         }
888
889         /// <summary>
890         /// Ungrabs the key specified by a key for the window.<br />
891         /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.<br />
892         /// </summary>
893         /// <param name="DaliKey">The key code to ungrab.</param>
894         /// <returns>True if the ungrab succeeds.</returns>
895         /// <since_tizen> 3 </since_tizen>
896         public bool UngrabKeyTopmost(int DaliKey)
897         {
898             bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
899             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
900             return ret;
901         }
902
903         /// <summary>
904         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
905         ///  Details: This function can be used for following example scenarios: <br />
906         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
907         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
908         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
909         /// </summary>
910         /// <param name="DaliKey">The key code to grab.</param>
911         /// <param name="GrabMode">The grab mode for the key.</param>
912         /// <returns>True if the grab succeeds.</returns>
913         /// <since_tizen> 3 </since_tizen>
914         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
915         {
916             bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
917             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
918             return ret;
919         }
920
921         /// <summary>
922         /// Ungrabs the key specified by a key for a window.<br />
923         /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event. <br />
924         /// </summary>
925         /// <param name="DaliKey">The key code to ungrab.</param>
926         /// <returns>True if the ungrab succeeds.</returns>
927         /// <since_tizen> 3 </since_tizen>
928         public bool UngrabKey(int DaliKey)
929         {
930             bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
931             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
932             return ret;
933         }
934
935         /// <summary>
936         /// Sets the keyboard repeat information.
937         /// </summary>
938         /// <param name="rate">The key repeat rate value in seconds.</param>
939         /// <param name="delay">The key repeat delay value in seconds.</param>
940         /// <returns>True if setting the keyboard repeat succeeds.</returns>
941         /// <since_tizen> 5 </since_tizen>
942         public bool SetKeyboardRepeatInfo(float rate, float delay)
943         {
944             bool ret = NDalicManualPINVOKE.SetKeyboardRepeatInfo(rate, delay);
945             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
946             return ret;
947         }
948
949         /// <summary>
950         /// Gets the keyboard repeat information.
951         /// </summary>
952         /// <param name="rate">The key repeat rate value in seconds.</param>
953         /// <param name="delay">The key repeat delay value in seconds.</param>
954         /// <returns>True if setting the keyboard repeat succeeds.</returns>
955         /// <since_tizen> 5 </since_tizen>
956         public bool GetKeyboardRepeatInfo(out float rate, out float delay)
957         {
958             bool ret = NDalicManualPINVOKE.GetKeyboardRepeatInfo(out rate, out delay);
959             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
960             return ret;
961         }
962
963         internal System.IntPtr GetNativeWindowHandler()
964         {
965             System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
966             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
967             return ret;
968         }
969
970         /// <summary>
971         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
972         /// </summary>
973         /// <since_tizen> 3 </since_tizen>
974         public enum WindowOrientation
975         {
976             /// <summary>
977             /// Portrait orientation. The height of the display area is greater than the width.
978             /// </summary>
979             /// <since_tizen> 3 </since_tizen>
980             Portrait = 0,
981             /// <summary>
982             /// Landscape orientation. A wide view area is needed.
983             /// </summary>
984             /// <since_tizen> 3 </since_tizen>
985             Landscape = 90,
986             /// <summary>
987             /// Portrait inverse orientation.
988             /// </summary>
989             /// <since_tizen> 3 </since_tizen>
990             PortraitInverse = 180,
991             /// <summary>
992             /// Landscape inverse orientation.
993             /// </summary>
994             /// <since_tizen> 3 </since_tizen>
995             LandscapeInverse = 270
996         }
997
998         /// <summary>
999         /// Enumeration for the key grab mode for platform-level APIs.
1000         /// </summary>
1001         /// <since_tizen> 3 </since_tizen>
1002         public enum KeyGrabMode
1003         {
1004             /// <summary>
1005             /// Grabs a key only when on the top of the grabbing-window stack mode.
1006             /// </summary>
1007             Topmost = 0,
1008             /// <summary>
1009             /// Grabs a key together with the other client window(s) mode.
1010             /// </summary>
1011             Shared,
1012             /// <summary>
1013             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode.
1014             /// </summary>
1015             OverrideExclusive,
1016             /// <summary>
1017             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
1018             /// </summary>
1019             Exclusive
1020         };
1021
1022         /// <summary>
1023         /// Enumeration for opacity of the indicator.
1024         /// </summary>
1025         internal enum IndicatorBackgroundOpacity
1026         {
1027             Opaque = 100,
1028             Translucent = 50,
1029             Transparent = 0
1030         }
1031
1032         /// <summary>
1033         /// Enumeration for visible mode of the indicator.
1034         /// </summary>
1035         internal enum IndicatorVisibleMode
1036         {
1037             Invisible = 0,
1038             Visible = 1,
1039             Auto = 2
1040         }
1041
1042         /// <summary>
1043         /// The touch event argument.
1044         /// </summary>
1045         /// <since_tizen> 3 </since_tizen>
1046         public class TouchEventArgs : EventArgs
1047         {
1048             private Touch _touch;
1049
1050             /// <summary>
1051             /// Touch.
1052             /// </summary>
1053             /// <since_tizen> 3 </since_tizen>
1054             public Touch Touch
1055             {
1056                 get
1057                 {
1058                     return _touch;
1059                 }
1060                 set
1061                 {
1062                     _touch = value;
1063                 }
1064             }
1065         }
1066
1067
1068         private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
1069         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1070         private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
1071         private RootLayerTouchDataCallbackType _rootLayerTouchDataCallback;
1072         /// <summary>
1073         /// This event is emitted when the screen is touched and when the touch ends.<br />
1074         /// If there are multiple touch points, then this will be emitted when the first touch occurs and
1075         /// then when the last finger is lifted.<br />
1076         /// An interrupted event will also be emitted (if it occurs).<br />
1077         /// </summary>
1078         /// <since_tizen> 3 </since_tizen>
1079         public event EventHandler<TouchEventArgs> TouchEvent
1080         {
1081             add
1082             {
1083                 if (_rootLayerTouchDataEventHandler == null)
1084                 {
1085                     _rootLayerTouchDataCallback = OnWindowTouch;
1086                     this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
1087                 }
1088                 _rootLayerTouchDataEventHandler += value;
1089             }
1090             remove
1091             {
1092                 _rootLayerTouchDataEventHandler -= value;
1093                 if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false)
1094                 {
1095                     this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
1096                 }
1097             }
1098         }
1099
1100         private bool OnWindowTouch(IntPtr view, IntPtr touchData)
1101         {
1102             if (touchData == global::System.IntPtr.Zero)
1103             {
1104                 NUILog.Error("touchData should not be null!");
1105                 return false;
1106             }
1107
1108             TouchEventArgs e = new TouchEventArgs();
1109
1110             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
1111
1112             if (_rootLayerTouchDataEventHandler != null)
1113             {
1114                 _rootLayerTouchDataEventHandler(this, e);
1115             }
1116             return false;
1117         }
1118
1119         /// <summary>
1120         /// Wheel event arguments.
1121         /// </summary>
1122         /// <since_tizen> 3 </since_tizen>
1123         public class WheelEventArgs : EventArgs
1124         {
1125             private Wheel _wheel;
1126
1127             /// <summary>
1128             /// Wheel.
1129             /// </summary>
1130             /// <since_tizen> 3 </since_tizen>
1131             public Wheel Wheel
1132             {
1133                 get
1134                 {
1135                     return _wheel;
1136                 }
1137                 set
1138                 {
1139                     _wheel = value;
1140                 }
1141             }
1142         }
1143
1144         private event EventHandler<WheelEventArgs> _stageWheelHandler;
1145
1146         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1147         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
1148         private WheelEventCallbackType _wheelEventCallback;
1149
1150         /// <summary>
1151         /// This event is emitted when the wheel event is received.
1152         /// </summary>
1153         /// <since_tizen> 3 </since_tizen>
1154         public event EventHandler<WheelEventArgs> WheelEvent
1155         {
1156             add
1157             {
1158                 if (_stageWheelHandler == null)
1159                 {
1160                     _wheelEventCallback = OnStageWheel;
1161                     this.StageWheelEventSignal().Connect(_wheelEventCallback);
1162                 }
1163                 _stageWheelHandler += value;
1164             }
1165             remove
1166             {
1167                 _stageWheelHandler -= value;
1168                 if (_stageWheelHandler == null && StageWheelEventSignal().Empty() == false)
1169                 {
1170                     this.StageWheelEventSignal().Disconnect(_wheelEventCallback);
1171                 }
1172             }
1173         }
1174
1175         private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
1176         {
1177             if (wheelEvent == global::System.IntPtr.Zero)
1178         {
1179                 NUILog.Error("wheelEvent should not be null!");
1180                 return true;
1181             }
1182
1183             WheelEventArgs e = new WheelEventArgs();
1184
1185             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1186
1187             if (_stageWheelHandler != null)
1188             {
1189                 _stageWheelHandler(this, e);
1190             }
1191             return true;
1192         }
1193
1194         /// <summary>
1195         /// Key event arguments.
1196         /// </summary>
1197         /// <since_tizen> 3 </since_tizen>
1198         public class KeyEventArgs : EventArgs
1199         {
1200             private Key _key;
1201
1202             /// <summary>
1203             /// Key.
1204             /// </summary>
1205             /// <since_tizen> 3 </since_tizen>
1206             public Key Key
1207             {
1208                 get
1209                 {
1210                     return _key;
1211                 }
1212                 set
1213                 {
1214                     _key = value;
1215                 }
1216             }
1217         }
1218
1219         private event EventHandler<KeyEventArgs> _stageKeyHandler;
1220         private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1221
1222         /// <summary>
1223         /// This event is emitted when the key event is received.
1224         /// </summary>
1225         /// <since_tizen> 3 </since_tizen>
1226         public event EventHandler<KeyEventArgs> KeyEvent
1227         {
1228             add
1229             {
1230                 if (_stageKeyHandler == null)
1231                 {
1232                     _stageKeyCallbackDelegate = OnStageKey;
1233                     KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1234                 }
1235                 _stageKeyHandler += value;
1236             }
1237             remove
1238             {
1239                 _stageKeyHandler -= value;
1240                 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1241                 {
1242                     KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1243                 }
1244             }
1245         }
1246
1247         // Callback for Stage KeyEventsignal
1248         private void OnStageKey(IntPtr data)
1249         {
1250             KeyEventArgs e = new KeyEventArgs();
1251
1252             if (data != null)
1253             {
1254                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1255             }
1256
1257             if (_stageKeyHandler != null)
1258             {
1259                 //here we send all data to user event handlers
1260                 _stageKeyHandler(this, e);
1261             }
1262         }
1263
1264
1265         private event EventHandler _stageEventProcessingFinishedEventHandler;
1266         private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1267
1268         internal event EventHandler EventProcessingFinished
1269         {
1270             add
1271             {
1272                 if (_stageEventProcessingFinishedEventHandler == null)
1273                 {
1274                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1275                     EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1276                 }
1277                 _stageEventProcessingFinishedEventHandler += value;
1278
1279             }
1280             remove
1281             {
1282                 _stageEventProcessingFinishedEventHandler -= value;
1283                 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1284                 {
1285                     EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1286                 }
1287             }
1288         }
1289
1290         // Callback for Stage EventProcessingFinishedSignal
1291         private void OnEventProcessingFinished()
1292         {
1293             if (_stageEventProcessingFinishedEventHandler != null)
1294             {
1295                 _stageEventProcessingFinishedEventHandler(this, null);
1296             }
1297         }
1298
1299
1300         private EventHandler _stageContextLostEventHandler;
1301         private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1302
1303         internal event EventHandler ContextLost
1304         {
1305             add
1306             {
1307                 if (_stageContextLostEventHandler == null)
1308                 {
1309                     _stageContextLostEventCallbackDelegate = OnContextLost;
1310                     ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1311                 }
1312                 _stageContextLostEventHandler += value;
1313             }
1314             remove
1315             {
1316                 _stageContextLostEventHandler -= value;
1317                 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1318                 {
1319                     ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1320                 }
1321             }
1322         }
1323
1324         // Callback for Stage ContextLostSignal
1325         private void OnContextLost()
1326         {
1327             if (_stageContextLostEventHandler != null)
1328             {
1329                 _stageContextLostEventHandler(this, null);
1330             }
1331         }
1332
1333
1334         private EventHandler _stageContextRegainedEventHandler;
1335         private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1336
1337         internal event EventHandler ContextRegained
1338         {
1339             add
1340             {
1341                 if (_stageContextRegainedEventHandler == null)
1342                 {
1343                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1344                     ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1345                 }
1346                 _stageContextRegainedEventHandler += value;
1347             }
1348             remove
1349             {
1350                 _stageContextRegainedEventHandler -= value;
1351                 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1352                 {
1353                     this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1354                 }
1355             }
1356         }
1357
1358         // Callback for Stage ContextRegainedSignal
1359         private void OnContextRegained()
1360         {
1361             if (_stageContextRegainedEventHandler != null)
1362             {
1363                 _stageContextRegainedEventHandler(this, null);
1364             }
1365         }
1366
1367
1368         private EventHandler _stageSceneCreatedEventHandler;
1369         private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1370
1371         internal event EventHandler SceneCreated
1372         {
1373             add
1374             {
1375                 if (_stageSceneCreatedEventHandler == null)
1376                 {
1377                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1378                     SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1379                 }
1380                 _stageSceneCreatedEventHandler += value;
1381             }
1382             remove
1383             {
1384                 _stageSceneCreatedEventHandler -= value;
1385                 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1386                 {
1387                     SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1388                 }
1389             }
1390         }
1391
1392         // Callback for Stage SceneCreatedSignal
1393         private void OnSceneCreated()
1394         {
1395             if (_stageSceneCreatedEventHandler != null)
1396             {
1397                 _stageSceneCreatedEventHandler(this, null);
1398             }
1399         }
1400
1401         /// <summary>
1402         /// This resized event arguments.
1403         /// </summary>
1404         /// <since_tizen> 3 </since_tizen>
1405         public class ResizedEventArgs : EventArgs
1406         {
1407             Size2D _windowSize;
1408
1409             /// <summary>
1410             /// This window size.
1411             /// </summary>
1412             /// <since_tizen> 4 </since_tizen>
1413             public Size2D WindowSize
1414             {
1415                 get
1416                 {
1417                     return _windowSize;
1418                 }
1419                 set
1420                 {
1421                     _windowSize = value;
1422                 }
1423             }
1424         }
1425
1426         private WindowResizedEventCallbackType _windowResizedEventCallback;
1427         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1428         private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1429         private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1430
1431         /// <summary>
1432         /// This event is emitted when the window resized.
1433         /// </summary>
1434         /// <since_tizen> 3 </since_tizen>
1435         public event EventHandler<ResizedEventArgs> Resized
1436         {
1437             add
1438             {
1439                 if (_windowResizedEventHandler == null)
1440                 {
1441                     _windowResizedEventCallback = OnResized;
1442                     ResizedSignal().Connect(_windowResizedEventCallback);
1443                 }
1444
1445                 _windowResizedEventHandler += value;
1446             }
1447             remove
1448             {
1449                 _windowResizedEventHandler -= value;
1450
1451                 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1452                 {
1453                     ResizedSignal().Disconnect(_windowResizedEventCallback);
1454                 }
1455             }
1456         }
1457
1458         private void OnResized(IntPtr windowSize)
1459         {
1460             ResizedEventArgs e = new ResizedEventArgs();
1461             var val = new Uint16Pair(windowSize, false);
1462             e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1463             val.Dispose();
1464
1465             if (_windowResizedEventHandler != null)
1466             {
1467                 _windowResizedEventHandler(this, e);
1468             }
1469         }
1470
1471         internal void SetWindowSize(Size2D size)
1472         {
1473             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1474             NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1475
1476             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1477
1478             if(rootLayoutItem != null)
1479             {
1480                 rootLayoutItem.RequestLayout();
1481             }
1482         }
1483
1484         internal Size2D GetWindowSize()
1485         {
1486             var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1487             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1488
1489             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1490             return ret;
1491         }
1492
1493         internal void SetPosition(Position2D position)
1494         {
1495             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1496             NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1497
1498             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1499
1500             if(rootLayoutItem != null)
1501             {
1502                 rootLayoutItem.RequestLayout();
1503             }
1504         }
1505
1506         internal Position2D GetPosition()
1507         {
1508             var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1509             Position2D ret = new Position2D(val.GetX(), val.GetY());
1510
1511             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1512             return ret;
1513         }
1514
1515         internal void SetPositionSize(Rectangle positionSize)
1516         {
1517             NDalicPINVOKE.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1518             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1519
1520             if(rootLayoutItem != null)
1521             {
1522                 rootLayoutItem.RequestLayout();
1523             }
1524         }
1525
1526         /// <summary>
1527         /// Sets whether the window is transparent or not.
1528         /// </summary>
1529         /// <param name="transparent">Whether the window is transparent or not.</param>
1530         /// <since_tizen> 5 </since_tizen>
1531         public void SetTransparency(bool transparent) {
1532             NDalicManualPINVOKE.SetTransparency(swigCPtr, transparent);
1533             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1534         }
1535
1536         /// <summary>
1537         /// The window size property (read-only).
1538         /// </summary>
1539         /// <since_tizen> 3 </since_tizen>
1540         public Size2D Size
1541         {
1542             get
1543             {
1544                 Size2D ret = GetSize();
1545                 return ret;
1546             }
1547         }
1548
1549         /// <summary>
1550         /// The background color property.
1551         /// </summary>
1552         /// <since_tizen> 3 </since_tizen>
1553         public Color BackgroundColor
1554         {
1555             set
1556             {
1557                 SetBackgroundColor(value);
1558             }
1559             get
1560             {
1561                 Color ret = GetBackgroundColor();
1562                 return ret;
1563             }
1564         }
1565
1566         /// <summary>
1567         /// The DPI property (read-only).<br />
1568         /// Retrieves the DPI of the display device to which the Window is connected.<br />
1569         /// </summary>
1570         /// <since_tizen> 3 </since_tizen>
1571         public Vector2 Dpi
1572         {
1573             get
1574             {
1575                 return GetDpi();
1576             }
1577         }
1578
1579         /// <summary>
1580         /// The layer count property (read-only).<br />
1581         /// Queries the number of on-Window layers.<br />
1582         /// </summary>
1583         /// <since_tizen> 3 </since_tizen>
1584         public uint LayerCount
1585         {
1586             get
1587             {
1588                 return GetLayerCount();
1589             }
1590         }
1591
1592
1593         /// <summary>
1594         /// Adds a layer to the stage.
1595         /// </summary>
1596         /// <param name="layer">Layer to add.</param>
1597         /// <since_tizen> 3 </since_tizen>
1598         public void AddLayer(Layer layer)
1599         {
1600             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1601             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1602
1603             LayersChildren.Add(layer);
1604         }
1605
1606         /// <summary>
1607         /// Removes a layer from the stage.
1608         /// </summary>
1609         /// <param name="layer">Layer to remove.</param>
1610         /// <since_tizen> 3 </since_tizen>
1611         public void RemoveLayer(Layer layer)
1612         {
1613             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1614             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1615
1616             LayersChildren.Remove(layer);
1617         }
1618
1619         /// <summary>
1620         /// Please do not use! this will be deprecated
1621         /// </summary>
1622         /// <since_tizen> 3 </since_tizen>
1623         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1624             "Like: " +
1625             "Window.Instance.FocusChanged = OnFocusChanged; " +
1626             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1627         [EditorBrowsable(EditorBrowsableState.Never)]
1628         public class WindowFocusChangedEventArgs : EventArgs
1629         {
1630             /// <summary>
1631             /// Please do not use! this will be deprecated
1632             /// </summary>
1633             /// <since_tizen> 3 </since_tizen>
1634             public bool FocusGained
1635             {
1636                 get;
1637                 set;
1638             }
1639         }
1640
1641         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1642         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1643         private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1644         private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1645
1646         /// <summary>
1647         /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
1648         /// </summary>
1649         /// <since_tizen> 3 </since_tizen>
1650         /// Please do not use! this will be deprecated!
1651         /// Instead please use FocusChanged.
1652         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
1653             "Like: " +
1654             "Window.Instance.FocusChanged = OnFocusChanged; " +
1655             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1656         [EditorBrowsable(EditorBrowsableState.Never)]
1657         public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1658         {
1659             add
1660             {
1661                 if (_windowFocusChangedEventHandler2 == null)
1662                 {
1663                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1664                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1665                 }
1666
1667                 _windowFocusChangedEventHandler2 += value;
1668             }
1669             remove
1670             {
1671                 _windowFocusChangedEventHandler2 -= value;
1672
1673                 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1674                 {
1675                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1676                 }
1677             }
1678         }
1679
1680         private void OnWindowFocusedChanged2(bool focusGained)
1681         {
1682             WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1683
1684             e.FocusGained = focusGained;
1685
1686             if (_windowFocusChangedEventHandler2 != null)
1687             {
1688                 _windowFocusChangedEventHandler2(this, e);
1689             }
1690         }
1691
1692         /// <summary>
1693         /// Gets or sets a size of the window.
1694         /// </summary>
1695         /// <since_tizen> 4 </since_tizen>
1696         public Size2D WindowSize
1697         {
1698             get
1699             {
1700                 return GetWindowSize();
1701             }
1702             set
1703             {
1704                 SetWindowSize(value);
1705             }
1706         }
1707
1708         /// <summary>
1709         /// Gets or sets a position of the window.
1710         /// </summary>
1711         /// <since_tizen> 4 </since_tizen>
1712         public Position2D WindowPosition
1713         {
1714             get
1715             {
1716                 return GetPosition();
1717             }
1718             set
1719             {
1720                 SetPosition(value);
1721             }
1722         }
1723
1724         /// <summary>
1725         /// Sets position and size of the window. This API guarantees that
1726         /// both moving and resizing of window will appear on the screen at once.
1727         /// </summary>
1728         [EditorBrowsable(EditorBrowsableState.Never)]
1729         public Rectangle WindowPositionSize
1730         {
1731             get
1732             {
1733                 Position2D position = GetPosition();
1734                 Size2D size = GetSize();
1735                 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
1736                 return ret;
1737             }
1738             set
1739             {
1740                 SetPositionSize(value);
1741             }
1742         }
1743
1744         /// <summary>
1745         /// Feeds a key event into the window.
1746         /// </summary>
1747         /// <param name="keyEvent">The key event to feed.</param>
1748         /// <since_tizen> 5 </since_tizen>
1749         public void FeedKey(Key keyEvent)
1750         {
1751             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1752             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1753         }
1754
1755         /// <summary>
1756         /// Feed a key-event into the window.
1757         /// </summary>
1758         /// <param name="keyEvent">The key event to feed.</param>
1759         /// <since_tizen> 4 </since_tizen>
1760         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
1761         public static void FeedKeyEvent(Key keyEvent)
1762         {
1763             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1764             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1765         }
1766
1767         /// <summary>
1768         /// Allows at least one more render, even when paused.
1769         /// The window should be shown, not minimised.
1770         /// </summary>
1771         /// <since_tizen> 4 </since_tizen>
1772         public void RenderOnce()
1773         {
1774             NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1775             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1776         }
1777
1778         /// <summary>
1779         /// Contains and encapsulates Native Window handle.
1780         /// </summary>
1781         /// <since_tizen> 4 </since_tizen>
1782         public class SafeNativeWindowHandle : SafeHandle
1783         {
1784             /// <summary>
1785             /// Contructor, Native window handle is set to handle.
1786             /// </summary>
1787             /// <since_tizen> 4 </since_tizen>
1788             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1789             {
1790                 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1791             }
1792             /// <summary>
1793             /// Null check if the handle is valid or not.
1794             /// </summary>
1795             /// <since_tizen> 4 </since_tizen>
1796             public override bool IsInvalid
1797             {
1798                 get
1799                 {
1800                     return this.handle == IntPtr.Zero;
1801                 }
1802             }
1803             /// <summary>
1804             /// Release handle itself.
1805             /// </summary>
1806             /// <returns>true when released successfully.</returns>
1807             /// <since_tizen> 4 </since_tizen>
1808             protected override bool ReleaseHandle()
1809             {
1810                 return true;
1811             }
1812         }
1813
1814         /// <summary>
1815         /// Disconnect all native signals
1816         /// </summary>
1817         /// <since_tizen> 5 </since_tizen>
1818         internal void DisconnectNativeSignals() 
1819         {
1820             if( _windowFocusChangedEventCallback != null )
1821             {
1822                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
1823             }
1824
1825             if( _rootLayerTouchDataCallback != null )
1826             {
1827                 TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
1828             }
1829
1830             if( _wheelEventCallback != null )
1831             {
1832                 StageWheelEventSignal().Disconnect(_wheelEventCallback);
1833             }
1834
1835             if( _stageKeyCallbackDelegate != null )
1836             {
1837                 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1838             }
1839
1840             if( _stageEventProcessingFinishedEventCallbackDelegate != null )
1841             {
1842                 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1843             }
1844
1845             if( _stageContextLostEventCallbackDelegate != null )
1846             {
1847                 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1848             }
1849
1850             if( _stageContextRegainedEventCallbackDelegate != null )
1851             {
1852                 ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1853             }
1854
1855             if( _stageSceneCreatedEventCallbackDelegate != null )
1856             {
1857                 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1858             }
1859
1860             if( _windowResizedEventCallback != null )
1861             {
1862                 ResizedSignal().Disconnect(_windowResizedEventCallback);
1863             }
1864
1865             if( _windowFocusChangedEventCallback2 != null )
1866             {
1867                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1868             }
1869
1870         }
1871
1872     }
1873 }