[NUI] NUI Integration - nui_1.2.83 version (#98)
[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         private StageWheelSignal WheelEventSignal()
732         {
733             StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
734             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735             return ret;
736         }
737
738         internal VoidSignal ContextLostSignal()
739         {
740             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
741             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742             return ret;
743         }
744
745         internal VoidSignal ContextRegainedSignal()
746         {
747             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
748             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749             return ret;
750         }
751
752         internal VoidSignal SceneCreatedSignal()
753         {
754             VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
755             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
756             return ret;
757         }
758
759         internal ResizedSignal ResizedSignal()
760         {
761             ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
762             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763             return ret;
764         }
765
766         internal static Vector4 DEFAULT_BACKGROUND_COLOR
767         {
768             get
769             {
770                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
771                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
772                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
773                 return ret;
774             }
775         }
776
777         internal static Vector4 DEBUG_BACKGROUND_COLOR
778         {
779             get
780             {
781                 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
782                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
783                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784                 return ret;
785             }
786         }
787
788         private static readonly Window instance = Application.Instance.GetWindow();
789
790         /// <summary>
791         /// The stage instance property (read-only).<br />
792         /// Gets the current window.<br />
793         /// </summary>
794         /// <since_tizen> 3 </since_tizen>
795         public static Window Instance
796         {
797             get
798             {
799                 return instance;
800             }
801         }
802
803         /// <summary>
804         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
805         /// This function can be used for following example scenarios: <br />
806         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
807         /// </summary>
808         /// <param name="DaliKey">The key code to grab.</param>
809         /// <returns>True if the grab succeeds.</returns>
810         /// <since_tizen> 3 </since_tizen>
811         public bool GrabKeyTopmost(int DaliKey)
812         {
813             bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
814             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815             return ret;
816         }
817
818         /// <summary>
819         /// Ungrabs the key specified by a key for the window.<br />
820         /// 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 />
821         /// </summary>
822         /// <param name="DaliKey">The key code to ungrab.</param>
823         /// <returns>True if the ungrab succeeds.</returns>
824         /// <since_tizen> 3 </since_tizen>
825         public bool UngrabKeyTopmost(int DaliKey)
826         {
827             bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
828             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
829             return ret;
830         }
831
832         /// <summary>
833         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
834         ///  Details: This function can be used for following example scenarios: <br />
835         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
836         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
837         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
838         /// </summary>
839         /// <param name="DaliKey">The key code to grab.</param>
840         /// <param name="GrabMode">The grab mode for the key.</param>
841         /// <returns>True if the grab succeeds.</returns>
842         /// <since_tizen> 3 </since_tizen>
843         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
844         {
845             bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
846             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847             return ret;
848         }
849
850         /// <summary>
851         /// Ungrabs the key specified by a key for a window.<br />
852         /// 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 />
853         /// </summary>
854         /// <param name="DaliKey">The key code to ungrab.</param>
855         /// <returns>True if the ungrab succeeds.</returns>
856         /// <since_tizen> 3 </since_tizen>
857         public bool UngrabKey(int DaliKey)
858         {
859             bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
860             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
861             return ret;
862         }
863
864         internal System.IntPtr GetNativeWindowHandler()
865         {
866             System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
867             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
868             return ret;
869         }
870
871         /// <summary>
872         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
873         /// </summary>
874         /// <since_tizen> 3 </since_tizen>
875         public enum WindowOrientation
876         {
877             /// <summary>
878             /// Portrait orientation. The height of the display area is greater than the width.
879             /// </summary>
880             /// <since_tizen> 3 </since_tizen>
881             Portrait = 0,
882             /// <summary>
883             /// Landscape orientation. A wide view area is needed.
884             /// </summary>
885             /// <since_tizen> 3 </since_tizen>
886             Landscape = 90,
887             /// <summary>
888             /// Portrait inverse orientation.
889             /// </summary>
890             /// <since_tizen> 3 </since_tizen>
891             PortraitInverse = 180,
892             /// <summary>
893             /// Landscape inverse orientation.
894             /// </summary>
895             /// <since_tizen> 3 </since_tizen>
896             LandscapeInverse = 270
897         }
898
899         /// <summary>
900         /// Enumeration for the key grab mode for platform-level APIs.
901         /// </summary>
902         /// <since_tizen> 3 </since_tizen>
903         public enum KeyGrabMode
904         {
905             /// <summary>
906             /// Grabs a key only when on the top of the grabbing-window stack mode.
907             /// </summary>
908             Topmost = 0,
909             /// <summary>
910             /// Grabs a key together with the other client window(s) mode.
911             /// </summary>
912             Shared,
913             /// <summary>
914             /// 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.
915             /// </summary>
916             OverrideExclusive,
917             /// <summary>
918             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
919             /// </summary>
920             Exclusive
921         };
922
923         /// <summary>
924         /// Enumeration for opacity of the indicator.
925         /// </summary>
926         internal enum IndicatorBackgroundOpacity
927         {
928             Opaque = 100,
929             Translucent = 50,
930             Transparent = 0
931         }
932
933         /// <summary>
934         /// Enumeration for visible mode of the indicator.
935         /// </summary>
936         internal enum IndicatorVisibleMode
937         {
938             Invisible = 0,
939             Visible = 1,
940             Auto = 2
941         }
942
943         /// <summary>
944         /// The touch event argument.
945         /// </summary>
946         /// <since_tizen> 3 </since_tizen>
947         public class TouchEventArgs : EventArgs
948         {
949             private Touch _touch;
950
951             /// <summary>
952             /// Touch.
953             /// </summary>
954             /// <since_tizen> 3 </since_tizen>
955             public Touch Touch
956             {
957                 get
958                 {
959                     return _touch;
960                 }
961                 set
962                 {
963                     _touch = value;
964                 }
965             }
966         }
967
968         private event EventHandler<TouchEventArgs> _stageTouchHandler;
969         private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
970
971         /// <summary>
972         /// This event is emitted when the screen is touched and when the touch ends.<br />
973         /// If there are multiple touch points, then this will be emitted when the first touch occurs and
974         /// then when the last finger is lifted.<br />
975         /// An interrupted event will also be emitted (if it occurs).<br />
976         /// </summary>
977         /// <since_tizen> 3 </since_tizen>
978         public event EventHandler<TouchEventArgs> TouchEvent
979         {
980             add
981             {
982                 lock (this)
983                 {
984                     _stageTouchHandler += value;
985                     _stageTouchCallbackDelegate = OnStageTouch;
986                     this.TouchSignal().Connect(_stageTouchCallbackDelegate);
987                 }
988             }
989             remove
990             {
991                 lock (this)
992                 {
993                     if (_stageTouchHandler != null)
994                     {
995                         this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
996                     }
997                     _stageTouchHandler -= value;
998                 }
999             }
1000         }
1001
1002         private void OnStageTouch(IntPtr data)
1003         {
1004             TouchEventArgs e = new TouchEventArgs();
1005
1006             if (data != null)
1007             {
1008                 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
1009             }
1010
1011             if (_stageTouchHandler != null)
1012             {
1013                 _stageTouchHandler(this, e);
1014             }
1015         }
1016
1017         /// <summary>
1018         /// Wheel event arguments.
1019         /// </summary>
1020         /// <since_tizen> 3 </since_tizen>
1021         public class WheelEventArgs : EventArgs
1022         {
1023             private Wheel _wheel;
1024
1025             /// <summary>
1026             /// Wheel.
1027             /// </summary>
1028             /// <since_tizen> 3 </since_tizen>
1029             public Wheel Wheel
1030             {
1031                 get
1032                 {
1033                     return _wheel;
1034                 }
1035                 set
1036                 {
1037                     _wheel = value;
1038                 }
1039             }
1040         }
1041
1042         private event EventHandler<WheelEventArgs> _stageWheelHandler;
1043         private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1044
1045         /// <summary>
1046         /// This event is emitted when the wheel event is received.
1047         /// </summary>
1048         /// <since_tizen> 3 </since_tizen>
1049         public event EventHandler<WheelEventArgs> WheelEvent
1050         {
1051             add
1052             {
1053                 if (_stageWheelHandler == null)
1054                 {
1055                     _stageWheelCallbackDelegate = OnStageWheel;
1056                     WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1057                 }
1058                 _stageWheelHandler += value;
1059             }
1060             remove
1061             {
1062                 _stageWheelHandler -= value;
1063                 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1064                 {
1065                     WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1066                 }
1067             }
1068         }
1069
1070         private void OnStageWheel(IntPtr data)
1071         {
1072             WheelEventArgs e = new WheelEventArgs();
1073
1074             if (data != null)
1075             {
1076                 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1077             }
1078
1079             if (_stageWheelHandler != null)
1080             {
1081                 _stageWheelHandler(this, e);
1082             }
1083         }
1084
1085         /// <summary>
1086         /// Key event arguments.
1087         /// </summary>
1088         /// <since_tizen> 3 </since_tizen>
1089         public class KeyEventArgs : EventArgs
1090         {
1091             private Key _key;
1092
1093             /// <summary>
1094             /// Key.
1095             /// </summary>
1096             /// <since_tizen> 3 </since_tizen>
1097             public Key Key
1098             {
1099                 get
1100                 {
1101                     return _key;
1102                 }
1103                 set
1104                 {
1105                     _key = value;
1106                 }
1107             }
1108         }
1109
1110         private event EventHandler<KeyEventArgs> _stageKeyHandler;
1111         private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1112
1113         /// <summary>
1114         /// This event is emitted when the key event is received.
1115         /// </summary>
1116         /// <since_tizen> 3 </since_tizen>
1117         public event EventHandler<KeyEventArgs> KeyEvent
1118         {
1119             add
1120             {
1121                 if (_stageKeyHandler == null)
1122                 {
1123                     _stageKeyCallbackDelegate = OnStageKey;
1124                     KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1125                 }
1126                 _stageKeyHandler += value;
1127             }
1128             remove
1129             {
1130                 _stageKeyHandler -= value;
1131                 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1132                 {
1133                     KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1134                 }
1135             }
1136         }
1137
1138         // Callback for Stage KeyEventsignal
1139         private void OnStageKey(IntPtr data)
1140         {
1141             KeyEventArgs e = new KeyEventArgs();
1142
1143             if (data != null)
1144             {
1145                 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1146             }
1147
1148             if (_stageKeyHandler != null)
1149             {
1150                 //here we send all data to user event handlers
1151                 _stageKeyHandler(this, e);
1152             }
1153         }
1154
1155
1156         private event EventHandler _stageEventProcessingFinishedEventHandler;
1157         private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1158
1159         internal event EventHandler EventProcessingFinished
1160         {
1161             add
1162             {
1163                 if (_stageEventProcessingFinishedEventHandler == null)
1164                 {
1165                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1166                     EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1167                 }
1168                 _stageEventProcessingFinishedEventHandler += value;
1169
1170             }
1171             remove
1172             {
1173                 _stageEventProcessingFinishedEventHandler -= value;
1174                 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1175                 {
1176                     EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1177                 }
1178             }
1179         }
1180
1181         // Callback for Stage EventProcessingFinishedSignal
1182         private void OnEventProcessingFinished()
1183         {
1184             if (_stageEventProcessingFinishedEventHandler != null)
1185             {
1186                 _stageEventProcessingFinishedEventHandler(this, null);
1187             }
1188         }
1189
1190
1191         private EventHandler _stageContextLostEventHandler;
1192         private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1193
1194         internal event EventHandler ContextLost
1195         {
1196             add
1197             {
1198                 if (_stageContextLostEventHandler == null)
1199                 {
1200                     _stageContextLostEventCallbackDelegate = OnContextLost;
1201                     ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1202                 }
1203                 _stageContextLostEventHandler += value;
1204             }
1205             remove
1206             {
1207                 _stageContextLostEventHandler -= value;
1208                 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1209                 {
1210                     ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1211                 }
1212             }
1213         }
1214
1215         // Callback for Stage ContextLostSignal
1216         private void OnContextLost()
1217         {
1218             if (_stageContextLostEventHandler != null)
1219             {
1220                 _stageContextLostEventHandler(this, null);
1221             }
1222         }
1223
1224
1225         private EventHandler _stageContextRegainedEventHandler;
1226         private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1227
1228         internal event EventHandler ContextRegained
1229         {
1230             add
1231             {
1232                 if (_stageContextRegainedEventHandler == null)
1233                 {
1234                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1235                     ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1236                 }
1237                 _stageContextRegainedEventHandler += value;
1238             }
1239             remove
1240             {
1241                 _stageContextRegainedEventHandler -= value;
1242                 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1243                 {
1244                     this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1245                 }
1246             }
1247         }
1248
1249         // Callback for Stage ContextRegainedSignal
1250         private void OnContextRegained()
1251         {
1252             if (_stageContextRegainedEventHandler != null)
1253             {
1254                 _stageContextRegainedEventHandler(this, null);
1255             }
1256         }
1257
1258
1259         private EventHandler _stageSceneCreatedEventHandler;
1260         private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1261
1262         internal event EventHandler SceneCreated
1263         {
1264             add
1265             {
1266                 if (_stageSceneCreatedEventHandler == null)
1267                 {
1268                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1269                     SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1270                 }
1271                 _stageSceneCreatedEventHandler += value;
1272             }
1273             remove
1274             {
1275                 _stageSceneCreatedEventHandler -= value;
1276                 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1277                 {
1278                     SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1279                 }
1280             }
1281         }
1282
1283         // Callback for Stage SceneCreatedSignal
1284         private void OnSceneCreated()
1285         {
1286             if (_stageSceneCreatedEventHandler != null)
1287             {
1288                 _stageSceneCreatedEventHandler(this, null);
1289             }
1290         }
1291
1292         /// <summary>
1293         /// This resized event arguments.
1294         /// </summary>
1295         /// <since_tizen> 3 </since_tizen>
1296         public class ResizedEventArgs : EventArgs
1297         {
1298             Size2D _windowSize;
1299
1300             /// <summary>
1301             /// This window size.
1302             /// </summary>
1303             /// <since_tizen> 4 </since_tizen>
1304             public Size2D WindowSize
1305             {
1306                 get
1307                 {
1308                     return _windowSize;
1309                 }
1310                 set
1311                 {
1312                     _windowSize = value;
1313                 }
1314             }
1315         }
1316
1317         private WindowResizedEventCallbackType _windowResizedEventCallback;
1318         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1319         private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1320         private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1321
1322         /// <summary>
1323         /// This event is emitted when the window resized.
1324         /// </summary>
1325         /// <since_tizen> 3 </since_tizen>
1326         public event EventHandler<ResizedEventArgs> Resized
1327         {
1328             add
1329             {
1330                 if (_windowResizedEventHandler == null)
1331                 {
1332                     _windowResizedEventCallback = OnResized;
1333                     ResizedSignal().Connect(_windowResizedEventCallback);
1334                 }
1335
1336                 _windowResizedEventHandler += value;
1337             }
1338             remove
1339             {
1340                 _windowResizedEventHandler -= value;
1341
1342                 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1343                 {
1344                     ResizedSignal().Disconnect(_windowResizedEventCallback);
1345                 }
1346             }
1347         }
1348
1349         private void OnResized(IntPtr windowSize)
1350         {
1351             ResizedEventArgs e = new ResizedEventArgs();
1352             var val = new Uint16Pair(windowSize, false);
1353             e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1354             val.Dispose();
1355
1356             if (_windowResizedEventHandler != null)
1357             {
1358                 _windowResizedEventHandler(this, e);
1359             }
1360         }
1361
1362         internal void SetWindowSize(Size2D size)
1363         {
1364             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1365             NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1366
1367             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1368         }
1369
1370         internal Size2D GetWindowSize()
1371         {
1372             var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1373             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1374
1375             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1376             return ret;
1377         }
1378
1379         internal void SetPosition(Position2D position)
1380         {
1381             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1382             NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1383
1384             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1385         }
1386
1387         internal Position2D GetPosition()
1388         {
1389             var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1390             Position2D ret = new Position2D(val.GetX(), val.GetY());
1391
1392             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1393             return ret;
1394         }
1395
1396         /// <summary>
1397         /// Sets whether the window is transparent or not.
1398         /// </summary>
1399         /// <param name="transparent">Whether the window is transparent.</param>
1400         /// <since_tizen> 5 </since_tizen>
1401         public void SetTransparency(bool transparent) {
1402             NDalicManualPINVOKE.SetTransparency(swigCPtr, transparent);
1403             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1404         }
1405
1406         /// <summary>
1407         /// The window size property (read-only).
1408         /// </summary>
1409         /// <since_tizen> 3 </since_tizen>
1410         public Size2D Size
1411         {
1412             get
1413             {
1414                 Size2D ret = GetSize();
1415                 return ret;
1416             }
1417         }
1418
1419         /// <summary>
1420         /// The background color property.
1421         /// </summary>
1422         /// <since_tizen> 3 </since_tizen>
1423         public Color BackgroundColor
1424         {
1425             set
1426             {
1427                 SetBackgroundColor(value);
1428             }
1429             get
1430             {
1431                 Color ret = GetBackgroundColor();
1432                 return ret;
1433             }
1434         }
1435
1436         /// <summary>
1437         /// The DPI property (read-only).<br />
1438         /// Retrieves the DPI of the display device to which the Window is connected.<br />
1439         /// </summary>
1440         /// <since_tizen> 3 </since_tizen>
1441         public Vector2 Dpi
1442         {
1443             get
1444             {
1445                 return GetDpi();
1446             }
1447         }
1448
1449         /// <summary>
1450         /// The layer count property (read-only).<br />
1451         /// Queries the number of on-Window layers.<br />
1452         /// </summary>
1453         /// <since_tizen> 3 </since_tizen>
1454         public uint LayerCount
1455         {
1456             get
1457             {
1458                 return GetLayerCount();
1459             }
1460         }
1461
1462
1463         /// <summary>
1464         /// Adds a layer to the stage.
1465         /// </summary>
1466         /// <param name="layer">Layer to add.</param>
1467         /// <since_tizen> 3 </since_tizen>
1468         public void AddLayer(Layer layer)
1469         {
1470             NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1471             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1472
1473             LayersChildren.Add(layer);
1474         }
1475
1476         /// <summary>
1477         /// Removes a layer from the stage.
1478         /// </summary>
1479         /// <param name="layer">Layer to remove.</param>
1480         /// <since_tizen> 3 </since_tizen>
1481         public void RemoveLayer(Layer layer)
1482         {
1483             NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1484             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1485
1486             LayersChildren.Remove(layer);
1487         }
1488
1489         /// <summary>
1490         /// Please do not use! this will be deprecated
1491         /// </summary>
1492         /// <since_tizen> 3 </since_tizen>
1493         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1494             "Like: " +
1495             "Window.Instance.FocusChanged = OnFocusChanged; " +
1496             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1497         [EditorBrowsable(EditorBrowsableState.Never)]
1498         public class WindowFocusChangedEventArgs : EventArgs
1499         {
1500             /// <summary>
1501             /// Please do not use! this will be deprecated
1502             /// </summary>
1503             /// <since_tizen> 3 </since_tizen>
1504             public bool FocusGained
1505             {
1506                 get;
1507                 set;
1508             }
1509         }
1510
1511         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1512         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1513         private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1514         private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1515
1516         /// <summary>
1517         /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
1518         /// </summary>
1519         /// <since_tizen> 3 </since_tizen>
1520         /// Please do not use! this will be deprecated!
1521         /// Instead please use FocusChanged.
1522         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
1523             "Like: " +
1524             "Window.Instance.FocusChanged = OnFocusChanged; " +
1525             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1526         [EditorBrowsable(EditorBrowsableState.Never)]
1527         public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1528         {
1529             add
1530             {
1531                 if (_windowFocusChangedEventHandler2 == null)
1532                 {
1533                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1534                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1535                 }
1536
1537                 _windowFocusChangedEventHandler2 += value;
1538             }
1539             remove
1540             {
1541                 _windowFocusChangedEventHandler2 -= value;
1542
1543                 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1544                 {
1545                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1546                 }
1547             }
1548         }
1549
1550         private void OnWindowFocusedChanged2(bool focusGained)
1551         {
1552             WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1553
1554             e.FocusGained = focusGained;
1555
1556             if (_windowFocusChangedEventHandler2 != null)
1557             {
1558                 _windowFocusChangedEventHandler2(this, e);
1559             }
1560         }
1561
1562         /// <summary>
1563         /// Gets or sets a size of the window.
1564         /// </summary>
1565         /// <since_tizen> 4 </since_tizen>
1566         public Size2D WindowSize
1567         {
1568             get
1569             {
1570                 return GetWindowSize();
1571             }
1572             set
1573             {
1574                 SetWindowSize(value);
1575             }
1576         }
1577
1578         /// <summary>
1579         /// Gets or sets a position of the window.
1580         /// </summary>
1581         /// <since_tizen> 4 </since_tizen>
1582         public Position2D WindowPosition
1583         {
1584             get
1585             {
1586                 return GetPosition();
1587             }
1588             set
1589             {
1590                 SetPosition(value);
1591             }
1592         }
1593
1594         /// <summary>
1595         /// Feed a key-event into the window.
1596         /// </summary>
1597         /// <param name="keyEvent">The key event to feed.</param>
1598         /// <since_tizen> 5 </since_tizen>
1599         public void FeedKey(Key keyEvent)
1600         {
1601             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1602             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1603         }
1604
1605         /// <summary>
1606         /// Feed a key-event into the window.
1607         /// </summary>
1608         /// <param name="keyEvent">The key event to feed.</param>
1609         /// <since_tizen> 4 </since_tizen>
1610         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
1611         public void FeedKeyEvent(Key keyEvent)
1612         {
1613             NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1614             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1615         }
1616
1617         /// <summary>
1618         /// Allows at least one more render, even when paused.
1619         /// The window should be shown, not minimised.
1620         /// </summary>
1621         /// <since_tizen> 4 </since_tizen>
1622         public void RenderOnce()
1623         {
1624             NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1625             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1626         }
1627
1628         /// <summary>
1629         /// Contains and encapsulates Native Window handle.
1630         /// </summary>
1631         /// <since_tizen> 4 </since_tizen>
1632         public class SafeNativeWindowHandle : SafeHandle
1633         {
1634             /// <summary>
1635             /// Contructor, Native window handle is set to handle.
1636             /// </summary>
1637             /// <since_tizen> 4 </since_tizen>
1638             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1639             {
1640                 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1641             }
1642             /// <summary>
1643             /// Null check if the handle is valid or not.
1644             /// </summary>
1645             /// <since_tizen> 4 </since_tizen>
1646             public override bool IsInvalid
1647             {
1648                 get
1649                 {
1650                     return this.handle == IntPtr.Zero;
1651                 }
1652             }
1653             /// <summary>
1654             /// Release handle itself.
1655             /// </summary>
1656             /// <returns>true when released successfully.</returns>
1657             /// <since_tizen> 4 </since_tizen>
1658             protected override bool ReleaseHandle()
1659             {
1660                 return true;
1661             }
1662         }
1663
1664     }
1665 }