1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
22 using Tizen.NUI.BaseComponents;
25 /// The window class is used internally for drawing.<br>
26 /// A Window has an orientation and indicator properties.<br>
28 public class Window : BaseHandle
30 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
32 private Layer _rootLayer;
33 private string _windowTitle;
35 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn)
37 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 if (NDalicPINVOKE.Stage_IsInstalled())
40 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
44 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
46 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
50 /// To make Window instance be disposed.
52 protected override void Dispose(DisposeTypes type)
59 if(type == DisposeTypes.Explicit)
62 //Release your own managed resources here.
63 //You should release all of your own disposable objects here.
66 //Release your own unmanaged resources here.
67 //You should not access any managed member here except static instance.
68 //because the execution order of Finalizes is non-deterministic.
70 if (_windowFocusChangedEventCallback != null)
72 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
75 if (_stageTouchCallbackDelegate != null)
77 TouchSignal().Disconnect(_stageTouchCallbackDelegate);
80 if (_stageWheelCallbackDelegate != null)
82 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
85 if (_stageKeyCallbackDelegate != null)
87 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
90 if (_stageEventProcessingFinishedEventCallbackDelegate != null)
92 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
95 if (_stageContextLostEventCallbackDelegate != null)
97 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
100 if (_stageContextRegainedEventCallbackDelegate != null)
102 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
105 if (_stageSceneCreatedEventCallbackDelegate != null)
107 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
110 if (_windowResizedEventCallback != null)
112 ResizedSignal().Disconnect(_windowResizedEventCallback);
115 if (_windowFocusChangedEventCallback2 != null)
117 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
120 if (swigCPtr.Handle != global::System.IntPtr.Zero)
125 NDalicPINVOKE.delete_Window(swigCPtr);
126 NDalicPINVOKE.delete_Stage(stageCPtr);
128 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
134 internal static Window GetCurrent()
136 Window ret = new Window(NDalicPINVOKE.Stage_GetCurrent(), true);
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
141 internal static bool IsInstalled()
143 bool ret = NDalicPINVOKE.Stage_IsInstalled();
144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 /// Sets whether window accepts focus or not.
151 /// <param name="accept">If focus is accepted or not. Default is true.</param>
152 public void SetAcceptFocus(bool accept)
154 NDalicPINVOKE.SetAcceptFocus(swigCPtr, accept);
155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
159 /// Returns whether window accepts focus or not.
161 /// <returns>True if the window accept focus, false otherwise</returns>
162 public bool IsFocusAcceptable()
164 return NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 /// Shows the window if it is hidden.
173 NDalicPINVOKE.Show(swigCPtr);
174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 /// Hides the window if it is showing.
182 NDalicPINVOKE.Hide(swigCPtr);
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187 /// Retrieves whether the window is visible or not.
189 /// <returns>true, if the windoe is visible</returns>
190 public bool IsVisible()
192 bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 /// Gets the count of supported auxiliary hints of the window.
200 /// <returns>The number of supported auxiliary hints.</returns>
201 public uint GetSupportedAuxiliaryHintCount() {
202 uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 /// Gets the supported auxiliary hint string of the window.
210 /// <param name="index">The index of the supported auxiliary hint lists.</param>
211 /// <returns>The auxiliary hint string of the index.</returns>
212 public string GetSupportedAuxiliaryHint(uint index) {
213 string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// Creates an auxiliary hint of the window.
221 /// <param name="hint">The auxiliary hint string.</param>
222 /// <param name="value">The value string.</param>
223 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
224 public uint AddAuxiliaryHint(string hint, string value) {
225 uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 /// Removes an auxiliary hint of the window.
233 /// <param name="id">The ID of the auxiliary hint.</param>
234 /// <returns>True if no error occurred, false otherwise.</returns>
235 public bool RemoveAuxiliaryHint(uint id) {
236 bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// Changes a value of the auxiliary hint.
244 /// <param name="id">The auxiliary hint ID.</param>
245 /// <param name="value">The value string to be set.</param>
246 /// <returns>True if no error occurred, false otherwise.</returns>
247 public bool SetAuxiliaryHintValue(uint id, string value) {
248 bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 /// Gets a value of the auxiliary hint.
256 /// <param name="id">The auxiliary hint ID.</param>
257 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
258 public string GetAuxiliaryHintValue(uint id) {
259 string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 /// Gets an ID of the auxiliary hint string.
267 /// <param name="hint">The auxiliary hint string.</param>
268 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
269 public uint GetAuxiliaryHintId(string hint) {
270 uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 /// Sets a region to accept input events.
278 /// <param name="inputRegion">The region to accept input events.</param>
279 public void SetInputRegion(Rectangle inputRegion) {
280 NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /// Gets/Sets a window type.
287 public WindowType Type
291 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 NDalicPINVOKE.SetType(swigCPtr, (int)value);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 /// Sets a priority level for the specified notification window.
305 /// <param name="level">The notification window level.</param>
306 /// <returns>True if no error occurred, false otherwise.</returns>
307 public bool SetNotificationLevel(NotificationLevel level) {
308 bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
309 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
314 /// Gets a priority level for the specified notification window.
316 /// <returns>The notification window level.</returns>
317 public NotificationLevel GetNotificationLevel() {
318 NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 /// Sets a transparent window's visual state to opaque.
326 /// <param name="opaque">Whether the window's visual state is opaque.</param>
327 public void SetOpaqueState(bool opaque) {
328 NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 /// Returns whether a transparent window's visual state is opaque or not.
335 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
336 public bool IsOpaqueState() {
337 bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
343 /// Sets a window's screen mode.
345 /// <param name="screenMode">The screen mode.</param>
346 /// <returns>True if no error occurred, false otherwise.</returns>
347 public bool SetScreenMode(ScreenMode screenMode) {
348 bool ret = NDalicPINVOKE.SetScreenMode(swigCPtr, (int)screenMode);
349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354 /// Gets a screen mode of the window.
356 /// <returns>The screen mode.</returns>
357 public ScreenMode GetScreenMode() {
358 ScreenMode ret = (ScreenMode)NDalicPINVOKE.GetScreenMode(swigCPtr);
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 /// Sets preferred brightness of the window.
366 /// <param name="brightness">The preferred brightness (0 to 100).</param>
367 /// <returns>True if no error occurred, false otherwise.</returns>
368 public bool SetBrightness(int brightness) {
369 bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375 /// Gets preffered brightness of the window.
377 /// <returns>The preffered brightness.</returns>
378 public int GetBrightness() {
379 int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 public class FocusChangedEventArgs : EventArgs
386 public bool FocusGained
393 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
394 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
395 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
396 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
398 public event EventHandler<FocusChangedEventArgs> FocusChanged
402 if (_windowFocusChangedEventHandler == null)
404 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
405 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
408 _windowFocusChangedEventHandler += value;
412 _windowFocusChangedEventHandler -= value;
414 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
416 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
421 private void OnWindowFocusedChanged(bool focusGained)
423 FocusChangedEventArgs e = new FocusChangedEventArgs();
425 e.FocusGained = focusGained;
427 if (_windowFocusChangedEventHandler != null)
429 _windowFocusChangedEventHandler(this, e);
434 /// Gets/Sets a window title.
444 _windowTitle = value;
445 SetClass( _windowTitle, "" );
449 internal WindowFocusSignalType WindowFocusChangedSignal()
451 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
461 internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
468 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
471 internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
473 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
478 NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
484 NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488 internal void RotateIndicator(Window.WindowOrientation orientation)
490 NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
491 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
495 /// Sets the window name and class string.
497 /// <param name="name">The name of the window</param>
498 /// <param name="klass">The class of the window</param>
499 public void SetClass(string name, string klass)
501 NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
502 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 /// Raises window to the top of Window stack.
510 NDalicPINVOKE.Window_Raise(swigCPtr);
511 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
515 /// Lowers window to the bottom of Window stack.
519 NDalicPINVOKE.Window_Lower(swigCPtr);
520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
524 /// Activates window to the top of Window stack even it is iconified.
526 public void Activate()
528 NDalicPINVOKE.Window_Activate(swigCPtr);
529 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
532 internal void AddAvailableOrientation(Window.WindowOrientation orientation)
534 NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
535 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
538 internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
540 NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
541 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
544 internal void SetPreferredOrientation(Window.WindowOrientation orientation)
546 NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
547 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550 internal Window.WindowOrientation GetPreferredOrientation()
552 Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557 internal DragAndDropDetector GetDragAndDropDetector()
559 DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564 internal Any GetNativeHandle()
566 Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
567 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
571 internal WindowFocusSignalType FocusChangedSignal()
573 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
574 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
579 /// Get default ( root ) layer.
581 /// <returns>The root layer</returns>
582 public Layer GetDefaultLayer()
584 return this.GetRootLayer();
587 internal void Add(Layer layer)
589 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
590 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593 internal void Remove(Layer layer)
595 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
596 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599 public void Add(View view)
601 NDalicPINVOKE.Stage_Add(stageCPtr, View.getCPtr(view));
602 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605 public void Remove(View view)
607 NDalicPINVOKE.Stage_Remove(stageCPtr, View.getCPtr(view));
608 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611 internal Vector2 GetSize()
613 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
614 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 internal RenderTaskList GetRenderTaskList()
620 RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
621 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626 /// Queries the number of on-window layers.
628 /// <returns>The number of layers.</returns>
629 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
630 internal uint GetLayerCount()
632 uint ret = NDalicPINVOKE.Stage_GetLayerCount(stageCPtr);
633 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637 public Layer GetLayer(uint depth)
639 IntPtr cPtr = NDalicPINVOKE.Stage_GetLayer(stageCPtr, depth);
640 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Layer;
642 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 internal Layer GetRootLayer()
648 if (_rootLayer == null)
649 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
652 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal void SetBackgroundColor(Vector4 color)
658 NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662 internal Vector4 GetBackgroundColor()
664 Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
665 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 internal Vector2 GetDpi()
671 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
672 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal ObjectRegistry GetObjectRegistry()
678 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
679 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 /// Keep rendering for at least the given amount of time.
686 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame</param>
687 public void KeepRendering(float durationSeconds)
689 NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
690 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693 internal KeyEventSignal KeyEventSignal()
695 KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 internal VoidSignal EventProcessingFinishedSignal()
702 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707 internal TouchSignal TouchSignal()
709 TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
710 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 private StageWheelSignal WheelEventSignal()
716 StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
717 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
721 internal VoidSignal ContextLostSignal()
723 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
724 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 internal VoidSignal ContextRegainedSignal()
730 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
731 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735 internal VoidSignal SceneCreatedSignal()
737 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
738 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742 internal ResizedSignal ResizedSignal()
744 ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
745 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
749 internal static Vector4 DEFAULT_BACKGROUND_COLOR
753 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
754 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
755 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
760 internal static Vector4 DEBUG_BACKGROUND_COLOR
764 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
765 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
766 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
771 private static readonly Window instance = Application.Instance.GetWindow();
774 /// Stage instance property (read-only).<br>
775 /// Gets the current Window.<br>
777 public static Window Instance
786 /// Grabs the key specified by a key for a window only when a window is the topmost window. <br>
787 /// This function can be used for following example scenarios: <br>
788 /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
790 /// <param name="DaliKey">The key code to grab</param>
791 /// <returns>true if the grab succeeds</returns>
792 public bool GrabKeyTopmost(int DaliKey)
794 bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
795 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
800 /// Ungrabs the key specified by a key for a window. <br>
801 /// 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>
803 /// <param name="DaliKey">The key code to ungrab</param>
804 /// <returns>true if the ungrab succeeds</returns>
805 public bool UngrabKeyTopmost(int DaliKey)
807 bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
808 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
813 /// Grabs the key specified by a key for a window in a GrabMode. <br>
814 /// Details: This function can be used for following example scenarios: <br>
815 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br>
816 /// - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app. <br>
817 /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
819 /// <param name="DaliKey">The key code to grab</param>
820 /// <param name="GrabMode">The grab mode for the key</param>
821 /// <returns>true if the grab succeeds</returns>
822 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
824 bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
825 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 /// Ungrabs the key specified by a key for a window. <br>
831 /// 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>
833 /// <param name="DaliKey">The key code to ungrab</param>
834 /// <returns>true if the ungrab succeeds</returns>
835 public bool UngrabKey(int DaliKey)
837 bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
838 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
842 internal System.IntPtr GetNativeWindowHandler()
844 System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
845 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
850 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
852 public enum WindowOrientation
856 PortraitInverse = 180,
857 LandscapeInverse = 270
861 /// Enumeration for key grab mode for platform-level APIs.
863 public enum KeyGrabMode
866 /// Grab a key only when on the top of the grabbing-window stack mode.
870 /// Grab a key together with the other client window(s) mode.
874 /// Grab 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.
878 /// Grab a key exclusively regardless of the grabbing-window's position on the window stack mode.
884 /// Enumeration for opacity of the indicator.
886 internal enum IndicatorBackgroundOpacity
894 /// Enumeration for visible mode of the indicator.
896 internal enum IndicatorVisibleMode
904 /// Touch event argument.
906 public class TouchEventArgs : EventArgs
908 private Touch _touch;
926 private event EventHandler<TouchEventArgs> _stageTouchHandler;
927 private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
930 /// This is emitted when the screen is touched and when the touch ends.<br>
931 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
932 /// then when the last finger is lifted.<br>
933 /// An interrupted event will also be emitted (if it occurs).<br>
935 public event EventHandler<TouchEventArgs> TouchEvent
941 _stageTouchHandler += value;
942 _stageTouchCallbackDelegate = OnStageTouch;
943 this.TouchSignal().Connect(_stageTouchCallbackDelegate);
950 if (_stageTouchHandler != null)
952 this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
954 _stageTouchHandler -= value;
959 private void OnStageTouch(IntPtr data)
961 TouchEventArgs e = new TouchEventArgs();
965 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
968 if (_stageTouchHandler != null)
970 _stageTouchHandler(this, e);
975 /// Wheel event arguments.
977 public class WheelEventArgs : EventArgs
979 private Wheel _wheel;
997 private event EventHandler<WheelEventArgs> _stageWheelHandler;
998 private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1001 /// Event emitted when wheel event is received.
1003 public event EventHandler<WheelEventArgs> WheelEvent
1007 if (_stageWheelHandler == null)
1009 _stageWheelCallbackDelegate = OnStageWheel;
1010 WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1012 _stageWheelHandler += value;
1016 _stageWheelHandler -= value;
1017 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1019 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1024 private void OnStageWheel(IntPtr data)
1026 WheelEventArgs e = new WheelEventArgs();
1030 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1033 if (_stageWheelHandler != null)
1035 _stageWheelHandler(this, e);
1040 /// Key event arguments.
1042 public class KeyEventArgs : EventArgs
1062 private event EventHandler<KeyEventArgs> _stageKeyHandler;
1063 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1066 /// Event emitted when key event is received.
1068 public event EventHandler<KeyEventArgs> KeyEvent
1072 if (_stageKeyHandler == null)
1074 _stageKeyCallbackDelegate = OnStageKey;
1075 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1077 _stageKeyHandler += value;
1081 _stageKeyHandler -= value;
1082 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1084 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1089 // Callback for Stage KeyEventsignal
1090 private void OnStageKey(IntPtr data)
1092 KeyEventArgs e = new KeyEventArgs();
1096 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1099 if (_stageKeyHandler != null)
1101 //here we send all data to user event handlers
1102 _stageKeyHandler(this, e);
1107 private event EventHandler _stageEventProcessingFinishedEventHandler;
1108 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1110 internal event EventHandler EventProcessingFinished
1114 if (_stageEventProcessingFinishedEventHandler == null)
1116 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1117 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1119 _stageEventProcessingFinishedEventHandler += value;
1124 _stageEventProcessingFinishedEventHandler -= value;
1125 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1127 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1132 // Callback for Stage EventProcessingFinishedSignal
1133 private void OnEventProcessingFinished()
1135 if (_stageEventProcessingFinishedEventHandler != null)
1137 _stageEventProcessingFinishedEventHandler(this, null);
1142 private EventHandler _stageContextLostEventHandler;
1143 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1145 internal event EventHandler ContextLost
1149 if (_stageContextLostEventHandler == null)
1151 _stageContextLostEventCallbackDelegate = OnContextLost;
1152 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1154 _stageContextLostEventHandler += value;
1158 _stageContextLostEventHandler -= value;
1159 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1161 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1166 // Callback for Stage ContextLostSignal
1167 private void OnContextLost()
1169 if (_stageContextLostEventHandler != null)
1171 _stageContextLostEventHandler(this, null);
1176 private EventHandler _stageContextRegainedEventHandler;
1177 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1179 internal event EventHandler ContextRegained
1183 if (_stageContextRegainedEventHandler == null)
1185 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1186 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1188 _stageContextRegainedEventHandler += value;
1192 _stageContextRegainedEventHandler -= value;
1193 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1195 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1200 // Callback for Stage ContextRegainedSignal
1201 private void OnContextRegained()
1203 if (_stageContextRegainedEventHandler != null)
1205 _stageContextRegainedEventHandler(this, null);
1210 private EventHandler _stageSceneCreatedEventHandler;
1211 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1213 internal event EventHandler SceneCreated
1217 if (_stageSceneCreatedEventHandler == null)
1219 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1220 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1222 _stageSceneCreatedEventHandler += value;
1226 _stageSceneCreatedEventHandler -= value;
1227 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1229 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1234 // Callback for Stage SceneCreatedSignal
1235 private void OnSceneCreated()
1237 if (_stageSceneCreatedEventHandler != null)
1239 _stageSceneCreatedEventHandler(this, null);
1243 public class ResizedEventArgs : EventArgs
1247 public Size2D WindowSize
1255 _windowSize = value;
1260 private WindowResizedEventCallbackType _windowResizedEventCallback;
1261 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1262 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1263 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1265 public event EventHandler<ResizedEventArgs> Resized
1269 if (_windowResizedEventHandler == null)
1271 _windowResizedEventCallback = OnResized;
1272 ResizedSignal().Connect(_windowResizedEventCallback);
1275 _windowResizedEventHandler += value;
1279 _windowResizedEventHandler -= value;
1281 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1283 ResizedSignal().Disconnect(_windowResizedEventCallback);
1288 private void OnResized(IntPtr windowSize)
1290 ResizedEventArgs e = new ResizedEventArgs();
1291 var val = new Uint16Pair(windowSize, false);
1292 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1295 if (_windowResizedEventHandler != null)
1297 _windowResizedEventHandler(this, e);
1301 internal void SetWindowSize(Size2D size)
1303 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1304 NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1309 internal Size2D GetWindowSize()
1311 var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1312 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1318 internal void SetPosition(Position2D position)
1320 var val = new Uint16Pair( (uint)position.X, (uint)position.Y );
1321 NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1323 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1326 internal Position2D GetPosition()
1328 var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1329 Position2D ret = new Position2D(val.GetX(), val.GetY());
1331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336 /// Window size property (read-only).
1342 Size2D ret = GetSize();
1348 /// Background color property.
1350 public Color BackgroundColor
1354 SetBackgroundColor(value);
1358 Color ret = GetBackgroundColor();
1364 /// Dpi property (read-only).<br>
1365 /// Retrieves the DPI of the display device to which the Window is connected.<br>
1376 /// Layer count property (read-only).<br>
1377 /// Queries the number of on-Window layers.<br>
1379 public uint LayerCount
1383 return GetLayerCount();
1389 /// Add layer to the Stage.
1391 /// <param name="layer">Layer to add</param>
1392 public void AddLayer(Layer layer)
1394 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1399 /// Remove layer from the Stage.
1401 /// <param name="layer">Layer to remove</param>
1402 public void RemoveLayer(Layer layer)
1404 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 [Obsolete("Please do not use! this will be deprecated")]
1409 public class WindowFocusChangedEventArgs : EventArgs
1411 public bool FocusGained
1418 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1419 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1420 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1421 private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1423 [Obsolete("Please do not use! this will be deprecated. Please use 'FocusChanged' event instead")]
1424 public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1428 if (_windowFocusChangedEventHandler2 == null)
1430 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1431 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1434 _windowFocusChangedEventHandler2 += value;
1438 _windowFocusChangedEventHandler2 -= value;
1440 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1442 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1447 private void OnWindowFocusedChanged2(bool focusGained)
1449 WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1451 e.FocusGained = focusGained;
1453 if (_windowFocusChangedEventHandler2 != null)
1455 _windowFocusChangedEventHandler2(this, e);
1460 /// Gets/Sets a size of the window.
1462 public Size2D WindowSize
1466 return GetWindowSize();
1470 SetWindowSize(value);
1475 /// Gets/Sets a position of the window.
1477 public Position2D WindowPosition
1481 return GetPosition();
1489 public static void FeedKeyEvent(Key keyEvent)
1491 NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();