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 stageCPtr;
34 private Layer _rootLayer;
35 private string _windowTitle;
36 private List<Layer> _childLayers = new List<Layer>();
37 private LayoutController localController;
39 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
41 if (Interop.Stage.Stage_IsInstalled())
43 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
45 localController = new LayoutController(this);
46 NUILog.Debug("layoutController id:" + localController.GetId() );
51 /// Creates a new Window.<br />
52 /// This creates an extra window in addition to the default main window<br />
54 /// <param name="windowPosition">The position and size of the Window.</param>
55 /// <param name="isTranslucent">Whether Window is translucent.</param>
56 /// <returns>A new Window.</returns>
57 /// <since_tizen> 6 </since_tizen>
58 public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
60 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
64 /// Creates a new Window with a specific name.<br />
65 /// This creates an extra window in addition to the default main window<br />
67 /// <param name="name">The name for extra window. </param>
68 /// <param name="windowPosition">The position and size of the Window.</param>
69 /// <param name="isTranslucent">Whether Window is translucent.</param>
70 /// <returns>A new Window.</returns>
71 /// <since_tizen> 6 </since_tizen>
72 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
74 this._windowTitle = name;
75 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
81 /// <since_tizen> 3 </since_tizen>
82 public enum WindowOrientation
85 /// Portrait orientation. The height of the display area is greater than the width.
87 /// <since_tizen> 3 </since_tizen>
90 /// Landscape orientation. A wide view area is needed.
92 /// <since_tizen> 3 </since_tizen>
95 /// Portrait inverse orientation.
97 /// <since_tizen> 3 </since_tizen>
98 PortraitInverse = 180,
100 /// Landscape inverse orientation.
102 /// <since_tizen> 3 </since_tizen>
103 LandscapeInverse = 270
107 /// Enumeration for the key grab mode for platform-level APIs.
109 /// <since_tizen> 3 </since_tizen>
110 public enum KeyGrabMode
113 /// Grabs a key only when on the top of the grabbing-window stack mode.
117 /// Grabs a key together with the other client window(s) mode.
121 /// 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.
125 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
131 /// Enumeration for transition effect's state.
133 [EditorBrowsable(EditorBrowsableState.Never)]
134 public enum EffectStates
139 [EditorBrowsable(EditorBrowsableState.Never)]
142 /// Transition effect is started.
144 [EditorBrowsable(EditorBrowsableState.Never)]
147 /// Transition effect is ended.
149 [EditorBrowsable(EditorBrowsableState.Never)]
154 /// Enumeration for transition effect's type.
156 [EditorBrowsable(EditorBrowsableState.Never)]
157 public enum EffectTypes
162 [EditorBrowsable(EditorBrowsableState.Never)]
165 /// Window show effect.
167 [EditorBrowsable(EditorBrowsableState.Never)]
170 /// Window hide effect.
172 [EditorBrowsable(EditorBrowsableState.Never)]
177 /// Enumeration for opacity of the indicator.
179 internal enum IndicatorBackgroundOpacity
187 /// Enumeration for visible mode of the indicator.
189 internal enum IndicatorVisibleMode
197 /// The stage instance property (read-only).<br />
198 /// Gets the current window.<br />
200 /// <since_tizen> 3 </since_tizen>
201 public static Window Instance
210 /// Get Resource ID of window
212 internal int ResourceID
216 int ret = Interop.Window.GetResouceID(swigCPtr);
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 /// Gets or sets a window type.
225 /// <since_tizen> 3 </since_tizen>
226 public WindowType Type
230 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236 Interop.Window.SetType(swigCPtr, (int)value);
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// Gets/Sets a window title.
244 /// <since_tizen> 4 </since_tizen>
253 _windowTitle = value;
254 SetClass(_windowTitle, "");
259 /// The rendering behavior of a Window.
261 /// <since_tizen> 5 </since_tizen>
262 public RenderingBehaviorType RenderingBehavior
266 return GetRenderingBehavior();
270 SetRenderingBehavior(value);
275 /// The window size property (read-only).
277 /// <since_tizen> 3 </since_tizen>
282 Size2D ret = GetSize();
288 /// The background color property.
290 /// <since_tizen> 3 </since_tizen>
291 public Color BackgroundColor
295 SetBackgroundColor(value);
299 Color ret = GetBackgroundColor();
305 /// The DPI property (read-only).<br />
306 /// Retrieves the DPI of the display device to which the Window is connected.<br />
308 /// <since_tizen> 3 </since_tizen>
318 /// The layer count property (read-only).<br />
319 /// Queries the number of on-Window layers.<br />
321 /// <since_tizen> 3 </since_tizen>
322 public uint LayerCount
326 return GetLayerCount();
331 /// Gets or sets a size of the window.
333 /// <since_tizen> 4 </since_tizen>
334 public Size2D WindowSize
338 return GetWindowSize();
342 SetWindowSize(value);
347 /// Gets or sets a position of the window.
349 /// <since_tizen> 4 </since_tizen>
350 public Position2D WindowPosition
354 return GetPosition();
363 /// Sets position and size of the window. This API guarantees that
364 /// both moving and resizing of window will appear on the screen at once.
366 [EditorBrowsable(EditorBrowsableState.Never)]
367 public Rectangle WindowPositionSize
371 Position2D position = GetPosition();
372 Size2D size = GetSize();
373 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
378 SetPositionSize(value);
382 internal static Vector4 DEFAULT_BACKGROUND_COLOR
386 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
387 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393 internal static Vector4 DEBUG_BACKGROUND_COLOR
397 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
398 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 internal List<Layer> LayersChildren
413 /// Get the LayoutController for this Window.
415 internal LayoutController LayoutController
419 return localController;
424 /// Feed a key-event into the window.
426 /// <param name="keyEvent">The key event to feed.</param>
427 /// <since_tizen> 4 </since_tizen>
428 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
429 public static void FeedKeyEvent(Key keyEvent)
431 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 /// Sets whether the window accepts a focus or not.
438 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
439 /// <since_tizen> 3 </since_tizen>
440 public void SetAcceptFocus(bool accept)
442 Interop.Window.SetAcceptFocus(swigCPtr, accept);
443 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
447 /// Returns whether the window accepts a focus or not.
449 /// <returns>True if the window accepts a focus, false otherwise.</returns>
450 /// <since_tizen> 3 </since_tizen>
451 public bool IsFocusAcceptable()
453 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 /// Shows the window if it is hidden.
462 /// <since_tizen> 3 </since_tizen>
465 Interop.Window.Show(swigCPtr);
466 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
470 /// Hides the window if it is showing.
472 /// <since_tizen> 3 </since_tizen>
475 Interop.Window.Hide(swigCPtr);
476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 /// Retrieves whether the window is visible or not.
482 /// <returns>True if the window is visible.</returns>
483 /// <since_tizen> 3 </since_tizen>
484 public bool IsVisible()
486 bool temp = Interop.Window.IsVisible(swigCPtr);
487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 /// Gets the count of supported auxiliary hints of the window.
494 /// <returns>The number of supported auxiliary hints.</returns>
495 /// <since_tizen> 3 </since_tizen>
496 public uint GetSupportedAuxiliaryHintCount()
498 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
504 /// Gets the supported auxiliary hint string of the window.
506 /// <param name="index">The index of the supported auxiliary hint lists.</param>
507 /// <returns>The auxiliary hint string of the index.</returns>
508 /// <since_tizen> 3 </since_tizen>
509 public string GetSupportedAuxiliaryHint(uint index)
511 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
512 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
517 /// Creates an auxiliary hint of the window.
519 /// <param name="hint">The auxiliary hint string.</param>
520 /// <param name="value">The value string.</param>
521 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
522 /// <since_tizen> 3 </since_tizen>
523 public uint AddAuxiliaryHint(string hint, string value)
525 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
526 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
531 /// Removes an auxiliary hint of the window.
533 /// <param name="id">The ID of the auxiliary hint.</param>
534 /// <returns>True if no error occurred, false otherwise.</returns>
535 /// <since_tizen> 3 </since_tizen>
536 public bool RemoveAuxiliaryHint(uint id)
538 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
539 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
544 /// Changes a value of the auxiliary hint.
546 /// <param name="id">The auxiliary hint ID.</param>
547 /// <param name="value">The value string to be set.</param>
548 /// <returns>True if no error occurred, false otherwise.</returns>
549 /// <since_tizen> 3 </since_tizen>
550 public bool SetAuxiliaryHintValue(uint id, string value)
552 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
558 /// Gets a value of the auxiliary hint.
560 /// <param name="id">The auxiliary hint ID.</param>
561 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
562 /// <since_tizen> 3 </since_tizen>
563 public string GetAuxiliaryHintValue(uint id)
565 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
566 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
571 /// Gets an ID of the auxiliary hint string.
573 /// <param name="hint">The auxiliary hint string.</param>
574 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
575 /// <since_tizen> 3 </since_tizen>
576 public uint GetAuxiliaryHintId(string hint)
578 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
579 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 /// Sets a region to accept input events.
586 /// <param name="inputRegion">The region to accept input events.</param>
587 /// <since_tizen> 3 </since_tizen>
588 public void SetInputRegion(Rectangle inputRegion)
590 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
591 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 /// Sets a priority level for the specified notification window.
597 /// <param name="level">The notification window level.</param>
598 /// <returns>True if no error occurred, false otherwise.</returns>
599 /// <since_tizen> 3 </since_tizen>
600 public bool SetNotificationLevel(NotificationLevel level)
602 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
603 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608 /// Gets a priority level for the specified notification window.
610 /// <returns>The notification window level.</returns>
611 /// <since_tizen> 3 </since_tizen>
612 public NotificationLevel GetNotificationLevel()
614 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
615 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
620 /// Sets a transparent window's visual state to opaque. <br />
621 /// If a visual state of a transparent window is opaque, <br />
622 /// then the window manager could handle it as an opaque window when calculating visibility.
624 /// <param name="opaque">Whether the window's visual state is opaque.</param>
625 /// <remarks>This will have no effect on an opaque window. <br />
626 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
628 /// <since_tizen> 3 </since_tizen>
629 public void SetOpaqueState(bool opaque)
631 Interop.Window.SetOpaqueState(swigCPtr, opaque);
632 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 /// Returns whether a transparent window's visual state is opaque or not.
638 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
639 /// <remarks> The return value has no meaning on an opaque window. </remarks>
640 /// <since_tizen> 3 </since_tizen>
641 public bool IsOpaqueState()
643 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
644 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 /// Sets a window's screen off mode.
651 /// <param name="screenOffMode">The screen mode.</param>
652 /// <returns>True if no error occurred, false otherwise.</returns>
653 /// <since_tizen> 4 </since_tizen>
654 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
656 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
657 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662 /// Gets the screen mode of the window.
664 /// <returns>The screen off mode.</returns>
665 /// <since_tizen> 4 </since_tizen>
666 public ScreenOffMode GetScreenOffMode()
668 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
669 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 /// Sets preferred brightness of the window.
676 /// <param name="brightness">The preferred brightness (0 to 100).</param>
677 /// <returns>True if no error occurred, false otherwise.</returns>
678 /// <since_tizen> 3 </since_tizen>
679 public bool SetBrightness(int brightness)
681 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
682 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 /// Gets the preferred brightness of the window.
689 /// <returns>The preferred brightness.</returns>
690 /// <since_tizen> 3 </since_tizen>
691 public int GetBrightness()
693 int ret = Interop.Window.GetBrightness(swigCPtr);
694 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 /// Sets the window name and the class string.
701 /// <param name="name">The name of the window.</param>
702 /// <param name="klass">The class of the window.</param>
703 /// <since_tizen> 4 </since_tizen>
704 public void SetClass(string name, string klass)
706 Interop.Window.Window_SetClass(swigCPtr, name, klass);
707 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
711 /// Raises the window to the top of the window stack.
713 /// <since_tizen> 3 </since_tizen>
716 Interop.Window.Window_Raise(swigCPtr);
717 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721 /// Lowers the window to the bottom of the window stack.
723 /// <since_tizen> 3 </since_tizen>
726 Interop.Window.Window_Lower(swigCPtr);
727 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731 /// Activates the window to the top of the window stack even it is iconified.
733 /// <since_tizen> 3 </since_tizen>
734 public void Activate()
736 Interop.Window.Window_Activate(swigCPtr);
737 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 /// Gets the default ( root ) layer.
743 /// <returns>The root layer.</returns>
744 /// <since_tizen> 3 </since_tizen>
745 public Layer GetDefaultLayer()
747 return this.GetRootLayer();
751 /// Add a child view to window.
753 /// <param name="view">the child should be added to the window.</param>
754 /// <since_tizen> 3 </since_tizen>
755 public void Add(View view)
757 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
758 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
759 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
760 view.InternalParent = this.GetRootLayer();
764 /// Remove a child view from window.
766 /// <param name="view">the child to be removed.</param>
767 /// <since_tizen> 3 </since_tizen>
768 public void Remove(View view)
770 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
771 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
772 view.InternalParent = null;
776 /// Retrieves the layer at a specified depth.
778 /// <param name="depth">The layer's depth index.</param>
779 /// <returns>The layer found at the given depth.</returns>
780 /// <since_tizen> 3 </since_tizen>
781 public Layer GetLayer(uint depth)
783 if (depth < LayersChildren?.Count)
785 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
795 /// Destroy the window immediately.
797 [EditorBrowsable(EditorBrowsableState.Never)]
798 public void Destroy()
804 /// Keep rendering for at least the given amount of time.
806 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
807 /// <since_tizen> 3 </since_tizen>
808 public void KeepRendering(float durationSeconds)
810 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
811 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
816 /// This function can be used for following example scenarios: <br />
817 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
819 /// <param name="DaliKey">The key code to grab.</param>
820 /// <returns>True if the grab succeeds.</returns>
821 /// <since_tizen> 3 </since_tizen>
822 public bool GrabKeyTopmost(int DaliKey)
824 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
825 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 /// Ungrabs the key specified by a key for the window.<br />
831 /// 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 />
833 /// <param name="DaliKey">The key code to ungrab.</param>
834 /// <returns>True if the ungrab succeeds.</returns>
835 /// <since_tizen> 3 </since_tizen>
836 public bool UngrabKeyTopmost(int DaliKey)
838 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
839 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844 /// Grabs the key specified by a key for a window in a GrabMode. <br />
845 /// Details: This function can be used for following example scenarios: <br />
846 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
847 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
848 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
850 /// <param name="DaliKey">The key code to grab.</param>
851 /// <param name="GrabMode">The grab mode for the key.</param>
852 /// <returns>True if the grab succeeds.</returns>
853 /// <since_tizen> 3 </since_tizen>
854 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
856 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
857 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
862 /// Ungrabs the key specified by a key for a window.<br />
863 /// 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 />
865 /// <param name="DaliKey">The key code to ungrab.</param>
866 /// <returns>True if the ungrab succeeds.</returns>
867 /// <since_tizen> 3 </since_tizen>
868 public bool UngrabKey(int DaliKey)
870 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
871 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876 /// Sets the keyboard repeat information.
878 /// <param name="rate">The key repeat rate value in seconds.</param>
879 /// <param name="delay">The key repeat delay value in seconds.</param>
880 /// <returns>True if setting the keyboard repeat succeeds.</returns>
881 /// <since_tizen> 5 </since_tizen>
882 public bool SetKeyboardRepeatInfo(float rate, float delay)
884 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
885 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
890 /// Gets the keyboard repeat information.
892 /// <param name="rate">The key repeat rate value in seconds.</param>
893 /// <param name="delay">The key repeat delay value in seconds.</param>
894 /// <returns>True if setting the keyboard repeat succeeds.</returns>
895 /// <since_tizen> 5 </since_tizen>
896 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
898 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
899 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904 /// Adds a layer to the stage.
906 /// <param name="layer">Layer to add.</param>
907 /// <since_tizen> 3 </since_tizen>
908 public void AddLayer(Layer layer)
914 /// Removes a layer from the stage.
916 /// <param name="layer">Layer to remove.</param>
917 /// <since_tizen> 3 </since_tizen>
918 public void RemoveLayer(Layer layer)
924 /// Feeds a key event into the window.
926 /// <param name="keyEvent">The key event to feed.</param>
927 /// <since_tizen> 5 </since_tizen>
928 public void FeedKey(Key keyEvent)
930 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
931 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
935 /// Allows at least one more render, even when paused.
936 /// The window should be shown, not minimised.
938 /// <since_tizen> 4 </since_tizen>
939 public void RenderOnce()
941 Interop.Window.Window_RenderOnce(swigCPtr);
942 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
946 /// Sets whether the window is transparent or not.
948 /// <param name="transparent">Whether the window is transparent or not.</param>
949 /// <since_tizen> 5 </since_tizen>
950 public void SetTransparency(bool transparent)
952 Interop.Window.SetTransparency(swigCPtr, transparent);
953 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
955 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
959 /// Sets parent window of the window.
960 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
961 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
962 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
964 /// <param name="parent">The parent window.</param>
965 /// <since_tizen> 6 </since_tizen>
966 public void SetParent(Window parent)
968 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
969 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973 /// Unsets parent window of the window.
974 /// After unsetting, the window is disconnected his parent window.
976 /// <since_tizen> 6 </since_tizen>
977 public void Unparent()
979 Interop.Window.Unparent(swigCPtr);
980 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
984 /// Gets parent window of the window.
986 /// <returns>The parent window of the window.</returns>
987 /// <since_tizen> 6 </since_tizen>
988 public Window GetParent()
990 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
991 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
995 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
997 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1000 internal static Window GetCurrent()
1002 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
1003 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1007 internal static bool IsInstalled()
1009 bool ret = Interop.Stage.Stage_IsInstalled();
1010 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1014 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1016 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1017 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1022 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1023 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1026 internal void RotateIndicator(Window.WindowOrientation orientation)
1028 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1029 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 /// Adds an orientation to the list of available orientations.
1035 /// <param name="orientation">The available orientation to add</param>
1036 /// <since_tizen> 6 </since_tizen>
1037 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1039 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1040 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1044 /// Removes an orientation from the list of available orientations.
1046 /// <param name="orientation">The available orientation to remove.</param>
1047 /// <since_tizen> 6 </since_tizen>
1048 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1050 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1051 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1055 /// Sets a preferred orientation.
1057 /// <param name="orientation">The preferred orientation.</param>
1058 /// <since_tizen> 6 </since_tizen>
1059 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1061 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1062 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066 /// Gets the preferred orientation.
1068 /// <since_tizen> 6 </since_tizen>
1069 /// <returns>The preferred orientation if previously set, or none.</returns>
1070 public Window.WindowOrientation GetPreferredOrientation()
1072 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1073 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1077 internal Any GetNativeHandle()
1079 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1080 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1084 internal void Add(Layer layer)
1086 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1087 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1089 LayersChildren?.Add(layer);
1090 layer.SetWindow(this);
1093 internal void Remove(Layer layer)
1095 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1096 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1098 LayersChildren?.Remove(layer);
1099 layer.SetWindow(null);
1102 internal Vector2 GetSize()
1104 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1105 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1110 internal RenderTaskList GetRenderTaskList()
1112 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1118 /// Queries the number of on-window layers.
1120 /// <returns>The number of layers.</returns>
1121 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1122 internal uint GetLayerCount()
1124 if (LayersChildren == null || LayersChildren.Count < 0)
1127 return (uint) LayersChildren.Count;
1130 internal Layer GetRootLayer()
1132 // Window.IsInstalled() is actually true only when called from event thread and
1133 // Core has been initialized, not when Stage is ready.
1134 if (_rootLayer == null && Window.IsInstalled())
1136 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1138 LayersChildren?.Add(_rootLayer);
1139 _rootLayer.SetWindow(this);
1144 internal void SetBackgroundColor(Vector4 color)
1146 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1150 internal Vector4 GetBackgroundColor()
1152 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1157 internal Vector2 GetDpi()
1159 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1164 internal ObjectRegistry GetObjectRegistry()
1166 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1171 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1173 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1177 internal RenderingBehaviorType GetRenderingBehavior()
1179 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1180 if (NDalicPINVOKE.SWIGPendingException.Pending)
1181 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1185 internal void SetWindowSize(Size2D size)
1187 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1188 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 // Resetting Window size should request a relayout of the tree.
1195 internal Size2D GetWindowSize()
1197 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1198 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1204 internal void SetPosition(Position2D position)
1206 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1207 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1210 // Setting Position of the window should request a relayout of the tree.
1213 internal Position2D GetPosition()
1215 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1216 Position2D ret = new Position2D(val.GetX(), val.GetY());
1218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1222 internal void SetPositionSize(Rectangle positionSize)
1224 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1228 // Setting Position of the window should request a relayout of the tree.
1232 /// Dispose for Window
1234 [EditorBrowsable(EditorBrowsableState.Never)]
1235 protected override void Dispose(DisposeTypes type)
1242 if (type == DisposeTypes.Explicit)
1245 //Release your own managed resources here.
1246 //You should release all of your own disposable objects here.
1248 _rootLayer.Dispose();
1249 localController.Dispose();
1251 foreach(var layer in _childLayers)
1255 _childLayers.Clear();
1258 this.DisconnectNativeSignals();
1263 /// This will not be public opened.
1264 [EditorBrowsable(EditorBrowsableState.Never)]
1265 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1267 Interop.Window.delete_Window(swigCPtr);