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