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 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
21 using System.ComponentModel;
22 using System.Collections.Generic;
23 using System.Runtime.InteropServices;
24 using Tizen.NUI.BaseComponents;
29 /// The window class is used internally for drawing.<br />
30 /// The window has an orientation and indicator properties.<br />
32 /// <since_tizen> 3 </since_tizen>
33 public partial class Window : BaseHandle
35 private static readonly Window instance = Application.Instance?.GetWindow();
36 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
37 private Layer _rootLayer;
38 private string _windowTitle;
39 private List<Layer> _childLayers = new List<Layer>();
40 private LayoutController localController;
42 private bool IsSupportedMultiWindow()
44 bool isSupported = false;
45 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
49 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
51 if (Interop.Stage.Stage_IsInstalled())
53 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
55 localController = new LayoutController(this);
56 NUILog.Debug("layoutController id:" + localController.GetId() );
61 /// Creates a new Window.<br />
62 /// This creates an extra window in addition to the default main window<br />
64 /// <param name="windowPosition">The position and size of the Window.</param>
65 /// <param name="isTranslucent">Whether Window is translucent.</param>
66 /// <returns>A new Window.</returns>
67 /// <since_tizen> 6 </since_tizen>
68 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
69 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
70 public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
72 if( IsSupportedMultiWindow() == false )
74 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80 /// Creates a new Window with a specific name.<br />
81 /// This creates an extra window in addition to the default main window<br />
83 /// <param name="name">The name for extra window. </param>
84 /// <param name="windowPosition">The position and size of the Window.</param>
85 /// <param name="isTranslucent">Whether Window is translucent.</param>
86 /// <returns>A new Window.</returns>
87 /// <since_tizen> 6 </since_tizen>
88 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
89 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
90 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
92 if (IsSupportedMultiWindow() == false)
94 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
96 this._windowTitle = name;
97 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
103 /// <since_tizen> 3 </since_tizen>
104 public enum WindowOrientation
107 /// Portrait orientation. The height of the display area is greater than the width.
109 /// <since_tizen> 3 </since_tizen>
112 /// Landscape orientation. A wide view area is needed.
114 /// <since_tizen> 3 </since_tizen>
117 /// Portrait inverse orientation.
119 /// <since_tizen> 3 </since_tizen>
120 PortraitInverse = 180,
122 /// Landscape inverse orientation.
124 /// <since_tizen> 3 </since_tizen>
125 LandscapeInverse = 270,
127 /// No orientation. It is for the preferred orientation
128 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
129 /// It is used to unset the preferred orientation with SetPreferredOrientation.
131 [EditorBrowsable(EditorBrowsableState.Never)]
132 NoOrientationPreference = -1
136 /// Enumeration for the key grab mode for platform-level APIs.
138 /// <since_tizen> 3 </since_tizen>
139 public enum KeyGrabMode
142 /// Grabs a key only when on the top of the grabbing-window stack mode.
146 /// Grabs a key together with the other client window(s) mode.
150 /// 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.
154 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
160 /// Enumeration for transition effect's state.
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public enum EffectStates
168 [EditorBrowsable(EditorBrowsableState.Never)]
171 /// Transition effect is started.
173 [EditorBrowsable(EditorBrowsableState.Never)]
176 /// Transition effect is ended.
178 [EditorBrowsable(EditorBrowsableState.Never)]
183 /// Enumeration for transition effect's type.
185 [EditorBrowsable(EditorBrowsableState.Never)]
186 public enum EffectTypes
191 [EditorBrowsable(EditorBrowsableState.Never)]
194 /// Window show effect.
196 [EditorBrowsable(EditorBrowsableState.Never)]
199 /// Window hide effect.
201 [EditorBrowsable(EditorBrowsableState.Never)]
206 /// Enumeration for opacity of the indicator.
208 internal enum IndicatorBackgroundOpacity
216 /// Enumeration for visible mode of the indicator.
218 internal enum IndicatorVisibleMode
226 /// The stage instance property (read-only).<br />
227 /// Gets the current window.<br />
229 /// <since_tizen> 3 </since_tizen>
230 public static Window Instance
239 /// Gets or sets a window type.
241 /// <since_tizen> 3 </since_tizen>
242 public WindowType Type
246 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 Interop.Window.SetType(swigCPtr, (int)value);
253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 /// Gets/Sets a window title.
260 /// <since_tizen> 4 </since_tizen>
269 _windowTitle = value;
270 SetClass(_windowTitle, "");
275 /// The rendering behavior of a Window.
277 /// <since_tizen> 5 </since_tizen>
278 public RenderingBehaviorType RenderingBehavior
282 return GetRenderingBehavior();
286 SetRenderingBehavior(value);
291 /// The window size property (read-only).
293 /// <since_tizen> 3 </since_tizen>
298 Size2D ret = GetSize();
304 /// The background color property.
306 /// <since_tizen> 3 </since_tizen>
307 public Color BackgroundColor
311 SetBackgroundColor(value);
315 Color ret = GetBackgroundColor();
321 /// The DPI property (read-only).<br />
322 /// Retrieves the DPI of the display device to which the Window is connected.<br />
324 /// <since_tizen> 3 </since_tizen>
334 /// The layer count property (read-only).<br />
335 /// Queries the number of on-Window layers.<br />
337 /// <since_tizen> 3 </since_tizen>
338 public uint LayerCount
342 return GetLayerCount();
347 /// Gets or sets a size of the window.
349 /// <since_tizen> 4 </since_tizen>
350 public Size2D WindowSize
354 return GetWindowSize();
358 SetWindowSize(value);
363 /// Gets or sets a position of the window.
365 /// <since_tizen> 4 </since_tizen>
366 public Position2D WindowPosition
370 return GetPosition();
379 /// Sets position and size of the window. This API guarantees that
380 /// both moving and resizing of window will appear on the screen at once.
382 [EditorBrowsable(EditorBrowsableState.Never)]
383 public Rectangle WindowPositionSize
387 Position2D position = GetPosition();
388 Size2D size = GetSize();
389 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
394 SetPositionSize(value);
398 internal static Vector4 DEFAULT_BACKGROUND_COLOR
402 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
403 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409 internal static Vector4 DEBUG_BACKGROUND_COLOR
413 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
414 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420 internal List<Layer> LayersChildren
429 /// Get the LayoutController for this Window.
431 internal LayoutController LayoutController
435 return localController;
440 /// Feed a key-event into the window.
442 /// <param name="keyEvent">The key event to feed.</param>
443 /// <since_tizen> 4 </since_tizen>
444 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
445 public static void FeedKeyEvent(Key keyEvent)
447 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 /// Sets whether the window accepts a focus or not.
454 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
455 /// <since_tizen> 3 </since_tizen>
456 public void SetAcceptFocus(bool accept)
458 Interop.Window.SetAcceptFocus(swigCPtr, accept);
459 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 /// Returns whether the window accepts a focus or not.
465 /// <returns>True if the window accepts a focus, false otherwise.</returns>
466 /// <since_tizen> 3 </since_tizen>
467 public bool IsFocusAcceptable()
469 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 /// Shows the window if it is hidden.
478 /// <since_tizen> 3 </since_tizen>
481 Interop.Window.Show(swigCPtr);
482 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
486 /// Hides the window if it is showing.
488 /// <since_tizen> 3 </since_tizen>
491 Interop.Window.Hide(swigCPtr);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 /// Retrieves whether the window is visible or not.
498 /// <returns>True if the window is visible.</returns>
499 /// <since_tizen> 3 </since_tizen>
500 public bool IsVisible()
502 bool temp = Interop.Window.IsVisible(swigCPtr);
503 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 /// Gets the count of supported auxiliary hints of the window.
510 /// <returns>The number of supported auxiliary hints.</returns>
511 /// <since_tizen> 3 </since_tizen>
512 public uint GetSupportedAuxiliaryHintCount()
514 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
515 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 /// Gets the supported auxiliary hint string of the window.
522 /// <param name="index">The index of the supported auxiliary hint lists.</param>
523 /// <returns>The auxiliary hint string of the index.</returns>
524 /// <since_tizen> 3 </since_tizen>
525 public string GetSupportedAuxiliaryHint(uint index)
527 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 /// Creates an auxiliary hint of the window.
535 /// <param name="hint">The auxiliary hint string.</param>
536 /// <param name="value">The value string.</param>
537 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
538 /// <since_tizen> 3 </since_tizen>
539 public uint AddAuxiliaryHint(string hint, string value)
541 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
547 /// Removes an auxiliary hint of the window.
549 /// <param name="id">The ID of the auxiliary hint.</param>
550 /// <returns>True if no error occurred, false otherwise.</returns>
551 /// <since_tizen> 3 </since_tizen>
552 public bool RemoveAuxiliaryHint(uint id)
554 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 /// Changes a value of the auxiliary hint.
562 /// <param name="id">The auxiliary hint ID.</param>
563 /// <param name="value">The value string to be set.</param>
564 /// <returns>True if no error occurred, false otherwise.</returns>
565 /// <since_tizen> 3 </since_tizen>
566 public bool SetAuxiliaryHintValue(uint id, string value)
568 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
569 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 /// Gets a value of the auxiliary hint.
576 /// <param name="id">The auxiliary hint ID.</param>
577 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
578 /// <since_tizen> 3 </since_tizen>
579 public string GetAuxiliaryHintValue(uint id)
581 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
582 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 /// Gets an ID of the auxiliary hint string.
589 /// <param name="hint">The auxiliary hint string.</param>
590 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
591 /// <since_tizen> 3 </since_tizen>
592 public uint GetAuxiliaryHintId(string hint)
594 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
595 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600 /// Sets a region to accept input events.
602 /// <param name="inputRegion">The region to accept input events.</param>
603 /// <since_tizen> 3 </since_tizen>
604 public void SetInputRegion(Rectangle inputRegion)
606 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
607 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611 /// Sets a priority level for the specified notification window.
613 /// <param name="level">The notification window level.</param>
614 /// <returns>True if no error occurred, false otherwise.</returns>
615 /// <since_tizen> 3 </since_tizen>
616 public bool SetNotificationLevel(NotificationLevel level)
618 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
619 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624 /// Gets a priority level for the specified notification window.
626 /// <returns>The notification window level.</returns>
627 /// <since_tizen> 3 </since_tizen>
628 public NotificationLevel GetNotificationLevel()
630 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
631 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 /// Sets a transparent window's visual state to opaque. <br />
637 /// If a visual state of a transparent window is opaque, <br />
638 /// then the window manager could handle it as an opaque window when calculating visibility.
640 /// <param name="opaque">Whether the window's visual state is opaque.</param>
641 /// <remarks>This will have no effect on an opaque window. <br />
642 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
644 /// <since_tizen> 3 </since_tizen>
645 public void SetOpaqueState(bool opaque)
647 Interop.Window.SetOpaqueState(swigCPtr, opaque);
648 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652 /// Returns whether a transparent window's visual state is opaque or not.
654 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
655 /// <remarks> The return value has no meaning on an opaque window. </remarks>
656 /// <since_tizen> 3 </since_tizen>
657 public bool IsOpaqueState()
659 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
660 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 /// Sets a window's screen off mode.
667 /// <param name="screenOffMode">The screen mode.</param>
668 /// <returns>True if no error occurred, false otherwise.</returns>
669 /// <since_tizen> 4 </since_tizen>
670 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
672 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
673 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 /// Gets the screen mode of the window.
680 /// <returns>The screen off mode.</returns>
681 /// <since_tizen> 4 </since_tizen>
682 public ScreenOffMode GetScreenOffMode()
684 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
685 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 /// Sets preferred brightness of the window.
692 /// <param name="brightness">The preferred brightness (0 to 100).</param>
693 /// <returns>True if no error occurred, false otherwise.</returns>
694 /// <since_tizen> 3 </since_tizen>
695 public bool SetBrightness(int brightness)
697 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
703 /// Gets the preferred brightness of the window.
705 /// <returns>The preferred brightness.</returns>
706 /// <since_tizen> 3 </since_tizen>
707 public int GetBrightness()
709 int ret = Interop.Window.GetBrightness(swigCPtr);
710 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715 /// Sets the window name and the class string.
717 /// <param name="name">The name of the window.</param>
718 /// <param name="klass">The class of the window.</param>
719 /// <since_tizen> 4 </since_tizen>
720 public void SetClass(string name, string klass)
722 Interop.Window.Window_SetClass(swigCPtr, name, klass);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 /// Raises the window to the top of the window stack.
729 /// <since_tizen> 3 </since_tizen>
732 Interop.Window.Window_Raise(swigCPtr);
733 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737 /// Lowers the window to the bottom of the window stack.
739 /// <since_tizen> 3 </since_tizen>
742 Interop.Window.Window_Lower(swigCPtr);
743 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
747 /// Activates the window to the top of the window stack even it is iconified.
749 /// <since_tizen> 3 </since_tizen>
750 public void Activate()
752 Interop.Window.Window_Activate(swigCPtr);
753 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757 /// Gets the default ( root ) layer.
759 /// <returns>The root layer.</returns>
760 /// <since_tizen> 3 </since_tizen>
761 public Layer GetDefaultLayer()
763 return this.GetRootLayer();
767 /// Add a child view to window.
769 /// <param name="view">the child should be added to the window.</param>
770 /// <since_tizen> 3 </since_tizen>
771 public void Add(View view)
773 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
774 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
775 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
776 view.InternalParent = this.GetRootLayer();
780 /// Remove a child view from window.
782 /// <param name="view">the child to be removed.</param>
783 /// <since_tizen> 3 </since_tizen>
784 public void Remove(View view)
786 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
787 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
788 view.InternalParent = null;
792 /// Retrieves the layer at a specified depth.
794 /// <param name="depth">The layer's depth index.</param>
795 /// <returns>The layer found at the given depth.</returns>
796 /// <since_tizen> 3 </since_tizen>
797 public Layer GetLayer(uint depth)
799 if (depth < LayersChildren?.Count)
801 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
811 /// Destroy the window immediately.
813 [EditorBrowsable(EditorBrowsableState.Never)]
814 public void Destroy()
820 /// Keep rendering for at least the given amount of time.
822 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
823 /// <since_tizen> 3 </since_tizen>
824 public void KeepRendering(float durationSeconds)
826 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
827 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
832 /// This function can be used for following example scenarios: <br />
833 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
835 /// <param name="DaliKey">The key code to grab.</param>
836 /// <returns>True if the grab succeeds.</returns>
837 /// <since_tizen> 3 </since_tizen>
838 public bool GrabKeyTopmost(int DaliKey)
840 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
841 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
846 /// Ungrabs the key specified by a key for the window.<br />
847 /// 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 />
849 /// <param name="DaliKey">The key code to ungrab.</param>
850 /// <returns>True if the ungrab succeeds.</returns>
851 /// <since_tizen> 3 </since_tizen>
852 public bool UngrabKeyTopmost(int DaliKey)
854 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
855 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
860 /// Grabs the key specified by a key for a window in a GrabMode. <br />
861 /// Details: This function can be used for following example scenarios: <br />
862 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
863 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
864 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
866 /// <param name="DaliKey">The key code to grab.</param>
867 /// <param name="GrabMode">The grab mode for the key.</param>
868 /// <returns>True if the grab succeeds.</returns>
869 /// <since_tizen> 3 </since_tizen>
870 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
872 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
873 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
878 /// Ungrabs the key specified by a key for a window.<br />
879 /// 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 />
881 /// <param name="DaliKey">The key code to ungrab.</param>
882 /// <returns>True if the ungrab succeeds.</returns>
883 /// <since_tizen> 3 </since_tizen>
884 public bool UngrabKey(int DaliKey)
886 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
887 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892 /// Sets the keyboard repeat information.
894 /// <param name="rate">The key repeat rate value in seconds.</param>
895 /// <param name="delay">The key repeat delay value in seconds.</param>
896 /// <returns>True if setting the keyboard repeat succeeds.</returns>
897 /// <since_tizen> 5 </since_tizen>
898 public bool SetKeyboardRepeatInfo(float rate, float delay)
900 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
901 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
906 /// Gets the keyboard repeat information.
908 /// <param name="rate">The key repeat rate value in seconds.</param>
909 /// <param name="delay">The key repeat delay value in seconds.</param>
910 /// <returns>True if setting the keyboard repeat succeeds.</returns>
911 /// <since_tizen> 5 </since_tizen>
912 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
914 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
915 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
920 /// Adds a layer to the stage.
922 /// <param name="layer">Layer to add.</param>
923 /// <since_tizen> 3 </since_tizen>
924 public void AddLayer(Layer layer)
930 /// Removes a layer from the stage.
932 /// <param name="layer">Layer to remove.</param>
933 /// <since_tizen> 3 </since_tizen>
934 public void RemoveLayer(Layer layer)
940 /// Feeds a key event into the window.
942 /// <param name="keyEvent">The key event to feed.</param>
943 /// <since_tizen> 5 </since_tizen>
944 public void FeedKey(Key keyEvent)
946 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
947 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951 /// Allows at least one more render, even when paused.
952 /// The window should be shown, not minimised.
954 /// <since_tizen> 4 </since_tizen>
955 public void RenderOnce()
957 Interop.Window.Window_RenderOnce(swigCPtr);
958 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
962 /// Sets whether the window is transparent or not.
964 /// <param name="transparent">Whether the window is transparent or not.</param>
965 /// <since_tizen> 5 </since_tizen>
966 public void SetTransparency(bool transparent)
968 Interop.Window.SetTransparency(swigCPtr, transparent);
969 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
975 /// Sets parent window of the window.
976 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
977 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
978 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
980 /// <param name="parent">The parent window.</param>
981 /// <since_tizen> 6 </since_tizen>
982 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
983 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
984 public void SetParent(Window parent)
986 if (IsSupportedMultiWindow() == false)
988 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
990 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
991 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
995 /// Unsets parent window of the window.
996 /// After unsetting, the window is disconnected his parent window.
998 /// <since_tizen> 6 </since_tizen>
999 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1000 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1001 public void Unparent()
1003 if (IsSupportedMultiWindow() == false)
1005 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1007 Interop.Window.Unparent(swigCPtr);
1008 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1012 /// Gets parent window of the window.
1014 /// <returns>The parent window of the window.</returns>
1015 /// <since_tizen> 6 </since_tizen>
1016 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1017 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1018 public Window GetParent()
1020 if (IsSupportedMultiWindow() == false)
1022 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1024 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
1025 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1029 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1030 [EditorBrowsable(EditorBrowsableState.Never)]
1031 public void ObjectDump()
1033 Layer rootLayer = GetRootLayer();
1034 foreach (View view in rootLayer.Children)
1040 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1042 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1045 internal static bool IsInstalled()
1047 bool ret = Interop.Stage.Stage_IsInstalled();
1048 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1052 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1054 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1055 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1058 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1060 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1061 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1064 internal void RotateIndicator(Window.WindowOrientation orientation)
1066 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1067 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1071 /// Adds an orientation to the list of available orientations.
1073 /// <param name="orientation">The available orientation to add</param>
1074 /// <since_tizen> 6 </since_tizen>
1075 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1077 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1078 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1082 /// Removes an orientation from the list of available orientations.
1084 /// <param name="orientation">The available orientation to remove.</param>
1085 /// <since_tizen> 6 </since_tizen>
1086 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1088 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1089 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1093 /// Sets a preferred orientation.
1095 /// <param name="orientation">The preferred orientation.</param>
1096 /// <since_tizen> 6 </since_tizen>
1097 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1099 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1104 /// Gets the preferred orientation.
1106 /// <since_tizen> 6 </since_tizen>
1107 /// <returns>The preferred orientation if previously set, or none.</returns>
1108 public Window.WindowOrientation GetPreferredOrientation()
1110 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1116 /// Gets current orientation of the window.
1118 /// <since_tizen> 6 </since_tizen>
1119 /// <returns>The current window orientation if previously set, or none.</returns>
1120 [EditorBrowsable(EditorBrowsableState.Never)]
1121 public Window.WindowOrientation GetCurrentOrientation()
1123 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetCurrentOrientation(swigCPtr);
1124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1129 /// Sets available orientations of the window.
1130 /// This API is for setting several orientations one time.
1132 /// <param name="orientations">The list of orientations.</param>
1133 /// <since_tizen> 6 </since_tizen>
1134 [EditorBrowsable(EditorBrowsableState.Never)]
1135 public void SetAvailableOrientations( List<Window.WindowOrientation> orientations )
1137 PropertyArray orientationArray = new PropertyArray();
1138 for( int i = 0; i < orientations.Count; i++ )
1140 orientationArray.PushBack(new PropertyValue((int)orientations[i]));
1143 Interop.Window.Window_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray));
1144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1148 /// Get native window ID
1150 /// <returns>native window ID</returns>
1151 [EditorBrowsable(EditorBrowsableState.Never)]
1152 public int GetNativeId()
1154 int ret = Interop.Window.GetNativeId(swigCPtr);
1155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1159 internal Any GetNativeHandle()
1161 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1162 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1166 internal void Add(Layer layer)
1168 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1171 LayersChildren?.Add(layer);
1172 layer.SetWindow(this);
1175 internal void Remove(Layer layer)
1177 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1178 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180 LayersChildren?.Remove(layer);
1181 layer.SetWindow(null);
1184 internal Vector2 GetSize()
1186 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1187 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1192 internal RenderTaskList GetRenderTaskList()
1194 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1200 /// Queries the number of on-window layers.
1202 /// <returns>The number of layers.</returns>
1203 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1204 internal uint GetLayerCount()
1206 if (LayersChildren == null || LayersChildren.Count < 0)
1209 return (uint) LayersChildren.Count;
1212 internal Layer GetRootLayer()
1214 // Window.IsInstalled() is actually true only when called from event thread and
1215 // Core has been initialized, not when Stage is ready.
1216 if (_rootLayer == null && Window.IsInstalled())
1218 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 LayersChildren?.Add(_rootLayer);
1221 _rootLayer.SetWindow(this);
1226 internal void SetBackgroundColor(Vector4 color)
1228 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232 internal Vector4 GetBackgroundColor()
1234 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1239 internal Vector2 GetDpi()
1241 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1246 internal ObjectRegistry GetObjectRegistry()
1248 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1253 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1255 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1259 internal RenderingBehaviorType GetRenderingBehavior()
1261 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1262 if (NDalicPINVOKE.SWIGPendingException.Pending)
1263 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267 internal void SetWindowSize(Size2D size)
1269 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1270 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1274 // Resetting Window size should request a relayout of the tree.
1277 internal Size2D GetWindowSize()
1279 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1280 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1286 internal void SetPosition(Position2D position)
1288 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1289 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1292 // Setting Position of the window should request a relayout of the tree.
1295 internal Position2D GetPosition()
1297 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1298 Position2D ret = new Position2D(val.GetX(), val.GetY());
1300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1304 internal void SetPositionSize(Rectangle positionSize)
1306 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1310 // Setting Position of the window should request a relayout of the tree.
1314 /// Dispose for Window
1316 [EditorBrowsable(EditorBrowsableState.Never)]
1317 protected override void Dispose(DisposeTypes type)
1324 if (type == DisposeTypes.Explicit)
1327 //Release your own managed resources here.
1328 //You should release all of your own disposable objects here.
1330 _rootLayer.Dispose();
1331 localController.Dispose();
1333 foreach(var layer in _childLayers)
1337 _childLayers.Clear();
1340 this.DisconnectNativeSignals();
1345 /// This will not be public opened.
1346 [EditorBrowsable(EditorBrowsableState.Never)]
1347 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1349 Interop.Window.delete_Window(swigCPtr);