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