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