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