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