2 * Copyright(c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21 using System.Collections.Generic;
26 /// The window class is used internally for drawing.<br />
27 /// The window has an orientation and indicator properties.<br />
29 /// <since_tizen> 3 </since_tizen>
30 public class Window : BaseHandle
32 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
33 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
34 private readonly global::System.Runtime.InteropServices.HandleRef rootLayoutCPtr;
35 private Layer _rootLayer;
36 private string _windowTitle;
37 private readonly LayoutItem rootLayoutItem;
39 private List<Layer> _childLayers = new List<Layer>();
40 internal List<Layer> LayersChildren
48 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn)
50 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
51 if (NDalicPINVOKE.Stage_IsInstalled())
53 global::System.IntPtr rootLayoutIntPtr;
54 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
55 // Create a root layout (AbsoluteLayout) that is invisible to the user but enables layouts added to the Window
56 // Enables layouts added to the Window to have a parent layout. As parent layout is needed to store measure spec properties.
57 // Currently without these measure specs the new layout added will always be the size of the window.
58 rootLayoutIntPtr = NDalicManualPINVOKE.Window_NewRootLayout();
59 // Store HandleRef used by Add()
60 rootLayoutCPtr = new global::System.Runtime.InteropServices.HandleRef(this, rootLayoutIntPtr);
61 Layer rootLayer = GetRootLayer();
62 // Add the root layout created above to the root layer.
63 NDalicPINVOKE.Actor_Add( Layer.getCPtr(rootLayer), rootLayoutCPtr );
64 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66 global::System.IntPtr rootControlLayoutIntPtr = Tizen.NUI.NDalicManualPINVOKE.GetLayout__SWIG_1(rootLayoutCPtr);
67 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
69 rootLayoutItem = new LayoutItem(rootControlLayoutIntPtr, true);
73 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
75 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
78 internal static Window GetCurrent()
80 Window ret = new Window(NDalicPINVOKE.Stage_GetCurrent(), true);
81 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
85 internal static bool IsInstalled()
87 bool ret = NDalicPINVOKE.Stage_IsInstalled();
88 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 /// Sets whether the window accepts a focus or not.
95 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
96 /// <since_tizen> 3 </since_tizen>
97 public void SetAcceptFocus(bool accept)
99 NDalicPINVOKE.SetAcceptFocus(swigCPtr, accept);
100 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
104 /// Returns whether the window accepts a focus or not.
106 /// <returns>True if the window accepts a focus, false otherwise.</returns>
107 /// <since_tizen> 3 </since_tizen>
108 public bool IsFocusAcceptable()
110 bool ret = NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117 /// Shows the window if it is hidden.
119 /// <since_tizen> 3 </since_tizen>
122 NDalicPINVOKE.Show(swigCPtr);
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 /// Hides the window if it is showing.
129 /// <since_tizen> 3 </since_tizen>
132 NDalicPINVOKE.Hide(swigCPtr);
133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137 /// Retrieves whether the window is visible or not.
139 /// <returns>True if the window is visible.</returns>
140 /// <since_tizen> 3 </since_tizen>
141 public bool IsVisible()
143 bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 /// Gets the count of supported auxiliary hints of the window.
151 /// <returns>The number of supported auxiliary hints.</returns>
152 /// <since_tizen> 3 </since_tizen>
153 public uint GetSupportedAuxiliaryHintCount()
155 uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161 /// Gets the supported auxiliary hint string of the window.
163 /// <param name="index">The index of the supported auxiliary hint lists.</param>
164 /// <returns>The auxiliary hint string of the index.</returns>
165 /// <since_tizen> 3 </since_tizen>
166 public string GetSupportedAuxiliaryHint(uint index)
168 string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 /// Creates an auxiliary hint of the window.
176 /// <param name="hint">The auxiliary hint string.</param>
177 /// <param name="value">The value string.</param>
178 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
179 /// <since_tizen> 3 </since_tizen>
180 public uint AddAuxiliaryHint(string hint, string value)
182 uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
188 /// Removes an auxiliary hint of the window.
190 /// <param name="id">The ID of the auxiliary hint.</param>
191 /// <returns>True if no error occurred, false otherwise.</returns>
192 /// <since_tizen> 3 </since_tizen>
193 public bool RemoveAuxiliaryHint(uint id)
195 bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 /// Changes a value of the auxiliary hint.
203 /// <param name="id">The auxiliary hint ID.</param>
204 /// <param name="value">The value string to be set.</param>
205 /// <returns>True if no error occurred, false otherwise.</returns>
206 /// <since_tizen> 3 </since_tizen>
207 public bool SetAuxiliaryHintValue(uint id, string value)
209 bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Gets a value of the auxiliary hint.
217 /// <param name="id">The auxiliary hint ID.</param>
218 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
219 /// <since_tizen> 3 </since_tizen>
220 public string GetAuxiliaryHintValue(uint id)
222 string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
228 /// Gets an ID of the auxiliary hint string.
230 /// <param name="hint">The auxiliary hint string.</param>
231 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
232 /// <since_tizen> 3 </since_tizen>
233 public uint GetAuxiliaryHintId(string hint)
235 uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241 /// Sets a region to accept input events.
243 /// <param name="inputRegion">The region to accept input events.</param>
244 /// <since_tizen> 3 </since_tizen>
245 public void SetInputRegion(Rectangle inputRegion)
247 NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 /// Gets or sets a window type.
254 /// <since_tizen> 3 </since_tizen>
255 public WindowType Type
259 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 NDalicPINVOKE.SetType(swigCPtr, (int)value);
266 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
271 /// Sets a priority level for the specified notification window.
273 /// <param name="level">The notification window level.</param>
274 /// <returns>True if no error occurred, false otherwise.</returns>
275 /// <since_tizen> 3 </since_tizen>
276 public bool SetNotificationLevel(NotificationLevel level)
278 bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 /// Gets a priority level for the specified notification window.
286 /// <returns>The notification window level.</returns>
287 /// <since_tizen> 3 </since_tizen>
288 public NotificationLevel GetNotificationLevel()
290 NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 /// Sets a transparent window's visual state to opaque. <br />
297 /// If a visual state of a transparent window is opaque, <br />
298 /// then the window manager could handle it as an opaque window when calculating visibility.
300 /// <param name="opaque">Whether the window's visual state is opaque.</param>
301 /// <remarks>This will have no effect on an opaque window. <br />
302 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
304 /// <since_tizen> 3 </since_tizen>
305 public void SetOpaqueState(bool opaque)
307 NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 /// Returns whether a transparent window's visual state is opaque or not.
314 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
315 /// <remarks> The return value has no meaning on an opaque window. </remarks>
316 /// <since_tizen> 3 </since_tizen>
317 public bool IsOpaqueState()
319 bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 /// Sets a window's screen off mode.
327 /// <param name="screenOffMode">The screen mode.</param>
328 /// <returns>True if no error occurred, false otherwise.</returns>
329 /// <since_tizen> 4 </since_tizen>
330 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
332 bool ret = NDalicPINVOKE.SetScreenOffMode(swigCPtr, (int)screenOffMode);
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
338 /// Gets the screen mode of the window.
340 /// <returns>The screen off mode.</returns>
341 /// <since_tizen> 4 </since_tizen>
342 public ScreenOffMode GetScreenOffMode()
344 ScreenOffMode ret = (ScreenOffMode)NDalicPINVOKE.GetScreenOffMode(swigCPtr);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
350 /// Sets preferred brightness of the window.
352 /// <param name="brightness">The preferred brightness (0 to 100).</param>
353 /// <returns>True if no error occurred, false otherwise.</returns>
354 /// <since_tizen> 3 </since_tizen>
355 public bool SetBrightness(int brightness)
357 bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 /// Gets the preferred brightness of the window.
365 /// <returns>The preferred brightness.</returns>
366 /// <since_tizen> 3 </since_tizen>
367 public int GetBrightness()
369 int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375 /// The focus changed event argument.
377 /// <since_tizen> 3 </since_tizen>
378 public class FocusChangedEventArgs : EventArgs
381 /// FocusGained flag.
383 /// <since_tizen> 3 </since_tizen>
384 public bool FocusGained
391 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
392 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
393 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
394 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
397 /// FocusChanged event.
399 /// <since_tizen> 3 </since_tizen>
400 public event EventHandler<FocusChangedEventArgs> FocusChanged
404 if (_windowFocusChangedEventHandler == null)
406 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
407 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
410 _windowFocusChangedEventHandler += value;
414 _windowFocusChangedEventHandler -= value;
416 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
418 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
423 private void OnWindowFocusedChanged(bool focusGained)
425 FocusChangedEventArgs e = new FocusChangedEventArgs();
427 e.FocusGained = focusGained;
429 if (_windowFocusChangedEventHandler != null)
431 _windowFocusChangedEventHandler(this, e);
436 /// Gets/Sets a window title.
438 /// <since_tizen> 4 </since_tizen>
447 _windowTitle = value;
448 SetClass(_windowTitle, "");
453 /// The rendering behavior of a Window.
455 /// <since_tizen> 5 </since_tizen>
456 public RenderingBehaviorType RenderingBehavior
460 return GetRenderingBehavior();
464 SetRenderingBehavior(value);
468 internal WindowFocusSignalType WindowFocusChangedSignal()
470 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475 internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
482 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485 internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490 internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
497 NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
498 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
501 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
503 NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
504 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
507 internal void RotateIndicator(Window.WindowOrientation orientation)
509 NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
510 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514 /// Sets the window name and the class string.
516 /// <param name="name">The name of the window.</param>
517 /// <param name="klass">The class of the window.</param>
518 /// <since_tizen> 4 </since_tizen>
519 public void SetClass(string name, string klass)
521 NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
522 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
526 /// Raises the window to the top of the window stack.
528 /// <since_tizen> 3 </since_tizen>
531 NDalicPINVOKE.Window_Raise(swigCPtr);
532 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536 /// Lowers the window to the bottom of the window stack.
538 /// <since_tizen> 3 </since_tizen>
541 NDalicPINVOKE.Window_Lower(swigCPtr);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 /// Activates the window to the top of the window stack even it is iconified.
548 /// <since_tizen> 3 </since_tizen>
549 public void Activate()
551 NDalicPINVOKE.Window_Activate(swigCPtr);
552 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
555 internal void AddAvailableOrientation(Window.WindowOrientation orientation)
557 NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
558 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
561 internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
563 NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
564 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 internal void SetPreferredOrientation(Window.WindowOrientation orientation)
569 NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573 internal Window.WindowOrientation GetPreferredOrientation()
575 Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
576 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580 internal DragAndDropDetector GetDragAndDropDetector()
582 DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
583 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 internal Any GetNativeHandle()
589 Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
590 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594 internal WindowFocusSignalType FocusChangedSignal()
596 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
597 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 /// Gets the default ( root ) layer.
604 /// <returns>The root layer.</returns>
605 /// <since_tizen> 3 </since_tizen>
606 public Layer GetDefaultLayer()
608 return this.GetRootLayer();
611 internal void Add(Layer layer)
613 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
614 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616 LayersChildren.Add(layer);
619 internal void Remove(Layer layer)
621 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
622 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624 LayersChildren.Remove(layer);
628 /// Add a child view to window.
630 /// <param name="view">the child should be added to the window.</param>
631 /// <since_tizen> 3 </since_tizen>
632 public void Add(View view)
634 NDalicPINVOKE.Actor_Add( rootLayoutCPtr, View.getCPtr(view) );
635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
637 view.InternalParent = this.GetRootLayer();
641 /// Remove a child view from window.
643 /// <param name="view">the child to be removed.</param>
644 /// <since_tizen> 3 </since_tizen>
645 public void Remove(View view)
647 NDalicPINVOKE.Actor_Remove( rootLayoutCPtr, View.getCPtr(view) );
648 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
649 view.InternalParent = null;
652 internal Vector2 GetSize()
654 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
655 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
659 internal RenderTaskList GetRenderTaskList()
661 RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
662 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
667 /// Queries the number of on-window layers.
669 /// <returns>The number of layers.</returns>
670 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
671 internal uint GetLayerCount()
673 if (LayersChildren == null || LayersChildren.Count < 0)
676 return (uint) LayersChildren.Count;
680 /// Retrieves the layer at a specified depth.
682 /// <param name="depth">The layer's depth index.</param>
683 /// <returns>The layer found at the given depth.</returns>
684 /// <since_tizen> 3 </since_tizen>
685 public Layer GetLayer(uint depth)
687 if (depth < LayersChildren.Count)
689 Layer ret = LayersChildren[Convert.ToInt32(depth)];
698 internal Layer GetRootLayer()
700 // Window.IsInstalled() is actually true only when called from event thread and
701 // Core has been initialized, not when Stage is ready.
702 if (_rootLayer == null && Window.IsInstalled())
704 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
705 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 LayersChildren.Add(_rootLayer);
711 internal void SetBackgroundColor(Vector4 color)
713 NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 internal Vector4 GetBackgroundColor()
719 Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
720 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
724 internal Vector2 GetDpi()
726 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
727 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731 internal ObjectRegistry GetObjectRegistry()
733 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
734 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739 /// Keep rendering for at least the given amount of time.
741 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
742 /// <since_tizen> 3 </since_tizen>
743 public void KeepRendering(float durationSeconds)
745 NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
746 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
751 NDalicPINVOKE.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
752 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
755 internal RenderingBehaviorType GetRenderingBehavior()
757 RenderingBehaviorType ret = (RenderingBehaviorType)NDalicPINVOKE.Stage_GetRenderingBehavior(stageCPtr);
758 if (NDalicPINVOKE.SWIGPendingException.Pending)
759 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763 internal KeyEventSignal KeyEventSignal()
765 KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
766 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770 internal VoidSignal EventProcessingFinishedSignal()
772 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
773 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
777 internal TouchSignal TouchSignal()
779 TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
780 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784 internal TouchDataSignal TouchDataSignal()
786 TouchDataSignal ret = new TouchDataSignal(NDalicPINVOKE.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
787 if (NDalicPINVOKE.SWIGPendingException.Pending)
788 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
792 private StageWheelSignal WheelEventSignal()
794 StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
795 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 private WheelSignal StageWheelEventSignal()
802 WheelSignal ret = new WheelSignal(NDalicPINVOKE.Actor_WheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
803 if (NDalicPINVOKE.SWIGPendingException.Pending)
804 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
809 internal VoidSignal ContextLostSignal()
811 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
812 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816 internal VoidSignal ContextRegainedSignal()
818 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
819 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
823 internal VoidSignal SceneCreatedSignal()
825 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
826 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 internal ResizedSignal ResizedSignal()
832 ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
833 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
837 internal static Vector4 DEFAULT_BACKGROUND_COLOR
841 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
842 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
843 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
848 internal static Vector4 DEBUG_BACKGROUND_COLOR
852 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
853 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
854 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
859 private static readonly Window instance = Application.Instance.GetWindow();
862 /// The stage instance property (read-only).<br />
863 /// Gets the current window.<br />
865 /// <since_tizen> 3 </since_tizen>
866 public static Window Instance
875 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
876 /// This function can be used for following example scenarios: <br />
877 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
879 /// <param name="DaliKey">The key code to grab.</param>
880 /// <returns>True if the grab succeeds.</returns>
881 /// <since_tizen> 3 </since_tizen>
882 public bool GrabKeyTopmost(int DaliKey)
884 bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
885 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
890 /// Ungrabs the key specified by a key for the window.<br />
891 /// 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 />
893 /// <param name="DaliKey">The key code to ungrab.</param>
894 /// <returns>True if the ungrab succeeds.</returns>
895 /// <since_tizen> 3 </since_tizen>
896 public bool UngrabKeyTopmost(int DaliKey)
898 bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
899 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904 /// Grabs the key specified by a key for a window in a GrabMode. <br />
905 /// Details: This function can be used for following example scenarios: <br />
906 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
907 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
908 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
910 /// <param name="DaliKey">The key code to grab.</param>
911 /// <param name="GrabMode">The grab mode for the key.</param>
912 /// <returns>True if the grab succeeds.</returns>
913 /// <since_tizen> 3 </since_tizen>
914 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
916 bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
917 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
922 /// Ungrabs the key specified by a key for a window.<br />
923 /// 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 />
925 /// <param name="DaliKey">The key code to ungrab.</param>
926 /// <returns>True if the ungrab succeeds.</returns>
927 /// <since_tizen> 3 </since_tizen>
928 public bool UngrabKey(int DaliKey)
930 bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
931 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
936 /// Sets the keyboard repeat information.
938 /// <param name="rate">The key repeat rate value in seconds.</param>
939 /// <param name="delay">The key repeat delay value in seconds.</param>
940 /// <returns>True if setting the keyboard repeat succeeds.</returns>
941 /// <since_tizen> 5 </since_tizen>
942 public bool SetKeyboardRepeatInfo(float rate, float delay)
944 bool ret = NDalicManualPINVOKE.SetKeyboardRepeatInfo(rate, delay);
945 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
950 /// Gets the keyboard repeat information.
952 /// <param name="rate">The key repeat rate value in seconds.</param>
953 /// <param name="delay">The key repeat delay value in seconds.</param>
954 /// <returns>True if setting the keyboard repeat succeeds.</returns>
955 /// <since_tizen> 5 </since_tizen>
956 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
958 bool ret = NDalicManualPINVOKE.GetKeyboardRepeatInfo(out rate, out delay);
959 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 internal System.IntPtr GetNativeWindowHandler()
965 System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
966 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
973 /// <since_tizen> 3 </since_tizen>
974 public enum WindowOrientation
977 /// Portrait orientation. The height of the display area is greater than the width.
979 /// <since_tizen> 3 </since_tizen>
982 /// Landscape orientation. A wide view area is needed.
984 /// <since_tizen> 3 </since_tizen>
987 /// Portrait inverse orientation.
989 /// <since_tizen> 3 </since_tizen>
990 PortraitInverse = 180,
992 /// Landscape inverse orientation.
994 /// <since_tizen> 3 </since_tizen>
995 LandscapeInverse = 270
999 /// Enumeration for the key grab mode for platform-level APIs.
1001 /// <since_tizen> 3 </since_tizen>
1002 public enum KeyGrabMode
1005 /// Grabs a key only when on the top of the grabbing-window stack mode.
1009 /// Grabs a key together with the other client window(s) mode.
1013 /// 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.
1017 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
1023 /// Enumeration for opacity of the indicator.
1025 internal enum IndicatorBackgroundOpacity
1033 /// Enumeration for visible mode of the indicator.
1035 internal enum IndicatorVisibleMode
1043 /// The touch event argument.
1045 /// <since_tizen> 3 </since_tizen>
1046 public class TouchEventArgs : EventArgs
1048 private Touch _touch;
1053 /// <since_tizen> 3 </since_tizen>
1068 private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
1069 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1070 private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
1071 private RootLayerTouchDataCallbackType _rootLayerTouchDataCallback;
1073 /// This event is emitted when the screen is touched and when the touch ends.<br />
1074 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
1075 /// then when the last finger is lifted.<br />
1076 /// An interrupted event will also be emitted (if it occurs).<br />
1078 /// <since_tizen> 3 </since_tizen>
1079 public event EventHandler<TouchEventArgs> TouchEvent
1083 if (_rootLayerTouchDataEventHandler == null)
1085 _rootLayerTouchDataCallback = OnWindowTouch;
1086 this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
1088 _rootLayerTouchDataEventHandler += value;
1092 _rootLayerTouchDataEventHandler -= value;
1093 if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false)
1095 this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
1100 private bool OnWindowTouch(IntPtr view, IntPtr touchData)
1102 if (touchData == global::System.IntPtr.Zero)
1104 NUILog.Error("touchData should not be null!");
1108 TouchEventArgs e = new TouchEventArgs();
1110 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
1112 if (_rootLayerTouchDataEventHandler != null)
1114 _rootLayerTouchDataEventHandler(this, e);
1120 /// Wheel event arguments.
1122 /// <since_tizen> 3 </since_tizen>
1123 public class WheelEventArgs : EventArgs
1125 private Wheel _wheel;
1130 /// <since_tizen> 3 </since_tizen>
1144 private event EventHandler<WheelEventArgs> _stageWheelHandler;
1146 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1147 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
1148 private WheelEventCallbackType _wheelEventCallback;
1151 /// This event is emitted when the wheel event is received.
1153 /// <since_tizen> 3 </since_tizen>
1154 public event EventHandler<WheelEventArgs> WheelEvent
1158 if (_stageWheelHandler == null)
1160 _wheelEventCallback = OnStageWheel;
1161 this.StageWheelEventSignal().Connect(_wheelEventCallback);
1163 _stageWheelHandler += value;
1167 _stageWheelHandler -= value;
1168 if (_stageWheelHandler == null && StageWheelEventSignal().Empty() == false)
1170 this.StageWheelEventSignal().Disconnect(_wheelEventCallback);
1175 private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
1177 if (wheelEvent == global::System.IntPtr.Zero)
1179 NUILog.Error("wheelEvent should not be null!");
1183 WheelEventArgs e = new WheelEventArgs();
1185 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1187 if (_stageWheelHandler != null)
1189 _stageWheelHandler(this, e);
1195 /// Key event arguments.
1197 /// <since_tizen> 3 </since_tizen>
1198 public class KeyEventArgs : EventArgs
1205 /// <since_tizen> 3 </since_tizen>
1219 private event EventHandler<KeyEventArgs> _stageKeyHandler;
1220 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1223 /// This event is emitted when the key event is received.
1225 /// <since_tizen> 3 </since_tizen>
1226 public event EventHandler<KeyEventArgs> KeyEvent
1230 if (_stageKeyHandler == null)
1232 _stageKeyCallbackDelegate = OnStageKey;
1233 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1235 _stageKeyHandler += value;
1239 _stageKeyHandler -= value;
1240 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1242 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1247 // Callback for Stage KeyEventsignal
1248 private void OnStageKey(IntPtr data)
1250 KeyEventArgs e = new KeyEventArgs();
1254 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1257 if (_stageKeyHandler != null)
1259 //here we send all data to user event handlers
1260 _stageKeyHandler(this, e);
1265 private event EventHandler _stageEventProcessingFinishedEventHandler;
1266 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1268 internal event EventHandler EventProcessingFinished
1272 if (_stageEventProcessingFinishedEventHandler == null)
1274 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1275 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1277 _stageEventProcessingFinishedEventHandler += value;
1282 _stageEventProcessingFinishedEventHandler -= value;
1283 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1285 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1290 // Callback for Stage EventProcessingFinishedSignal
1291 private void OnEventProcessingFinished()
1293 if (_stageEventProcessingFinishedEventHandler != null)
1295 _stageEventProcessingFinishedEventHandler(this, null);
1300 private EventHandler _stageContextLostEventHandler;
1301 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1303 internal event EventHandler ContextLost
1307 if (_stageContextLostEventHandler == null)
1309 _stageContextLostEventCallbackDelegate = OnContextLost;
1310 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1312 _stageContextLostEventHandler += value;
1316 _stageContextLostEventHandler -= value;
1317 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1319 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1324 // Callback for Stage ContextLostSignal
1325 private void OnContextLost()
1327 if (_stageContextLostEventHandler != null)
1329 _stageContextLostEventHandler(this, null);
1334 private EventHandler _stageContextRegainedEventHandler;
1335 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1337 internal event EventHandler ContextRegained
1341 if (_stageContextRegainedEventHandler == null)
1343 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1344 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1346 _stageContextRegainedEventHandler += value;
1350 _stageContextRegainedEventHandler -= value;
1351 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1353 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1358 // Callback for Stage ContextRegainedSignal
1359 private void OnContextRegained()
1361 if (_stageContextRegainedEventHandler != null)
1363 _stageContextRegainedEventHandler(this, null);
1368 private EventHandler _stageSceneCreatedEventHandler;
1369 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1371 internal event EventHandler SceneCreated
1375 if (_stageSceneCreatedEventHandler == null)
1377 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1378 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1380 _stageSceneCreatedEventHandler += value;
1384 _stageSceneCreatedEventHandler -= value;
1385 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1387 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1392 // Callback for Stage SceneCreatedSignal
1393 private void OnSceneCreated()
1395 if (_stageSceneCreatedEventHandler != null)
1397 _stageSceneCreatedEventHandler(this, null);
1402 /// This resized event arguments.
1404 /// <since_tizen> 3 </since_tizen>
1405 public class ResizedEventArgs : EventArgs
1410 /// This window size.
1412 /// <since_tizen> 4 </since_tizen>
1413 public Size2D WindowSize
1421 _windowSize = value;
1426 private WindowResizedEventCallbackType _windowResizedEventCallback;
1427 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1428 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1429 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1432 /// This event is emitted when the window resized.
1434 /// <since_tizen> 3 </since_tizen>
1435 public event EventHandler<ResizedEventArgs> Resized
1439 if (_windowResizedEventHandler == null)
1441 _windowResizedEventCallback = OnResized;
1442 ResizedSignal().Connect(_windowResizedEventCallback);
1445 _windowResizedEventHandler += value;
1449 _windowResizedEventHandler -= value;
1451 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1453 ResizedSignal().Disconnect(_windowResizedEventCallback);
1458 private void OnResized(IntPtr windowSize)
1460 ResizedEventArgs e = new ResizedEventArgs();
1461 var val = new Uint16Pair(windowSize, false);
1462 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1465 if (_windowResizedEventHandler != null)
1467 _windowResizedEventHandler(this, e);
1471 internal void SetWindowSize(Size2D size)
1473 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1474 NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1478 if(rootLayoutItem != null)
1480 rootLayoutItem.RequestLayout();
1484 internal Size2D GetWindowSize()
1486 var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1487 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1493 internal void SetPosition(Position2D position)
1495 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1496 NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1498 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1500 if(rootLayoutItem != null)
1502 rootLayoutItem.RequestLayout();
1506 internal Position2D GetPosition()
1508 var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1509 Position2D ret = new Position2D(val.GetX(), val.GetY());
1511 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1515 internal void SetPositionSize(Rectangle positionSize)
1517 NDalicPINVOKE.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1518 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1520 if(rootLayoutItem != null)
1522 rootLayoutItem.RequestLayout();
1527 /// Sets whether the window is transparent or not.
1529 /// <param name="transparent">Whether the window is transparent or not.</param>
1530 /// <since_tizen> 5 </since_tizen>
1531 public void SetTransparency(bool transparent) {
1532 NDalicManualPINVOKE.SetTransparency(swigCPtr, transparent);
1533 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1537 /// The window size property (read-only).
1539 /// <since_tizen> 3 </since_tizen>
1544 Size2D ret = GetSize();
1550 /// The background color property.
1552 /// <since_tizen> 3 </since_tizen>
1553 public Color BackgroundColor
1557 SetBackgroundColor(value);
1561 Color ret = GetBackgroundColor();
1567 /// The DPI property (read-only).<br />
1568 /// Retrieves the DPI of the display device to which the Window is connected.<br />
1570 /// <since_tizen> 3 </since_tizen>
1580 /// The layer count property (read-only).<br />
1581 /// Queries the number of on-Window layers.<br />
1583 /// <since_tizen> 3 </since_tizen>
1584 public uint LayerCount
1588 return GetLayerCount();
1594 /// Adds a layer to the stage.
1596 /// <param name="layer">Layer to add.</param>
1597 /// <since_tizen> 3 </since_tizen>
1598 public void AddLayer(Layer layer)
1600 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1601 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1603 LayersChildren.Add(layer);
1607 /// Removes a layer from the stage.
1609 /// <param name="layer">Layer to remove.</param>
1610 /// <since_tizen> 3 </since_tizen>
1611 public void RemoveLayer(Layer layer)
1613 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1614 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1616 LayersChildren.Remove(layer);
1620 /// Please do not use! this will be deprecated
1622 /// <since_tizen> 3 </since_tizen>
1623 [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1625 "Window.Instance.FocusChanged = OnFocusChanged; " +
1626 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1627 [EditorBrowsable(EditorBrowsableState.Never)]
1628 public class WindowFocusChangedEventArgs : EventArgs
1631 /// Please do not use! this will be deprecated
1633 /// <since_tizen> 3 </since_tizen>
1634 public bool FocusGained
1641 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1642 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1643 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1644 private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1647 /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
1649 /// <since_tizen> 3 </since_tizen>
1650 /// Please do not use! this will be deprecated!
1651 /// Instead please use FocusChanged.
1652 [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
1654 "Window.Instance.FocusChanged = OnFocusChanged; " +
1655 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1656 [EditorBrowsable(EditorBrowsableState.Never)]
1657 public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1661 if (_windowFocusChangedEventHandler2 == null)
1663 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1664 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1667 _windowFocusChangedEventHandler2 += value;
1671 _windowFocusChangedEventHandler2 -= value;
1673 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1675 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1680 private void OnWindowFocusedChanged2(bool focusGained)
1682 WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1684 e.FocusGained = focusGained;
1686 if (_windowFocusChangedEventHandler2 != null)
1688 _windowFocusChangedEventHandler2(this, e);
1693 /// Gets or sets a size of the window.
1695 /// <since_tizen> 4 </since_tizen>
1696 public Size2D WindowSize
1700 return GetWindowSize();
1704 SetWindowSize(value);
1709 /// Gets or sets a position of the window.
1711 /// <since_tizen> 4 </since_tizen>
1712 public Position2D WindowPosition
1716 return GetPosition();
1725 /// Sets position and size of the window. This API guarantees that
1726 /// both moving and resizing of window will appear on the screen at once.
1728 [EditorBrowsable(EditorBrowsableState.Never)]
1729 public Rectangle WindowPositionSize
1733 Position2D position = GetPosition();
1734 Size2D size = GetSize();
1735 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
1740 SetPositionSize(value);
1745 /// Feeds a key event into the window.
1747 /// <param name="keyEvent">The key event to feed.</param>
1748 /// <since_tizen> 5 </since_tizen>
1749 public void FeedKey(Key keyEvent)
1751 NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1752 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1756 /// Feed a key-event into the window.
1758 /// <param name="keyEvent">The key event to feed.</param>
1759 /// <since_tizen> 4 </since_tizen>
1760 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
1761 public static void FeedKeyEvent(Key keyEvent)
1763 NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1764 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1768 /// Allows at least one more render, even when paused.
1769 /// The window should be shown, not minimised.
1771 /// <since_tizen> 4 </since_tizen>
1772 public void RenderOnce()
1774 NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1775 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1779 /// Contains and encapsulates Native Window handle.
1781 /// <since_tizen> 4 </since_tizen>
1782 public class SafeNativeWindowHandle : SafeHandle
1785 /// Contructor, Native window handle is set to handle.
1787 /// <since_tizen> 4 </since_tizen>
1788 public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1790 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1793 /// Null check if the handle is valid or not.
1795 /// <since_tizen> 4 </since_tizen>
1796 public override bool IsInvalid
1800 return this.handle == IntPtr.Zero;
1804 /// Release handle itself.
1806 /// <returns>true when released successfully.</returns>
1807 /// <since_tizen> 4 </since_tizen>
1808 protected override bool ReleaseHandle()
1815 /// Disconnect all native signals
1817 /// <since_tizen> 5 </since_tizen>
1818 internal void DisconnectNativeSignals()
1820 if( _windowFocusChangedEventCallback != null )
1822 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
1825 if( _rootLayerTouchDataCallback != null )
1827 TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
1830 if( _wheelEventCallback != null )
1832 StageWheelEventSignal().Disconnect(_wheelEventCallback);
1835 if( _stageKeyCallbackDelegate != null )
1837 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1840 if( _stageEventProcessingFinishedEventCallbackDelegate != null )
1842 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1845 if( _stageContextLostEventCallbackDelegate != null )
1847 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1850 if( _stageContextRegainedEventCallbackDelegate != null )
1852 ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1855 if( _stageSceneCreatedEventCallbackDelegate != null )
1857 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1860 if( _windowResizedEventCallback != null )
1862 ResizedSignal().Disconnect(_windowResizedEventCallback);
1865 if( _windowFocusChangedEventCallback2 != null )
1867 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);