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