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 bool ret = NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171 /// Shows the window if it is hidden.
175 NDalicPINVOKE.Show(swigCPtr);
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 /// Hides the window if it is showing.
184 NDalicPINVOKE.Hide(swigCPtr);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
189 /// Retrieves whether the window is visible or not.
191 /// <returns>true, if the windoe is visible</returns>
192 public bool IsVisible()
194 bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
200 /// Gets the count of supported auxiliary hints of the window.
202 /// <returns>The number of supported auxiliary hints.</returns>
203 public uint GetSupportedAuxiliaryHintCount() {
204 uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210 /// Gets the supported auxiliary hint string of the window.
212 /// <param name="index">The index of the supported auxiliary hint lists.</param>
213 /// <returns>The auxiliary hint string of the index.</returns>
214 public string GetSupportedAuxiliaryHint(uint index) {
215 string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221 /// Creates an auxiliary hint of the window.
223 /// <param name="hint">The auxiliary hint string.</param>
224 /// <param name="value">The value string.</param>
225 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
226 public uint AddAuxiliaryHint(string hint, string value) {
227 uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// Removes an auxiliary hint of the window.
235 /// <param name="id">The ID of the auxiliary hint.</param>
236 /// <returns>True if no error occurred, false otherwise.</returns>
237 public bool RemoveAuxiliaryHint(uint id) {
238 bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
239 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 /// Changes a value of the auxiliary hint.
246 /// <param name="id">The auxiliary hint ID.</param>
247 /// <param name="value">The value string to be set.</param>
248 /// <returns>True if no error occurred, false otherwise.</returns>
249 public bool SetAuxiliaryHintValue(uint id, string value) {
250 bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 /// Gets a value of the auxiliary hint.
258 /// <param name="id">The auxiliary hint ID.</param>
259 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
260 public string GetAuxiliaryHintValue(uint id) {
261 string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 /// Gets an ID of the auxiliary hint string.
269 /// <param name="hint">The auxiliary hint string.</param>
270 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
271 public uint GetAuxiliaryHintId(string hint) {
272 uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
273 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
278 /// Sets a region to accept input events.
280 /// <param name="inputRegion">The region to accept input events.</param>
281 public void SetInputRegion(Rectangle inputRegion) {
282 NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 /// Gets/Sets a window type.
289 public WindowType Type
293 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 NDalicPINVOKE.SetType(swigCPtr, (int)value);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305 /// Sets a priority level for the specified notification window.
307 /// <param name="level">The notification window level.</param>
308 /// <returns>True if no error occurred, false otherwise.</returns>
309 public bool SetNotificationLevel(NotificationLevel level) {
310 bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
311 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316 /// Gets a priority level for the specified notification window.
318 /// <returns>The notification window level.</returns>
319 public NotificationLevel GetNotificationLevel() {
320 NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326 /// Sets a transparent window's visual state to opaque.
328 /// <param name="opaque">Whether the window's visual state is opaque.</param>
329 public void SetOpaqueState(bool opaque) {
330 NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335 /// Returns whether a transparent window's visual state is opaque or not.
337 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
338 public bool IsOpaqueState() {
339 bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345 /// Sets a window's screen mode.
347 /// <param name="screenMode">The screen mode.</param>
348 /// <returns>True if no error occurred, false otherwise.</returns>
349 public bool SetScreenMode(ScreenMode screenMode) {
350 bool ret = NDalicPINVOKE.SetScreenMode(swigCPtr, (int)screenMode);
351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 /// Gets a screen mode of the window.
358 /// <returns>The screen mode.</returns>
359 public ScreenMode GetScreenMode() {
360 ScreenMode ret = (ScreenMode)NDalicPINVOKE.GetScreenMode(swigCPtr);
361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366 /// Sets preferred brightness of the window.
368 /// <param name="brightness">The preferred brightness (0 to 100).</param>
369 /// <returns>True if no error occurred, false otherwise.</returns>
370 public bool SetBrightness(int brightness) {
371 bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377 /// Gets preffered brightness of the window.
379 /// <returns>The preffered brightness.</returns>
380 public int GetBrightness() {
381 int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386 public class FocusChangedEventArgs : EventArgs
388 public bool FocusGained
395 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
396 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
397 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
398 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
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.
446 _windowTitle = value;
447 SetClass( _windowTitle, "" );
451 internal WindowFocusSignalType WindowFocusChangedSignal()
453 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
463 internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468 internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
473 internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
480 NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
481 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
484 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
486 NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490 internal void RotateIndicator(Window.WindowOrientation orientation)
492 NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
493 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
497 /// Sets the window name and class string.
499 /// <param name="name">The name of the window</param>
500 /// <param name="klass">The class of the window</param>
501 public void SetClass(string name, string klass)
503 NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
504 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 /// Raises window to the top of Window stack.
512 NDalicPINVOKE.Window_Raise(swigCPtr);
513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
517 /// Lowers window to the bottom of Window stack.
521 NDalicPINVOKE.Window_Lower(swigCPtr);
522 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
526 /// Activates window to the top of Window stack even it is iconified.
528 public void Activate()
530 NDalicPINVOKE.Window_Activate(swigCPtr);
531 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
534 internal void AddAvailableOrientation(Window.WindowOrientation orientation)
536 NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
537 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
540 internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
542 NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
543 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 internal void SetPreferredOrientation(Window.WindowOrientation orientation)
548 NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552 internal Window.WindowOrientation GetPreferredOrientation()
554 Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 internal DragAndDropDetector GetDragAndDropDetector()
561 DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
562 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
566 internal Any GetNativeHandle()
568 Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
569 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573 internal WindowFocusSignalType FocusChangedSignal()
575 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
576 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 /// Get default ( root ) layer.
583 /// <returns>The root layer</returns>
584 public Layer GetDefaultLayer()
586 return this.GetRootLayer();
589 internal void Add(Layer layer)
591 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
592 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 internal void Remove(Layer layer)
597 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
598 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
601 public void Add(View view)
603 NDalicPINVOKE.Stage_Add(stageCPtr, View.getCPtr(view));
604 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607 public void Remove(View view)
609 NDalicPINVOKE.Stage_Remove(stageCPtr, View.getCPtr(view));
610 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 internal Vector2 GetSize()
615 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
616 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
620 internal RenderTaskList GetRenderTaskList()
622 RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
623 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 /// Queries the number of on-window layers.
630 /// <returns>The number of layers.</returns>
631 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
632 internal uint GetLayerCount()
634 uint ret = NDalicPINVOKE.Stage_GetLayerCount(stageCPtr);
635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639 public Layer GetLayer(uint depth)
641 IntPtr cPtr = NDalicPINVOKE.Stage_GetLayer(stageCPtr, depth);
642 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Layer;
644 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
648 internal Layer GetRootLayer()
650 if (_rootLayer == null)
651 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
654 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 internal void SetBackgroundColor(Vector4 color)
660 NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
661 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 internal Vector4 GetBackgroundColor()
666 Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
667 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671 internal Vector2 GetDpi()
673 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
674 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 internal ObjectRegistry GetObjectRegistry()
680 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
681 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
686 /// Keep rendering for at least the given amount of time.
688 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame</param>
689 public void KeepRendering(float durationSeconds)
691 NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
692 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
695 internal KeyEventSignal KeyEventSignal()
697 KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
702 internal VoidSignal EventProcessingFinishedSignal()
704 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
705 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
709 internal TouchSignal TouchSignal()
711 TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
712 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
716 private StageWheelSignal WheelEventSignal()
718 StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723 internal VoidSignal ContextLostSignal()
725 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
726 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730 internal VoidSignal ContextRegainedSignal()
732 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
733 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737 internal VoidSignal SceneCreatedSignal()
739 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
740 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744 internal ResizedSignal ResizedSignal()
746 ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
747 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
751 internal static Vector4 DEFAULT_BACKGROUND_COLOR
755 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
756 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
757 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
762 internal static Vector4 DEBUG_BACKGROUND_COLOR
766 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
767 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
768 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
773 private static readonly Window instance = Application.Instance.GetWindow();
776 /// Stage instance property (read-only).<br>
777 /// Gets the current Window.<br>
779 public static Window Instance
788 /// Grabs the key specified by a key for a window only when a window is the topmost window. <br>
789 /// This function can be used for following example scenarios: <br>
790 /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
792 /// <param name="DaliKey">The key code to grab</param>
793 /// <returns>true if the grab succeeds</returns>
794 public bool GrabKeyTopmost(int DaliKey)
796 bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
797 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802 /// Ungrabs the key specified by a key for a window. <br>
803 /// 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>
805 /// <param name="DaliKey">The key code to ungrab</param>
806 /// <returns>true if the ungrab succeeds</returns>
807 public bool UngrabKeyTopmost(int DaliKey)
809 bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
810 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
815 /// Grabs the key specified by a key for a window in a GrabMode. <br>
816 /// Details: This function can be used for following example scenarios: <br>
817 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br>
818 /// - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app. <br>
819 /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
821 /// <param name="DaliKey">The key code to grab</param>
822 /// <param name="GrabMode">The grab mode for the key</param>
823 /// <returns>true if the grab succeeds</returns>
824 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
826 bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
827 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 /// Ungrabs the key specified by a key for a window. <br>
833 /// 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>
835 /// <param name="DaliKey">The key code to ungrab</param>
836 /// <returns>true if the ungrab succeeds</returns>
837 public bool UngrabKey(int DaliKey)
839 bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
840 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844 public System.IntPtr GetNativeWindowHandler()
846 System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
847 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
852 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
854 public enum WindowOrientation
858 PortraitInverse = 180,
859 LandscapeInverse = 270
863 /// Enumeration for key grab mode for platform-level APIs.
865 public enum KeyGrabMode
868 /// Grab a key only when on the top of the grabbing-window stack mode.
872 /// Grab a key together with the other client window(s) mode.
876 /// 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.
880 /// Grab a key exclusively regardless of the grabbing-window's position on the window stack mode.
886 /// Enumeration for opacity of the indicator.
888 internal enum IndicatorBackgroundOpacity
896 /// Enumeration for visible mode of the indicator.
898 internal enum IndicatorVisibleMode
906 /// Touch event argument.
908 public class TouchEventArgs : EventArgs
910 private Touch _touch;
928 private event EventHandler<TouchEventArgs> _stageTouchHandler;
929 private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
932 /// This is emitted when the screen is touched and when the touch ends.<br>
933 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
934 /// then when the last finger is lifted.<br>
935 /// An interrupted event will also be emitted (if it occurs).<br>
937 public event EventHandler<TouchEventArgs> TouchEvent
943 _stageTouchHandler += value;
944 _stageTouchCallbackDelegate = OnStageTouch;
945 this.TouchSignal().Connect(_stageTouchCallbackDelegate);
952 if (_stageTouchHandler != null)
954 this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
956 _stageTouchHandler -= value;
961 private void OnStageTouch(IntPtr data)
963 TouchEventArgs e = new TouchEventArgs();
967 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
970 if (_stageTouchHandler != null)
972 _stageTouchHandler(this, e);
977 /// Wheel event arguments.
979 public class WheelEventArgs : EventArgs
981 private Wheel _wheel;
999 private event EventHandler<WheelEventArgs> _stageWheelHandler;
1000 private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1003 /// Event emitted when wheel event is received.
1005 public event EventHandler<WheelEventArgs> WheelEvent
1009 if (_stageWheelHandler == null)
1011 _stageWheelCallbackDelegate = OnStageWheel;
1012 WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1014 _stageWheelHandler += value;
1018 _stageWheelHandler -= value;
1019 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1021 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1026 private void OnStageWheel(IntPtr data)
1028 WheelEventArgs e = new WheelEventArgs();
1032 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1035 if (_stageWheelHandler != null)
1037 _stageWheelHandler(this, e);
1042 /// Key event arguments.
1044 public class KeyEventArgs : EventArgs
1064 private event EventHandler<KeyEventArgs> _stageKeyHandler;
1065 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1068 /// Event emitted when key event is received.
1070 public event EventHandler<KeyEventArgs> KeyEvent
1074 if (_stageKeyHandler == null)
1076 _stageKeyCallbackDelegate = OnStageKey;
1077 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1079 _stageKeyHandler += value;
1083 _stageKeyHandler -= value;
1084 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1086 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1091 // Callback for Stage KeyEventsignal
1092 private void OnStageKey(IntPtr data)
1094 KeyEventArgs e = new KeyEventArgs();
1098 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1101 if (_stageKeyHandler != null)
1103 //here we send all data to user event handlers
1104 _stageKeyHandler(this, e);
1109 private event EventHandler _stageEventProcessingFinishedEventHandler;
1110 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1112 internal event EventHandler EventProcessingFinished
1116 if (_stageEventProcessingFinishedEventHandler == null)
1118 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1119 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1121 _stageEventProcessingFinishedEventHandler += value;
1126 _stageEventProcessingFinishedEventHandler -= value;
1127 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1129 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1134 // Callback for Stage EventProcessingFinishedSignal
1135 private void OnEventProcessingFinished()
1137 if (_stageEventProcessingFinishedEventHandler != null)
1139 _stageEventProcessingFinishedEventHandler(this, null);
1144 private EventHandler _stageContextLostEventHandler;
1145 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1147 internal event EventHandler ContextLost
1151 if (_stageContextLostEventHandler == null)
1153 _stageContextLostEventCallbackDelegate = OnContextLost;
1154 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1156 _stageContextLostEventHandler += value;
1160 _stageContextLostEventHandler -= value;
1161 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1163 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1168 // Callback for Stage ContextLostSignal
1169 private void OnContextLost()
1171 if (_stageContextLostEventHandler != null)
1173 _stageContextLostEventHandler(this, null);
1178 private EventHandler _stageContextRegainedEventHandler;
1179 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1181 internal event EventHandler ContextRegained
1185 if (_stageContextRegainedEventHandler == null)
1187 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1188 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1190 _stageContextRegainedEventHandler += value;
1194 _stageContextRegainedEventHandler -= value;
1195 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1197 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1202 // Callback for Stage ContextRegainedSignal
1203 private void OnContextRegained()
1205 if (_stageContextRegainedEventHandler != null)
1207 _stageContextRegainedEventHandler(this, null);
1212 private EventHandler _stageSceneCreatedEventHandler;
1213 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1215 internal event EventHandler SceneCreated
1219 if (_stageSceneCreatedEventHandler == null)
1221 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1222 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1224 _stageSceneCreatedEventHandler += value;
1228 _stageSceneCreatedEventHandler -= value;
1229 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1231 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1236 // Callback for Stage SceneCreatedSignal
1237 private void OnSceneCreated()
1239 if (_stageSceneCreatedEventHandler != null)
1241 _stageSceneCreatedEventHandler(this, null);
1245 public class ResizedEventArgs : EventArgs
1249 public Size2D WindowSize
1257 _windowSize = value;
1262 private WindowResizedEventCallbackType _windowResizedEventCallback;
1263 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1264 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1265 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1267 public event EventHandler<ResizedEventArgs> Resized
1271 if (_windowResizedEventHandler == null)
1273 _windowResizedEventCallback = OnResized;
1274 ResizedSignal().Connect(_windowResizedEventCallback);
1277 _windowResizedEventHandler += value;
1281 _windowResizedEventHandler -= value;
1283 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1285 ResizedSignal().Disconnect(_windowResizedEventCallback);
1290 private void OnResized(IntPtr windowSize)
1292 ResizedEventArgs e = new ResizedEventArgs();
1293 var val = new Uint16Pair(windowSize, false);
1294 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1297 if (_windowResizedEventHandler != null)
1299 _windowResizedEventHandler(this, e);
1303 internal void SetWindowSize(Size2D size)
1305 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1306 NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1311 internal Size2D GetWindowSize()
1313 var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1314 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1320 internal void SetPosition(Position2D position)
1322 var val = new Uint16Pair( (uint)position.X, (uint)position.Y );
1323 NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1328 internal Position2D GetPosition()
1330 var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1331 Position2D ret = new Position2D(val.GetX(), val.GetY());
1333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1338 /// Window size property (read-only).
1344 Size2D ret = GetSize();
1350 /// Background color property.
1352 public Color BackgroundColor
1356 SetBackgroundColor(value);
1360 Color ret = GetBackgroundColor();
1366 /// Dpi property (read-only).<br>
1367 /// Retrieves the DPI of the display device to which the Window is connected.<br>
1378 /// Layer count property (read-only).<br>
1379 /// Queries the number of on-Window layers.<br>
1381 public uint LayerCount
1385 return GetLayerCount();
1391 /// Add layer to the Stage.
1393 /// <param name="layer">Layer to add</param>
1394 public void AddLayer(Layer layer)
1396 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1401 /// Remove layer from the Stage.
1403 /// <param name="layer">Layer to remove</param>
1404 public void RemoveLayer(Layer layer)
1406 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1407 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1410 [Obsolete("Please do not use! this will be deprecated")]
1411 public class WindowFocusChangedEventArgs : EventArgs
1413 public bool FocusGained
1420 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1421 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1422 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1423 private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1425 [Obsolete("Please do not use! this will be deprecated. Please use 'FocusChanged' event instead")]
1426 public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1430 if (_windowFocusChangedEventHandler2 == null)
1432 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1433 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1436 _windowFocusChangedEventHandler2 += value;
1440 _windowFocusChangedEventHandler2 -= value;
1442 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1444 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1449 private void OnWindowFocusedChanged2(bool focusGained)
1451 WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1453 e.FocusGained = focusGained;
1455 if (_windowFocusChangedEventHandler2 != null)
1457 _windowFocusChangedEventHandler2(this, e);
1462 /// Gets/Sets a size of the window.
1464 public Size2D WindowSize
1468 return GetWindowSize();
1472 SetWindowSize(value);
1477 /// Gets/Sets a position of the window.
1479 public Position2D WindowPosition
1483 return GetPosition();
1491 public static void FeedKeyEvent(Key keyEvent)
1493 NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();