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