01e2ffd2cc2b3c2bf044e6d137b4201fa63301cd
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / Window.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
20
21 using System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
25
26 using Tizen.NUI.BaseComponents;
27
28 namespace Tizen.NUI
29 {
30     /// <summary>
31     /// The window class is used internally for drawing.<br />
32     /// The window has an orientation and indicator properties.<br />
33     /// </summary>
34     /// <since_tizen> 3 </since_tizen>
35     public partial class Window : BaseHandle
36     {
37         private HandleRef stageCPtr;
38         private Layer rootLayer;
39         private Layer overlayLayer;
40         private Layer borderLayer;
41         private string windowTitle;
42         private List<Layer> childLayers = new List<Layer>();
43         private LayoutController localController;
44         private Key internalLastKeyEvent;
45         private Touch internalLastTouchEvent;
46
47         static internal bool IsSupportedMultiWindow()
48         {
49             bool isSupported = false;
50             try
51             {
52                 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
53             }
54             catch (DllNotFoundException e)
55             {
56                 Tizen.Log.Fatal("NUI", $"{e}\n");
57             }
58             return isSupported;
59         }
60
61         internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
62         {
63             if (Interop.Stage.IsInstalled())
64             {
65                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
66
67                 localController = new LayoutController(this);
68                 NUILog.Debug("layoutController id:" + localController.GetId());
69             }
70         }
71
72         /// <summary>
73         /// A helper method to get the current window where the view is added
74         /// </summary>
75         /// <param name="view">The View added to the window</param>
76         /// <returns>A Window.</returns>
77         [EditorBrowsable(EditorBrowsableState.Never)]
78         static public Window Get(View view)
79         {
80             if (view == null)
81             {
82                 NUILog.Error("if there is no view, it can not get a window");
83                 return null;
84             }
85
86             //to fix memory leak issue, match the handle count with native side.
87             Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
88             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89             return ret;
90         }
91
92         /// <summary>
93         /// Creates a new Window.<br />
94         /// This creates an extra window in addition to the default main window<br />
95         /// </summary>
96         /// <param name="windowPosition">The position and size of the Window.</param>
97         /// <param name="isTranslucent">Whether Window is translucent.</param>
98         /// <returns>A new Window.</returns>
99         /// <since_tizen> 6 </since_tizen>
100         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
101         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
102         public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
103         {
104             if (IsSupportedMultiWindow() == false)
105             {
106                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
107             }
108             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109         }
110
111         /// <summary>
112         /// Creates a new Window with a specific name.<br />
113         /// This creates an extra window in addition to the default main window<br />
114         /// </summary>
115         /// <param name="name">The name for extra window. </param>
116         /// <param name="windowPosition">The position and size of the Window.</param>
117         /// <param name="isTranslucent">Whether Window is translucent.</param>
118         /// <returns>A new Window.</returns>
119         /// <since_tizen> 6 </since_tizen>
120         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
121         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
122         public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
123         {
124             if (IsSupportedMultiWindow() == false)
125             {
126                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
127             }
128             this.windowTitle = name;
129             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130         }
131
132         /// <summary>
133         /// Creates a new Window with a specific name.<br />
134         /// This creates an extra window in addition to the default main window<br />
135         /// </summary>
136         /// <param name="name">The name for extra window. </param>
137         /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
138         /// <param name="windowPosition">The position and size of the Window.</param>
139         /// <param name="isTranslucent">Whether Window is translucent.</param>
140         /// <returns>A new Window.</returns>
141         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
142         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
145         {
146             if (IsSupportedMultiWindow() == false)
147             {
148                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
149             }
150             this.windowTitle = name;
151             this.EnableBorder(borderInterface);
152             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153         }
154
155
156         /// <summary>
157         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
158         /// </summary>
159         /// <since_tizen> 3 </since_tizen>
160         public enum WindowOrientation
161         {
162             /// <summary>
163             /// Portrait orientation. The height of the display area is greater than the width.
164             /// </summary>
165             /// <since_tizen> 3 </since_tizen>
166             Portrait = 0,
167             /// <summary>
168             /// Landscape orientation. A wide view area is needed.
169             /// </summary>
170             /// <since_tizen> 3 </since_tizen>
171             Landscape = 90,
172             /// <summary>
173             /// Portrait inverse orientation.
174             /// </summary>
175             /// <since_tizen> 3 </since_tizen>
176             PortraitInverse = 180,
177             /// <summary>
178             /// Landscape inverse orientation.
179             /// </summary>
180             /// <since_tizen> 3 </since_tizen>
181             LandscapeInverse = 270,
182             /// <summary>
183             /// No orientation. It is for the preferred orientation
184             /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
185             /// It is used to unset the preferred orientation with SetPreferredOrientation.
186             /// </summary>
187             [EditorBrowsable(EditorBrowsableState.Never)]
188             NoOrientationPreference = -1
189         }
190
191         /// <summary>
192         /// Enumeration for the key grab mode for platform-level APIs.
193         /// </summary>
194         /// <since_tizen> 3 </since_tizen>
195         public enum KeyGrabMode
196         {
197             /// <summary>
198             /// Grabs a key only when on the top of the grabbing-window stack mode.
199             /// </summary>
200             Topmost = 0,
201             /// <summary>
202             /// Grabs a key together with the other client window(s) mode.
203             /// </summary>
204             Shared,
205             /// <summary>
206             /// 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.
207             /// </summary>
208             OverrideExclusive,
209             /// <summary>
210             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
211             /// </summary>
212             Exclusive
213         };
214
215         /// <summary>
216         /// Enumeration for transition effect's state.
217         /// </summary>
218         [Obsolete("Do not use this, that will be removed. Use Window.EffectState instead.")]
219         [EditorBrowsable(EditorBrowsableState.Never)]
220         //  This is already deprecated, so suppress warning here.
221         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
222         public enum EffectStates
223         {
224             /// <summary>
225             /// None state.
226             /// </summary>
227             [Obsolete("Do not use this, that will be removed. Use Window.EffectState.None instead.")]
228             [EditorBrowsable(EditorBrowsableState.Never)]
229             None = 0,
230             /// <summary>
231             /// Transition effect is started.
232             /// </summary>
233             [Obsolete("Do not use this, that will be removed. Use Window.EffectState.Start instead.")]
234             [EditorBrowsable(EditorBrowsableState.Never)]
235             Start,
236             /// <summary>
237             /// Transition effect is ended.
238             /// </summary>
239             [Obsolete("Do not use this, that will be removed. Use Window.EffectState.End instead.")]
240             [EditorBrowsable(EditorBrowsableState.Never)]
241             End,
242         }
243
244         /// <summary>
245         /// Enumeration for transition effect's state.
246         /// </summary>
247         [EditorBrowsable(EditorBrowsableState.Never)]
248         public enum EffectState
249         {
250             /// <summary>
251             /// None state.
252             /// </summary>
253             [EditorBrowsable(EditorBrowsableState.Never)]
254             None = 0,
255             /// <summary>
256             /// Transition effect is started.
257             /// </summary>
258             [EditorBrowsable(EditorBrowsableState.Never)]
259             Start,
260             /// <summary>
261             /// Transition effect is ended.
262             /// </summary>
263             [EditorBrowsable(EditorBrowsableState.Never)]
264             End,
265         }
266
267         /// <summary>
268         /// Enumeration for transition effect's type.
269         /// </summary>
270         [Obsolete("Do not use this, that will be removed. Use Window.EffectType instead.")]
271         [EditorBrowsable(EditorBrowsableState.Never)]
272         //  This is already deprecated, so suppress warning here.
273         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
274         public enum EffectTypes
275         {
276             /// <summary>
277             /// None type.
278             /// </summary>
279             [Obsolete("Do not use this, that will be removed. Use Window.EffectType.None instead.")]
280             [EditorBrowsable(EditorBrowsableState.Never)]
281             None = 0,
282             /// <summary>
283             /// Window show effect.
284             /// </summary>
285             [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Show instead.")]
286             [EditorBrowsable(EditorBrowsableState.Never)]
287             Show,
288             /// <summary>
289             /// Window hide effect.
290             /// </summary>
291             [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Hide instead.")]
292             [EditorBrowsable(EditorBrowsableState.Never)]
293             Hide,
294         }
295
296         /// <summary>
297         /// Enumeration for transition effect's type.
298         /// </summary>
299         [EditorBrowsable(EditorBrowsableState.Never)]
300         public enum EffectType
301         {
302             /// <summary>
303             /// None type.
304             /// </summary>
305             [EditorBrowsable(EditorBrowsableState.Never)]
306             None = 0,
307             /// <summary>
308             /// Window show effect.
309             /// </summary>
310             [EditorBrowsable(EditorBrowsableState.Never)]
311             Show,
312             /// <summary>
313             /// Window hide effect.
314             /// </summary>
315             [EditorBrowsable(EditorBrowsableState.Never)]
316             Hide,
317         }
318
319         /// <summary>
320         /// Enumeration for result of window operation.
321         /// </summary>
322         internal enum OperationResult
323         {
324             /// <summary>
325             /// Failed for unknown reason
326             /// </summary>
327             UnknownError = 0,
328             /// <summary>
329             /// Succeed
330             /// </summary>
331             Succeed,
332             /// <summary>
333             /// Permission denied
334             /// </summary>
335             PermissionDenied,
336             /// <summary>
337             /// The operation is not supported.
338             /// </summary>
339             NotSupported,
340         }
341
342         /// <summary>
343         /// Enumeration for window resized mode by display server.
344         /// </summary>
345         [EditorBrowsable(EditorBrowsableState.Never)]
346         public enum ResizeDirection
347         {
348             /// <summary>
349             /// None type.
350             /// </summary>
351             [EditorBrowsable(EditorBrowsableState.Never)]
352             None = 0,
353             /// <summary>
354             /// Start resizing window to the top-left edge.
355             /// </summary>
356             [EditorBrowsable(EditorBrowsableState.Never)]
357             TopLeft = 1,
358             /// <summary>
359             /// Start resizing window to the top side.
360             /// </summary>
361             [EditorBrowsable(EditorBrowsableState.Never)]
362             Top = 2,
363             /// <summary>
364             /// Start resizing window to the top-right edge.
365             /// </summary>
366             [EditorBrowsable(EditorBrowsableState.Never)]
367             TopRight = 3,
368             /// <summary>
369             /// Start resizing window to the left side.
370             /// </summary>
371             [EditorBrowsable(EditorBrowsableState.Never)]
372             Left = 4,
373             /// <summary>
374             /// Start resizing window to the right side.
375             /// </summary>
376             [EditorBrowsable(EditorBrowsableState.Never)]
377             Right = 5,
378             /// <summary>
379             /// Start resizing window to the bottom-left edge.
380             /// </summary>
381             [EditorBrowsable(EditorBrowsableState.Never)]
382             BottomLeft = 6,
383             /// <summary>
384             /// Start resizing window to the bottom side.
385             /// </summary>
386             [EditorBrowsable(EditorBrowsableState.Never)]
387             Bottom = 7,
388             /// <summary>
389             /// Start resizing window to the bottom-right edge.
390             /// </summary>
391             [EditorBrowsable(EditorBrowsableState.Never)]
392             BottomRight = 8,
393         }
394
395
396         /// <summary>
397         /// The stage instance property (read-only).<br />
398         /// Gets the current window.<br />
399         /// </summary>
400         /// <since_tizen> 3 </since_tizen>
401         public static Window Instance { get; internal set; }
402
403         /// <summary>
404         /// Gets or sets a window type.
405         /// Most of window type can be set to use WindowType, except for IME type.
406         /// IME type can be set to use one of NUIApplication's constrcutors.
407         /// </summary>
408         /// <since_tizen> 3 </since_tizen>
409         public WindowType Type
410         {
411             get
412             {
413                 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
414                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
415                 return ret;
416             }
417             set
418             {
419                 Interop.Window.SetType(SwigCPtr, (int)value);
420                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421             }
422         }
423
424         /// <summary>
425         /// Gets/Sets a window title.
426         /// </summary>
427         /// <since_tizen> 4 </since_tizen>
428         public string Title
429         {
430             get
431             {
432                 return windowTitle;
433             }
434             set
435             {
436                 windowTitle = value;
437                 SetClass(windowTitle, "");
438             }
439         }
440
441         /// <summary>
442         /// The rendering behavior of a Window.
443         /// </summary>
444         /// <since_tizen> 5 </since_tizen>
445         public RenderingBehaviorType RenderingBehavior
446         {
447             get
448             {
449                 return GetRenderingBehavior();
450             }
451             set
452             {
453                 SetRenderingBehavior(value);
454             }
455         }
456
457         /// <summary>
458         /// The window size property (read-only).
459         /// </summary>
460         /// <since_tizen> 3 </since_tizen>
461         public Size2D Size
462         {
463             get
464             {
465                 Size2D ret = GetSize();
466                 return ret;
467             }
468         }
469
470         /// <summary>
471         /// The background color property.
472         /// </summary>
473         /// <since_tizen> 3 </since_tizen>
474         public Color BackgroundColor
475         {
476             set
477             {
478                 SetBackgroundColor(value);
479             }
480             get
481             {
482                 Color ret = GetBackgroundColor();
483                 return ret;
484             }
485         }
486
487         /// <summary>
488         /// The DPI property (read-only).<br />
489         /// Retrieves the DPI of the display device to which the Window is connected.<br />
490         /// </summary>
491         /// <since_tizen> 3 </since_tizen>
492         public Vector2 Dpi
493         {
494             get
495             {
496                 return GetDpi();
497             }
498         }
499
500         /// <summary>
501         /// The layer count property (read-only).<br />
502         /// Queries the number of on-Window layers.<br />
503         /// </summary>
504         /// <since_tizen> 3 </since_tizen>
505         public uint LayerCount
506         {
507             get
508             {
509                 return GetLayerCount();
510             }
511         }
512
513         /// <summary>
514         /// Gets or sets a size of the window.
515         /// </summary>
516         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
517         /// <since_tizen> 4 </since_tizen>
518         public Size2D WindowSize
519         {
520             get
521             {
522                 return GetWindowSize();
523             }
524             set
525             {
526                 SetWindowSize(value);
527             }
528         }
529
530         /// <summary>
531         /// Gets or sets a position of the window.
532         /// </summary>
533         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
534         /// <since_tizen> 4 </since_tizen>
535         public Position2D WindowPosition
536         {
537             get
538             {
539                 return GetPosition();
540             }
541             set
542             {
543                 SetPosition(value);
544             }
545         }
546
547         /// <summary>
548         /// Sets position and size of the window. This API guarantees that
549         /// both moving and resizing of window will appear on the screen at once.
550         /// </summary>
551         [EditorBrowsable(EditorBrowsableState.Never)]
552         public Rectangle WindowPositionSize
553         {
554             get
555             {
556                 Position2D position = GetPosition();
557                 Size2D size = GetSize();
558                 Rectangle ret = new Rectangle(position?.X ?? 0, position?.Y ?? 0, size?.Width ?? 0, size?.Height ?? 0);
559                 position.Dispose();
560                 return ret;
561             }
562             set
563             {
564                 SetPositionSize(value);
565             }
566         }
567
568         internal static Vector4 DEFAULT_BACKGROUND_COLOR
569         {
570             get
571             {
572                 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
573                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
574                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
575                 return ret;
576             }
577         }
578
579         internal static Vector4 DEBUG_BACKGROUND_COLOR
580         {
581             get
582             {
583                 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
584                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
585                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586                 return ret;
587             }
588         }
589
590         internal List<Layer> LayersChildren
591         {
592             get
593             {
594                 return childLayers;
595             }
596         }
597
598         /// <summary>
599         ///  Get the LayoutController for this Window.
600         /// </summary>
601         internal LayoutController LayoutController
602         {
603             get
604             {
605                 return localController;
606             }
607         }
608
609         /// <summary>
610         /// Feed a key-event into the window.
611         /// </summary>
612         /// <param name="keyEvent">The key event to feed.</param>
613         /// <since_tizen> 4 </since_tizen>
614         [Obsolete("Do not use this, that will be deprecated. Use FeedKey(Key keyEvent) instead.")]
615         public static void FeedKeyEvent(Key keyEvent)
616         {
617             Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
618             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
619         }
620
621         /// <summary>
622         /// Sets whether the window accepts a focus or not.
623         /// </summary>
624         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
625         /// <since_tizen> 3 </since_tizen>
626         public void SetAcceptFocus(bool accept)
627         {
628             Interop.Window.SetAcceptFocus(SwigCPtr, accept);
629             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
630         }
631
632         /// <summary>
633         /// Returns whether the window accepts a focus or not.
634         /// </summary>
635         /// <returns>True if the window accepts a focus, false otherwise.</returns>
636         /// <since_tizen> 3 </since_tizen>
637         public bool IsFocusAcceptable()
638         {
639             bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
640             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641
642             return ret;
643         }
644
645         /// <summary>
646         /// Shows the window if it is hidden.
647         /// </summary>
648         /// <since_tizen> 3 </since_tizen>
649         public void Show()
650         {
651             Interop.Window.Show(SwigCPtr);
652             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653         }
654
655         /// <summary>
656         /// Hides the window if it is showing.
657         /// </summary>
658         /// <since_tizen> 3 </since_tizen>
659         public void Hide()
660         {
661             Interop.Window.Hide(SwigCPtr);
662             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663         }
664
665         /// <summary>
666         /// Retrieves whether the window is visible or not.
667         /// </summary>
668         /// <returns>True if the window is visible.</returns>
669         /// <since_tizen> 3 </since_tizen>
670         public bool IsVisible()
671         {
672             bool temp = Interop.Window.IsVisible(SwigCPtr);
673             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674             return temp;
675         }
676
677         /// <summary>
678         /// Gets the count of supported auxiliary hints of the window.
679         /// </summary>
680         /// <returns>The number of supported auxiliary hints.</returns>
681         /// <since_tizen> 3 </since_tizen>
682         public uint GetSupportedAuxiliaryHintCount()
683         {
684             uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
685             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
686             return ret;
687         }
688
689         /// <summary>
690         /// Gets the supported auxiliary hint string of the window.
691         /// </summary>
692         /// <param name="index">The index of the supported auxiliary hint lists.</param>
693         /// <returns>The auxiliary hint string of the index.</returns>
694         /// <since_tizen> 3 </since_tizen>
695         public string GetSupportedAuxiliaryHint(uint index)
696         {
697             string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
698             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699             return ret;
700         }
701
702         /// <summary>
703         /// Creates an auxiliary hint of the window.
704         /// </summary>
705         /// <param name="hint">The auxiliary hint string.</param>
706         /// <param name="value">The value string.</param>
707         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
708         /// <since_tizen> 3 </since_tizen>
709         public uint AddAuxiliaryHint(string hint, string value)
710         {
711             uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
712             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
713             return ret;
714         }
715
716         /// <summary>
717         /// Removes an auxiliary hint of the window.
718         /// </summary>
719         /// <param name="id">The ID of the auxiliary hint.</param>
720         /// <returns>True if no error occurred, false otherwise.</returns>
721         /// <since_tizen> 3 </since_tizen>
722         public bool RemoveAuxiliaryHint(uint id)
723         {
724             bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
725             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
726             return ret;
727         }
728
729         /// <summary>
730         /// Changes a value of the auxiliary hint.
731         /// </summary>
732         /// <param name="id">The auxiliary hint ID.</param>
733         /// <param name="value">The value string to be set.</param>
734         /// <returns>True if no error occurred, false otherwise.</returns>
735         /// <since_tizen> 3 </since_tizen>
736         public bool SetAuxiliaryHintValue(uint id, string value)
737         {
738             bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
739             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
740             return ret;
741         }
742
743         /// <summary>
744         /// Gets a value of the auxiliary hint.
745         /// </summary>
746         /// <param name="id">The auxiliary hint ID.</param>
747         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
748         /// <since_tizen> 3 </since_tizen>
749         public string GetAuxiliaryHintValue(uint id)
750         {
751             string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
752             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
753             return ret;
754         }
755
756         /// <summary>
757         /// Gets an ID of the auxiliary hint string.
758         /// </summary>
759         /// <param name="hint">The auxiliary hint string.</param>
760         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
761         /// <since_tizen> 3 </since_tizen>
762         public uint GetAuxiliaryHintId(string hint)
763         {
764             uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
765             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766             return ret;
767         }
768
769         /// <summary>
770         /// Sets a region to accept input events.
771         /// </summary>
772         /// <param name="inputRegion">The region to accept input events.</param>
773         /// <since_tizen> 3 </since_tizen>
774         public void SetInputRegion(Rectangle inputRegion)
775         {
776             Interop.Window.SetInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
777             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778         }
779
780         /// <summary>
781         /// Sets a priority level for the specified notification window.
782         /// </summary>
783         /// <param name="level">The notification window level.</param>
784         /// <returns>True if no error occurred, false otherwise.</returns>
785         /// <since_tizen> 3 </since_tizen>
786         public bool SetNotificationLevel(NotificationLevel level)
787         {
788             var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
789             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
790             return ret == OperationResult.Succeed;
791         }
792
793         /// <summary>
794         /// Gets a priority level for the specified notification window.
795         /// </summary>
796         /// <returns>The notification window level.</returns>
797         /// <since_tizen> 3 </since_tizen>
798         public NotificationLevel GetNotificationLevel()
799         {
800             NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
801             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802             return ret;
803         }
804
805         /// <summary>
806         /// Sets a transparent window's visual state to opaque. <br />
807         /// If a visual state of a transparent window is opaque, <br />
808         /// then the window manager could handle it as an opaque window when calculating visibility.
809         /// </summary>
810         /// <param name="opaque">Whether the window's visual state is opaque.</param>
811         /// <remarks>This will have no effect on an opaque window. <br />
812         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
813         /// </remarks>
814         /// <since_tizen> 3 </since_tizen>
815         public void SetOpaqueState(bool opaque)
816         {
817             Interop.Window.SetOpaqueState(SwigCPtr, opaque);
818             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
819         }
820
821         /// <summary>
822         /// Returns whether a transparent window's visual state is opaque or not.
823         /// </summary>
824         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
825         /// <remarks> The return value has no meaning on an opaque window. </remarks>
826         /// <since_tizen> 3 </since_tizen>
827         public bool IsOpaqueState()
828         {
829             bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
830             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831             return ret;
832         }
833
834         /// <summary>
835         /// Sets a window's screen off mode.
836         /// </summary>
837         /// <param name="screenOffMode">The screen mode.</param>
838         /// <returns>True if no error occurred, false otherwise.</returns>
839         /// <since_tizen> 4 </since_tizen>
840         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
841         {
842             var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
843             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844             return ret == OperationResult.Succeed;
845         }
846
847         /// <summary>
848         /// Gets the screen mode of the window.
849         /// </summary>
850         /// <returns>The screen off mode.</returns>
851         /// <since_tizen> 4 </since_tizen>
852         public ScreenOffMode GetScreenOffMode()
853         {
854             ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
855             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
856             return ret;
857         }
858
859         /// <summary>
860         /// Sets preferred brightness of the window.
861         /// </summary>
862         /// <param name="brightness">The preferred brightness (0 to 100).</param>
863         /// <returns>True if no error occurred, false otherwise.</returns>
864         /// <since_tizen> 3 </since_tizen>
865         public bool SetBrightness(int brightness)
866         {
867             var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
868             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
869             return ret == OperationResult.Succeed;
870         }
871
872         /// <summary>
873         /// Gets the preferred brightness of the window.
874         /// </summary>
875         /// <returns>The preferred brightness.</returns>
876         /// <since_tizen> 3 </since_tizen>
877         public int GetBrightness()
878         {
879             int ret = Interop.Window.GetBrightness(SwigCPtr);
880             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
881             return ret;
882         }
883
884         /// <summary>
885         /// Sets the window name and the class string.
886         /// </summary>
887         /// <param name="name">The name of the window.</param>
888         /// <param name="klass">The class of the window.</param>
889         /// <since_tizen> 4 </since_tizen>
890         public void SetClass(string name, string klass)
891         {
892             Interop.Window.SetClass(SwigCPtr, name, klass);
893             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
894         }
895
896         /// <summary>
897         /// Raises the window to the top of the window stack.
898         /// </summary>
899         /// <since_tizen> 3 </since_tizen>
900         public void Raise()
901         {
902             Interop.Window.Raise(SwigCPtr);
903             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904         }
905
906         /// <summary>
907         /// Lowers the window to the bottom of the window stack.
908         /// </summary>
909         /// <since_tizen> 3 </since_tizen>
910         public void Lower()
911         {
912             Interop.Window.Lower(SwigCPtr);
913             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
914         }
915
916         /// <summary>
917         /// Activates the window to the top of the window stack even it is iconified.
918         /// </summary>
919         /// <since_tizen> 3 </since_tizen>
920         public void Activate()
921         {
922             Interop.Window.Activate(SwigCPtr);
923             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
924         }
925
926         /// <summary>
927         /// Gets the default ( root ) layer.
928         /// </summary>
929         /// <returns>The root layer.</returns>
930         /// <since_tizen> 3 </since_tizen>
931         public Layer GetDefaultLayer()
932         {
933             return this.GetRootLayer();
934         }
935
936         /// <summary>
937         /// Gets the overlay layer.
938         /// </summary>
939         /// <returns>The overlay layer.</returns>
940         [EditorBrowsable(EditorBrowsableState.Never)]
941         public Layer GetOverlayLayer()
942         {
943             // Window.IsInstalled() is actually true only when called from event thread and
944             // Core has been initialized, not when Stage is ready.
945             if (overlayLayer == null && Window.IsInstalled())
946             {
947                 overlayLayer = new Layer(Interop.Window.GetOverlayLayer(SwigCPtr), true);
948                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
949                 LayersChildren?.Add(overlayLayer);
950                 overlayLayer.SetWindow(this);
951             }
952             return overlayLayer;
953         }
954
955         /// <summary>
956         /// Add a child view to window.
957         /// </summary>
958         /// <param name="view">the child should be added to the window.</param>
959         /// <since_tizen> 3 </since_tizen>
960         public void Add(View view)
961         {
962             this.GetRootLayer().Add(view);
963         }
964
965         /// <summary>
966         /// Remove a child view from window.
967         /// </summary>
968         /// <param name="view">the child to be removed.</param>
969         /// <since_tizen> 3 </since_tizen>
970         public void Remove(View view)
971         {
972             this.GetRootLayer().Remove(view);
973         }
974
975         /// <summary>
976         /// Retrieves the layer at a specified depth.
977         /// </summary>
978         /// <param name="depth">The layer's depth index.</param>
979         /// <returns>The layer found at the given depth.</returns>
980         /// <since_tizen> 3 </since_tizen>
981         public Layer GetLayer(uint depth)
982         {
983             if (depth < LayersChildren?.Count)
984             {
985                 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
986                 return ret;
987             }
988             else
989             {
990                 return null;
991             }
992         }
993
994         /// <summary>
995         /// Destroy the window immediately.
996         /// </summary>
997         [EditorBrowsable(EditorBrowsableState.Never)]
998         public void Destroy()
999         {
1000             this.Dispose();
1001         }
1002
1003         /// <summary>
1004         /// Keep rendering for at least the given amount of time.
1005         /// </summary>
1006         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1007         /// <since_tizen> 3 </since_tizen>
1008         public void KeepRendering(float durationSeconds)
1009         {
1010             Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
1011             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012         }
1013
1014         /// <summary>
1015         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1016         /// This function can be used for following example scenarios: <br />
1017         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1018         /// </summary>
1019         /// <param name="DaliKey">The key code to grab.</param>
1020         /// <returns>True if the grab succeeds.</returns>
1021         /// <since_tizen> 3 </since_tizen>
1022         public bool GrabKeyTopmost(int DaliKey)
1023         {
1024             bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1025             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1026             return ret;
1027         }
1028
1029         /// <summary>
1030         /// Ungrabs the key specified by a key for the window.<br />
1031         /// 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 />
1032         /// </summary>
1033         /// <param name="DaliKey">The key code to ungrab.</param>
1034         /// <returns>True if the ungrab succeeds.</returns>
1035         /// <since_tizen> 3 </since_tizen>
1036         public bool UngrabKeyTopmost(int DaliKey)
1037         {
1038             bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1039             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1040             return ret;
1041         }
1042
1043         /// <summary>
1044         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
1045         ///  Details: This function can be used for following example scenarios: <br />
1046         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1047         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1048         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1049         /// </summary>
1050         /// <param name="DaliKey">The key code to grab.</param>
1051         /// <param name="GrabMode">The grab mode for the key.</param>
1052         /// <returns>True if the grab succeeds.</returns>
1053         /// <since_tizen> 3 </since_tizen>
1054         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1055         {
1056             bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1057             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1058             return ret;
1059         }
1060
1061         /// <summary>
1062         /// Ungrabs the key specified by a key for a window.<br />
1063         /// 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 />
1064         /// </summary>
1065         /// <param name="DaliKey">The key code to ungrab.</param>
1066         /// <returns>True if the ungrab succeeds.</returns>
1067         /// <since_tizen> 3 </since_tizen>
1068         public bool UngrabKey(int DaliKey)
1069         {
1070             bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1071             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1072             return ret;
1073         }
1074
1075         /// <summary>
1076         /// Sets the keyboard repeat information.
1077         /// </summary>
1078         /// <param name="rate">The key repeat rate value in seconds.</param>
1079         /// <param name="delay">The key repeat delay value in seconds.</param>
1080         /// <returns>True if setting the keyboard repeat succeeds.</returns>
1081         /// <since_tizen> 5 </since_tizen>
1082         public bool SetKeyboardRepeatInfo(float rate, float delay)
1083         {
1084             bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1085             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1086             return ret;
1087         }
1088
1089         /// <summary>
1090         /// Gets the keyboard repeat information.
1091         /// </summary>
1092         /// <param name="rate">The key repeat rate value in seconds.</param>
1093         /// <param name="delay">The key repeat delay value in seconds.</param>
1094         /// <returns>True if setting the keyboard repeat succeeds.</returns>
1095         /// <since_tizen> 5 </since_tizen>
1096         public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1097         {
1098             bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1099             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1100             return ret;
1101         }
1102
1103         /// <summary>
1104         /// Adds a layer to the stage.
1105         /// </summary>
1106         /// <param name="layer">Layer to add.</param>
1107         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1108         /// <since_tizen> 3 </since_tizen>
1109         public void AddLayer(Layer layer)
1110         {
1111             Add(layer);
1112         }
1113
1114         /// <summary>
1115         /// Removes a layer from the stage.
1116         /// </summary>
1117         /// <param name="layer">Layer to remove.</param>
1118         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1119         /// <since_tizen> 3 </since_tizen>
1120         public void RemoveLayer(Layer layer)
1121         {
1122             Remove(layer);
1123         }
1124
1125         /// <summary>
1126         /// Feeds a key event into the window.
1127         /// </summary>
1128         /// <param name="keyEvent">The key event to feed.</param>
1129         /// <since_tizen> 5 </since_tizen>
1130         public void FeedKey(Key keyEvent)
1131         {
1132             Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1133             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1134         }
1135
1136         /// <summary>
1137         /// Feeds a touch point into the window.
1138         /// </summary>
1139         /// <param name="touchPoint">The touch point to feed.</param>
1140         /// <param name="timeStamp">The timeStamp.</param>
1141         internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1142         {
1143             Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1145         }
1146
1147         /// <summary>
1148         /// Feeds a wheel event into the window.
1149         /// </summary>
1150         /// <param name="wheelEvent">The wheel event to feed.</param>
1151         internal void FeedWheel(Wheel wheelEvent)
1152         {
1153             Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1155         }
1156
1157         /// <summary>
1158         /// Allows at least one more render, even when paused.
1159         /// The window should be shown, not minimised.
1160         /// </summary>
1161         /// <since_tizen> 4 </since_tizen>
1162         public void RenderOnce()
1163         {
1164             Interop.Window.RenderOnce(SwigCPtr);
1165             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1166         }
1167
1168         /// <summary>
1169         /// Sets whether the window is transparent or not.
1170         /// </summary>
1171         /// <param name="transparent">Whether the window is transparent or not.</param>
1172         /// <since_tizen> 5 </since_tizen>
1173         public void SetTransparency(bool transparent)
1174         {
1175             Interop.Window.SetTransparency(SwigCPtr, transparent);
1176             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1177
1178             // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1179         }
1180
1181         /// <summary>
1182         /// Sets parent window of the window.
1183         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1184         /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1185         /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1186         /// </summary>
1187         /// <param name="parent">The parent window.</param>
1188         /// <since_tizen> 6 </since_tizen>
1189         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1190         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1191         public void SetParent(Window parent)
1192         {
1193             if (IsSupportedMultiWindow() == false)
1194             {
1195                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1196             }
1197             Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1199         }
1200
1201         /// <summary>
1202         /// Sets parent window of the window.
1203         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1204         /// This function has the additional flag whether the child is located above or below of the parent.
1205         /// </summary>
1206         /// <param name="parent">The parent window.</param>
1207         /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1208         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1209         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1210         [EditorBrowsable(EditorBrowsableState.Never)]
1211         public void SetParent(Window parent, bool belowParent)
1212         {
1213             if (IsSupportedMultiWindow() == false)
1214             {
1215                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1216             }
1217             Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1218             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219         }
1220
1221         /// <summary>
1222         /// Unsets parent window of the window.
1223         /// After unsetting, the window is disconnected his parent window.
1224         /// </summary>
1225         /// <since_tizen> 6 </since_tizen>
1226         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1227         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1228         public void Unparent()
1229         {
1230             if (IsSupportedMultiWindow() == false)
1231             {
1232                 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1233             }
1234             Interop.Window.Unparent(SwigCPtr);
1235             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1236         }
1237
1238         /// <summary>
1239         /// Gets parent window of the window.
1240         /// </summary>
1241         /// <returns>The parent window of the window.</returns>
1242         /// <since_tizen> 6 </since_tizen>
1243         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1244         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1245         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1246         public Window GetParent()
1247         {
1248             if (IsSupportedMultiWindow() == false)
1249             {
1250                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1251             }
1252             Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254             return ret;
1255         }
1256
1257         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1258         [EditorBrowsable(EditorBrowsableState.Never)]
1259         public void ObjectDump()
1260         {
1261             Layer rootLayer = GetRootLayer();
1262             foreach (View view in rootLayer.Children)
1263             {
1264                 view.ObjectDump();
1265             }
1266         }
1267
1268         internal static bool IsInstalled()
1269         {
1270             bool ret = Interop.Stage.IsInstalled();
1271             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272             return ret;
1273         }
1274
1275         /// <summary>
1276         /// Adds an orientation to the list of available orientations.
1277         /// </summary>
1278         /// <param name="orientation">The available orientation to add</param>
1279         /// <since_tizen> 6 </since_tizen>
1280         public void AddAvailableOrientation(Window.WindowOrientation orientation)
1281         {
1282             Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1283             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1284         }
1285
1286         /// <summary>
1287         /// Removes an orientation from the list of available orientations.
1288         /// </summary>
1289         /// <param name="orientation">The available orientation to remove.</param>
1290         /// <since_tizen> 6 </since_tizen>
1291         public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1292         {
1293             Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1294             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1295         }
1296
1297         /// <summary>
1298         /// Sets a preferred orientation.
1299         /// </summary>
1300         /// <param name="orientation">The preferred orientation.</param>
1301         /// <since_tizen> 6 </since_tizen>
1302         public void SetPreferredOrientation(Window.WindowOrientation orientation)
1303         {
1304             Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1305             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1306         }
1307
1308         /// <summary>
1309         /// Gets the preferred orientation.
1310         /// </summary>
1311         /// <since_tizen> 6 </since_tizen>
1312         /// <returns>The preferred orientation if previously set, or none.</returns>
1313         public Window.WindowOrientation GetPreferredOrientation()
1314         {
1315             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1316             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1317             return ret;
1318         }
1319
1320         /// <summary>
1321         /// Gets current orientation of the window.
1322         /// </summary>
1323         /// <since_tizen> 6 </since_tizen>
1324         /// <returns>The current window orientation if previously set, or none.</returns>
1325         [EditorBrowsable(EditorBrowsableState.Never)]
1326         public Window.WindowOrientation GetCurrentOrientation()
1327         {
1328             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1329             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1330             return ret;
1331         }
1332
1333         /// <summary>
1334         /// Sets available orientations of the window.
1335         /// This API is for setting several orientations one time.
1336         /// </summary>
1337         /// <param name="orientations">The list of orientations.</param>
1338         /// <since_tizen> 6 </since_tizen>
1339         [EditorBrowsable(EditorBrowsableState.Never)]
1340         public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1341         {
1342             if (null == orientations)
1343             {
1344                 throw new ArgumentNullException(nameof(orientations));
1345             }
1346
1347             PropertyArray orientationArray = new PropertyArray();
1348             for (int i = 0; i < orientations.Count; i++)
1349             {
1350                 PropertyValue value = new PropertyValue((int)orientations[i]);
1351                 orientationArray.PushBack(value);
1352                 value.Dispose();
1353             }
1354
1355             Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1356             orientationArray.Dispose();
1357             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1358         }
1359
1360         /// <summary>
1361         /// Get native window ID
1362         /// </summary>
1363         /// <returns>native window ID</returns>
1364         [EditorBrowsable(EditorBrowsableState.Never)]
1365         public int GetNativeId()
1366         {
1367             int ret = Interop.Window.GetNativeId(SwigCPtr);
1368             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1369             return ret;
1370         }
1371
1372         internal Any GetNativeHandle()
1373         {
1374             Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1375             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1376             return ret;
1377         }
1378
1379         internal void Add(Layer layer)
1380         {
1381             if (null == layer)
1382             {
1383                 throw new ArgumentNullException(nameof(layer));
1384             }
1385
1386             if (isBorderWindow)
1387             {
1388                 Interop.Actor.Add(GetRootLayer().SwigCPtr, layer.SwigCPtr);
1389                 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1390             }
1391             else
1392             {
1393                 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1394                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1395             }
1396
1397             LayersChildren?.Add(layer);
1398             layer.SetWindow(this);
1399         }
1400
1401         internal void Remove(Layer layer)
1402         {
1403             if (null == layer)
1404             {
1405                 throw new ArgumentNullException(nameof(layer));
1406             }
1407             Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1408             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1409
1410             LayersChildren?.Remove(layer);
1411             layer.SetWindow(null);
1412         }
1413
1414         internal Vector2 GetSize()
1415         {
1416             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1417
1418             convertRealWindowSizeToBorderWindowSize(val);
1419
1420             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1421             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1422             val.Dispose();
1423             return ret;
1424         }
1425
1426         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1427         [EditorBrowsable(EditorBrowsableState.Never)]
1428         public RenderTaskList GetRenderTaskList()
1429         {
1430             RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1431             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1432             return ret;
1433         }
1434
1435         /// <summary>
1436         /// Queries the number of on-window layers.
1437         /// </summary>
1438         /// <returns>The number of layers.</returns>
1439         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1440         internal uint GetLayerCount()
1441         {
1442             if (LayersChildren == null || LayersChildren.Count < 0)
1443                 return 0;
1444
1445             return (uint)LayersChildren.Count;
1446         }
1447
1448         internal Layer GetRootLayer()
1449         {
1450             if (isBorderWindow)
1451             {
1452                 if (borderLayer == null)
1453                 {
1454                     borderLayer = GetBorderWindowRootLayer();
1455                     LayersChildren?.Add(borderLayer);
1456                     borderLayer.SetWindow(this);
1457                 }
1458                 return borderLayer;
1459             }
1460             else
1461             {
1462                 // Window.IsInstalled() is actually true only when called from event thread and
1463                 // Core has been initialized, not when Stage is ready.
1464                 if (rootLayer == null && Window.IsInstalled())
1465                 {
1466                     rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1467                     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1468                     LayersChildren?.Add(rootLayer);
1469                     rootLayer.SetWindow(this);
1470                 }
1471                 return rootLayer;
1472             }
1473         }
1474
1475         internal void SetBackgroundColor(Vector4 color)
1476         {
1477             Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1478             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1479         }
1480
1481         internal Vector4 GetBackgroundColor()
1482         {
1483             Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1484             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1485             return ret;
1486         }
1487
1488         internal Vector2 GetDpi()
1489         {
1490             Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1491             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1492             return ret;
1493         }
1494
1495         internal ObjectRegistry GetObjectRegistry()
1496         {
1497             ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1498             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1499             return ret;
1500         }
1501
1502         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1503         {
1504             Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1505             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1506         }
1507
1508         internal RenderingBehaviorType GetRenderingBehavior()
1509         {
1510             RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1511             if (NDalicPINVOKE.SWIGPendingException.Pending)
1512                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1513             return ret;
1514         }
1515
1516         internal void SetWindowSize(Size2D size)
1517         {
1518             if (null == size)
1519             {
1520                 throw new ArgumentNullException(nameof(size));
1521             }
1522             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1523
1524             convertBorderWindowSizeToRealWindowSize(val);
1525
1526             Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1527             val.Dispose();
1528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1529             // Resetting Window size should request a relayout of the tree.
1530         }
1531
1532         internal Size2D GetWindowSize()
1533         {
1534             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1535
1536             convertRealWindowSizeToBorderWindowSize(val);
1537
1538             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1539             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1540             val.Dispose();
1541             return ret;
1542         }
1543
1544         internal void SetPosition(Position2D position)
1545         {
1546             if (null == position)
1547             {
1548                 throw new ArgumentNullException(nameof(position));
1549             }
1550             var val = new Int32Pair(position.X, position.Y);
1551             Interop.Window.SetPosition(SwigCPtr, Int32Pair.getCPtr(val));
1552             val.Dispose();
1553             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1554             // Setting Position of the window should request a relayout of the tree.
1555         }
1556
1557         internal Position2D GetPosition()
1558         {
1559             var val = new Int32Pair(Interop.Window.GetPosition(SwigCPtr), true);
1560             Position2D ret = new Position2D((int)val.GetX(), (int)val.GetY());
1561             val.Dispose();
1562             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1563             return ret;
1564         }
1565
1566         internal void SetPositionSize(Rectangle positionSize)
1567         {
1568             if (positionSize == null)
1569             {
1570                 throw new ArgumentNullException(nameof(positionSize));
1571             }
1572             var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1573
1574             convertBorderWindowSizeToRealWindowSize(val);
1575
1576             positionSize.Width = val.GetX();
1577             positionSize.Height = val.GetY();
1578
1579             Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1580             val.Dispose();
1581
1582             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1583
1584             // Setting Position of the window should request a relayout of the tree.
1585         }
1586
1587         /// <summary>
1588         /// Enables the floating mode of window.
1589         /// The floating mode is to support window is moved or resized by display server.
1590         /// For example, if the video-player window sets the floating mode,
1591         /// then display server changes its geometry and handles it like a popup.
1592         /// The way of handling floating mode window is decided by display server.
1593         /// A special display server(as a Tizen display server) supports this mode.
1594         /// </summary>
1595         /// <param name="enable">Enable floating mode or not.</param>
1596         [EditorBrowsable(EditorBrowsableState.Never)]
1597         public void EnableFloatingMode(bool enable)
1598         {
1599             Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1600             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1601         }
1602
1603         /// <summary>
1604         /// Requests to display server for the window is moved by display server.
1605         /// It can be work with setting window floating mode.
1606         /// </summary>
1607         [EditorBrowsable(EditorBrowsableState.Never)]
1608         public void RequestMoveToServer()
1609         {
1610             Interop.Window.RequestMoveToServer(SwigCPtr);
1611             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1612         }
1613
1614         /// <summary>
1615         ///  Requests to display server for the window is resized by display server.
1616         /// It can be work with setting window floating mode.
1617         /// </summary>
1618         /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1619         [EditorBrowsable(EditorBrowsableState.Never)]
1620         public void RequestResizeToServer(ResizeDirection direction)
1621         {
1622             Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1623             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1624         }
1625
1626         /// <summary>
1627         /// Includes input region.
1628         /// This function inlcudes input regions.
1629         /// It can be used multiple times and supports multiple regions.
1630         /// It means input region will be extended.
1631         /// This input is related to mouse and touch event.
1632         /// If device has touch screen, this function is useful.
1633         /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1634         /// </summary>
1635         /// <param name="inputRegion">The included region to accept input events.</param>
1636         [EditorBrowsable(EditorBrowsableState.Never)]
1637         public void IncludeInputRegion(Rectangle inputRegion)
1638         {
1639             Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1640             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1641         }
1642
1643         /// <summary>
1644         /// This function excludes input regions.
1645         /// It can be used multiple times and supports multiple regions.
1646         /// It means input region will be reduced.
1647         /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1648         /// This input is related to mouse and touch event.
1649         /// If device has touch screen, this function is useful.
1650         /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1651         /// </summary>
1652         /// <param name="inputRegion">The excluded region to except input events.</param>
1653         [EditorBrowsable(EditorBrowsableState.Never)]
1654         public void ExcludeInputRegion(Rectangle inputRegion)
1655         {
1656             Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1657             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1658         }
1659
1660         /// <summary>
1661         /// Maximizes window's size.
1662         /// If this function is called with true, window will be resized with screen size.
1663         /// Otherwise window will be resized with previous size.
1664         /// It is for the window's MAX button in window's border.
1665         /// If window border is supported by display server, it is not necessary.
1666         /// </summary>
1667         /// <param name="max">If window is maximized or unmaximized.</param>
1668         [EditorBrowsable(EditorBrowsableState.Never)]
1669         public void Maximize(bool max)
1670         {
1671             Interop.Window.Maximize(SwigCPtr, max);
1672             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1673         }
1674
1675         /// <summary>
1676         /// Returns whether the window is maximized or not.
1677         /// </summary>
1678         /// <returns>True if the window is maximized, false otherwise.</returns>
1679         [EditorBrowsable(EditorBrowsableState.Never)]
1680         public bool IsMaximized()
1681         {
1682             bool ret = Interop.Window.IsMaximized(SwigCPtr);
1683             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1684             return ret;
1685         }
1686
1687         /// <summary>
1688         /// Sets window's maximum size.
1689         ///
1690         /// It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
1691         /// Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
1692         ///
1693         /// After setting, if Maximize() is called, window is resized with the setting size and move the center.
1694         ///
1695         /// </summary>
1696         /// <param name="size">the maximum size.</param>
1697         [EditorBrowsable(EditorBrowsableState.Never)]
1698         public void SetMaximumSize(Size2D size)
1699         {
1700             if (null == size)
1701             {
1702                 throw new ArgumentNullException(nameof(size));
1703             }
1704             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1705
1706             Interop.Window.SetMaximumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1707             val.Dispose();
1708             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1709         }
1710
1711         /// <summary>
1712         /// Minimizes window's size.
1713         /// If this function is called with true, window will be iconified.
1714         /// Otherwise window will be activated.
1715         /// It is for the window's MIN button in window border.
1716         /// If window border is supported by display server, it is not necessary.
1717         /// </summary>
1718         /// <param name="min">If window is minimized or unminimized.</param>
1719         [EditorBrowsable(EditorBrowsableState.Never)]
1720         public void Minimize(bool min)
1721         {
1722             Interop.Window.Minimize(SwigCPtr, min);
1723             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1724         }
1725
1726         /// <summary>
1727         /// Returns whether the window is minimized or not.
1728         /// </summary>
1729         /// <returns>True if the window is minimized, false otherwise.</returns>
1730         [EditorBrowsable(EditorBrowsableState.Never)]
1731         public bool IsMinimized()
1732         {
1733             bool ret = Interop.Window.IsMinimized(SwigCPtr);
1734             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1735             return ret;
1736         }
1737
1738         /// <summary>
1739         /// Sets window's minimum size.
1740         /// It is to set the minimum size when window's size is decreased by RequestResizeToServer().
1741         /// Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
1742         /// </summary>
1743         /// <param name="size">the minimum size.</param>
1744         [EditorBrowsable(EditorBrowsableState.Never)]
1745         public void SetMimimumSize(Size2D size)
1746         {
1747             if (null == size)
1748             {
1749                 throw new ArgumentNullException(nameof(size));
1750             }
1751             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1752
1753             Interop.Window.SetMimimumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1754             val.Dispose();
1755             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1756         }
1757
1758         /// <summary>
1759         /// Sets the layout of the window.
1760         /// </summary>
1761         /// <param name="numCols">The number of columns in the layout.</param>
1762         /// <param name="numRows">The number of rows in the layout.</param>
1763         /// <param name="column">The column number of the window within the layout.</param>
1764         /// <param name="row">The row number of the window within the layout.</param>
1765         /// <param name="colSpan">The number of columns the window should span within the layout.</param>
1766         /// <param name="rowSpan">The number of rows the window should span within the layout.</param>
1767         [EditorBrowsable(EditorBrowsableState.Never)]
1768         public void SetLayout(uint numCols, uint numRows, uint column, uint row, uint colSpan, uint rowSpan)
1769         {
1770             Interop.Window.SetLayout(SwigCPtr, numCols, numRows, column, row, colSpan, rowSpan);
1771             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1772
1773         }
1774
1775         /// <summary>
1776         /// Sets the layout of the window.
1777         /// </summary>
1778         /// <param name="layoutType">The type of layout to set for the window.</param>
1779         [EditorBrowsable(EditorBrowsableState.Never)]
1780         public void SetLayout(WindowLayoutType layoutType)
1781         {
1782             switch (layoutType)
1783             {
1784                 case WindowLayoutType.LeftHalf:
1785                     Interop.Window.SetLayout(SwigCPtr, 2, 1, 0, 0, 1, 1);
1786                     break;
1787                 case WindowLayoutType.RightHalf:
1788                     Interop.Window.SetLayout(SwigCPtr, 2, 1, 1, 0, 1, 1);
1789                     break;
1790
1791                 case WindowLayoutType.TopHalf:
1792                     Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 0, 1, 1);
1793                     break;
1794                 case WindowLayoutType.BottomHalf:
1795                     Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 1, 1, 1);
1796                     break;
1797
1798                 case WindowLayoutType.UpperLeftQuarter:
1799                     Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 0, 1, 1);
1800                     break;
1801                 case WindowLayoutType.UpperRightQuarter:
1802                     Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 0, 1, 1);
1803                     break;
1804                 case WindowLayoutType.LowerLeftQuarter:
1805                     Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 1, 1, 1);
1806                     break;
1807                 case WindowLayoutType.LowerRightQuarter:
1808                     Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 1, 1, 1);
1809                     break;
1810
1811                 case WindowLayoutType.LeftThird:
1812                     Interop.Window.SetLayout(SwigCPtr, 3, 1, 0, 0, 1, 1);
1813                     break;
1814                 case WindowLayoutType.CenterThird:
1815                     Interop.Window.SetLayout(SwigCPtr, 3, 1, 1, 0, 1, 1);
1816                     break;
1817                 case WindowLayoutType.RightThird:
1818                     Interop.Window.SetLayout(SwigCPtr, 3, 1, 2, 0, 1, 1);
1819                     break;
1820
1821                 case WindowLayoutType.TopThird:
1822                     Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 0, 1, 1);
1823                     break;
1824                 case WindowLayoutType.MiddleThird:
1825                     Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 1, 1, 1);
1826                     break;
1827                 case WindowLayoutType.BottomThird:
1828                     Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 2, 1, 1);
1829                     break;
1830             }
1831             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1832
1833         }
1834
1835         /// <summary>
1836         /// Query whether window is rotating or not.
1837         /// </summary>
1838         /// <returns>True if window is rotating, false otherwise.</returns>
1839         [EditorBrowsable(EditorBrowsableState.Never)]
1840         public bool IsWindowRotating()
1841         {
1842             bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
1843             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1844             return ret;
1845         }
1846
1847         /// <summary>
1848         /// Gets the last key event the window gets.
1849         /// </summary>
1850         /// <returns>The last key event the window gets.</returns>
1851         [EditorBrowsable(EditorBrowsableState.Never)]
1852         public Key GetLastKeyEvent()
1853         {
1854             if(internalLastKeyEvent == null)
1855             {
1856                 internalLastKeyEvent = new Key();
1857             }
1858             Interop.Window.InternalRetrievingLastKeyEvent(SwigCPtr, internalLastKeyEvent.SwigCPtr);
1859             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1860             return internalLastKeyEvent;
1861         }
1862
1863         /// <summary>
1864         /// Gets the last touch event the window gets.
1865         /// </summary>
1866         /// <returns>The last touch event the window gets.</returns>
1867         [EditorBrowsable(EditorBrowsableState.Never)]
1868         public Touch GetLastTouchEvent()
1869         {
1870             if(internalLastTouchEvent == null)
1871             {
1872                 internalLastTouchEvent = new Touch();
1873             }
1874             Interop.Window.InternalRetrievingLastTouchEvent(SwigCPtr, internalLastTouchEvent.SwigCPtr);
1875             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1876             return internalLastTouchEvent;
1877         }
1878
1879         /// <summary>
1880         /// Sets the necessary for window rotation Acknowledgement.
1881         /// After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
1882         ///
1883         /// This function is supprot that application has the window rotation acknowledgement's control.
1884         /// It means display server waits when application's rotation work is finished.
1885         /// It is useful application has the other rendering engine which works asynchronous.
1886         /// For instance, GlView.
1887         /// </summary>
1888         /// <param name="needAcknowledgement">the flag is true if window rotation acknowledge is sent.</param>
1889         [EditorBrowsable(EditorBrowsableState.Never)]
1890         public void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1891         {
1892             Interop.Window.SetNeedsRotationCompletedAcknowledgement(SwigCPtr, needAcknowledgement);
1893             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1894         }
1895
1896         /// <summary>
1897         /// send the Acknowledgement to complete window rotation.
1898         /// For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
1899         /// </summary>
1900         [EditorBrowsable(EditorBrowsableState.Never)]
1901         public void SendRotationCompletedAcknowledgement()
1902         {
1903             Interop.Window.SendRotationCompletedAcknowledgement(SwigCPtr);
1904             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1905         }
1906
1907         /// <summary>
1908         /// Add FrameUpdateCallback
1909         /// </summary>
1910         [EditorBrowsable(EditorBrowsableState.Never)]
1911         public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1912         {
1913             frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1914         }
1915
1916         /// <summary>
1917         /// Remove FrameUpdateCallback
1918         /// </summary>
1919         [EditorBrowsable(EditorBrowsableState.Never)]
1920         public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1921         {
1922             frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1923         }
1924
1925         /// <summary>
1926         /// Dispose for Window
1927         /// </summary>
1928         [EditorBrowsable(EditorBrowsableState.Never)]
1929         protected override void Dispose(DisposeTypes type)
1930         {
1931             if (disposed)
1932             {
1933                 return;
1934             }
1935
1936             this.DisconnectNativeSignals();
1937
1938             if (type == DisposeTypes.Explicit)
1939             {
1940                 //Called by User
1941                 //Release your own managed resources here.
1942                 //You should release all of your own disposable objects here.
1943
1944                 if (IsBorderEnabled)
1945                 {
1946                     DisposeBorder();
1947                 }
1948
1949                 foreach (var layer in childLayers)
1950                 {
1951                     if (layer != null)
1952                     {
1953                         layer.Dispose();
1954                     }
1955                 }
1956
1957                 childLayers.Clear();
1958
1959                 localController?.Dispose();
1960
1961                 internalLastKeyEvent?.Dispose();
1962                 internalLastKeyEvent = null;
1963                 internalLastTouchEvent?.Dispose();
1964                 internalLastTouchEvent = null;
1965             }
1966
1967
1968             base.Dispose(type);
1969         }
1970
1971         /// This will not be public opened.
1972         [EditorBrowsable(EditorBrowsableState.Never)]
1973         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1974         {
1975             Interop.Window.DeleteWindow(swigCPtr);
1976         }
1977
1978         private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1979
1980         private static readonly object locker = new object();
1981
1982         private static int key = 0;
1983
1984         private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1985
1986         private struct internalHookCallbackType
1987         {
1988             public FrameCallbackType userCallback;
1989             public int frameId;
1990         }
1991
1992         private static void OnInternalHookFrameCallback(int id)
1993         {
1994             lock (locker)
1995             {
1996                 if (frameCallbackList.ContainsKey(id))
1997                 {
1998                     if (frameCallbackList[id].userCallback != null)
1999                     {
2000                         frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
2001                         frameCallbackList.Remove(id);
2002                     }
2003                     else
2004                     {
2005                         NUILog.Error($"found userCallback is NULL");
2006                         frameCallbackList.Remove(id);
2007                     }
2008                 }
2009             }
2010         }
2011
2012         private int AddInterHookCallback(FrameCallbackType callback, int frameId)
2013         {
2014             if (null == callback)
2015             {
2016                 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
2017             }
2018             var assignedKey = 0;
2019             lock (locker)
2020             {
2021                 key++;
2022                 assignedKey = key;
2023                 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
2024                 {
2025                     userCallback = callback,
2026                     frameId = frameId,
2027                 });
2028             }
2029             return assignedKey;
2030         }
2031
2032         /// <summary>
2033         /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
2034         /// </summary>
2035         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2036         [EditorBrowsable(EditorBrowsableState.Never)]
2037         public delegate void FrameCallbackType(int frameId);
2038
2039         /// <summary>
2040         /// Adds a callback that is called when the frame rendering is done by the graphics driver.
2041         /// A callback of the following type may be used:
2042         /// <code>
2043         /// void MyFunction( int frameId )
2044         /// </code>
2045         /// This callback will be deleted once it is called.
2046         /// <remarks>
2047         /// Ownership of the callback is passed onto this class
2048         /// </remarks>
2049         /// </summary>
2050         /// <param name="callback">The function to call</param>
2051         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2052         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
2053         [EditorBrowsable(EditorBrowsableState.Never)]
2054         public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
2055         {
2056             var assignedKey = AddInterHookCallback(callback, frameId);
2057             Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
2058
2059             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2060         }
2061
2062         /// <summary>
2063         /// Adds a callback that is called when the frame is displayed on the display.
2064         /// A callback of the following type may be used:
2065         /// <code>
2066         /// void MyFunction( int frameId )
2067         /// </code>
2068         /// This callback will be deleted once it is called.
2069         /// <remarks>
2070         /// Ownership of the callback is passed onto this class
2071         /// </remarks>
2072         /// </summary>
2073         /// <param name="callback">The function to call</param>
2074         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2075         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
2076         [EditorBrowsable(EditorBrowsableState.Never)]
2077         public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
2078         {
2079             var assignedKey = AddInterHookCallback(callback, frameId);
2080             Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
2081
2082             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2083         }
2084
2085         /// <summary>
2086         /// Search through this Window for a Layer with the given unique ID.
2087         /// </summary>
2088         /// <param name="id">The ID of the Layer to find.</param>
2089         /// <remarks>Hidden-API</remarks>
2090         /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
2091         [EditorBrowsable(EditorBrowsableState.Never)]
2092         public Layer FindLayerByID(uint id)
2093         {
2094             Layer defaultLayer = this.GetDefaultLayer();
2095             IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
2096             Layer ret = this.GetInstanceSafely<Layer>(cPtr);
2097
2098             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2099             return ret;
2100         }
2101
2102         /// <summary>
2103         /// Get Native Window handle.
2104         /// <example>
2105         /// How to get Native Window handle
2106         /// <code>
2107         /// Window window = NUIApplication.GetDefaultWindow();
2108         /// var handle = window.NativeHandle;
2109         /// if(handle.IsInvalid == false)
2110         /// {
2111         ///     IntPtr nativeHandle = handle.DangerousGetHandle();
2112         ///     // do something with nativeHandle
2113         /// }
2114         /// </code>
2115         /// </example>
2116         /// </summary>
2117         /// <since_tizen> 9 </since_tizen>
2118         public SafeHandle NativeHandle
2119         {
2120             get
2121             {
2122                 return new NUI.SafeNativeWindowHandle(this);
2123             }
2124         }
2125     }
2126 }