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,
107 /// No orientation. It is for the preferred orientation
108 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
109 /// It is used to unset the preferred orientation with SetPreferredOrientation.
111 [EditorBrowsable(EditorBrowsableState.Never)]
112 NoOrientationPreference = -1
116 /// Enumeration for the key grab mode for platform-level APIs.
118 /// <since_tizen> 3 </since_tizen>
119 public enum KeyGrabMode
122 /// Grabs a key only when on the top of the grabbing-window stack mode.
126 /// Grabs a key together with the other client window(s) mode.
130 /// 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.
134 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
140 /// Enumeration for transition effect's state.
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public enum EffectStates
148 [EditorBrowsable(EditorBrowsableState.Never)]
151 /// Transition effect is started.
153 [EditorBrowsable(EditorBrowsableState.Never)]
156 /// Transition effect is ended.
158 [EditorBrowsable(EditorBrowsableState.Never)]
163 /// Enumeration for transition effect's type.
165 [EditorBrowsable(EditorBrowsableState.Never)]
166 public enum EffectTypes
171 [EditorBrowsable(EditorBrowsableState.Never)]
174 /// Window show effect.
176 [EditorBrowsable(EditorBrowsableState.Never)]
179 /// Window hide effect.
181 [EditorBrowsable(EditorBrowsableState.Never)]
186 /// Enumeration for opacity of the indicator.
188 internal enum IndicatorBackgroundOpacity
196 /// Enumeration for visible mode of the indicator.
198 internal enum IndicatorVisibleMode
206 /// The stage instance property (read-only).<br />
207 /// Gets the current window.<br />
209 /// <since_tizen> 3 </since_tizen>
210 public static Window Instance
219 /// Get Resource ID of window
221 internal int ResourceID
225 int ret = Interop.Window.GetResouceID(swigCPtr);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 /// Gets or sets a window type.
234 /// <since_tizen> 3 </since_tizen>
235 public WindowType Type
239 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 Interop.Window.SetType(swigCPtr, (int)value);
246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 /// Gets/Sets a window title.
253 /// <since_tizen> 4 </since_tizen>
262 _windowTitle = value;
263 SetClass(_windowTitle, "");
268 /// The rendering behavior of a Window.
270 /// <since_tizen> 5 </since_tizen>
271 public RenderingBehaviorType RenderingBehavior
275 return GetRenderingBehavior();
279 SetRenderingBehavior(value);
284 /// The window size property (read-only).
286 /// <since_tizen> 3 </since_tizen>
291 Size2D ret = GetSize();
297 /// The background color property.
299 /// <since_tizen> 3 </since_tizen>
300 public Color BackgroundColor
304 SetBackgroundColor(value);
308 Color ret = GetBackgroundColor();
314 /// The DPI property (read-only).<br />
315 /// Retrieves the DPI of the display device to which the Window is connected.<br />
317 /// <since_tizen> 3 </since_tizen>
327 /// The layer count property (read-only).<br />
328 /// Queries the number of on-Window layers.<br />
330 /// <since_tizen> 3 </since_tizen>
331 public uint LayerCount
335 return GetLayerCount();
340 /// Gets or sets a size of the window.
342 /// <since_tizen> 4 </since_tizen>
343 public Size2D WindowSize
347 return GetWindowSize();
351 SetWindowSize(value);
356 /// Gets or sets a position of the window.
358 /// <since_tizen> 4 </since_tizen>
359 public Position2D WindowPosition
363 return GetPosition();
372 /// Sets position and size of the window. This API guarantees that
373 /// both moving and resizing of window will appear on the screen at once.
375 [EditorBrowsable(EditorBrowsableState.Never)]
376 public Rectangle WindowPositionSize
380 Position2D position = GetPosition();
381 Size2D size = GetSize();
382 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
387 SetPositionSize(value);
391 internal static Vector4 DEFAULT_BACKGROUND_COLOR
395 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
396 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402 internal static Vector4 DEBUG_BACKGROUND_COLOR
406 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
407 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
413 internal List<Layer> LayersChildren
422 /// Get the LayoutController for this Window.
424 internal LayoutController LayoutController
428 return localController;
433 /// Feed a key-event into the window.
435 /// <param name="keyEvent">The key event to feed.</param>
436 /// <since_tizen> 4 </since_tizen>
437 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
438 public static void FeedKeyEvent(Key keyEvent)
440 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
445 /// Sets whether the window accepts a focus or not.
447 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
448 /// <since_tizen> 3 </since_tizen>
449 public void SetAcceptFocus(bool accept)
451 Interop.Window.SetAcceptFocus(swigCPtr, accept);
452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 /// Returns whether the window accepts a focus or not.
458 /// <returns>True if the window accepts a focus, false otherwise.</returns>
459 /// <since_tizen> 3 </since_tizen>
460 public bool IsFocusAcceptable()
462 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 /// Shows the window if it is hidden.
471 /// <since_tizen> 3 </since_tizen>
474 Interop.Window.Show(swigCPtr);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 /// Hides the window if it is showing.
481 /// <since_tizen> 3 </since_tizen>
484 Interop.Window.Hide(swigCPtr);
485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489 /// Retrieves whether the window is visible or not.
491 /// <returns>True if the window is visible.</returns>
492 /// <since_tizen> 3 </since_tizen>
493 public bool IsVisible()
495 bool temp = Interop.Window.IsVisible(swigCPtr);
496 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
501 /// Gets the count of supported auxiliary hints of the window.
503 /// <returns>The number of supported auxiliary hints.</returns>
504 /// <since_tizen> 3 </since_tizen>
505 public uint GetSupportedAuxiliaryHintCount()
507 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
508 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
513 /// Gets the supported auxiliary hint string of the window.
515 /// <param name="index">The index of the supported auxiliary hint lists.</param>
516 /// <returns>The auxiliary hint string of the index.</returns>
517 /// <since_tizen> 3 </since_tizen>
518 public string GetSupportedAuxiliaryHint(uint index)
520 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
521 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
526 /// Creates an auxiliary hint of the window.
528 /// <param name="hint">The auxiliary hint string.</param>
529 /// <param name="value">The value string.</param>
530 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
531 /// <since_tizen> 3 </since_tizen>
532 public uint AddAuxiliaryHint(string hint, string value)
534 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
535 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
540 /// Removes an auxiliary hint of the window.
542 /// <param name="id">The ID of the auxiliary hint.</param>
543 /// <returns>True if no error occurred, false otherwise.</returns>
544 /// <since_tizen> 3 </since_tizen>
545 public bool RemoveAuxiliaryHint(uint id)
547 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
548 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553 /// Changes a value of the auxiliary hint.
555 /// <param name="id">The auxiliary hint ID.</param>
556 /// <param name="value">The value string to be set.</param>
557 /// <returns>True if no error occurred, false otherwise.</returns>
558 /// <since_tizen> 3 </since_tizen>
559 public bool SetAuxiliaryHintValue(uint id, string value)
561 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
562 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 /// Gets a value of the auxiliary hint.
569 /// <param name="id">The auxiliary hint ID.</param>
570 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
571 /// <since_tizen> 3 </since_tizen>
572 public string GetAuxiliaryHintValue(uint id)
574 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
575 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580 /// Gets an ID of the auxiliary hint string.
582 /// <param name="hint">The auxiliary hint string.</param>
583 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
584 /// <since_tizen> 3 </since_tizen>
585 public uint GetAuxiliaryHintId(string hint)
587 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
588 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593 /// Sets a region to accept input events.
595 /// <param name="inputRegion">The region to accept input events.</param>
596 /// <since_tizen> 3 </since_tizen>
597 public void SetInputRegion(Rectangle inputRegion)
599 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
600 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 /// Sets a priority level for the specified notification window.
606 /// <param name="level">The notification window level.</param>
607 /// <returns>True if no error occurred, false otherwise.</returns>
608 /// <since_tizen> 3 </since_tizen>
609 public bool SetNotificationLevel(NotificationLevel level)
611 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
612 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
617 /// Gets a priority level for the specified notification window.
619 /// <returns>The notification window level.</returns>
620 /// <since_tizen> 3 </since_tizen>
621 public NotificationLevel GetNotificationLevel()
623 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
629 /// Sets a transparent window's visual state to opaque. <br />
630 /// If a visual state of a transparent window is opaque, <br />
631 /// then the window manager could handle it as an opaque window when calculating visibility.
633 /// <param name="opaque">Whether the window's visual state is opaque.</param>
634 /// <remarks>This will have no effect on an opaque window. <br />
635 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
637 /// <since_tizen> 3 </since_tizen>
638 public void SetOpaqueState(bool opaque)
640 Interop.Window.SetOpaqueState(swigCPtr, opaque);
641 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 /// Returns whether a transparent window's visual state is opaque or not.
647 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
648 /// <remarks> The return value has no meaning on an opaque window. </remarks>
649 /// <since_tizen> 3 </since_tizen>
650 public bool IsOpaqueState()
652 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
653 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 /// Sets a window's screen off mode.
660 /// <param name="screenOffMode">The screen mode.</param>
661 /// <returns>True if no error occurred, false otherwise.</returns>
662 /// <since_tizen> 4 </since_tizen>
663 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
665 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
666 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671 /// Gets the screen mode of the window.
673 /// <returns>The screen off mode.</returns>
674 /// <since_tizen> 4 </since_tizen>
675 public ScreenOffMode GetScreenOffMode()
677 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
678 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 /// Sets preferred brightness of the window.
685 /// <param name="brightness">The preferred brightness (0 to 100).</param>
686 /// <returns>True if no error occurred, false otherwise.</returns>
687 /// <since_tizen> 3 </since_tizen>
688 public bool SetBrightness(int brightness)
690 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
691 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696 /// Gets the preferred brightness of the window.
698 /// <returns>The preferred brightness.</returns>
699 /// <since_tizen> 3 </since_tizen>
700 public int GetBrightness()
702 int ret = Interop.Window.GetBrightness(swigCPtr);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 /// Sets the window name and the class string.
710 /// <param name="name">The name of the window.</param>
711 /// <param name="klass">The class of the window.</param>
712 /// <since_tizen> 4 </since_tizen>
713 public void SetClass(string name, string klass)
715 Interop.Window.Window_SetClass(swigCPtr, name, klass);
716 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
720 /// Raises the window to the top of the window stack.
722 /// <since_tizen> 3 </since_tizen>
725 Interop.Window.Window_Raise(swigCPtr);
726 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730 /// Lowers the window to the bottom of the window stack.
732 /// <since_tizen> 3 </since_tizen>
735 Interop.Window.Window_Lower(swigCPtr);
736 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
740 /// Activates the window to the top of the window stack even it is iconified.
742 /// <since_tizen> 3 </since_tizen>
743 public void Activate()
745 Interop.Window.Window_Activate(swigCPtr);
746 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
750 /// Gets the default ( root ) layer.
752 /// <returns>The root layer.</returns>
753 /// <since_tizen> 3 </since_tizen>
754 public Layer GetDefaultLayer()
756 return this.GetRootLayer();
760 /// Add a child view to window.
762 /// <param name="view">the child should be added to the window.</param>
763 /// <since_tizen> 3 </since_tizen>
764 public void Add(View view)
766 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
767 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
768 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
769 view.InternalParent = this.GetRootLayer();
773 /// Remove a child view from window.
775 /// <param name="view">the child to be removed.</param>
776 /// <since_tizen> 3 </since_tizen>
777 public void Remove(View view)
779 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
780 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
781 view.InternalParent = null;
785 /// Retrieves the layer at a specified depth.
787 /// <param name="depth">The layer's depth index.</param>
788 /// <returns>The layer found at the given depth.</returns>
789 /// <since_tizen> 3 </since_tizen>
790 public Layer GetLayer(uint depth)
792 if (depth < LayersChildren?.Count)
794 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
804 /// Destroy the window immediately.
806 [EditorBrowsable(EditorBrowsableState.Never)]
807 public void Destroy()
813 /// Keep rendering for at least the given amount of time.
815 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
816 /// <since_tizen> 3 </since_tizen>
817 public void KeepRendering(float durationSeconds)
819 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
820 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
824 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
825 /// This function can be used for following example scenarios: <br />
826 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
828 /// <param name="DaliKey">The key code to grab.</param>
829 /// <returns>True if the grab succeeds.</returns>
830 /// <since_tizen> 3 </since_tizen>
831 public bool GrabKeyTopmost(int DaliKey)
833 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
834 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
839 /// Ungrabs the key specified by a key for the window.<br />
840 /// 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 />
842 /// <param name="DaliKey">The key code to ungrab.</param>
843 /// <returns>True if the ungrab succeeds.</returns>
844 /// <since_tizen> 3 </since_tizen>
845 public bool UngrabKeyTopmost(int DaliKey)
847 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
848 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853 /// Grabs the key specified by a key for a window in a GrabMode. <br />
854 /// Details: This function can be used for following example scenarios: <br />
855 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
856 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
857 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
859 /// <param name="DaliKey">The key code to grab.</param>
860 /// <param name="GrabMode">The grab mode for the key.</param>
861 /// <returns>True if the grab succeeds.</returns>
862 /// <since_tizen> 3 </since_tizen>
863 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
865 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
866 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
871 /// Ungrabs the key specified by a key for a window.<br />
872 /// 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 />
874 /// <param name="DaliKey">The key code to ungrab.</param>
875 /// <returns>True if the ungrab succeeds.</returns>
876 /// <since_tizen> 3 </since_tizen>
877 public bool UngrabKey(int DaliKey)
879 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
880 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 /// Sets the keyboard repeat information.
887 /// <param name="rate">The key repeat rate value in seconds.</param>
888 /// <param name="delay">The key repeat delay value in seconds.</param>
889 /// <returns>True if setting the keyboard repeat succeeds.</returns>
890 /// <since_tizen> 5 </since_tizen>
891 public bool SetKeyboardRepeatInfo(float rate, float delay)
893 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
894 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
899 /// Gets the keyboard repeat information.
901 /// <param name="rate">The key repeat rate value in seconds.</param>
902 /// <param name="delay">The key repeat delay value in seconds.</param>
903 /// <returns>True if setting the keyboard repeat succeeds.</returns>
904 /// <since_tizen> 5 </since_tizen>
905 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
907 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
908 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
913 /// Adds a layer to the stage.
915 /// <param name="layer">Layer to add.</param>
916 /// <since_tizen> 3 </since_tizen>
917 public void AddLayer(Layer layer)
919 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
920 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
922 LayersChildren?.Add(layer);
923 layer.SetWindow(this);
927 /// Removes a layer from the stage.
929 /// <param name="layer">Layer to remove.</param>
930 /// <since_tizen> 3 </since_tizen>
931 public void RemoveLayer(Layer layer)
933 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
934 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 LayersChildren?.Remove(layer);
937 layer.SetWindow(null);
941 /// Feeds a key event into the window.
943 /// <param name="keyEvent">The key event to feed.</param>
944 /// <since_tizen> 5 </since_tizen>
945 public void FeedKey(Key keyEvent)
947 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
948 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
952 /// Allows at least one more render, even when paused.
953 /// The window should be shown, not minimised.
955 /// <since_tizen> 4 </since_tizen>
956 public void RenderOnce()
958 Interop.Window.Window_RenderOnce(swigCPtr);
959 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 /// Sets whether the window is transparent or not.
965 /// <param name="transparent">Whether the window is transparent or not.</param>
966 /// <since_tizen> 5 </since_tizen>
967 public void SetTransparency(bool transparent)
969 Interop.Window.SetTransparency(swigCPtr, transparent);
970 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
972 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
976 /// Sets parent window of the window.
977 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
978 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
979 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
981 /// <param name="parent">The parent window.</param>
982 /// <since_tizen> 6 </since_tizen>
983 public void SetParent(Window parent)
985 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
986 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
990 /// Unsets parent window of the window.
991 /// After unsetting, the window is disconnected his parent window.
993 /// <since_tizen> 6 </since_tizen>
994 public void Unparent()
996 Interop.Window.Unparent(swigCPtr);
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1001 /// Gets parent window of the window.
1003 /// <returns>The parent window of the window.</returns>
1004 /// <since_tizen> 6 </since_tizen>
1005 public Window GetParent()
1007 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
1008 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1014 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
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();
1088 /// Gets current orientation of the window.
1090 /// <since_tizen> 6 </since_tizen>
1091 /// <returns>The current window orientation if previously set, or none.</returns>
1092 [EditorBrowsable(EditorBrowsableState.Never)]
1093 public Window.WindowOrientation GetCurrentOrientation()
1095 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetCurrentOrientation(swigCPtr);
1096 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1101 /// Sets available orientations of the window.
1102 /// This API is for setting several orientations one time.
1104 /// <param name="orientations">The list of orientations.</param>
1105 /// <since_tizen> 6 </since_tizen>
1106 [EditorBrowsable(EditorBrowsableState.Never)]
1107 public void SetAvailableOrientations( List<Window.WindowOrientation> orientations )
1109 PropertyArray orientationArray = new PropertyArray();
1110 for( int i = 0; i < orientations.Count; i++ )
1112 orientationArray.PushBack(new PropertyValue((int)orientations[i]));
1115 Interop.Window.Window_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray));
1116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1119 internal Any GetNativeHandle()
1121 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1126 internal void Add(Layer layer)
1128 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1131 LayersChildren?.Add(layer);
1132 layer.SetWindow(this);
1135 internal void Remove(Layer layer)
1137 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1140 LayersChildren?.Remove(layer);
1141 layer.SetWindow(null);
1144 internal Vector2 GetSize()
1146 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1147 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1148 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1152 internal RenderTaskList GetRenderTaskList()
1154 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1160 /// Queries the number of on-window layers.
1162 /// <returns>The number of layers.</returns>
1163 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1164 internal uint GetLayerCount()
1166 if (LayersChildren == null || LayersChildren.Count < 0)
1169 return (uint) LayersChildren.Count;
1172 internal Layer GetRootLayer()
1174 // Window.IsInstalled() is actually true only when called from event thread and
1175 // Core has been initialized, not when Stage is ready.
1176 if (_rootLayer == null && Window.IsInstalled())
1178 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180 LayersChildren?.Add(_rootLayer);
1181 _rootLayer.SetWindow(this);
1186 internal void SetBackgroundColor(Vector4 color)
1188 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1189 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 internal Vector4 GetBackgroundColor()
1194 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1199 internal Vector2 GetDpi()
1201 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1206 internal ObjectRegistry GetObjectRegistry()
1208 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1213 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1215 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219 internal RenderingBehaviorType GetRenderingBehavior()
1221 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1222 if (NDalicPINVOKE.SWIGPendingException.Pending)
1223 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1227 internal void SetWindowSize(Size2D size)
1229 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1230 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1232 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1234 // Resetting Window size should request a relayout of the tree.
1237 internal Size2D GetWindowSize()
1239 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1240 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1246 internal void SetPosition(Position2D position)
1248 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1249 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1252 // Setting Position of the window should request a relayout of the tree.
1255 internal Position2D GetPosition()
1257 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1258 Position2D ret = new Position2D(val.GetX(), val.GetY());
1260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264 internal void SetPositionSize(Rectangle positionSize)
1266 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1270 // Setting Position of the window should request a relayout of the tree.
1274 /// Dispose for Window
1276 [EditorBrowsable(EditorBrowsableState.Never)]
1277 protected override void Dispose(DisposeTypes type)
1284 if (type == DisposeTypes.Explicit)
1287 //Release your own managed resources here.
1288 //You should release all of your own disposable objects here.
1290 _rootLayer.Dispose();
1291 localController.Dispose();
1293 foreach(var layer in _childLayers)
1297 _childLayers.Clear();
1300 this.DisconnectNativeSignals();
1302 //Release your own unmanaged resources here.
1303 //You should not access any managed member here except static instance.
1304 //because the execution order of Finalizes is non-deterministic.
1306 if (swigCPtr.Handle != global::System.IntPtr.Zero)
1310 swigCMemOwn = false;
1311 Interop.Window.delete_Window(swigCPtr);
1313 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);