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