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;
23 using System.ComponentModel;
26 /// The window class is used internally for drawing.<br>
27 /// The window has an orientation and indicator properties.<br>
29 public class Window : BaseHandle
31 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
32 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
33 private Layer _rootLayer;
34 private string _windowTitle;
36 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn)
38 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
39 if (NDalicPINVOKE.Stage_IsInstalled())
41 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
45 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
47 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
51 /// To make the window instance be disposed.
53 protected override void Dispose(DisposeTypes type)
60 if(type == DisposeTypes.Explicit)
63 //Release your own managed resources here.
64 //You should release all of your own disposable objects here.
67 //Release your own unmanaged resources here.
68 //You should not access any managed member here except static instance.
69 //because the execution order of Finalizes is non-deterministic.
71 if (_windowFocusChangedEventCallback != null)
73 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
76 if (_stageTouchCallbackDelegate != null)
78 TouchSignal().Disconnect(_stageTouchCallbackDelegate);
81 if (_stageWheelCallbackDelegate != null)
83 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
86 if (_stageKeyCallbackDelegate != null)
88 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
91 if (_stageEventProcessingFinishedEventCallbackDelegate != null)
93 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
96 if (_stageContextLostEventCallbackDelegate != null)
98 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
101 if (_stageContextRegainedEventCallbackDelegate != null)
103 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
106 if (_stageSceneCreatedEventCallbackDelegate != null)
108 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
111 if (_windowResizedEventCallback != null)
113 ResizedSignal().Disconnect(_windowResizedEventCallback);
116 if (_windowFocusChangedEventCallback2 != null)
118 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
121 if (swigCPtr.Handle != global::System.IntPtr.Zero)
126 NDalicPINVOKE.delete_Window(swigCPtr);
127 NDalicPINVOKE.delete_Stage(stageCPtr);
129 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
135 internal static Window GetCurrent()
137 Window ret = new Window(NDalicPINVOKE.Stage_GetCurrent(), true);
138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142 internal static bool IsInstalled()
144 bool ret = NDalicPINVOKE.Stage_IsInstalled();
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150 /// Sets whether the window accepts a focus or not.
152 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
153 public void SetAcceptFocus(bool accept)
155 NDalicPINVOKE.SetAcceptFocus(swigCPtr, accept);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 /// Returns whether the window accepts a focus or not.
162 /// <returns>True if the window accepts a focus, false otherwise.</returns>
163 public bool IsFocusAcceptable()
165 bool ret = NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172 /// Shows the window if it is hidden.
176 NDalicPINVOKE.Show(swigCPtr);
177 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181 /// Hides the window if it is showing.
185 NDalicPINVOKE.Hide(swigCPtr);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// Retrieves whether the window is visible or not.
192 /// <returns>True if the window is visible.</returns>
193 public bool IsVisible()
195 bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201 /// Gets the count of supported auxiliary hints of the window.
203 /// <returns>The number of supported auxiliary hints.</returns>
204 public uint GetSupportedAuxiliaryHintCount() {
205 uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211 /// Gets the supported auxiliary hint string of the window.
213 /// <param name="index">The index of the supported auxiliary hint lists.</param>
214 /// <returns>The auxiliary hint string of the index.</returns>
215 public string GetSupportedAuxiliaryHint(uint index) {
216 string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222 /// Creates an auxiliary hint of the window.
224 /// <param name="hint">The auxiliary hint string.</param>
225 /// <param name="value">The value string.</param>
226 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
227 public uint AddAuxiliaryHint(string hint, string value) {
228 uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 /// Removes an auxiliary hint of the window.
236 /// <param name="id">The ID of the auxiliary hint.</param>
237 /// <returns>True if no error occurred, false otherwise.</returns>
238 public bool RemoveAuxiliaryHint(uint id) {
239 bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 /// Changes a value of the auxiliary hint.
247 /// <param name="id">The auxiliary hint ID.</param>
248 /// <param name="value">The value string to be set.</param>
249 /// <returns>True if no error occurred, false otherwise.</returns>
250 public bool SetAuxiliaryHintValue(uint id, string value) {
251 bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 /// Gets a value of the auxiliary hint.
259 /// <param name="id">The auxiliary hint ID.</param>
260 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
261 public string GetAuxiliaryHintValue(uint id) {
262 string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268 /// Gets an ID of the auxiliary hint string.
270 /// <param name="hint">The auxiliary hint string.</param>
271 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
272 public uint GetAuxiliaryHintId(string hint) {
273 uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279 /// Sets a region to accept input events.
281 /// <param name="inputRegion">The region to accept input events.</param>
282 public void SetInputRegion(Rectangle inputRegion) {
283 NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 /// Gets or sets a window type.
290 public WindowType Type
294 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300 NDalicPINVOKE.SetType(swigCPtr, (int)value);
301 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
306 /// Sets a priority level for the specified notification window.
308 /// <param name="level">The notification window level.</param>
309 /// <returns>True if no error occurred, false otherwise.</returns>
310 public bool SetNotificationLevel(NotificationLevel level) {
311 bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 /// Gets a priority level for the specified notification window.
319 /// <returns>The notification window level.</returns>
320 public NotificationLevel GetNotificationLevel() {
321 NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
327 /// Sets a transparent window's visual state to opaque.
329 /// <param name="opaque">Whether the window's visual state is opaque.</param>
330 public void SetOpaqueState(bool opaque) {
331 NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 /// Returns whether a transparent window's visual state is opaque or not.
338 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
339 public bool IsOpaqueState() {
340 bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
341 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346 /// Sets a window's screen mode.
348 /// <param name="screenMode">The screen mode.</param>
349 /// <returns>True if no error occurred, false otherwise.</returns>
350 public bool SetScreenMode(ScreenMode screenMode) {
351 bool ret = NDalicPINVOKE.SetScreenMode(swigCPtr, (int)screenMode);
352 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 /// Gets the screen mode of the window.
359 /// <returns>The screen mode.</returns>
360 public ScreenMode GetScreenMode() {
361 ScreenMode ret = (ScreenMode)NDalicPINVOKE.GetScreenMode(swigCPtr);
362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
367 /// Sets preferred brightness of the window.
369 /// <param name="brightness">The preferred brightness (0 to 100).</param>
370 /// <returns>True if no error occurred, false otherwise.</returns>
371 public bool SetBrightness(int brightness) {
372 bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 /// Gets the preferred brightness of the window.
380 /// <returns>The preferred brightness.</returns>
381 public int GetBrightness() {
382 int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 public class FocusChangedEventArgs : EventArgs
389 public bool FocusGained
396 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
397 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
398 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
399 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
401 public event EventHandler<FocusChangedEventArgs> FocusChanged
405 if (_windowFocusChangedEventHandler == null)
407 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
408 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
411 _windowFocusChangedEventHandler += value;
415 _windowFocusChangedEventHandler -= value;
417 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
419 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
424 private void OnWindowFocusedChanged(bool focusGained)
426 FocusChangedEventArgs e = new FocusChangedEventArgs();
428 e.FocusGained = focusGained;
430 if (_windowFocusChangedEventHandler != null)
432 _windowFocusChangedEventHandler(this, e);
437 /// Gets/Sets a window title.
447 _windowTitle = value;
448 SetClass( _windowTitle, "" );
452 internal WindowFocusSignalType WindowFocusChangedSignal()
454 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
459 internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
466 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
474 internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
481 NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
482 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
487 NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
488 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
491 internal void RotateIndicator(Window.WindowOrientation orientation)
493 NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498 /// Sets the window name and the class string.
500 /// <param name="name">The name of the window.</param>
501 /// <param name="klass">The class of the window.</param>
502 public void SetClass(string name, string klass)
504 NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
505 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
509 /// Raises the window to the top of the window stack.
513 NDalicPINVOKE.Window_Raise(swigCPtr);
514 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 /// Lowers the window to the bottom of the window stack.
522 NDalicPINVOKE.Window_Lower(swigCPtr);
523 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
527 /// Activates the window to the top of the window stack even it is iconified.
529 public void Activate()
531 NDalicPINVOKE.Window_Activate(swigCPtr);
532 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535 internal void AddAvailableOrientation(Window.WindowOrientation orientation)
537 NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
538 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
541 internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
543 NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
544 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
547 internal void SetPreferredOrientation(Window.WindowOrientation orientation)
549 NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
550 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553 internal Window.WindowOrientation GetPreferredOrientation()
555 Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
556 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 internal DragAndDropDetector GetDragAndDropDetector()
562 DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
563 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 internal Any GetNativeHandle()
569 Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 internal WindowFocusSignalType FocusChangedSignal()
576 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
577 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
582 /// Gets the default ( root ) layer.
584 /// <returns>The root layer.</returns>
585 public Layer GetDefaultLayer()
587 return this.GetRootLayer();
590 internal void Add(Layer layer)
592 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
593 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
596 internal void Remove(Layer layer)
598 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
599 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 public void Add(View view)
604 NDalicPINVOKE.Stage_Add(stageCPtr, View.getCPtr(view));
605 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608 public void Remove(View view)
610 NDalicPINVOKE.Stage_Remove(stageCPtr, View.getCPtr(view));
611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614 internal Vector2 GetSize()
616 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
617 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal RenderTaskList GetRenderTaskList()
623 RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
629 /// Queries the number of on-window layers.
631 /// <returns>The number of layers.</returns>
632 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
633 internal uint GetLayerCount()
635 uint ret = NDalicPINVOKE.Stage_GetLayerCount(stageCPtr);
636 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
640 public Layer GetLayer(uint depth)
642 IntPtr cPtr = NDalicPINVOKE.Stage_GetLayer(stageCPtr, depth);
643 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Layer;
645 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal Layer GetRootLayer()
651 if (_rootLayer == null)
652 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
655 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
659 internal void SetBackgroundColor(Vector4 color)
661 NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
662 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 internal Vector4 GetBackgroundColor()
667 Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
668 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
672 internal Vector2 GetDpi()
674 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
675 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679 internal ObjectRegistry GetObjectRegistry()
681 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
682 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 /// Keep rendering for at least the given amount of time.
689 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
690 public void KeepRendering(float durationSeconds)
692 NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
693 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696 internal KeyEventSignal KeyEventSignal()
698 KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
699 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
703 internal VoidSignal EventProcessingFinishedSignal()
705 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
706 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710 internal TouchSignal TouchSignal()
712 TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
713 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 private StageWheelSignal WheelEventSignal()
719 StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
720 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
724 internal VoidSignal ContextLostSignal()
726 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
727 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731 internal VoidSignal ContextRegainedSignal()
733 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
734 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
738 internal VoidSignal SceneCreatedSignal()
740 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
741 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
745 internal ResizedSignal ResizedSignal()
747 ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
748 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752 internal static Vector4 DEFAULT_BACKGROUND_COLOR
756 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
757 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
758 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
763 internal static Vector4 DEBUG_BACKGROUND_COLOR
767 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
768 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
769 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
774 private static readonly Window instance = Application.Instance.GetWindow();
777 /// The stage instance property (read-only).<br>
778 /// Gets the current window.<br>
780 public static Window Instance
789 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br>
790 /// This function can be used for following example scenarios: <br>
791 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br>
793 /// <param name="DaliKey">The key code to grab.</param>
794 /// <returns>True if the grab succeeds.</returns>
795 public bool GrabKeyTopmost(int DaliKey)
797 bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
798 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803 /// Ungrabs the key specified by a key for the window.<br>
804 /// 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>
806 /// <param name="DaliKey">The key code to ungrab.</param>
807 /// <returns>True if the ungrab succeeds.</returns>
808 public bool UngrabKeyTopmost(int DaliKey)
810 bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
811 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
816 /// Grabs the key specified by a key for a window in a GrabMode. <br>
817 /// Details: This function can be used for following example scenarios: <br>
818 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br>
819 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br>
820 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br>
822 /// <param name="DaliKey">The key code to grab.</param>
823 /// <param name="GrabMode">The grab mode for the key.</param>
824 /// <returns>True if the grab succeeds.</returns>
825 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
827 bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
828 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
833 /// Ungrabs the key specified by a key for a window.<br>
834 /// 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>
836 /// <param name="DaliKey">The key code to ungrab.</param>
837 /// <returns>True if the ungrab succeeds.</returns>
838 public bool UngrabKey(int DaliKey)
840 bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
841 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
845 internal System.IntPtr GetNativeWindowHandler()
847 System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
848 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
853 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
855 public enum WindowOrientation
859 PortraitInverse = 180,
860 LandscapeInverse = 270
864 /// Enumeration for the key grab mode for platform-level APIs.
866 public enum KeyGrabMode
869 /// Grabs a key only when on the top of the grabbing-window stack mode.
873 /// Grabs a key together with the other client window(s) mode.
877 /// 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.
881 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
887 /// Enumeration for opacity of the indicator.
889 internal enum IndicatorBackgroundOpacity
897 /// Enumeration for visible mode of the indicator.
899 internal enum IndicatorVisibleMode
907 /// The touch event argument.
909 public class TouchEventArgs : EventArgs
911 private Touch _touch;
929 private event EventHandler<TouchEventArgs> _stageTouchHandler;
930 private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
933 /// This event is emitted when the screen is touched and when the touch ends.<br>
934 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
935 /// then when the last finger is lifted.<br>
936 /// An interrupted event will also be emitted (if it occurs).<br>
938 public event EventHandler<TouchEventArgs> TouchEvent
944 _stageTouchHandler += value;
945 _stageTouchCallbackDelegate = OnStageTouch;
946 this.TouchSignal().Connect(_stageTouchCallbackDelegate);
953 if (_stageTouchHandler != null)
955 this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
957 _stageTouchHandler -= value;
962 private void OnStageTouch(IntPtr data)
964 TouchEventArgs e = new TouchEventArgs();
968 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
971 if (_stageTouchHandler != null)
973 _stageTouchHandler(this, e);
978 /// Wheel event arguments.
980 public class WheelEventArgs : EventArgs
982 private Wheel _wheel;
1000 private event EventHandler<WheelEventArgs> _stageWheelHandler;
1001 private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
1004 /// This event is emitted when the wheel event is received.
1006 public event EventHandler<WheelEventArgs> WheelEvent
1010 if (_stageWheelHandler == null)
1012 _stageWheelCallbackDelegate = OnStageWheel;
1013 WheelEventSignal().Connect(_stageWheelCallbackDelegate);
1015 _stageWheelHandler += value;
1019 _stageWheelHandler -= value;
1020 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
1022 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
1027 private void OnStageWheel(IntPtr data)
1029 WheelEventArgs e = new WheelEventArgs();
1033 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
1036 if (_stageWheelHandler != null)
1038 _stageWheelHandler(this, e);
1043 /// Key event arguments.
1045 public class KeyEventArgs : EventArgs
1065 private event EventHandler<KeyEventArgs> _stageKeyHandler;
1066 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
1069 /// This event is emitted when the key event is received.
1071 public event EventHandler<KeyEventArgs> KeyEvent
1075 if (_stageKeyHandler == null)
1077 _stageKeyCallbackDelegate = OnStageKey;
1078 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1080 _stageKeyHandler += value;
1084 _stageKeyHandler -= value;
1085 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1087 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1092 // Callback for Stage KeyEventsignal
1093 private void OnStageKey(IntPtr data)
1095 KeyEventArgs e = new KeyEventArgs();
1099 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1102 if (_stageKeyHandler != null)
1104 //here we send all data to user event handlers
1105 _stageKeyHandler(this, e);
1110 private event EventHandler _stageEventProcessingFinishedEventHandler;
1111 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1113 internal event EventHandler EventProcessingFinished
1117 if (_stageEventProcessingFinishedEventHandler == null)
1119 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1120 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1122 _stageEventProcessingFinishedEventHandler += value;
1127 _stageEventProcessingFinishedEventHandler -= value;
1128 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1130 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1135 // Callback for Stage EventProcessingFinishedSignal
1136 private void OnEventProcessingFinished()
1138 if (_stageEventProcessingFinishedEventHandler != null)
1140 _stageEventProcessingFinishedEventHandler(this, null);
1145 private EventHandler _stageContextLostEventHandler;
1146 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1148 internal event EventHandler ContextLost
1152 if (_stageContextLostEventHandler == null)
1154 _stageContextLostEventCallbackDelegate = OnContextLost;
1155 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1157 _stageContextLostEventHandler += value;
1161 _stageContextLostEventHandler -= value;
1162 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1164 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1169 // Callback for Stage ContextLostSignal
1170 private void OnContextLost()
1172 if (_stageContextLostEventHandler != null)
1174 _stageContextLostEventHandler(this, null);
1179 private EventHandler _stageContextRegainedEventHandler;
1180 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1182 internal event EventHandler ContextRegained
1186 if (_stageContextRegainedEventHandler == null)
1188 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1189 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1191 _stageContextRegainedEventHandler += value;
1195 _stageContextRegainedEventHandler -= value;
1196 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1198 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1203 // Callback for Stage ContextRegainedSignal
1204 private void OnContextRegained()
1206 if (_stageContextRegainedEventHandler != null)
1208 _stageContextRegainedEventHandler(this, null);
1213 private EventHandler _stageSceneCreatedEventHandler;
1214 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1216 internal event EventHandler SceneCreated
1220 if (_stageSceneCreatedEventHandler == null)
1222 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1223 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1225 _stageSceneCreatedEventHandler += value;
1229 _stageSceneCreatedEventHandler -= value;
1230 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1232 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1237 // Callback for Stage SceneCreatedSignal
1238 private void OnSceneCreated()
1240 if (_stageSceneCreatedEventHandler != null)
1242 _stageSceneCreatedEventHandler(this, null);
1246 public class ResizedEventArgs : EventArgs
1250 public Size2D WindowSize
1258 _windowSize = value;
1263 private WindowResizedEventCallbackType _windowResizedEventCallback;
1264 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1265 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1266 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1268 public event EventHandler<ResizedEventArgs> Resized
1272 if (_windowResizedEventHandler == null)
1274 _windowResizedEventCallback = OnResized;
1275 ResizedSignal().Connect(_windowResizedEventCallback);
1278 _windowResizedEventHandler += value;
1282 _windowResizedEventHandler -= value;
1284 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1286 ResizedSignal().Disconnect(_windowResizedEventCallback);
1291 private void OnResized(IntPtr windowSize)
1293 ResizedEventArgs e = new ResizedEventArgs();
1294 var val = new Uint16Pair(windowSize, false);
1295 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1298 if (_windowResizedEventHandler != null)
1300 _windowResizedEventHandler(this, e);
1304 internal void SetWindowSize(Size2D size)
1306 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1307 NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1309 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1312 internal Size2D GetWindowSize()
1314 var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1315 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1321 internal void SetPosition(Position2D position)
1323 var val = new Uint16Pair( (uint)position.X, (uint)position.Y );
1324 NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1329 internal Position2D GetPosition()
1331 var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1332 Position2D ret = new Position2D(val.GetX(), val.GetY());
1334 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1339 /// The window size property (read-only).
1345 Size2D ret = GetSize();
1351 /// The background color property.
1353 public Color BackgroundColor
1357 SetBackgroundColor(value);
1361 Color ret = GetBackgroundColor();
1367 /// The DPI property (read-only).<br>
1368 /// Retrieves the DPI of the display device to which the Window is connected.<br>
1379 /// The layer count property (read-only).<br>
1380 /// Queries the number of on-Window layers.<br>
1382 public uint LayerCount
1386 return GetLayerCount();
1392 /// Adds a layer to the stage.
1394 /// <param name="layer">Layer to add.</param>
1395 public void AddLayer(Layer layer)
1397 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1402 /// Removes a layer from the stage.
1404 /// <param name="layer">Layer to remove.</param>
1405 public void RemoveLayer(Layer layer)
1407 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1411 //Please do not use! this will be deprecated
1412 [EditorBrowsable(EditorBrowsableState.Never)]
1413 public class WindowFocusChangedEventArgs : EventArgs
1415 public bool FocusGained
1422 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1423 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1424 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1425 private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1427 [Obsolete("Please do not use! this will be deprecated. Please use 'FocusChanged' event instead")]
1428 public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1432 if (_windowFocusChangedEventHandler2 == null)
1434 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1435 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1438 _windowFocusChangedEventHandler2 += value;
1442 _windowFocusChangedEventHandler2 -= value;
1444 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1446 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1451 private void OnWindowFocusedChanged2(bool focusGained)
1453 WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1455 e.FocusGained = focusGained;
1457 if (_windowFocusChangedEventHandler2 != null)
1459 _windowFocusChangedEventHandler2(this, e);
1464 /// Gets or sets a size of the window.
1466 public Size2D WindowSize
1470 return GetWindowSize();
1474 SetWindowSize(value);
1479 /// Gets or sets a position of the window.
1481 public Position2D WindowPosition
1485 return GetPosition();
1494 /// Feed a key-event into the window.
1496 public static void FeedKeyEvent(Key keyEvent)
1498 NDalicManualPINVOKE.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1503 /// Allows at least one more render, even when paused.
1504 /// The window should be shown, not minimised.
1506 public void RenderOnce()
1508 NDalicManualPINVOKE.Window_RenderOnce(swigCPtr);
1509 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();