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;
34 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Window_SWIGUpcast(cPtr), cMemoryOwn)
36 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
37 if (NDalicPINVOKE.Stage_IsInstalled())
39 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, NDalicPINVOKE.Stage_GetCurrent());
43 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
45 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
49 /// To make Window instance be disposed.
51 protected override void Dispose(DisposeTypes type)
58 if(type == DisposeTypes.Explicit)
61 //Release your own managed resources here.
62 //You should release all of your own disposable objects here.
65 //Release your own unmanaged resources here.
66 //You should not access any managed member here except static instance.
67 //because the execution order of Finalizes is non-deterministic.
69 if (swigCPtr.Handle != global::System.IntPtr.Zero)
74 NDalicPINVOKE.delete_Window(swigCPtr);
75 NDalicPINVOKE.delete_Stage(stageCPtr);
77 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
83 internal static Window GetCurrent()
85 Window ret = new Window(NDalicPINVOKE.Stage_GetCurrent(), true);
86 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90 internal static bool IsInstalled()
92 bool ret = NDalicPINVOKE.Stage_IsInstalled();
93 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
98 /// Sets whether window accepts focus or not.
100 /// <param name="accept">If focus is accepted or not. Default is true.</param>
101 public void SetAcceptFocus(bool accept)
103 NDalicPINVOKE.SetAcceptFocus(swigCPtr, accept);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 /// Returns whether window accepts focus or not.
110 /// <returns>True if the window accept focus, false otherwise</returns>
111 public bool IsFocusAcceptable()
113 return NDalicPINVOKE.IsFocusAcceptable(swigCPtr);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118 /// Shows the window if it is hidden.
122 NDalicPINVOKE.Show(swigCPtr);
123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
127 /// Hides the window if it is showing.
131 NDalicPINVOKE.Hide(swigCPtr);
132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
136 /// Retrieves whether the window is visible or not.
138 /// <returns>true, if the windoe is visible</returns>
139 public bool IsVisible()
141 bool temp = NDalicPINVOKE.IsVisible(swigCPtr);
142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 /// Gets the count of supported auxiliary hints of the window.
149 /// <returns>The number of supported auxiliary hints.</returns>
150 public uint GetSupportedAuxiliaryHintCount() {
151 uint ret = NDalicPINVOKE.GetSupportedAuxiliaryHintCount(swigCPtr);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 /// Gets the supported auxiliary hint string of the window.
159 /// <param name="index">The index of the supported auxiliary hint lists.</param>
160 /// <returns>The auxiliary hint string of the index.</returns>
161 public string GetSupportedAuxiliaryHint(uint index) {
162 string ret = NDalicPINVOKE.GetSupportedAuxiliaryHint(swigCPtr, index);
163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168 /// Creates an auxiliary hint of the window.
170 /// <param name="hint">The auxiliary hint string.</param>
171 /// <param name="value">The value string.</param>
172 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
173 public uint AddAuxiliaryHint(string hint, string value) {
174 uint ret = NDalicPINVOKE.AddAuxiliaryHint(swigCPtr, hint, value);
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180 /// Removes an auxiliary hint of the window.
182 /// <param name="id">The ID of the auxiliary hint.</param>
183 /// <returns>True if no error occurred, false otherwise.</returns>
184 public bool RemoveAuxiliaryHint(uint id) {
185 bool ret = NDalicPINVOKE.RemoveAuxiliaryHint(swigCPtr, id);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 /// Changes a value of the auxiliary hint.
193 /// <param name="id">The auxiliary hint ID.</param>
194 /// <param name="value">The value string to be set.</param>
195 /// <returns>True if no error occurred, false otherwise.</returns>
196 public bool SetAuxiliaryHintValue(uint id, string value) {
197 bool ret = NDalicPINVOKE.SetAuxiliaryHintValue(swigCPtr, id, value);
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
203 /// Gets a value of the auxiliary hint.
205 /// <param name="id">The auxiliary hint ID.</param>
206 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
207 public string GetAuxiliaryHintValue(uint id) {
208 string ret = NDalicPINVOKE.GetAuxiliaryHintValue(swigCPtr, id);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214 /// Gets an ID of the auxiliary hint string.
216 /// <param name="hint">The auxiliary hint string.</param>
217 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
218 public uint GetAuxiliaryHintId(string hint) {
219 uint ret = NDalicPINVOKE.GetAuxiliaryHintId(swigCPtr, hint);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 /// Sets a region to accept input events.
227 /// <param name="inputRegion">The region to accept input events.</param>
228 public void SetInputRegion(Rectangle inputRegion) {
229 NDalicPINVOKE.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 /// Gets/Sets a window type.
236 public WindowType Type
240 WindowType ret = (WindowType)NDalicPINVOKE.GetType(swigCPtr);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 NDalicPINVOKE.SetType(swigCPtr, (int)value);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 /// Sets a priority level for the specified notification window.
254 /// <param name="level">The notification window level.</param>
255 /// <returns>True if no error occurred, false otherwise.</returns>
256 public bool SetNotificationLevel(NotificationLevel level) {
257 bool ret = NDalicPINVOKE.SetNotificationLevel(swigCPtr, (int)level);
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263 /// Gets a priority level for the specified notification window.
265 /// <returns>The notification window level.</returns>
266 public NotificationLevel GetNotificationLevel() {
267 NotificationLevel ret = (NotificationLevel)NDalicPINVOKE.GetNotificationLevel(swigCPtr);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 /// Sets a transparent window's visual state to opaque.
275 /// <param name="opaque">Whether the window's visual state is opaque.</param>
276 public void SetOpaqueState(bool opaque) {
277 NDalicPINVOKE.SetOpaqueState(swigCPtr, opaque);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282 /// Returns whether a transparent window's visual state is opaque or not.
284 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
285 public bool IsOpaqueState() {
286 bool ret = NDalicPINVOKE.IsOpaqueState(swigCPtr);
287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292 /// Sets a window's screen mode.
294 /// <param name="screenMode">The screen mode.</param>
295 /// <returns>True if no error occurred, false otherwise.</returns>
296 public bool SetScreenMode(ScreenMode screenMode) {
297 bool ret = NDalicPINVOKE.SetScreenMode(swigCPtr, (int)screenMode);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 /// Gets a screen mode of the window.
305 /// <returns>The screen mode.</returns>
306 public ScreenMode GetScreenMode() {
307 ScreenMode ret = (ScreenMode)NDalicPINVOKE.GetScreenMode(swigCPtr);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 /// Sets preferred brightness of the window.
315 /// <param name="brightness">The preferred brightness (0 to 100).</param>
316 /// <returns>True if no error occurred, false otherwise.</returns>
317 public bool SetBrightness(int brightness) {
318 bool ret = NDalicPINVOKE.SetBrightness(swigCPtr, brightness);
319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 /// Gets preffered brightness of the window.
326 /// <returns>The preffered brightness.</returns>
327 public int GetBrightness() {
328 int ret = NDalicPINVOKE.GetBrightness(swigCPtr);
329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
333 public class FocusChangedEventArgs : EventArgs
335 public bool FocusGained
342 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
343 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
344 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
345 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
347 public event EventHandler<FocusChangedEventArgs> FocusChanged
351 if (_windowFocusChangedEventHandler == null)
353 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
354 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
357 _windowFocusChangedEventHandler += value;
361 _windowFocusChangedEventHandler -= value;
363 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
365 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
370 private void OnWindowFocusedChanged(bool focusGained)
372 FocusChangedEventArgs e = new FocusChangedEventArgs();
374 e.FocusGained = focusGained;
376 if (_windowFocusChangedEventHandler != null)
378 _windowFocusChangedEventHandler(this, e);
382 internal WindowFocusSignalType WindowFocusChangedSignal()
384 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 internal Window(Rectangle windowPosition, string name, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTransparent), true)
391 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394 internal Window(Rectangle windowPosition, string name) : this(NDalicPINVOKE.Window_New__SWIG_1(Rectangle.getCPtr(windowPosition), name), true)
396 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 internal Window(Rectangle windowPosition, string name, string className, bool isTransparent) : this(NDalicPINVOKE.Window_New__SWIG_2(Rectangle.getCPtr(windowPosition), name, className, isTransparent), true)
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 internal Window(Rectangle windowPosition, string name, string className) : this(NDalicPINVOKE.Window_New__SWIG_3(Rectangle.getCPtr(windowPosition), name, className), true)
406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
409 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
411 NDalicPINVOKE.Window_ShowIndicator(swigCPtr, (int)visibleMode);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
417 NDalicPINVOKE.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
421 internal void RotateIndicator(Window.WindowOrientation orientation)
423 NDalicPINVOKE.Window_RotateIndicator(swigCPtr, (int)orientation);
424 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
427 internal void SetClass(string name, string klass)
429 NDalicPINVOKE.Window_SetClass(swigCPtr, name, klass);
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 /// Raises window to the top of Window stack.
438 NDalicPINVOKE.Window_Raise(swigCPtr);
439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 /// Lowers window to the bottom of Window stack.
447 NDalicPINVOKE.Window_Lower(swigCPtr);
448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 /// Activates window to the top of Window stack even it is iconified.
454 public void Activate()
456 NDalicPINVOKE.Window_Activate(swigCPtr);
457 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 internal void AddAvailableOrientation(Window.WindowOrientation orientation)
462 NDalicPINVOKE.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 internal void RemoveAvailableOrientation(Window.WindowOrientation orientation)
468 NDalicPINVOKE.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
469 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 internal void SetPreferredOrientation(Window.WindowOrientation orientation)
474 NDalicPINVOKE.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478 internal Window.WindowOrientation GetPreferredOrientation()
480 Window.WindowOrientation ret = (Window.WindowOrientation)NDalicPINVOKE.Window_GetPreferredOrientation(swigCPtr);
481 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485 internal DragAndDropDetector GetDragAndDropDetector()
487 DragAndDropDetector ret = new DragAndDropDetector(NDalicPINVOKE.Window_GetDragAndDropDetector(swigCPtr), true);
488 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 internal Any GetNativeHandle()
494 Any ret = new Any(NDalicPINVOKE.Window_GetNativeHandle(swigCPtr), true);
495 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
499 internal WindowFocusSignalType FocusChangedSignal()
501 WindowFocusSignalType ret = new WindowFocusSignalType(NDalicPINVOKE.FocusChangedSignal(swigCPtr), false);
502 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
507 /// Get default ( root ) layer.
509 /// <returns>The root layer</returns>
510 public Layer GetDefaultLayer()
512 return this.GetRootLayer();
515 internal void Add(Layer layer)
517 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
518 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521 internal void Remove(Layer layer)
523 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
524 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
527 public void Add(View view)
529 NDalicPINVOKE.Stage_Add(stageCPtr, View.getCPtr(view));
530 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 public void Remove(View view)
535 NDalicPINVOKE.Stage_Remove(stageCPtr, View.getCPtr(view));
536 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539 internal Vector2 GetSize()
541 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetSize(stageCPtr), true);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 internal RenderTaskList GetRenderTaskList()
548 RenderTaskList ret = new RenderTaskList(NDalicPINVOKE.Stage_GetRenderTaskList(stageCPtr), true);
549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
554 /// Queries the number of on-window layers.
556 /// <returns>The number of layers.</returns>
557 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
558 internal uint GetLayerCount()
560 uint ret = NDalicPINVOKE.Stage_GetLayerCount(stageCPtr);
561 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
565 public Layer GetLayer(uint depth)
567 IntPtr cPtr = NDalicPINVOKE.Stage_GetLayer(stageCPtr, depth);
568 Layer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Layer;
570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 internal Layer GetRootLayer()
576 if (_rootLayer == null)
577 _rootLayer = new Layer(NDalicPINVOKE.Stage_GetRootLayer(stageCPtr), true);
580 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 internal void SetBackgroundColor(Vector4 color)
586 NDalicPINVOKE.Stage_SetBackgroundColor(stageCPtr, Vector4.getCPtr(color));
587 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590 internal Vector4 GetBackgroundColor()
592 Vector4 ret = new Vector4(NDalicPINVOKE.Stage_GetBackgroundColor(stageCPtr), true);
593 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 internal Vector2 GetDpi()
599 Vector2 ret = new Vector2(NDalicPINVOKE.Stage_GetDpi(stageCPtr), true);
600 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 internal ObjectRegistry GetObjectRegistry()
606 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.Stage_GetObjectRegistry(stageCPtr), true);
607 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
612 /// Keep rendering for at least the given amount of time.
614 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame</param>
615 public void KeepRendering(float durationSeconds)
617 NDalicPINVOKE.Stage_KeepRendering(stageCPtr, durationSeconds);
618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal KeyEventSignal KeyEventSignal()
623 KeyEventSignal ret = new KeyEventSignal(NDalicPINVOKE.Stage_KeyEventSignal(stageCPtr), false);
624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal VoidSignal EventProcessingFinishedSignal()
630 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_EventProcessingFinishedSignal(stageCPtr), false);
631 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 internal TouchSignal TouchSignal()
637 TouchSignal ret = new TouchSignal(NDalicPINVOKE.Stage_TouchSignal(stageCPtr), false);
638 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642 private StageWheelSignal WheelEventSignal()
644 StageWheelSignal ret = new StageWheelSignal(NDalicPINVOKE.Stage_WheelEventSignal(stageCPtr), false);
645 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal VoidSignal ContextLostSignal()
651 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextLostSignal(stageCPtr), false);
652 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal VoidSignal ContextRegainedSignal()
658 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_ContextRegainedSignal(stageCPtr), false);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 internal VoidSignal SceneCreatedSignal()
665 VoidSignal ret = new VoidSignal(NDalicPINVOKE.Stage_SceneCreatedSignal(stageCPtr), false);
666 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 internal ResizedSignal ResizedSignal()
672 ResizedSignal ret = new ResizedSignal(NDalicManualPINVOKE.Window_ResizedSignal(swigCPtr), false);
673 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
677 internal static Vector4 DEFAULT_BACKGROUND_COLOR
681 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEFAULT_BACKGROUND_COLOR_get();
682 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
683 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
688 internal static Vector4 DEBUG_BACKGROUND_COLOR
692 global::System.IntPtr cPtr = NDalicPINVOKE.Stage_DEBUG_BACKGROUND_COLOR_get();
693 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
694 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 private static readonly Window instance = Application.Instance.GetWindow();
702 /// Stage instance property (read-only).<br>
703 /// Gets the current Window.<br>
705 public static Window Instance
714 /// Grabs the key specified by a key for a window only when a window is the topmost window. <br>
715 /// This function can be used for following example scenarios: <br>
716 /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
718 /// <param name="DaliKey">The key code to grab</param>
719 /// <returns>true if the grab succeeds</returns>
720 public bool GrabKeyTopmost(int DaliKey)
722 bool ret = NDalicManualPINVOKE.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 /// Ungrabs the key specified by a key for a window. <br>
729 /// 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>
731 /// <param name="DaliKey">The key code to ungrab</param>
732 /// <returns>true if the ungrab succeeds</returns>
733 public bool UngrabKeyTopmost(int DaliKey)
735 bool ret = NDalicManualPINVOKE.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
736 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 /// Grabs the key specified by a key for a window in a GrabMode. <br>
742 /// Details: This function can be used for following example scenarios: <br>
743 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br>
744 /// - Mobile - When a user presses Home key, the homescreen appears regardless of current foreground app. <br>
745 /// - Mobile - Using volume up/down as zoom up/down in camera apps. <br>
747 /// <param name="DaliKey">The key code to grab</param>
748 /// <param name="GrabMode">The grab mode for the key</param>
749 /// <returns>true if the grab succeeds</returns>
750 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
752 bool ret = NDalicManualPINVOKE.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
753 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758 /// Ungrabs the key specified by a key for a window. <br>
759 /// 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>
761 /// <param name="DaliKey">The key code to ungrab</param>
762 /// <returns>true if the ungrab succeeds</returns>
763 public bool UngrabKey(int DaliKey)
765 bool ret = NDalicManualPINVOKE.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
766 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770 internal System.IntPtr GetNativeWindowHandler()
772 System.IntPtr ret = NDalicManualPINVOKE.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
773 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
780 public enum WindowOrientation
784 PortraitInverse = 180,
785 LandscapeInverse = 270
789 /// Enumeration for key grab mode for platform-level APIs.
791 public enum KeyGrabMode
794 /// Grab a key only when on the top of the grabbing-window stack mode.
798 /// Grab a key together with the other client window(s) mode.
802 /// 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.
806 /// Grab a key exclusively regardless of the grabbing-window's position on the window stack mode.
812 /// Enumeration for opacity of the indicator.
814 internal enum IndicatorBackgroundOpacity
822 /// Enumeration for visible mode of the indicator.
824 internal enum IndicatorVisibleMode
832 /// Touch event argument.
834 public class TouchEventArgs : EventArgs
836 private Touch _touch;
854 private event EventHandler<TouchEventArgs> _stageTouchHandler;
855 private EventCallbackDelegateType1 _stageTouchCallbackDelegate;
858 /// This is emitted when the screen is touched and when the touch ends.<br>
859 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
860 /// then when the last finger is lifted.<br>
861 /// An interrupted event will also be emitted (if it occurs).<br>
863 public event EventHandler<TouchEventArgs> TouchEvent
869 _stageTouchHandler += value;
870 _stageTouchCallbackDelegate = OnStageTouch;
871 this.TouchSignal().Connect(_stageTouchCallbackDelegate);
878 if (_stageTouchHandler != null)
880 this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
882 _stageTouchHandler -= value;
887 private void OnStageTouch(IntPtr data)
889 TouchEventArgs e = new TouchEventArgs();
893 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(data);
896 if (_stageTouchHandler != null)
898 _stageTouchHandler(this, e);
903 /// Wheel event arguments.
905 public class WheelEventArgs : EventArgs
907 private Wheel _wheel;
925 private event EventHandler<WheelEventArgs> _stageWheelHandler;
926 private EventCallbackDelegateType1 _stageWheelCallbackDelegate;
929 /// Event emitted when wheel event is received.
931 public event EventHandler<WheelEventArgs> WheelEvent
935 if (_stageWheelHandler == null)
937 _stageWheelCallbackDelegate = OnStageWheel;
938 WheelEventSignal().Connect(_stageWheelCallbackDelegate);
940 _stageWheelHandler += value;
944 _stageWheelHandler -= value;
945 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
947 WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
952 private void OnStageWheel(IntPtr data)
954 WheelEventArgs e = new WheelEventArgs();
958 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(data);
961 if (_stageWheelHandler != null)
963 _stageWheelHandler(this, e);
968 /// Key event arguments.
970 public class KeyEventArgs : EventArgs
990 private event EventHandler<KeyEventArgs> _stageKeyHandler;
991 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
994 /// Event emitted when key event is received.
996 public event EventHandler<KeyEventArgs> KeyEvent
1000 if (_stageKeyHandler == null)
1002 _stageKeyCallbackDelegate = OnStageKey;
1003 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
1005 _stageKeyHandler += value;
1009 _stageKeyHandler -= value;
1010 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
1012 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1017 // Callback for Stage KeyEventsignal
1018 private void OnStageKey(IntPtr data)
1020 KeyEventArgs e = new KeyEventArgs();
1024 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1027 if (_stageKeyHandler != null)
1029 //here we send all data to user event handlers
1030 _stageKeyHandler(this, e);
1035 private event EventHandler _stageEventProcessingFinishedEventHandler;
1036 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
1038 internal event EventHandler EventProcessingFinished
1042 if (_stageEventProcessingFinishedEventHandler == null)
1044 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
1045 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
1047 _stageEventProcessingFinishedEventHandler += value;
1052 _stageEventProcessingFinishedEventHandler -= value;
1053 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
1055 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1060 // Callback for Stage EventProcessingFinishedSignal
1061 private void OnEventProcessingFinished()
1063 if (_stageEventProcessingFinishedEventHandler != null)
1065 _stageEventProcessingFinishedEventHandler(this, null);
1070 private EventHandler _stageContextLostEventHandler;
1071 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
1073 internal event EventHandler ContextLost
1077 if (_stageContextLostEventHandler == null)
1079 _stageContextLostEventCallbackDelegate = OnContextLost;
1080 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
1082 _stageContextLostEventHandler += value;
1086 _stageContextLostEventHandler -= value;
1087 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
1089 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1094 // Callback for Stage ContextLostSignal
1095 private void OnContextLost()
1097 if (_stageContextLostEventHandler != null)
1099 _stageContextLostEventHandler(this, null);
1104 private EventHandler _stageContextRegainedEventHandler;
1105 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
1107 internal event EventHandler ContextRegained
1111 if (_stageContextRegainedEventHandler == null)
1113 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
1114 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
1116 _stageContextRegainedEventHandler += value;
1120 _stageContextRegainedEventHandler -= value;
1121 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
1123 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1128 // Callback for Stage ContextRegainedSignal
1129 private void OnContextRegained()
1131 if (_stageContextRegainedEventHandler != null)
1133 _stageContextRegainedEventHandler(this, null);
1138 private EventHandler _stageSceneCreatedEventHandler;
1139 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
1141 internal event EventHandler SceneCreated
1145 if (_stageSceneCreatedEventHandler == null)
1147 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
1148 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
1150 _stageSceneCreatedEventHandler += value;
1154 _stageSceneCreatedEventHandler -= value;
1155 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
1157 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1162 // Callback for Stage SceneCreatedSignal
1163 private void OnSceneCreated()
1165 if (_stageSceneCreatedEventHandler != null)
1167 _stageSceneCreatedEventHandler(this, null);
1171 public class ResizedEventArgs : EventArgs
1175 public Size2D WindowSize
1183 _windowSize = value;
1188 private WindowResizedEventCallbackType _windowResizedEventCallback;
1189 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1190 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
1191 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
1193 public event EventHandler<ResizedEventArgs> Resized
1197 if (_windowResizedEventHandler == null)
1199 _windowResizedEventCallback = OnResized;
1200 ResizedSignal().Connect(_windowResizedEventCallback);
1203 _windowResizedEventHandler += value;
1207 _windowResizedEventHandler -= value;
1209 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
1211 ResizedSignal().Disconnect(_windowResizedEventCallback);
1216 private void OnResized(IntPtr windowSize)
1218 ResizedEventArgs e = new ResizedEventArgs();
1219 var val = new Uint16Pair(windowSize, false);
1220 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1223 if (_windowResizedEventHandler != null)
1225 _windowResizedEventHandler(this, e);
1229 internal void SetWindowSize(Size2D size)
1231 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1232 NDalicManualPINVOKE.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1237 internal Size2D GetWindowSize()
1239 var val = new Uint16Pair(NDalicManualPINVOKE.GetSize(swigCPtr), false);
1240 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1246 internal void SetPosition(Position2D position)
1248 var val = new Uint16Pair( (uint)position.X, (uint)position.Y );
1249 NDalicManualPINVOKE.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254 internal Position2D GetPosition()
1256 var val = new Uint16Pair(NDalicManualPINVOKE.GetPosition(swigCPtr), true);
1257 Position2D ret = new Position2D(val.GetX(), val.GetY());
1259 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264 /// Window size property (read-only).
1270 Size2D ret = GetSize();
1276 /// Background color property.
1278 public Color BackgroundColor
1282 SetBackgroundColor(value);
1286 Color ret = GetBackgroundColor();
1292 /// Dpi property (read-only).<br>
1293 /// Retrieves the DPI of the display device to which the Window is connected.<br>
1304 /// Layer count property (read-only).<br>
1305 /// Queries the number of on-Window layers.<br>
1307 public uint LayerCount
1311 return GetLayerCount();
1317 /// Add layer to the Stage.
1319 /// <param name="layer">Layer to add</param>
1320 public void AddLayer(Layer layer)
1322 NDalicPINVOKE.Stage_Add(stageCPtr, Layer.getCPtr(layer));
1323 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1327 /// Remove layer from the Stage.
1329 /// <param name="layer">Layer to remove</param>
1330 public void RemoveLayer(Layer layer)
1332 NDalicPINVOKE.Stage_Remove(stageCPtr, Layer.getCPtr(layer));
1333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336 [Obsolete("Please do not use! this will be deprecated")]
1337 public class WindowFocusChangedEventArgs : EventArgs
1339 public bool FocusGained
1346 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
1347 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1348 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
1349 private event EventHandler<WindowFocusChangedEventArgs> _windowFocusChangedEventHandler2;
1351 [Obsolete("Please do not use! this will be deprecated. Please use 'FocusChanged' event instead")]
1352 public event EventHandler<WindowFocusChangedEventArgs> WindowFocusChanged
1356 if (_windowFocusChangedEventHandler2 == null)
1358 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
1359 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
1362 _windowFocusChangedEventHandler2 += value;
1366 _windowFocusChangedEventHandler2 -= value;
1368 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
1370 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1375 private void OnWindowFocusedChanged2(bool focusGained)
1377 WindowFocusChangedEventArgs e = new WindowFocusChangedEventArgs();
1379 e.FocusGained = focusGained;
1381 if (_windowFocusChangedEventHandler2 != null)
1383 _windowFocusChangedEventHandler2(this, e);
1388 /// Gets/Sets a size of the window.
1390 public Size2D WindowSize
1394 return GetWindowSize();
1398 SetWindowSize(value);
1403 /// Gets/Sets a position of the window.
1405 public Position2D WindowPosition
1409 return GetPosition();