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