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,
105 /// No orientation. It is for the preferred orientation
106 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
107 /// It is used to unset the preferred orientation with SetPreferredOrientation.
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 NoOrientationPreference = -1
114 /// Enumeration for the key grab mode for platform-level APIs.
116 /// <since_tizen> 3 </since_tizen>
117 public enum KeyGrabMode
120 /// Grabs a key only when on the top of the grabbing-window stack mode.
124 /// Grabs a key together with the other client window(s) mode.
128 /// 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.
132 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
138 /// Enumeration for transition effect's state.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public enum EffectStates
146 [EditorBrowsable(EditorBrowsableState.Never)]
149 /// Transition effect is started.
151 [EditorBrowsable(EditorBrowsableState.Never)]
154 /// Transition effect is ended.
156 [EditorBrowsable(EditorBrowsableState.Never)]
161 /// Enumeration for transition effect's type.
163 [EditorBrowsable(EditorBrowsableState.Never)]
164 public enum EffectTypes
169 [EditorBrowsable(EditorBrowsableState.Never)]
172 /// Window show effect.
174 [EditorBrowsable(EditorBrowsableState.Never)]
177 /// Window hide effect.
179 [EditorBrowsable(EditorBrowsableState.Never)]
184 /// Enumeration for opacity of the indicator.
186 internal enum IndicatorBackgroundOpacity
194 /// Enumeration for visible mode of the indicator.
196 internal enum IndicatorVisibleMode
204 /// The stage instance property (read-only).<br />
205 /// Gets the current window.<br />
207 /// <since_tizen> 3 </since_tizen>
208 public static Window Instance
217 /// Get Resource ID of window
219 internal int ResourceID
223 int ret = Interop.Window.GetResouceID(swigCPtr);
224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 /// Gets or sets a window type.
232 /// <since_tizen> 3 </since_tizen>
233 public WindowType Type
237 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243 Interop.Window.SetType(swigCPtr, (int)value);
244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 /// Gets/Sets a window title.
251 /// <since_tizen> 4 </since_tizen>
260 _windowTitle = value;
261 SetClass(_windowTitle, "");
266 /// The rendering behavior of a Window.
268 /// <since_tizen> 5 </since_tizen>
269 public RenderingBehaviorType RenderingBehavior
273 return GetRenderingBehavior();
277 SetRenderingBehavior(value);
282 /// The window size property (read-only).
284 /// <since_tizen> 3 </since_tizen>
289 Size2D ret = GetSize();
295 /// The background color property.
297 /// <since_tizen> 3 </since_tizen>
298 public Color BackgroundColor
302 SetBackgroundColor(value);
306 Color ret = GetBackgroundColor();
312 /// The DPI property (read-only).<br />
313 /// Retrieves the DPI of the display device to which the Window is connected.<br />
315 /// <since_tizen> 3 </since_tizen>
325 /// The layer count property (read-only).<br />
326 /// Queries the number of on-Window layers.<br />
328 /// <since_tizen> 3 </since_tizen>
329 public uint LayerCount
333 return GetLayerCount();
338 /// Gets or sets a size of the window.
340 /// <since_tizen> 4 </since_tizen>
341 public Size2D WindowSize
345 return GetWindowSize();
349 SetWindowSize(value);
354 /// Gets or sets a position of the window.
356 /// <since_tizen> 4 </since_tizen>
357 public Position2D WindowPosition
361 return GetPosition();
370 /// Sets position and size of the window. This API guarantees that
371 /// both moving and resizing of window will appear on the screen at once.
373 [EditorBrowsable(EditorBrowsableState.Never)]
374 public Rectangle WindowPositionSize
378 Position2D position = GetPosition();
379 Size2D size = GetSize();
380 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
385 SetPositionSize(value);
389 internal static Vector4 DEFAULT_BACKGROUND_COLOR
393 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
394 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400 internal static Vector4 DEBUG_BACKGROUND_COLOR
404 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
405 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411 internal List<Layer> LayersChildren
420 /// Get the LayoutController for this Window.
422 internal LayoutController LayoutController
426 return localController;
431 /// Feed a key-event into the window.
433 /// <param name="keyEvent">The key event to feed.</param>
434 /// <since_tizen> 4 </since_tizen>
435 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
436 public static void FeedKeyEvent(Key keyEvent)
438 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 /// Sets whether the window accepts a focus or not.
445 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
446 /// <since_tizen> 3 </since_tizen>
447 public void SetAcceptFocus(bool accept)
449 Interop.Window.SetAcceptFocus(swigCPtr, accept);
450 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
454 /// Returns whether the window accepts a focus or not.
456 /// <returns>True if the window accepts a focus, false otherwise.</returns>
457 /// <since_tizen> 3 </since_tizen>
458 public bool IsFocusAcceptable()
460 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
467 /// Shows the window if it is hidden.
469 /// <since_tizen> 3 </since_tizen>
472 Interop.Window.Show(swigCPtr);
473 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
477 /// Hides the window if it is showing.
479 /// <since_tizen> 3 </since_tizen>
482 Interop.Window.Hide(swigCPtr);
483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
487 /// Retrieves whether the window is visible or not.
489 /// <returns>True if the window is visible.</returns>
490 /// <since_tizen> 3 </since_tizen>
491 public bool IsVisible()
493 bool temp = Interop.Window.IsVisible(swigCPtr);
494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 /// Gets the count of supported auxiliary hints of the window.
501 /// <returns>The number of supported auxiliary hints.</returns>
502 /// <since_tizen> 3 </since_tizen>
503 public uint GetSupportedAuxiliaryHintCount()
505 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511 /// Gets the supported auxiliary hint string of the window.
513 /// <param name="index">The index of the supported auxiliary hint lists.</param>
514 /// <returns>The auxiliary hint string of the index.</returns>
515 /// <since_tizen> 3 </since_tizen>
516 public string GetSupportedAuxiliaryHint(uint index)
518 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
519 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
524 /// Creates an auxiliary hint of the window.
526 /// <param name="hint">The auxiliary hint string.</param>
527 /// <param name="value">The value string.</param>
528 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
529 /// <since_tizen> 3 </since_tizen>
530 public uint AddAuxiliaryHint(string hint, string value)
532 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
533 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538 /// Removes an auxiliary hint of the window.
540 /// <param name="id">The ID of the auxiliary hint.</param>
541 /// <returns>True if no error occurred, false otherwise.</returns>
542 /// <since_tizen> 3 </since_tizen>
543 public bool RemoveAuxiliaryHint(uint id)
545 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
546 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
551 /// Changes a value of the auxiliary hint.
553 /// <param name="id">The auxiliary hint ID.</param>
554 /// <param name="value">The value string to be set.</param>
555 /// <returns>True if no error occurred, false otherwise.</returns>
556 /// <since_tizen> 3 </since_tizen>
557 public bool SetAuxiliaryHintValue(uint id, string value)
559 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
565 /// Gets a value of the auxiliary hint.
567 /// <param name="id">The auxiliary hint ID.</param>
568 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
569 /// <since_tizen> 3 </since_tizen>
570 public string GetAuxiliaryHintValue(uint id)
572 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
573 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
578 /// Gets an ID of the auxiliary hint string.
580 /// <param name="hint">The auxiliary hint string.</param>
581 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
582 /// <since_tizen> 3 </since_tizen>
583 public uint GetAuxiliaryHintId(string hint)
585 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
586 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
591 /// Sets a region to accept input events.
593 /// <param name="inputRegion">The region to accept input events.</param>
594 /// <since_tizen> 3 </since_tizen>
595 public void SetInputRegion(Rectangle inputRegion)
597 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
598 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 /// Sets a priority level for the specified notification window.
604 /// <param name="level">The notification window level.</param>
605 /// <returns>True if no error occurred, false otherwise.</returns>
606 /// <since_tizen> 3 </since_tizen>
607 public bool SetNotificationLevel(NotificationLevel level)
609 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
610 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615 /// Gets a priority level for the specified notification window.
617 /// <returns>The notification window level.</returns>
618 /// <since_tizen> 3 </since_tizen>
619 public NotificationLevel GetNotificationLevel()
621 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
622 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627 /// Sets a transparent window's visual state to opaque. <br />
628 /// If a visual state of a transparent window is opaque, <br />
629 /// then the window manager could handle it as an opaque window when calculating visibility.
631 /// <param name="opaque">Whether the window's visual state is opaque.</param>
632 /// <remarks>This will have no effect on an opaque window. <br />
633 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
635 /// <since_tizen> 3 </since_tizen>
636 public void SetOpaqueState(bool opaque)
638 Interop.Window.SetOpaqueState(swigCPtr, opaque);
639 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 /// Returns whether a transparent window's visual state is opaque or not.
645 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
646 /// <remarks> The return value has no meaning on an opaque window. </remarks>
647 /// <since_tizen> 3 </since_tizen>
648 public bool IsOpaqueState()
650 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
651 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 /// Sets a window's screen off mode.
658 /// <param name="screenOffMode">The screen mode.</param>
659 /// <returns>True if no error occurred, false otherwise.</returns>
660 /// <since_tizen> 4 </since_tizen>
661 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
663 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
664 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 /// Gets the screen mode of the window.
671 /// <returns>The screen off mode.</returns>
672 /// <since_tizen> 4 </since_tizen>
673 public ScreenOffMode GetScreenOffMode()
675 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
676 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
681 /// Sets preferred brightness of the window.
683 /// <param name="brightness">The preferred brightness (0 to 100).</param>
684 /// <returns>True if no error occurred, false otherwise.</returns>
685 /// <since_tizen> 3 </since_tizen>
686 public bool SetBrightness(int brightness)
688 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
689 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
694 /// Gets the preferred brightness of the window.
696 /// <returns>The preferred brightness.</returns>
697 /// <since_tizen> 3 </since_tizen>
698 public int GetBrightness()
700 int ret = Interop.Window.GetBrightness(swigCPtr);
701 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 /// Sets the window name and the class string.
708 /// <param name="name">The name of the window.</param>
709 /// <param name="klass">The class of the window.</param>
710 /// <since_tizen> 4 </since_tizen>
711 public void SetClass(string name, string klass)
713 Interop.Window.Window_SetClass(swigCPtr, name, klass);
714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
718 /// Raises the window to the top of the window stack.
720 /// <since_tizen> 3 </since_tizen>
723 Interop.Window.Window_Raise(swigCPtr);
724 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 /// Lowers the window to the bottom of the window stack.
730 /// <since_tizen> 3 </since_tizen>
733 Interop.Window.Window_Lower(swigCPtr);
734 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
738 /// Activates the window to the top of the window stack even it is iconified.
740 /// <since_tizen> 3 </since_tizen>
741 public void Activate()
743 Interop.Window.Window_Activate(swigCPtr);
744 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
748 /// Gets the default ( root ) layer.
750 /// <returns>The root layer.</returns>
751 /// <since_tizen> 3 </since_tizen>
752 public Layer GetDefaultLayer()
754 return this.GetRootLayer();
758 /// Add a child view to window.
760 /// <param name="view">the child should be added to the window.</param>
761 /// <since_tizen> 3 </since_tizen>
762 public void Add(View view)
764 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
765 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
767 view.InternalParent = this.GetRootLayer();
771 /// Remove a child view from window.
773 /// <param name="view">the child to be removed.</param>
774 /// <since_tizen> 3 </since_tizen>
775 public void Remove(View view)
777 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
778 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
779 view.InternalParent = null;
783 /// Retrieves the layer at a specified depth.
785 /// <param name="depth">The layer's depth index.</param>
786 /// <returns>The layer found at the given depth.</returns>
787 /// <since_tizen> 3 </since_tizen>
788 public Layer GetLayer(uint depth)
790 if (depth < LayersChildren?.Count)
792 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
802 /// Destroy the window immediately.
804 [EditorBrowsable(EditorBrowsableState.Never)]
805 public void Destroy()
811 /// Keep rendering for at least the given amount of time.
813 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
814 /// <since_tizen> 3 </since_tizen>
815 public void KeepRendering(float durationSeconds)
817 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
818 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
823 /// This function can be used for following example scenarios: <br />
824 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
826 /// <param name="DaliKey">The key code to grab.</param>
827 /// <returns>True if the grab succeeds.</returns>
828 /// <since_tizen> 3 </since_tizen>
829 public bool GrabKeyTopmost(int DaliKey)
831 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
832 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
837 /// Ungrabs the key specified by a key for the window.<br />
838 /// 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 />
840 /// <param name="DaliKey">The key code to ungrab.</param>
841 /// <returns>True if the ungrab succeeds.</returns>
842 /// <since_tizen> 3 </since_tizen>
843 public bool UngrabKeyTopmost(int DaliKey)
845 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
846 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851 /// Grabs the key specified by a key for a window in a GrabMode. <br />
852 /// Details: This function can be used for following example scenarios: <br />
853 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
854 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
855 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
857 /// <param name="DaliKey">The key code to grab.</param>
858 /// <param name="GrabMode">The grab mode for the key.</param>
859 /// <returns>True if the grab succeeds.</returns>
860 /// <since_tizen> 3 </since_tizen>
861 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
863 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
864 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
869 /// Ungrabs the key specified by a key for a window.<br />
870 /// 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 />
872 /// <param name="DaliKey">The key code to ungrab.</param>
873 /// <returns>True if the ungrab succeeds.</returns>
874 /// <since_tizen> 3 </since_tizen>
875 public bool UngrabKey(int DaliKey)
877 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
878 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883 /// Sets the keyboard repeat information.
885 /// <param name="rate">The key repeat rate value in seconds.</param>
886 /// <param name="delay">The key repeat delay value in seconds.</param>
887 /// <returns>True if setting the keyboard repeat succeeds.</returns>
888 /// <since_tizen> 5 </since_tizen>
889 public bool SetKeyboardRepeatInfo(float rate, float delay)
891 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
892 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
897 /// Gets the keyboard repeat information.
899 /// <param name="rate">The key repeat rate value in seconds.</param>
900 /// <param name="delay">The key repeat delay value in seconds.</param>
901 /// <returns>True if setting the keyboard repeat succeeds.</returns>
902 /// <since_tizen> 5 </since_tizen>
903 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
905 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
906 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
911 /// Adds a layer to the stage.
913 /// <param name="layer">Layer to add.</param>
914 /// <since_tizen> 3 </since_tizen>
915 public void AddLayer(Layer layer)
921 /// Removes a layer from the stage.
923 /// <param name="layer">Layer to remove.</param>
924 /// <since_tizen> 3 </since_tizen>
925 public void RemoveLayer(Layer layer)
931 /// Feeds a key event into the window.
933 /// <param name="keyEvent">The key event to feed.</param>
934 /// <since_tizen> 5 </since_tizen>
935 public void FeedKey(Key keyEvent)
937 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
938 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
942 /// Allows at least one more render, even when paused.
943 /// The window should be shown, not minimised.
945 /// <since_tizen> 4 </since_tizen>
946 public void RenderOnce()
948 Interop.Window.Window_RenderOnce(swigCPtr);
949 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
953 /// Sets whether the window is transparent or not.
955 /// <param name="transparent">Whether the window is transparent or not.</param>
956 /// <since_tizen> 5 </since_tizen>
957 public void SetTransparency(bool transparent)
959 Interop.Window.SetTransparency(swigCPtr, transparent);
960 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
962 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
966 /// Sets parent window of the window.
967 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
968 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
969 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
971 /// <param name="parent">The parent window.</param>
972 /// <since_tizen> 6 </since_tizen>
973 public void SetParent(Window parent)
975 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
976 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
980 /// Unsets parent window of the window.
981 /// After unsetting, the window is disconnected his parent window.
983 /// <since_tizen> 6 </since_tizen>
984 public void Unparent()
986 Interop.Window.Unparent(swigCPtr);
987 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
991 /// Gets parent window of the window.
993 /// <returns>The parent window of the window.</returns>
994 /// <since_tizen> 6 </since_tizen>
995 public Window GetParent()
997 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
998 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1002 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1004 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1007 internal static Window GetCurrent()
1009 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
1010 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1014 internal static bool IsInstalled()
1016 bool ret = Interop.Stage.Stage_IsInstalled();
1017 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1021 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1023 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1024 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1027 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1029 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1030 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 internal void RotateIndicator(Window.WindowOrientation orientation)
1035 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1036 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1040 /// Adds an orientation to the list of available orientations.
1042 /// <param name="orientation">The available orientation to add</param>
1043 /// <since_tizen> 6 </since_tizen>
1044 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1046 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1047 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1051 /// Removes an orientation from the list of available orientations.
1053 /// <param name="orientation">The available orientation to remove.</param>
1054 /// <since_tizen> 6 </since_tizen>
1055 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1057 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1058 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1062 /// Sets a preferred orientation.
1064 /// <param name="orientation">The preferred orientation.</param>
1065 /// <since_tizen> 6 </since_tizen>
1066 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1068 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1069 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1073 /// Gets the preferred orientation.
1075 /// <since_tizen> 6 </since_tizen>
1076 /// <returns>The preferred orientation if previously set, or none.</returns>
1077 public Window.WindowOrientation GetPreferredOrientation()
1079 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1080 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1084 internal Any GetNativeHandle()
1086 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1087 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1091 internal void Add(Layer layer)
1093 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1094 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1096 LayersChildren?.Add(layer);
1097 layer.SetWindow(this);
1100 internal void Remove(Layer layer)
1102 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1105 LayersChildren?.Remove(layer);
1106 layer.SetWindow(null);
1109 internal Vector2 GetSize()
1111 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1112 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1117 internal RenderTaskList GetRenderTaskList()
1119 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1120 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1125 /// Queries the number of on-window layers.
1127 /// <returns>The number of layers.</returns>
1128 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1129 internal uint GetLayerCount()
1131 if (LayersChildren == null || LayersChildren.Count < 0)
1134 return (uint) LayersChildren.Count;
1137 internal Layer GetRootLayer()
1139 // Window.IsInstalled() is actually true only when called from event thread and
1140 // Core has been initialized, not when Stage is ready.
1141 if (_rootLayer == null && Window.IsInstalled())
1143 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1145 LayersChildren?.Add(_rootLayer);
1146 _rootLayer.SetWindow(this);
1151 internal void SetBackgroundColor(Vector4 color)
1153 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1157 internal Vector4 GetBackgroundColor()
1159 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1164 internal Vector2 GetDpi()
1166 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1167 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1171 internal ObjectRegistry GetObjectRegistry()
1173 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1178 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1180 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1184 internal RenderingBehaviorType GetRenderingBehavior()
1186 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1187 if (NDalicPINVOKE.SWIGPendingException.Pending)
1188 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 internal void SetWindowSize(Size2D size)
1194 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1195 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1199 // Resetting Window size should request a relayout of the tree.
1202 internal Size2D GetWindowSize()
1204 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1205 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1211 internal void SetPosition(Position2D position)
1213 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1214 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1217 // Setting Position of the window should request a relayout of the tree.
1220 internal Position2D GetPosition()
1222 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1223 Position2D ret = new Position2D(val.GetX(), val.GetY());
1225 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1229 internal void SetPositionSize(Rectangle positionSize)
1231 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1235 // Setting Position of the window should request a relayout of the tree.
1239 /// Dispose for Window
1241 [EditorBrowsable(EditorBrowsableState.Never)]
1242 protected override void Dispose(DisposeTypes type)
1249 if (type == DisposeTypes.Explicit)
1252 //Release your own managed resources here.
1253 //You should release all of your own disposable objects here.
1255 _rootLayer.Dispose();
1256 localController.Dispose();
1258 foreach(var layer in _childLayers)
1262 _childLayers.Clear();
1265 this.DisconnectNativeSignals();
1270 /// This will not be public opened.
1271 [EditorBrowsable(EditorBrowsableState.Never)]
1272 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1274 Interop.Window.delete_Window(swigCPtr);