2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.ComponentModel;
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.BaseComponents;
26 /// The window class is used internally for drawing.<br />
27 /// The window has an orientation and indicator properties.<br />
29 /// <since_tizen> 3 </since_tizen>
30 public partial class Window : BaseHandle
32 private static readonly Window instance = Application.Instance?.GetWindow();
33 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
35 private Layer _rootLayer;
36 private string _windowTitle;
37 private List<Layer> _childLayers = new List<Layer>();
38 private LayoutController localController;
40 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
42 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43 if (Interop.Stage.Stage_IsInstalled())
45 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
47 localController = new LayoutController(this);
48 NUILog.Debug("layoutController id:" + localController.GetId() );
53 /// Creates a new Window.<br />
54 /// This creates an extra window in addition to the default main window<br />
56 /// <param name="windowPosition">The position and size of the Window.</param>
57 /// <param name="isTranslucent">Whether Window is translucent.</param>
58 /// <returns>A new Window.</returns>
59 /// <since_tizen> 6 </since_tizen>
60 public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
62 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66 /// Creates a new Window with a specific name.<br />
67 /// This creates an extra window in addition to the default main window<br />
69 /// <param name="name">The name for extra window. </param>
70 /// <param name="windowPosition">The position and size of the Window.</param>
71 /// <param name="isTranslucent">Whether Window is translucent.</param>
72 /// <returns>A new Window.</returns>
73 /// <since_tizen> 6 </since_tizen>
74 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
76 this._windowTitle = name;
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
83 /// <since_tizen> 3 </since_tizen>
84 public enum WindowOrientation
87 /// Portrait orientation. The height of the display area is greater than the width.
89 /// <since_tizen> 3 </since_tizen>
92 /// Landscape orientation. A wide view area is needed.
94 /// <since_tizen> 3 </since_tizen>
97 /// Portrait inverse orientation.
99 /// <since_tizen> 3 </since_tizen>
100 PortraitInverse = 180,
102 /// Landscape inverse orientation.
104 /// <since_tizen> 3 </since_tizen>
105 LandscapeInverse = 270
109 /// Enumeration for the key grab mode for platform-level APIs.
111 /// <since_tizen> 3 </since_tizen>
112 public enum KeyGrabMode
115 /// Grabs a key only when on the top of the grabbing-window stack mode.
119 /// Grabs a key together with the other client window(s) mode.
123 /// 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.
127 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
133 /// Enumeration for transition effect's state.
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 public enum EffectStates
141 [EditorBrowsable(EditorBrowsableState.Never)]
144 /// Transition effect is started.
146 [EditorBrowsable(EditorBrowsableState.Never)]
149 /// Transition effect is ended.
151 [EditorBrowsable(EditorBrowsableState.Never)]
156 /// Enumeration for transition effect's type.
158 [EditorBrowsable(EditorBrowsableState.Never)]
159 public enum EffectTypes
164 [EditorBrowsable(EditorBrowsableState.Never)]
167 /// Window show effect.
169 [EditorBrowsable(EditorBrowsableState.Never)]
172 /// Window hide effect.
174 [EditorBrowsable(EditorBrowsableState.Never)]
179 /// Enumeration for opacity of the indicator.
181 internal enum IndicatorBackgroundOpacity
189 /// Enumeration for visible mode of the indicator.
191 internal enum IndicatorVisibleMode
199 /// The stage instance property (read-only).<br />
200 /// Gets the current window.<br />
202 /// <since_tizen> 3 </since_tizen>
203 public static Window Instance
212 /// Get Resource ID of window
214 internal int ResourceID
218 int ret = Interop.Window.GetResouceID(swigCPtr);
219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 /// Gets or sets a window type.
227 /// <since_tizen> 3 </since_tizen>
228 public WindowType Type
232 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 Interop.Window.SetType(swigCPtr, (int)value);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 /// Gets/Sets a window title.
246 /// <since_tizen> 4 </since_tizen>
255 _windowTitle = value;
256 SetClass(_windowTitle, "");
261 /// The rendering behavior of a Window.
263 /// <since_tizen> 5 </since_tizen>
264 public RenderingBehaviorType RenderingBehavior
268 return GetRenderingBehavior();
272 SetRenderingBehavior(value);
277 /// The window size property (read-only).
279 /// <since_tizen> 3 </since_tizen>
284 Size2D ret = GetSize();
290 /// The background color property.
292 /// <since_tizen> 3 </since_tizen>
293 public Color BackgroundColor
297 SetBackgroundColor(value);
301 Color ret = GetBackgroundColor();
307 /// The DPI property (read-only).<br />
308 /// Retrieves the DPI of the display device to which the Window is connected.<br />
310 /// <since_tizen> 3 </since_tizen>
320 /// The layer count property (read-only).<br />
321 /// Queries the number of on-Window layers.<br />
323 /// <since_tizen> 3 </since_tizen>
324 public uint LayerCount
328 return GetLayerCount();
333 /// Gets or sets a size of the window.
335 /// <since_tizen> 4 </since_tizen>
336 public Size2D WindowSize
340 return GetWindowSize();
344 SetWindowSize(value);
349 /// Gets or sets a position of the window.
351 /// <since_tizen> 4 </since_tizen>
352 public Position2D WindowPosition
356 return GetPosition();
365 /// Sets position and size of the window. This API guarantees that
366 /// both moving and resizing of window will appear on the screen at once.
368 [EditorBrowsable(EditorBrowsableState.Never)]
369 public Rectangle WindowPositionSize
373 Position2D position = GetPosition();
374 Size2D size = GetSize();
375 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
380 SetPositionSize(value);
384 internal static Vector4 DEFAULT_BACKGROUND_COLOR
388 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
389 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
395 internal static Vector4 DEBUG_BACKGROUND_COLOR
399 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
400 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 internal List<Layer> LayersChildren
415 /// Get the LayoutController for this Window.
417 internal LayoutController LayoutController
421 return localController;
426 /// Feed a key-event into the window.
428 /// <param name="keyEvent">The key event to feed.</param>
429 /// <since_tizen> 4 </since_tizen>
430 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
431 public static void FeedKeyEvent(Key keyEvent)
433 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
434 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438 /// Sets whether the window accepts a focus or not.
440 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
441 /// <since_tizen> 3 </since_tizen>
442 public void SetAcceptFocus(bool accept)
444 Interop.Window.SetAcceptFocus(swigCPtr, accept);
445 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449 /// Returns whether the window accepts a focus or not.
451 /// <returns>True if the window accepts a focus, false otherwise.</returns>
452 /// <since_tizen> 3 </since_tizen>
453 public bool IsFocusAcceptable()
455 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462 /// Shows the window if it is hidden.
464 /// <since_tizen> 3 </since_tizen>
467 Interop.Window.Show(swigCPtr);
468 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 /// Hides the window if it is showing.
474 /// <since_tizen> 3 </since_tizen>
477 Interop.Window.Hide(swigCPtr);
478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482 /// Retrieves whether the window is visible or not.
484 /// <returns>True if the window is visible.</returns>
485 /// <since_tizen> 3 </since_tizen>
486 public bool IsVisible()
488 bool temp = Interop.Window.IsVisible(swigCPtr);
489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
494 /// Gets the count of supported auxiliary hints of the window.
496 /// <returns>The number of supported auxiliary hints.</returns>
497 /// <since_tizen> 3 </since_tizen>
498 public uint GetSupportedAuxiliaryHintCount()
500 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
501 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 /// Gets the supported auxiliary hint string of the window.
508 /// <param name="index">The index of the supported auxiliary hint lists.</param>
509 /// <returns>The auxiliary hint string of the index.</returns>
510 /// <since_tizen> 3 </since_tizen>
511 public string GetSupportedAuxiliaryHint(uint index)
513 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
514 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
519 /// Creates an auxiliary hint of the window.
521 /// <param name="hint">The auxiliary hint string.</param>
522 /// <param name="value">The value string.</param>
523 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
524 /// <since_tizen> 3 </since_tizen>
525 public uint AddAuxiliaryHint(string hint, string value)
527 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 /// Removes an auxiliary hint of the window.
535 /// <param name="id">The ID of the auxiliary hint.</param>
536 /// <returns>True if no error occurred, false otherwise.</returns>
537 /// <since_tizen> 3 </since_tizen>
538 public bool RemoveAuxiliaryHint(uint id)
540 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
541 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 /// Changes a value of the auxiliary hint.
548 /// <param name="id">The auxiliary hint ID.</param>
549 /// <param name="value">The value string to be set.</param>
550 /// <returns>True if no error occurred, false otherwise.</returns>
551 /// <since_tizen> 3 </since_tizen>
552 public bool SetAuxiliaryHintValue(uint id, string value)
554 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 /// Gets a value of the auxiliary hint.
562 /// <param name="id">The auxiliary hint ID.</param>
563 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
564 /// <since_tizen> 3 </since_tizen>
565 public string GetAuxiliaryHintValue(uint id)
567 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
568 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573 /// Gets an ID of the auxiliary hint string.
575 /// <param name="hint">The auxiliary hint string.</param>
576 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
577 /// <since_tizen> 3 </since_tizen>
578 public uint GetAuxiliaryHintId(string hint)
580 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
581 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586 /// Sets a region to accept input events.
588 /// <param name="inputRegion">The region to accept input events.</param>
589 /// <since_tizen> 3 </since_tizen>
590 public void SetInputRegion(Rectangle inputRegion)
592 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
593 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 /// Sets a priority level for the specified notification window.
599 /// <param name="level">The notification window level.</param>
600 /// <returns>True if no error occurred, false otherwise.</returns>
601 /// <since_tizen> 3 </since_tizen>
602 public bool SetNotificationLevel(NotificationLevel level)
604 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
605 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 /// Gets a priority level for the specified notification window.
612 /// <returns>The notification window level.</returns>
613 /// <since_tizen> 3 </since_tizen>
614 public NotificationLevel GetNotificationLevel()
616 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
617 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622 /// Sets a transparent window's visual state to opaque. <br />
623 /// If a visual state of a transparent window is opaque, <br />
624 /// then the window manager could handle it as an opaque window when calculating visibility.
626 /// <param name="opaque">Whether the window's visual state is opaque.</param>
627 /// <remarks>This will have no effect on an opaque window. <br />
628 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
630 /// <since_tizen> 3 </since_tizen>
631 public void SetOpaqueState(bool opaque)
633 Interop.Window.SetOpaqueState(swigCPtr, opaque);
634 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
638 /// Returns whether a transparent window's visual state is opaque or not.
640 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
641 /// <remarks> The return value has no meaning on an opaque window. </remarks>
642 /// <since_tizen> 3 </since_tizen>
643 public bool IsOpaqueState()
645 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
651 /// Sets a window's screen off mode.
653 /// <param name="screenOffMode">The screen mode.</param>
654 /// <returns>True if no error occurred, false otherwise.</returns>
655 /// <since_tizen> 4 </since_tizen>
656 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
658 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 /// Gets the screen mode of the window.
666 /// <returns>The screen off mode.</returns>
667 /// <since_tizen> 4 </since_tizen>
668 public ScreenOffMode GetScreenOffMode()
670 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
671 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 /// Sets preferred brightness of the window.
678 /// <param name="brightness">The preferred brightness (0 to 100).</param>
679 /// <returns>True if no error occurred, false otherwise.</returns>
680 /// <since_tizen> 3 </since_tizen>
681 public bool SetBrightness(int brightness)
683 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
684 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
689 /// Gets the preferred brightness of the window.
691 /// <returns>The preferred brightness.</returns>
692 /// <since_tizen> 3 </since_tizen>
693 public int GetBrightness()
695 int ret = Interop.Window.GetBrightness(swigCPtr);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
701 /// Sets the window name and the class string.
703 /// <param name="name">The name of the window.</param>
704 /// <param name="klass">The class of the window.</param>
705 /// <since_tizen> 4 </since_tizen>
706 public void SetClass(string name, string klass)
708 Interop.Window.Window_SetClass(swigCPtr, name, klass);
709 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
713 /// Raises the window to the top of the window stack.
715 /// <since_tizen> 3 </since_tizen>
718 Interop.Window.Window_Raise(swigCPtr);
719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723 /// Lowers the window to the bottom of the window stack.
725 /// <since_tizen> 3 </since_tizen>
728 Interop.Window.Window_Lower(swigCPtr);
729 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
733 /// Activates the window to the top of the window stack even it is iconified.
735 /// <since_tizen> 3 </since_tizen>
736 public void Activate()
738 Interop.Window.Window_Activate(swigCPtr);
739 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743 /// Gets the default ( root ) layer.
745 /// <returns>The root layer.</returns>
746 /// <since_tizen> 3 </since_tizen>
747 public Layer GetDefaultLayer()
749 return this.GetRootLayer();
753 /// Add a child view to window.
755 /// <param name="view">the child should be added to the window.</param>
756 /// <since_tizen> 3 </since_tizen>
757 public void Add(View view)
759 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
760 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
761 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
762 view.InternalParent = this.GetRootLayer();
766 /// Remove a child view from window.
768 /// <param name="view">the child to be removed.</param>
769 /// <since_tizen> 3 </since_tizen>
770 public void Remove(View view)
772 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
773 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
774 view.InternalParent = null;
778 /// Retrieves the layer at a specified depth.
780 /// <param name="depth">The layer's depth index.</param>
781 /// <returns>The layer found at the given depth.</returns>
782 /// <since_tizen> 3 </since_tizen>
783 public Layer GetLayer(uint depth)
785 if (depth < LayersChildren?.Count)
787 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
797 /// Destroy the window immediately.
799 [EditorBrowsable(EditorBrowsableState.Never)]
800 public void Destroy()
806 /// Keep rendering for at least the given amount of time.
808 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
809 /// <since_tizen> 3 </since_tizen>
810 public void KeepRendering(float durationSeconds)
812 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
813 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
817 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
818 /// This function can be used for following example scenarios: <br />
819 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
821 /// <param name="DaliKey">The key code to grab.</param>
822 /// <returns>True if the grab succeeds.</returns>
823 /// <since_tizen> 3 </since_tizen>
824 public bool GrabKeyTopmost(int DaliKey)
826 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
827 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 /// Ungrabs the key specified by a key for the window.<br />
833 /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.<br />
835 /// <param name="DaliKey">The key code to ungrab.</param>
836 /// <returns>True if the ungrab succeeds.</returns>
837 /// <since_tizen> 3 </since_tizen>
838 public bool UngrabKeyTopmost(int DaliKey)
840 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
841 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
846 /// Grabs the key specified by a key for a window in a GrabMode. <br />
847 /// Details: This function can be used for following example scenarios: <br />
848 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
849 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
850 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
852 /// <param name="DaliKey">The key code to grab.</param>
853 /// <param name="GrabMode">The grab mode for the key.</param>
854 /// <returns>True if the grab succeeds.</returns>
855 /// <since_tizen> 3 </since_tizen>
856 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
858 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
859 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
864 /// Ungrabs the key specified by a key for a window.<br />
865 /// 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 />
867 /// <param name="DaliKey">The key code to ungrab.</param>
868 /// <returns>True if the ungrab succeeds.</returns>
869 /// <since_tizen> 3 </since_tizen>
870 public bool UngrabKey(int DaliKey)
872 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
873 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878 /// Sets the keyboard repeat information.
880 /// <param name="rate">The key repeat rate value in seconds.</param>
881 /// <param name="delay">The key repeat delay value in seconds.</param>
882 /// <returns>True if setting the keyboard repeat succeeds.</returns>
883 /// <since_tizen> 5 </since_tizen>
884 public bool SetKeyboardRepeatInfo(float rate, float delay)
886 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
887 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892 /// Gets the keyboard repeat information.
894 /// <param name="rate">The key repeat rate value in seconds.</param>
895 /// <param name="delay">The key repeat delay value in seconds.</param>
896 /// <returns>True if setting the keyboard repeat succeeds.</returns>
897 /// <since_tizen> 5 </since_tizen>
898 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
900 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
901 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
906 /// Adds a layer to the stage.
908 /// <param name="layer">Layer to add.</param>
909 /// <since_tizen> 3 </since_tizen>
910 public void AddLayer(Layer layer)
912 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
913 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
915 LayersChildren?.Add(layer);
916 layer.SetWindow(this);
920 /// Removes a layer from the stage.
922 /// <param name="layer">Layer to remove.</param>
923 /// <since_tizen> 3 </since_tizen>
924 public void RemoveLayer(Layer layer)
926 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
927 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
929 LayersChildren?.Remove(layer);
930 layer.SetWindow(null);
934 /// Feeds a key event into the window.
936 /// <param name="keyEvent">The key event to feed.</param>
937 /// <since_tizen> 5 </since_tizen>
938 public void FeedKey(Key keyEvent)
940 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
941 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
945 /// Allows at least one more render, even when paused.
946 /// The window should be shown, not minimised.
948 /// <since_tizen> 4 </since_tizen>
949 public void RenderOnce()
951 Interop.Window.Window_RenderOnce(swigCPtr);
952 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
956 /// Sets whether the window is transparent or not.
958 /// <param name="transparent">Whether the window is transparent or not.</param>
959 /// <since_tizen> 5 </since_tizen>
960 public void SetTransparency(bool transparent)
962 Interop.Window.SetTransparency(swigCPtr, transparent);
963 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
965 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
969 /// Sets parent window of the window.
970 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
971 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
972 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
974 /// <param name="parent">The parent window.</param>
975 /// <since_tizen> 6 </since_tizen>
976 public void SetParent(Window parent)
978 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
979 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
983 /// Unsets parent window of the window.
984 /// After unsetting, the window is disconnected his parent window.
986 /// <since_tizen> 6 </since_tizen>
987 public void Unparent()
989 Interop.Window.Unparent(swigCPtr);
990 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
994 /// Gets parent window of the window.
996 /// <returns>The parent window of the window.</returns>
997 /// <since_tizen> 6 </since_tizen>
998 public Window GetParent()
1000 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
1001 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1005 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1007 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1010 internal static Window GetCurrent()
1012 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
1013 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017 internal static bool IsInstalled()
1019 bool ret = Interop.Stage.Stage_IsInstalled();
1020 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1024 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1026 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1027 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1032 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1033 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1036 internal void RotateIndicator(Window.WindowOrientation orientation)
1038 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1039 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1043 /// Adds an orientation to the list of available orientations.
1045 /// <param name="orientation">The available orientation to add</param>
1046 /// <since_tizen> 6 </since_tizen>
1047 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1049 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1050 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1054 /// Removes an orientation from the list of available orientations.
1056 /// <param name="orientation">The available orientation to remove.</param>
1057 /// <since_tizen> 6 </since_tizen>
1058 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1060 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1061 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1065 /// Sets a preferred orientation.
1067 /// <param name="orientation">The preferred orientation.</param>
1068 /// <since_tizen> 6 </since_tizen>
1069 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1071 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1072 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1076 /// Gets the preferred orientation.
1078 /// <since_tizen> 6 </since_tizen>
1079 /// <returns>The preferred orientation if previously set, or none.</returns>
1080 public Window.WindowOrientation GetPreferredOrientation()
1082 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1083 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1087 internal Any GetNativeHandle()
1089 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1090 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1094 internal void Add(Layer layer)
1096 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1097 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1099 LayersChildren?.Add(layer);
1100 layer.SetWindow(this);
1103 internal void Remove(Layer layer)
1105 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1108 LayersChildren?.Remove(layer);
1109 layer.SetWindow(null);
1112 internal Vector2 GetSize()
1114 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1115 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1120 internal RenderTaskList GetRenderTaskList()
1122 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1128 /// Queries the number of on-window layers.
1130 /// <returns>The number of layers.</returns>
1131 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1132 internal uint GetLayerCount()
1134 if (LayersChildren == null || LayersChildren.Count < 0)
1137 return (uint) LayersChildren.Count;
1140 internal Layer GetRootLayer()
1142 // Window.IsInstalled() is actually true only when called from event thread and
1143 // Core has been initialized, not when Stage is ready.
1144 if (_rootLayer == null && Window.IsInstalled())
1146 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1148 LayersChildren?.Add(_rootLayer);
1149 _rootLayer.SetWindow(this);
1154 internal void SetBackgroundColor(Vector4 color)
1156 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1160 internal Vector4 GetBackgroundColor()
1162 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1167 internal Vector2 GetDpi()
1169 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1174 internal ObjectRegistry GetObjectRegistry()
1176 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1181 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1183 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1187 internal RenderingBehaviorType GetRenderingBehavior()
1189 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1190 if (NDalicPINVOKE.SWIGPendingException.Pending)
1191 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1195 internal void SetWindowSize(Size2D size)
1197 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1198 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1202 // Resetting Window size should request a relayout of the tree.
1205 internal Size2D GetWindowSize()
1207 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1208 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1214 internal void SetPosition(Position2D position)
1216 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1217 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 // Setting Position of the window should request a relayout of the tree.
1223 internal Position2D GetPosition()
1225 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1226 Position2D ret = new Position2D(val.GetX(), val.GetY());
1228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232 internal void SetPositionSize(Rectangle positionSize)
1234 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238 // Setting Position of the window should request a relayout of the tree.
1242 /// Dispose for Window
1244 [EditorBrowsable(EditorBrowsableState.Never)]
1245 protected override void Dispose(DisposeTypes type)
1252 if (type == DisposeTypes.Explicit)
1255 //Release your own managed resources here.
1256 //You should release all of your own disposable objects here.
1258 _rootLayer.Dispose();
1259 localController.Dispose();
1261 foreach(var layer in _childLayers)
1265 _childLayers.Clear();
1268 this.DisconnectNativeSignals();
1270 //Release your own unmanaged resources here.
1271 //You should not access any managed member here except static instance.
1272 //because the execution order of Finalizes is non-deterministic.
1274 if (swigCPtr.Handle != global::System.IntPtr.Zero)
1278 swigCMemOwn = false;
1279 Interop.Window.delete_Window(swigCPtr);
1281 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);