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