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