4 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.BaseComponents;
22 using System.ComponentModel;
23 using System.Collections.Generic;
28 /// The window class is used internally for drawing.<br />
29 /// The window has an orientation and indicator properties.<br />
31 /// <since_tizen> 3 </since_tizen>
32 public class Window : BaseHandle
34 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
36 private Layer _rootLayer;
37 private string _windowTitle;
38 private List<Layer> _childLayers = new List<Layer>();
39 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
40 private RootLayerTouchDataCallbackType _rootLayerTouchDataCallback;
41 private WheelEventCallbackType _wheelEventCallback;
42 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
43 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
44 private EventHandler _stageContextLostEventHandler;
45 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
46 private EventHandler _stageContextRegainedEventHandler;
47 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
48 private EventHandler _stageSceneCreatedEventHandler;
49 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
50 private WindowResizedEventCallbackType _windowResizedEventCallback;
51 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
53 private static readonly Window instance = Application.Instance?.GetWindow();
55 private LayoutController localController;
57 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
59 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
60 if (Interop.Stage.Stage_IsInstalled())
62 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
64 localController = new LayoutController(this);
65 NUILog.Debug("layoutController id:" + localController.GetId() );
70 /// Creates a new Window.<br />
71 /// This creates an extra window in addition to the default main window<br />
73 /// <param name="windowPosition">The position and size of the Window.</param>
74 /// <param name="isTranslucent">Whether Window is translucent.</param>
75 /// <returns>A new Window.</returns>
76 /// <since_tizen> 6 </since_tizen>
77 public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
79 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83 /// Creates a new Window.<br />
84 /// This creates an extra window in addition to the default main window<br />
86 /// <param name="name">The name for extra window. </param>
87 /// <param name="windowPosition">The position and size of the Window.</param>
88 /// <param name="isTranslucent">Whether Window is translucent.</param>
89 /// <returns>A new Window.</returns>
90 /// <since_tizen> 6 </since_tizen>
91 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
93 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
96 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
97 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
98 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
99 private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
100 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
101 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
102 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
103 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
104 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
105 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
108 /// FocusChanged event.
110 /// <since_tizen> 3 </since_tizen>
111 public event EventHandler<FocusChangedEventArgs> FocusChanged
115 if (_windowFocusChangedEventHandler == null)
117 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
118 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
121 _windowFocusChangedEventHandler += value;
125 _windowFocusChangedEventHandler -= value;
127 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
129 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
135 /// This event is emitted when the screen is touched and when the touch ends.<br />
136 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
137 /// then when the last finger is lifted.<br />
138 /// An interrupted event will also be emitted (if it occurs).<br />
140 /// <since_tizen> 3 </since_tizen>
141 public event EventHandler<TouchEventArgs> TouchEvent
145 if (_rootLayerTouchDataEventHandler == null)
147 _rootLayerTouchDataCallback = OnWindowTouch;
148 this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
150 _rootLayerTouchDataEventHandler += value;
154 _rootLayerTouchDataEventHandler -= value;
155 if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false)
157 this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
163 /// This event is emitted when the wheel event is received.
165 /// <since_tizen> 3 </since_tizen>
166 public event EventHandler<WheelEventArgs> WheelEvent
170 if (_stageWheelHandler == null)
172 _wheelEventCallback = OnStageWheel;
173 this.StageWheelEventSignal().Connect(_wheelEventCallback);
175 _stageWheelHandler += value;
179 _stageWheelHandler -= value;
180 if (_stageWheelHandler == null && StageWheelEventSignal().Empty() == false)
182 this.StageWheelEventSignal().Disconnect(_wheelEventCallback);
188 /// This event is emitted when the key event is received.
190 /// <since_tizen> 3 </since_tizen>
191 public event EventHandler<KeyEventArgs> KeyEvent
195 if (_stageKeyHandler == null)
197 _stageKeyCallbackDelegate = OnStageKey;
198 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
200 _stageKeyHandler += value;
204 _stageKeyHandler -= value;
205 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
207 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
213 /// This event is emitted when the window resized.
215 /// <since_tizen> 3 </since_tizen>
216 public event EventHandler<ResizedEventArgs> Resized
220 if (_windowResizedEventHandler == null)
222 _windowResizedEventCallback = OnResized;
223 ResizedSignal().Connect(_windowResizedEventCallback);
226 _windowResizedEventHandler += value;
230 _windowResizedEventHandler -= value;
232 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
234 ResizedSignal().Disconnect(_windowResizedEventCallback);
240 /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
242 /// <since_tizen> 3 </since_tizen>
243 /// Please do not use! this will be deprecated!
244 /// Instead please use FocusChanged.
245 [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
247 "Window.Instance.FocusChanged = OnFocusChanged; " +
248 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
249 [EditorBrowsable(EditorBrowsableState.Never)]
250 public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
254 if (_windowFocusChangedEventHandler2 == null)
256 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
257 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
260 _windowFocusChangedEventHandler2 += value;
264 _windowFocusChangedEventHandler2 -= value;
266 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
268 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
274 /// ViewAdded will be triggered when the view added on Window
276 /// <since_tizen> 6 </since_tizen>
277 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
278 [EditorBrowsable(EditorBrowsableState.Never)]
279 public event EventHandler ViewAdded;
281 internal void SendViewAdded(View view)
283 ViewAdded?.Invoke(view, EventArgs.Empty);
286 internal event EventHandler EventProcessingFinished
290 if (_stageEventProcessingFinishedEventHandler == null)
292 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
293 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
295 _stageEventProcessingFinishedEventHandler += value;
300 _stageEventProcessingFinishedEventHandler -= value;
301 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
303 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
308 internal event EventHandler ContextLost
312 if (_stageContextLostEventHandler == null)
314 _stageContextLostEventCallbackDelegate = OnContextLost;
315 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
317 _stageContextLostEventHandler += value;
321 _stageContextLostEventHandler -= value;
322 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
324 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
329 internal event EventHandler ContextRegained
333 if (_stageContextRegainedEventHandler == null)
335 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
336 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
338 _stageContextRegainedEventHandler += value;
342 _stageContextRegainedEventHandler -= value;
343 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
345 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
350 internal event EventHandler SceneCreated
354 if (_stageSceneCreatedEventHandler == null)
356 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
357 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
359 _stageSceneCreatedEventHandler += value;
363 _stageSceneCreatedEventHandler -= value;
364 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
366 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
371 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
372 private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
373 private event EventHandler<WheelEventArgs> _stageWheelHandler;
374 private event EventHandler<KeyEventArgs> _stageKeyHandler;
375 private event EventHandler _stageEventProcessingFinishedEventHandler;
376 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
377 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler2;
380 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
382 /// <since_tizen> 3 </since_tizen>
383 public enum WindowOrientation
386 /// Portrait orientation. The height of the display area is greater than the width.
388 /// <since_tizen> 3 </since_tizen>
391 /// Landscape orientation. A wide view area is needed.
393 /// <since_tizen> 3 </since_tizen>
396 /// Portrait inverse orientation.
398 /// <since_tizen> 3 </since_tizen>
399 PortraitInverse = 180,
401 /// Landscape inverse orientation.
403 /// <since_tizen> 3 </since_tizen>
404 LandscapeInverse = 270
408 /// Enumeration for the key grab mode for platform-level APIs.
410 /// <since_tizen> 3 </since_tizen>
411 public enum KeyGrabMode
414 /// Grabs a key only when on the top of the grabbing-window stack mode.
418 /// Grabs a key together with the other client window(s) mode.
422 /// 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.
426 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
432 /// Enumeration for opacity of the indicator.
434 internal enum IndicatorBackgroundOpacity
442 /// Enumeration for visible mode of the indicator.
444 internal enum IndicatorVisibleMode
452 /// The stage instance property (read-only).<br />
453 /// Gets the current window.<br />
455 /// <since_tizen> 3 </since_tizen>
456 public static Window Instance
465 /// Gets or sets a window type.
467 /// <since_tizen> 3 </since_tizen>
468 public WindowType Type
472 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
473 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478 Interop.Window.SetType(swigCPtr, (int)value);
479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
484 /// Gets/Sets a window title.
486 /// <since_tizen> 4 </since_tizen>
495 _windowTitle = value;
496 SetClass(_windowTitle, "");
501 /// The rendering behavior of a Window.
503 /// <since_tizen> 5 </since_tizen>
504 public RenderingBehaviorType RenderingBehavior
508 return GetRenderingBehavior();
512 SetRenderingBehavior(value);
517 /// The window size property (read-only).
519 /// <since_tizen> 3 </since_tizen>
524 Size2D ret = GetSize();
530 /// The background color property.
532 /// <since_tizen> 3 </since_tizen>
533 public Color BackgroundColor
537 SetBackgroundColor(value);
541 Color ret = GetBackgroundColor();
547 /// The DPI property (read-only).<br />
548 /// Retrieves the DPI of the display device to which the Window is connected.<br />
550 /// <since_tizen> 3 </since_tizen>
560 /// The layer count property (read-only).<br />
561 /// Queries the number of on-Window layers.<br />
563 /// <since_tizen> 3 </since_tizen>
564 public uint LayerCount
568 return GetLayerCount();
573 /// Gets or sets a size of the window.
575 /// <since_tizen> 4 </since_tizen>
576 public Size2D WindowSize
580 return GetWindowSize();
584 SetWindowSize(value);
589 /// Gets or sets a position of the window.
591 /// <since_tizen> 4 </since_tizen>
592 public Position2D WindowPosition
596 return GetPosition();
603 internal static Vector4 DEFAULT_BACKGROUND_COLOR
607 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
608 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
609 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 internal static Vector4 DEBUG_BACKGROUND_COLOR
618 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
619 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
620 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
625 internal List<Layer> LayersChildren
633 internal LayoutController LayoutController
637 return localController;
642 /// Feed a key-event into the window.
644 /// <param name="keyEvent">The key event to feed.</param>
645 /// <since_tizen> 4 </since_tizen>
646 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
647 public static void FeedKeyEvent(Key keyEvent)
649 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
650 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 /// Sets whether the window accepts a focus or not.
656 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
657 /// <since_tizen> 3 </since_tizen>
658 public void SetAcceptFocus(bool accept)
660 Interop.Window.SetAcceptFocus(swigCPtr, accept);
661 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 /// Returns whether the window accepts a focus or not.
667 /// <returns>True if the window accepts a focus, false otherwise.</returns>
668 /// <since_tizen> 3 </since_tizen>
669 public bool IsFocusAcceptable()
671 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
672 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 /// Shows the window if it is hidden.
680 /// <since_tizen> 3 </since_tizen>
683 Interop.Window.Show(swigCPtr);
684 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
688 /// Hides the window if it is showing.
690 /// <since_tizen> 3 </since_tizen>
693 Interop.Window.Hide(swigCPtr);
694 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
698 /// Retrieves whether the window is visible or not.
700 /// <returns>True if the window is visible.</returns>
701 /// <since_tizen> 3 </since_tizen>
702 public bool IsVisible()
704 bool temp = Interop.Window.IsVisible(swigCPtr);
705 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710 /// Gets the count of supported auxiliary hints of the window.
712 /// <returns>The number of supported auxiliary hints.</returns>
713 /// <since_tizen> 3 </since_tizen>
714 public uint GetSupportedAuxiliaryHintCount()
716 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
717 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722 /// Gets the supported auxiliary hint string of the window.
724 /// <param name="index">The index of the supported auxiliary hint lists.</param>
725 /// <returns>The auxiliary hint string of the index.</returns>
726 /// <since_tizen> 3 </since_tizen>
727 public string GetSupportedAuxiliaryHint(uint index)
729 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
730 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735 /// Creates an auxiliary hint of the window.
737 /// <param name="hint">The auxiliary hint string.</param>
738 /// <param name="value">The value string.</param>
739 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
740 /// <since_tizen> 3 </since_tizen>
741 public uint AddAuxiliaryHint(string hint, string value)
743 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
744 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 /// Removes an auxiliary hint of the window.
751 /// <param name="id">The ID of the auxiliary hint.</param>
752 /// <returns>True if no error occurred, false otherwise.</returns>
753 /// <since_tizen> 3 </since_tizen>
754 public bool RemoveAuxiliaryHint(uint id)
756 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
757 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
762 /// Changes a value of the auxiliary hint.
764 /// <param name="id">The auxiliary hint ID.</param>
765 /// <param name="value">The value string to be set.</param>
766 /// <returns>True if no error occurred, false otherwise.</returns>
767 /// <since_tizen> 3 </since_tizen>
768 public bool SetAuxiliaryHintValue(uint id, string value)
770 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
771 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
776 /// Gets a value of the auxiliary hint.
778 /// <param name="id">The auxiliary hint ID.</param>
779 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
780 /// <since_tizen> 3 </since_tizen>
781 public string GetAuxiliaryHintValue(uint id)
783 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
784 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
789 /// Gets an ID of the auxiliary hint string.
791 /// <param name="hint">The auxiliary hint string.</param>
792 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
793 /// <since_tizen> 3 </since_tizen>
794 public uint GetAuxiliaryHintId(string hint)
796 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
797 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802 /// Sets a region to accept input events.
804 /// <param name="inputRegion">The region to accept input events.</param>
805 /// <since_tizen> 3 </since_tizen>
806 public void SetInputRegion(Rectangle inputRegion)
808 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
809 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
813 /// Sets a priority level for the specified notification window.
815 /// <param name="level">The notification window level.</param>
816 /// <returns>True if no error occurred, false otherwise.</returns>
817 /// <since_tizen> 3 </since_tizen>
818 public bool SetNotificationLevel(NotificationLevel level)
820 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
821 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826 /// Gets a priority level for the specified notification window.
828 /// <returns>The notification window level.</returns>
829 /// <since_tizen> 3 </since_tizen>
830 public NotificationLevel GetNotificationLevel()
832 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
833 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
838 /// Sets a transparent window's visual state to opaque. <br />
839 /// If a visual state of a transparent window is opaque, <br />
840 /// then the window manager could handle it as an opaque window when calculating visibility.
842 /// <param name="opaque">Whether the window's visual state is opaque.</param>
843 /// <remarks>This will have no effect on an opaque window. <br />
844 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
846 /// <since_tizen> 3 </since_tizen>
847 public void SetOpaqueState(bool opaque)
849 Interop.Window.SetOpaqueState(swigCPtr, opaque);
850 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
854 /// Returns whether a transparent window's visual state is opaque or not.
856 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
857 /// <remarks> The return value has no meaning on an opaque window. </remarks>
858 /// <since_tizen> 3 </since_tizen>
859 public bool IsOpaqueState()
861 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
862 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
867 /// Sets a window's screen off mode.
869 /// <param name="screenOffMode">The screen mode.</param>
870 /// <returns>True if no error occurred, false otherwise.</returns>
871 /// <since_tizen> 4 </since_tizen>
872 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
874 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
875 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
880 /// Gets the screen mode of the window.
882 /// <returns>The screen off mode.</returns>
883 /// <since_tizen> 4 </since_tizen>
884 public ScreenOffMode GetScreenOffMode()
886 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
887 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
892 /// Sets preferred brightness of the window.
894 /// <param name="brightness">The preferred brightness (0 to 100).</param>
895 /// <returns>True if no error occurred, false otherwise.</returns>
896 /// <since_tizen> 3 </since_tizen>
897 public bool SetBrightness(int brightness)
899 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
900 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
905 /// Gets the preferred brightness of the window.
907 /// <returns>The preferred brightness.</returns>
908 /// <since_tizen> 3 </since_tizen>
909 public int GetBrightness()
911 int ret = Interop.Window.GetBrightness(swigCPtr);
912 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
917 /// Sets the window name and the class string.
919 /// <param name="name">The name of the window.</param>
920 /// <param name="klass">The class of the window.</param>
921 /// <since_tizen> 4 </since_tizen>
922 public void SetClass(string name, string klass)
924 Interop.Window.Window_SetClass(swigCPtr, name, klass);
925 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
929 /// Raises the window to the top of the window stack.
931 /// <since_tizen> 3 </since_tizen>
934 Interop.Window.Window_Raise(swigCPtr);
935 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
939 /// Lowers the window to the bottom of the window stack.
941 /// <since_tizen> 3 </since_tizen>
944 Interop.Window.Window_Lower(swigCPtr);
945 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
949 /// Activates the window to the top of the window stack even it is iconified.
951 /// <since_tizen> 3 </since_tizen>
952 public void Activate()
954 Interop.Window.Window_Activate(swigCPtr);
955 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
959 /// Gets the default ( root ) layer.
961 /// <returns>The root layer.</returns>
962 /// <since_tizen> 3 </since_tizen>
963 public Layer GetDefaultLayer()
965 return this.GetRootLayer();
969 /// Add a child view to window.
971 /// <param name="view">the child should be added to the window.</param>
972 /// <since_tizen> 3 </since_tizen>
973 public void Add(View view)
975 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
976 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
977 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
978 view.InternalParent = this.GetRootLayer();
982 /// Remove a child view from window.
984 /// <param name="view">the child to be removed.</param>
985 /// <since_tizen> 3 </since_tizen>
986 public void Remove(View view)
988 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
989 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
990 view.InternalParent = null;
994 /// Retrieves the layer at a specified depth.
996 /// <param name="depth">The layer's depth index.</param>
997 /// <returns>The layer found at the given depth.</returns>
998 /// <since_tizen> 3 </since_tizen>
999 public Layer GetLayer(uint depth)
1001 if (depth < LayersChildren?.Count)
1003 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
1013 /// Destroy the window immediately.
1015 [EditorBrowsable(EditorBrowsableState.Never)]
1016 public void Destroy()
1022 /// Keep rendering for at least the given amount of time.
1024 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1025 /// <since_tizen> 3 </since_tizen>
1026 public void KeepRendering(float durationSeconds)
1028 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
1029 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1034 /// This function can be used for following example scenarios: <br />
1035 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1037 /// <param name="DaliKey">The key code to grab.</param>
1038 /// <returns>True if the grab succeeds.</returns>
1039 /// <since_tizen> 3 </since_tizen>
1040 public bool GrabKeyTopmost(int DaliKey)
1042 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
1043 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1048 /// Ungrabs the key specified by a key for the window.<br />
1049 /// 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 />
1051 /// <param name="DaliKey">The key code to ungrab.</param>
1052 /// <returns>True if the ungrab succeeds.</returns>
1053 /// <since_tizen> 3 </since_tizen>
1054 public bool UngrabKeyTopmost(int DaliKey)
1056 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
1057 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1062 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1063 /// Details: This function can be used for following example scenarios: <br />
1064 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1065 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1066 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1068 /// <param name="DaliKey">The key code to grab.</param>
1069 /// <param name="GrabMode">The grab mode for the key.</param>
1070 /// <returns>True if the grab succeeds.</returns>
1071 /// <since_tizen> 3 </since_tizen>
1072 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1074 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
1075 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1080 /// Ungrabs the key specified by a key for a window.<br />
1081 /// 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 />
1083 /// <param name="DaliKey">The key code to ungrab.</param>
1084 /// <returns>True if the ungrab succeeds.</returns>
1085 /// <since_tizen> 3 </since_tizen>
1086 public bool UngrabKey(int DaliKey)
1088 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
1089 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1094 /// Sets the keyboard repeat information.
1096 /// <param name="rate">The key repeat rate value in seconds.</param>
1097 /// <param name="delay">The key repeat delay value in seconds.</param>
1098 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1099 /// <since_tizen> 5 </since_tizen>
1100 public bool SetKeyboardRepeatInfo(float rate, float delay)
1102 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1108 /// Gets the keyboard repeat information.
1110 /// <param name="rate">The key repeat rate value in seconds.</param>
1111 /// <param name="delay">The key repeat delay value in seconds.</param>
1112 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1113 /// <since_tizen> 5 </since_tizen>
1114 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1116 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1122 /// Adds a layer to the stage.
1124 /// <param name="layer">Layer to add.</param>
1125 /// <since_tizen> 3 </since_tizen>
1126 public void AddLayer(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);
1136 /// Removes a layer from the stage.
1138 /// <param name="layer">Layer to remove.</param>
1139 /// <since_tizen> 3 </since_tizen>
1140 public void RemoveLayer(Layer layer)
1142 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1145 LayersChildren?.Remove(layer);
1146 layer.SetWindow(null);
1150 /// Feeds a key event into the window.
1152 /// <param name="keyEvent">The key event to feed.</param>
1153 /// <since_tizen> 5 </since_tizen>
1154 public void FeedKey(Key keyEvent)
1156 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1161 /// Allows at least one more render, even when paused.
1162 /// The window should be shown, not minimised.
1164 /// <since_tizen> 4 </since_tizen>
1165 public void RenderOnce()
1167 Interop.Window.Window_RenderOnce(swigCPtr);
1168 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1171 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1173 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1176 internal static Window GetCurrent()
1178 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
1179 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1183 internal static bool IsInstalled()
1185 bool ret = Interop.Stage.Stage_IsInstalled();
1186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1190 internal WindowFocusSignalType WindowFocusChangedSignal()
1192 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
1193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1199 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1203 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1205 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1209 internal void RotateIndicator(Window.WindowOrientation orientation)
1211 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1216 /// Adds an orientation to the list of available orientations.
1218 /// <param name="orientation">The available orientation to add</param>
1219 /// <since_tizen> 6 </since_tizen>
1220 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1222 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1227 /// Removes an orientation from the list of available orientations.
1229 /// <param name="orientation">The available orientation to remove.</param>
1230 /// <since_tizen> 6 </since_tizen>
1231 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1233 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238 /// Sets a preferred orientation.
1240 /// <param name="orientation">The preferred orientation.</param>
1241 /// <since_tizen> 6 </since_tizen>
1242 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1244 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1249 /// Gets the preferred orientation.
1251 /// <since_tizen> 6 </since_tizen>
1252 /// <returns>The preferred orientation if previously set, or none.</returns>
1253 public Window.WindowOrientation GetPreferredOrientation()
1255 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260 internal Any GetNativeHandle()
1262 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267 internal WindowFocusSignalType FocusChangedSignal()
1269 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
1270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1274 internal void Add(Layer layer)
1276 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1279 LayersChildren?.Add(layer);
1280 layer.SetWindow(this);
1283 internal void Remove(Layer layer)
1285 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1288 LayersChildren?.Remove(layer);
1289 layer.SetWindow(null);
1292 internal Vector2 GetSize()
1294 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1295 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1300 internal RenderTaskList GetRenderTaskList()
1302 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1308 /// Queries the number of on-window layers.
1310 /// <returns>The number of layers.</returns>
1311 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1312 internal uint GetLayerCount()
1314 if (LayersChildren == null || LayersChildren.Count < 0)
1317 return (uint) LayersChildren.Count;
1320 internal Layer GetRootLayer()
1322 // Window.IsInstalled() is actually true only when called from event thread and
1323 // Core has been initialized, not when Stage is ready.
1324 if (_rootLayer == null && Window.IsInstalled())
1326 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1328 LayersChildren?.Add(_rootLayer);
1329 _rootLayer.SetWindow(this);
1334 internal void SetBackgroundColor(Vector4 color)
1336 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1340 internal Vector4 GetBackgroundColor()
1342 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1347 internal Vector2 GetDpi()
1349 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1354 internal ObjectRegistry GetObjectRegistry()
1356 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1361 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1363 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1367 internal RenderingBehaviorType GetRenderingBehavior()
1369 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1370 if (NDalicPINVOKE.SWIGPendingException.Pending)
1371 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1375 internal KeyEventSignal KeyEventSignal()
1377 KeyEventSignal ret = new KeyEventSignal(Interop.Window.KeyEventSignal(swigCPtr), false);
1378 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1382 internal VoidSignal EventProcessingFinishedSignal()
1384 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_EventProcessingFinishedSignal(stageCPtr), false);
1385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1389 internal TouchSignal TouchSignal()
1391 TouchSignal ret = new TouchSignal(Interop.Window.TouchSignal(swigCPtr), false);
1392 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1396 internal TouchDataSignal TouchDataSignal()
1398 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
1399 if (NDalicPINVOKE.SWIGPendingException.Pending)
1400 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1404 internal VoidSignal ContextLostSignal()
1406 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextLostSignal(stageCPtr), false);
1407 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1411 internal VoidSignal ContextRegainedSignal()
1413 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextRegainedSignal(stageCPtr), false);
1414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1418 internal VoidSignal SceneCreatedSignal()
1420 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_SceneCreatedSignal(stageCPtr), false);
1421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1425 internal ResizedSignal ResizedSignal()
1427 ResizedSignal ret = new ResizedSignal(Interop.Window.Window_ResizedSignal(swigCPtr), false);
1428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1432 internal void SetWindowSize(Size2D size)
1434 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1435 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1439 // Resetting Window size should request a relayout of the tree.
1442 internal Size2D GetWindowSize()
1444 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1445 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1451 internal void SetPosition(Position2D position)
1453 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1454 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1458 // Setting Position of the window should request a relayout of the tree.
1462 internal Position2D GetPosition()
1464 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1465 Position2D ret = new Position2D(val.GetX(), val.GetY());
1467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1471 internal void SetPositionSize(Rectangle positionSize)
1473 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1477 // Setting Position of the window should request a relayout of the tree.
1482 /// Sets whether the window is transparent or not.
1484 /// <param name="transparent">Whether the window is transparent or not.</param>
1485 /// <since_tizen> 5 </since_tizen>
1486 public void SetTransparency(bool transparent) {
1487 Interop.Window.SetTransparency(swigCPtr, transparent);
1488 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1490 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1495 /// Sets parent window of the window.
1496 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1497 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1498 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1500 /// <param name="parent">The parent window.</param>
1501 /// <since_tizen> 6 </since_tizen>
1502 public void SetParent(Window parent) {
1503 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
1504 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1508 /// Unsets parent window of the window.
1509 /// After unsetting, the window is disconnected his parent window.
1511 /// <since_tizen> 6 </since_tizen>
1512 public void Unparent() {
1513 Interop.Window.Unparent(swigCPtr);
1514 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1518 /// Gets parent window of the window.
1520 /// <returns>The parent window of the window.</returns>
1521 /// <since_tizen> 6 </since_tizen>
1522 public Window GetParent() {
1523 Window ret = new Window(Interop.Window.GetParent(swigCPtr), true);
1524 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1529 /// Dispose for Window
1531 [EditorBrowsable(EditorBrowsableState.Never)]
1532 protected override void Dispose(DisposeTypes type)
1539 if (type == DisposeTypes.Explicit)
1542 //Release your own managed resources here.
1543 //You should release all of your own disposable objects here.
1545 _rootLayer.Dispose();
1546 localController.Dispose();
1548 foreach(var layer in _childLayers)
1552 _childLayers.Clear();
1555 this.DisconnectNativeSignals();
1557 //Release your own unmanaged resources here.
1558 //You should not access any managed member here except static instance.
1559 //because the execution order of Finalizes is non-deterministic.
1561 if (swigCPtr.Handle != global::System.IntPtr.Zero)
1565 swigCMemOwn = false;
1566 Interop.Window.delete_Window(swigCPtr);
1568 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
1574 internal System.IntPtr GetNativeWindowHandler()
1576 System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
1577 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1581 private void OnWindowFocusedChanged(bool focusGained)
1583 FocusChangedEventArgs e = new FocusChangedEventArgs();
1585 e.FocusGained = focusGained;
1587 if (_windowFocusChangedEventHandler != null)
1589 _windowFocusChangedEventHandler(this, e);
1593 private StageWheelSignal WheelEventSignal()
1595 StageWheelSignal ret = new StageWheelSignal(Interop.StageSignal.Stage_WheelEventSignal(stageCPtr), false);
1596 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1600 private WheelSignal StageWheelEventSignal()
1602 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
1603 if (NDalicPINVOKE.SWIGPendingException.Pending)
1604 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1608 private bool OnWindowTouch(IntPtr view, IntPtr touchData)
1610 if (touchData == global::System.IntPtr.Zero)
1612 NUILog.Error("touchData should not be null!");
1616 TouchEventArgs e = new TouchEventArgs();
1618 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
1620 if (_rootLayerTouchDataEventHandler != null)
1622 _rootLayerTouchDataEventHandler(this, e);
1627 private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
1629 if (wheelEvent == global::System.IntPtr.Zero)
1631 NUILog.Error("wheelEvent should not be null!");
1635 WheelEventArgs e = new WheelEventArgs();
1637 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1639 if (_stageWheelHandler != null)
1641 _stageWheelHandler(this, e);
1646 // Callback for Stage KeyEventsignal
1647 private void OnStageKey(IntPtr data)
1649 KeyEventArgs e = new KeyEventArgs();
1650 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1653 if (_stageKeyHandler != null)
1655 //here we send all data to user event handlers
1656 _stageKeyHandler(this, e);
1660 // Callback for Stage EventProcessingFinishedSignal
1661 private void OnEventProcessingFinished()
1663 if (_stageEventProcessingFinishedEventHandler != null)
1665 _stageEventProcessingFinishedEventHandler(this, null);
1669 // Callback for Stage ContextLostSignal
1670 private void OnContextLost()
1672 if (_stageContextLostEventHandler != null)
1674 _stageContextLostEventHandler(this, null);
1678 // Callback for Stage ContextRegainedSignal
1679 private void OnContextRegained()
1681 if (_stageContextRegainedEventHandler != null)
1683 _stageContextRegainedEventHandler(this, null);
1687 // Callback for Stage SceneCreatedSignal
1688 private void OnSceneCreated()
1690 if (_stageSceneCreatedEventHandler != null)
1692 _stageSceneCreatedEventHandler(this, null);
1696 private void OnResized(IntPtr windowSize)
1698 ResizedEventArgs e = new ResizedEventArgs();
1699 var val = new Uint16Pair(windowSize, false);
1700 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1703 if (_windowResizedEventHandler != null)
1705 _windowResizedEventHandler(this, e);
1709 private void OnWindowFocusedChanged2(bool focusGained)
1711 FocusChangedEventArgs e = new FocusChangedEventArgs();
1713 e.FocusGained = focusGained;
1715 if (_windowFocusChangedEventHandler2 != null)
1717 _windowFocusChangedEventHandler2(this, e);
1722 /// The focus changed event argument.
1724 /// <since_tizen> 3 </since_tizen>
1725 public class FocusChangedEventArgs : EventArgs
1728 /// FocusGained flag.
1730 /// <since_tizen> 3 </since_tizen>
1731 public bool FocusGained
1739 /// The touch event argument.
1741 /// <since_tizen> 3 </since_tizen>
1742 public class TouchEventArgs : EventArgs
1744 private Touch _touch;
1749 /// <since_tizen> 3 </since_tizen>
1764 /// Wheel event arguments.
1766 /// <since_tizen> 3 </since_tizen>
1767 public class WheelEventArgs : EventArgs
1769 private Wheel _wheel;
1774 /// <since_tizen> 3 </since_tizen>
1789 /// Key event arguments.
1791 /// <since_tizen> 3 </since_tizen>
1792 public class KeyEventArgs : EventArgs
1799 /// <since_tizen> 3 </since_tizen>
1814 /// Sets position and size of the window. This API guarantees that
1815 /// both moving and resizing of window will appear on the screen at once.
1817 [EditorBrowsable(EditorBrowsableState.Never)]
1818 public Rectangle WindowPositionSize
1822 Position2D position = GetPosition();
1823 Size2D size = GetSize();
1824 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
1829 SetPositionSize(value);
1834 /// Feeds a key event into the window.
1835 /// This resized event arguments.
1837 /// <since_tizen> 3 </since_tizen>
1838 public class ResizedEventArgs : EventArgs
1843 /// This window size.
1845 /// <since_tizen> 4 </since_tizen>
1846 public Size2D WindowSize
1854 _windowSize = value;
1860 /// Please do not use! this will be deprecated
1862 /// <since_tizen> 3 </since_tizen>
1863 [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1865 "Window.Instance.FocusChanged = OnFocusChanged; " +
1866 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1867 [EditorBrowsable(EditorBrowsableState.Never)]
1868 public class WindowFocusChangedEventArgs : EventArgs
1871 /// Please do not use! this will be deprecated
1873 /// <since_tizen> 3 </since_tizen>
1874 public bool FocusGained
1882 /// Contains and encapsulates Native Window handle.
1884 /// <since_tizen> 4 </since_tizen>
1885 public class SafeNativeWindowHandle : SafeHandle
1888 /// Contructor, Native window handle is set to handle.
1890 /// <since_tizen> 4 </since_tizen>
1891 public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1893 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1896 /// Null check if the handle is valid or not.
1898 /// <since_tizen> 4 </since_tizen>
1899 public override bool IsInvalid
1903 return this.handle == IntPtr.Zero;
1907 /// Release handle itself.
1909 /// <returns>true when released successfully.</returns>
1910 /// <since_tizen> 4 </since_tizen>
1911 protected override bool ReleaseHandle()
1918 /// Disconnect all native signals
1920 /// <since_tizen> 5 </since_tizen>
1921 internal void DisconnectNativeSignals()
1923 if( _windowFocusChangedEventCallback != null )
1925 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
1928 if( _rootLayerTouchDataCallback != null )
1930 TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
1933 if( _wheelEventCallback != null )
1935 StageWheelEventSignal().Disconnect(_wheelEventCallback);
1938 if( _stageKeyCallbackDelegate != null )
1940 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1943 if( _stageEventProcessingFinishedEventCallbackDelegate != null )
1945 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1948 if( _stageContextLostEventCallbackDelegate != null )
1950 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1953 if( _stageContextRegainedEventCallbackDelegate != null )
1955 ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1958 if( _stageSceneCreatedEventCallbackDelegate != null )
1960 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1963 if( _windowResizedEventCallback != null )
1965 ResizedSignal().Disconnect(_windowResizedEventCallback);
1968 if( _windowFocusChangedEventCallback2 != null )
1970 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);