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 /// Gets or sets a window type.
212 /// <since_tizen> 3 </since_tizen>
213 public WindowType Type
217 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 Interop.Window.SetType(swigCPtr, (int)value);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
229 /// Gets/Sets a window title.
231 /// <since_tizen> 4 </since_tizen>
240 _windowTitle = value;
241 SetClass(_windowTitle, "");
246 /// The rendering behavior of a Window.
248 /// <since_tizen> 5 </since_tizen>
249 public RenderingBehaviorType RenderingBehavior
253 return GetRenderingBehavior();
257 SetRenderingBehavior(value);
262 /// The window size property (read-only).
264 /// <since_tizen> 3 </since_tizen>
269 Size2D ret = GetSize();
275 /// The background color property.
277 /// <since_tizen> 3 </since_tizen>
278 public Color BackgroundColor
282 SetBackgroundColor(value);
286 Color ret = GetBackgroundColor();
292 /// The DPI property (read-only).<br />
293 /// Retrieves the DPI of the display device to which the Window is connected.<br />
295 /// <since_tizen> 3 </since_tizen>
305 /// The layer count property (read-only).<br />
306 /// Queries the number of on-Window layers.<br />
308 /// <since_tizen> 3 </since_tizen>
309 public uint LayerCount
313 return GetLayerCount();
318 /// Gets or sets a size of the window.
320 /// <since_tizen> 4 </since_tizen>
321 public Size2D WindowSize
325 return GetWindowSize();
329 SetWindowSize(value);
334 /// Gets or sets a position of the window.
336 /// <since_tizen> 4 </since_tizen>
337 public Position2D WindowPosition
341 return GetPosition();
350 /// Sets position and size of the window. This API guarantees that
351 /// both moving and resizing of window will appear on the screen at once.
353 [EditorBrowsable(EditorBrowsableState.Never)]
354 public Rectangle WindowPositionSize
358 Position2D position = GetPosition();
359 Size2D size = GetSize();
360 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
365 SetPositionSize(value);
369 internal static Vector4 DEFAULT_BACKGROUND_COLOR
373 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
374 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 internal static Vector4 DEBUG_BACKGROUND_COLOR
384 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
385 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
391 internal List<Layer> LayersChildren
400 /// Get the LayoutController for this Window.
402 internal LayoutController LayoutController
406 return localController;
411 /// Feed a key-event into the window.
413 /// <param name="keyEvent">The key event to feed.</param>
414 /// <since_tizen> 4 </since_tizen>
415 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
416 public static void FeedKeyEvent(Key keyEvent)
418 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 /// Sets whether the window accepts a focus or not.
425 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
426 /// <since_tizen> 3 </since_tizen>
427 public void SetAcceptFocus(bool accept)
429 Interop.Window.SetAcceptFocus(swigCPtr, accept);
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 /// Returns whether the window accepts a focus or not.
436 /// <returns>True if the window accepts a focus, false otherwise.</returns>
437 /// <since_tizen> 3 </since_tizen>
438 public bool IsFocusAcceptable()
440 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
447 /// Shows the window if it is hidden.
449 /// <since_tizen> 3 </since_tizen>
452 Interop.Window.Show(swigCPtr);
453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457 /// Hides the window if it is showing.
459 /// <since_tizen> 3 </since_tizen>
462 Interop.Window.Hide(swigCPtr);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 /// Retrieves whether the window is visible or not.
469 /// <returns>True if the window is visible.</returns>
470 /// <since_tizen> 3 </since_tizen>
471 public bool IsVisible()
473 bool temp = Interop.Window.IsVisible(swigCPtr);
474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 /// Gets the count of supported auxiliary hints of the window.
481 /// <returns>The number of supported auxiliary hints.</returns>
482 /// <since_tizen> 3 </since_tizen>
483 public uint GetSupportedAuxiliaryHintCount()
485 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491 /// Gets the supported auxiliary hint string of the window.
493 /// <param name="index">The index of the supported auxiliary hint lists.</param>
494 /// <returns>The auxiliary hint string of the index.</returns>
495 /// <since_tizen> 3 </since_tizen>
496 public string GetSupportedAuxiliaryHint(uint index)
498 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
504 /// Creates an auxiliary hint of the window.
506 /// <param name="hint">The auxiliary hint string.</param>
507 /// <param name="value">The value string.</param>
508 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
509 /// <since_tizen> 3 </since_tizen>
510 public uint AddAuxiliaryHint(string hint, string value)
512 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 /// Removes an auxiliary hint of the window.
520 /// <param name="id">The ID of the auxiliary hint.</param>
521 /// <returns>True if no error occurred, false otherwise.</returns>
522 /// <since_tizen> 3 </since_tizen>
523 public bool RemoveAuxiliaryHint(uint id)
525 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
526 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
531 /// Changes a value of the auxiliary hint.
533 /// <param name="id">The auxiliary hint ID.</param>
534 /// <param name="value">The value string to be set.</param>
535 /// <returns>True if no error occurred, false otherwise.</returns>
536 /// <since_tizen> 3 </since_tizen>
537 public bool SetAuxiliaryHintValue(uint id, string value)
539 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
540 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 /// Gets a value of the auxiliary hint.
547 /// <param name="id">The auxiliary hint ID.</param>
548 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
549 /// <since_tizen> 3 </since_tizen>
550 public string GetAuxiliaryHintValue(uint id)
552 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
558 /// Gets an ID of the auxiliary hint string.
560 /// <param name="hint">The auxiliary hint string.</param>
561 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
562 /// <since_tizen> 3 </since_tizen>
563 public uint GetAuxiliaryHintId(string hint)
565 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
566 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
571 /// Sets a region to accept input events.
573 /// <param name="inputRegion">The region to accept input events.</param>
574 /// <since_tizen> 3 </since_tizen>
575 public void SetInputRegion(Rectangle inputRegion)
577 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
578 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
582 /// Sets a priority level for the specified notification window.
584 /// <param name="level">The notification window level.</param>
585 /// <returns>True if no error occurred, false otherwise.</returns>
586 /// <since_tizen> 3 </since_tizen>
587 public bool SetNotificationLevel(NotificationLevel level)
589 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
590 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 /// Gets a priority level for the specified notification window.
597 /// <returns>The notification window level.</returns>
598 /// <since_tizen> 3 </since_tizen>
599 public NotificationLevel GetNotificationLevel()
601 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
602 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 /// Sets a transparent window's visual state to opaque. <br />
608 /// If a visual state of a transparent window is opaque, <br />
609 /// then the window manager could handle it as an opaque window when calculating visibility.
611 /// <param name="opaque">Whether the window's visual state is opaque.</param>
612 /// <remarks>This will have no effect on an opaque window. <br />
613 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
615 /// <since_tizen> 3 </since_tizen>
616 public void SetOpaqueState(bool opaque)
618 Interop.Window.SetOpaqueState(swigCPtr, opaque);
619 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623 /// Returns whether a transparent window's visual state is opaque or not.
625 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
626 /// <remarks> The return value has no meaning on an opaque window. </remarks>
627 /// <since_tizen> 3 </since_tizen>
628 public bool IsOpaqueState()
630 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
631 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 /// Sets a window's screen off mode.
638 /// <param name="screenOffMode">The screen mode.</param>
639 /// <returns>True if no error occurred, false otherwise.</returns>
640 /// <since_tizen> 4 </since_tizen>
641 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
643 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
644 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 /// Gets the screen mode of the window.
651 /// <returns>The screen off mode.</returns>
652 /// <since_tizen> 4 </since_tizen>
653 public ScreenOffMode GetScreenOffMode()
655 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
656 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661 /// Sets preferred brightness of the window.
663 /// <param name="brightness">The preferred brightness (0 to 100).</param>
664 /// <returns>True if no error occurred, false otherwise.</returns>
665 /// <since_tizen> 3 </since_tizen>
666 public bool SetBrightness(int brightness)
668 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
669 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 /// Gets the preferred brightness of the window.
676 /// <returns>The preferred brightness.</returns>
677 /// <since_tizen> 3 </since_tizen>
678 public int GetBrightness()
680 int ret = Interop.Window.GetBrightness(swigCPtr);
681 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
686 /// Sets the window name and the class string.
688 /// <param name="name">The name of the window.</param>
689 /// <param name="klass">The class of the window.</param>
690 /// <since_tizen> 4 </since_tizen>
691 public void SetClass(string name, string klass)
693 Interop.Window.Window_SetClass(swigCPtr, name, klass);
694 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
698 /// Raises the window to the top of the window stack.
700 /// <since_tizen> 3 </since_tizen>
703 Interop.Window.Window_Raise(swigCPtr);
704 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 /// Lowers the window to the bottom of the window stack.
710 /// <since_tizen> 3 </since_tizen>
713 Interop.Window.Window_Lower(swigCPtr);
714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718 /// Activates the window to the top of the window stack even it is iconified.
720 /// <since_tizen> 3 </since_tizen>
721 public void Activate()
723 Interop.Window.Window_Activate(swigCPtr);
724 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 /// Gets the default ( root ) layer.
730 /// <returns>The root layer.</returns>
731 /// <since_tizen> 3 </since_tizen>
732 public Layer GetDefaultLayer()
734 return this.GetRootLayer();
738 /// Add a child view to window.
740 /// <param name="view">the child should be added to the window.</param>
741 /// <since_tizen> 3 </since_tizen>
742 public void Add(View view)
744 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
745 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
746 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
747 view.InternalParent = this.GetRootLayer();
751 /// Remove a child view from window.
753 /// <param name="view">the child to be removed.</param>
754 /// <since_tizen> 3 </since_tizen>
755 public void Remove(View view)
757 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
758 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
759 view.InternalParent = null;
763 /// Retrieves the layer at a specified depth.
765 /// <param name="depth">The layer's depth index.</param>
766 /// <returns>The layer found at the given depth.</returns>
767 /// <since_tizen> 3 </since_tizen>
768 public Layer GetLayer(uint depth)
770 if (depth < LayersChildren?.Count)
772 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
782 /// Destroy the window immediately.
784 [EditorBrowsable(EditorBrowsableState.Never)]
785 public void Destroy()
791 /// Keep rendering for at least the given amount of time.
793 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
794 /// <since_tizen> 3 </since_tizen>
795 public void KeepRendering(float durationSeconds)
797 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
798 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
803 /// This function can be used for following example scenarios: <br />
804 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
806 /// <param name="DaliKey">The key code to grab.</param>
807 /// <returns>True if the grab succeeds.</returns>
808 /// <since_tizen> 3 </since_tizen>
809 public bool GrabKeyTopmost(int DaliKey)
811 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
812 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
817 /// Ungrabs the key specified by a key for the window.<br />
818 /// 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 />
820 /// <param name="DaliKey">The key code to ungrab.</param>
821 /// <returns>True if the ungrab succeeds.</returns>
822 /// <since_tizen> 3 </since_tizen>
823 public bool UngrabKeyTopmost(int DaliKey)
825 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
826 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831 /// Grabs the key specified by a key for a window in a GrabMode. <br />
832 /// Details: This function can be used for following example scenarios: <br />
833 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
834 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
835 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
837 /// <param name="DaliKey">The key code to grab.</param>
838 /// <param name="GrabMode">The grab mode for the key.</param>
839 /// <returns>True if the grab succeeds.</returns>
840 /// <since_tizen> 3 </since_tizen>
841 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
843 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
844 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
849 /// Ungrabs the key specified by a key for a window.<br />
850 /// 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 />
852 /// <param name="DaliKey">The key code to ungrab.</param>
853 /// <returns>True if the ungrab succeeds.</returns>
854 /// <since_tizen> 3 </since_tizen>
855 public bool UngrabKey(int DaliKey)
857 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
858 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
863 /// Sets the keyboard repeat information.
865 /// <param name="rate">The key repeat rate value in seconds.</param>
866 /// <param name="delay">The key repeat delay value in seconds.</param>
867 /// <returns>True if setting the keyboard repeat succeeds.</returns>
868 /// <since_tizen> 5 </since_tizen>
869 public bool SetKeyboardRepeatInfo(float rate, float delay)
871 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
872 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
877 /// Gets the keyboard repeat information.
879 /// <param name="rate">The key repeat rate value in seconds.</param>
880 /// <param name="delay">The key repeat delay value in seconds.</param>
881 /// <returns>True if setting the keyboard repeat succeeds.</returns>
882 /// <since_tizen> 5 </since_tizen>
883 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
885 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
886 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
891 /// Adds a layer to the stage.
893 /// <param name="layer">Layer to add.</param>
894 /// <since_tizen> 3 </since_tizen>
895 public void AddLayer(Layer layer)
901 /// Removes a layer from the stage.
903 /// <param name="layer">Layer to remove.</param>
904 /// <since_tizen> 3 </since_tizen>
905 public void RemoveLayer(Layer layer)
911 /// Feeds a key event into the window.
913 /// <param name="keyEvent">The key event to feed.</param>
914 /// <since_tizen> 5 </since_tizen>
915 public void FeedKey(Key keyEvent)
917 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
918 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
922 /// Allows at least one more render, even when paused.
923 /// The window should be shown, not minimised.
925 /// <since_tizen> 4 </since_tizen>
926 public void RenderOnce()
928 Interop.Window.Window_RenderOnce(swigCPtr);
929 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
933 /// Sets whether the window is transparent or not.
935 /// <param name="transparent">Whether the window is transparent or not.</param>
936 /// <since_tizen> 5 </since_tizen>
937 public void SetTransparency(bool transparent)
939 Interop.Window.SetTransparency(swigCPtr, transparent);
940 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
942 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
946 /// Sets parent window of the window.
947 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
948 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
949 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
951 /// <param name="parent">The parent window.</param>
952 /// <since_tizen> 6 </since_tizen>
953 public void SetParent(Window parent)
955 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
956 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
960 /// Unsets parent window of the window.
961 /// After unsetting, the window is disconnected his parent window.
963 /// <since_tizen> 6 </since_tizen>
964 public void Unparent()
966 Interop.Window.Unparent(swigCPtr);
967 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971 /// Gets parent window of the window.
973 /// <returns>The parent window of the window.</returns>
974 /// <since_tizen> 6 </since_tizen>
975 public Window GetParent()
977 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
978 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
982 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
984 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
987 internal static Window GetCurrent()
989 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
990 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
994 internal static bool IsInstalled()
996 bool ret = Interop.Stage.Stage_IsInstalled();
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1003 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1004 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1007 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1009 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1010 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 internal void RotateIndicator(Window.WindowOrientation orientation)
1015 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1016 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 /// Adds an orientation to the list of available orientations.
1022 /// <param name="orientation">The available orientation to add</param>
1023 /// <since_tizen> 6 </since_tizen>
1024 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1026 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1027 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1031 /// Removes an orientation from the list of available orientations.
1033 /// <param name="orientation">The available orientation to remove.</param>
1034 /// <since_tizen> 6 </since_tizen>
1035 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1037 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1038 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1042 /// Sets a preferred orientation.
1044 /// <param name="orientation">The preferred orientation.</param>
1045 /// <since_tizen> 6 </since_tizen>
1046 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1048 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1049 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1053 /// Gets the preferred orientation.
1055 /// <since_tizen> 6 </since_tizen>
1056 /// <returns>The preferred orientation if previously set, or none.</returns>
1057 public Window.WindowOrientation GetPreferredOrientation()
1059 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1060 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1064 internal Any GetNativeHandle()
1066 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1067 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1071 internal void Add(Layer layer)
1073 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1074 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1076 LayersChildren?.Add(layer);
1077 layer.SetWindow(this);
1080 internal void Remove(Layer layer)
1082 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1083 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1085 LayersChildren?.Remove(layer);
1086 layer.SetWindow(null);
1089 internal Vector2 GetSize()
1091 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1092 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1093 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1097 internal RenderTaskList GetRenderTaskList()
1099 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1105 /// Queries the number of on-window layers.
1107 /// <returns>The number of layers.</returns>
1108 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1109 internal uint GetLayerCount()
1111 if (LayersChildren == null || LayersChildren.Count < 0)
1114 return (uint) LayersChildren.Count;
1117 internal Layer GetRootLayer()
1119 // Window.IsInstalled() is actually true only when called from event thread and
1120 // Core has been initialized, not when Stage is ready.
1121 if (_rootLayer == null && Window.IsInstalled())
1123 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1125 LayersChildren?.Add(_rootLayer);
1126 _rootLayer.SetWindow(this);
1131 internal void SetBackgroundColor(Vector4 color)
1133 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1137 internal Vector4 GetBackgroundColor()
1139 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1140 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1144 internal Vector2 GetDpi()
1146 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1151 internal ObjectRegistry GetObjectRegistry()
1153 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1158 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1160 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1164 internal RenderingBehaviorType GetRenderingBehavior()
1166 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1167 if (NDalicPINVOKE.SWIGPendingException.Pending)
1168 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1172 internal void SetWindowSize(Size2D size)
1174 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1175 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1179 // Resetting Window size should request a relayout of the tree.
1182 internal Size2D GetWindowSize()
1184 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1185 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1191 internal void SetPosition(Position2D position)
1193 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1194 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197 // Setting Position of the window should request a relayout of the tree.
1200 internal Position2D GetPosition()
1202 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1203 Position2D ret = new Position2D(val.GetX(), val.GetY());
1205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1209 internal void SetPositionSize(Rectangle positionSize)
1211 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1215 // Setting Position of the window should request a relayout of the tree.
1219 /// Dispose for Window
1221 [EditorBrowsable(EditorBrowsableState.Never)]
1222 protected override void Dispose(DisposeTypes type)
1229 if (type == DisposeTypes.Explicit)
1232 //Release your own managed resources here.
1233 //You should release all of your own disposable objects here.
1235 _rootLayer.Dispose();
1236 localController.Dispose();
1238 foreach(var layer in _childLayers)
1242 _childLayers.Clear();
1245 this.DisconnectNativeSignals();
1250 /// This will not be public opened.
1251 [EditorBrowsable(EditorBrowsableState.Never)]
1252 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1254 Interop.Window.delete_Window(swigCPtr);