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;
24 internal class PageTurnView : View
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal PageTurnView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PageTurnView_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PageTurnView obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 if (type == DisposeTypes.Explicit)
48 //Release your own managed resources here.
49 //You should release all of your own disposable objects here.
53 //Release your own unmanaged resources here.
54 //You should not access any managed member here except static instance.
55 //because the execution order of Finalizes is non-deterministic.
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
62 NDalicPINVOKE.delete_PageTurnView(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73 public class PagePanStartedEventArgs : EventArgs
75 private PageTurnView _pageTurnView;
77 public PageTurnView PageTurnView
85 _pageTurnView = value;
90 public class PagePanFinishedEventArgs : EventArgs
92 private PageTurnView _pageTurnView;
94 public PageTurnView PageTurnView
102 _pageTurnView = value;
107 public class PageTurnStartedEventArgs : EventArgs
109 private PageTurnView _pageTurnView;
110 private uint _pageIndex;
111 private bool _isTurningForward;
113 public PageTurnView PageTurnView
117 return _pageTurnView;
121 _pageTurnView = value;
125 public uint PageIndex
137 public bool IsTurningForward
141 return _isTurningForward;
145 _isTurningForward = value;
151 public class PageTurnFinishedEventArgs : EventArgs
153 private PageTurnView _pageTurnView;
154 private uint _pageIndex;
155 private bool _isTurningForward;
157 public PageTurnView PageTurnView
161 return _pageTurnView;
165 _pageTurnView = value;
169 public uint PageIndex
181 public bool IsTurningForward
185 return _isTurningForward;
189 _isTurningForward = value;
195 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
196 private delegate void PagePanStartedCallbackDelegate(IntPtr page);
197 private DaliEventHandler<object, PagePanStartedEventArgs> _pageTurnViewPagePanStartedEventHandler;
198 private PagePanStartedCallbackDelegate _pageTurnViewPagePanStartedCallbackDelegate;
200 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
201 private delegate void PagePanFinishedCallbackDelegate(IntPtr page);
202 private DaliEventHandler<object, PagePanFinishedEventArgs> _pageTurnViewPagePanFinishedEventHandler;
203 private PagePanFinishedCallbackDelegate _pageTurnViewPagePanFinishedCallbackDelegate;
205 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
206 private delegate void PageTurnStartedCallbackDelegate(IntPtr page, uint pageIndex, bool isTurningForward);
207 private DaliEventHandler<object, PageTurnStartedEventArgs> _pageTurnViewPageTurnStartedEventHandler;
208 private PageTurnStartedCallbackDelegate _pageTurnViewPageTurnStartedCallbackDelegate;
210 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
211 private delegate void PageTurnFinishedCallbackDelegate(IntPtr page, uint pageIndex, bool isTurningForward);
212 private DaliEventHandler<object, PageTurnFinishedEventArgs> _pageTurnViewPageTurnFinishedEventHandler;
213 private PageTurnFinishedCallbackDelegate _pageTurnViewPageTurnFinishedCallbackDelegate;
215 public event DaliEventHandler<object, PagePanStartedEventArgs> PagePanStarted
221 // Restricted to only one listener
222 if (_pageTurnViewPagePanStartedEventHandler == null)
224 _pageTurnViewPagePanStartedEventHandler += value;
226 _pageTurnViewPagePanStartedCallbackDelegate = new PagePanStartedCallbackDelegate(OnPagePanStarted);
227 this.PagePanStartedSignal().Connect(_pageTurnViewPagePanStartedCallbackDelegate);
236 if (_pageTurnViewPagePanStartedEventHandler != null)
238 this.PagePanStartedSignal().Disconnect(_pageTurnViewPagePanStartedCallbackDelegate);
241 _pageTurnViewPagePanStartedEventHandler -= value;
246 // Callback for PageTurnView PagePanStarted signal
247 private void OnPagePanStarted(IntPtr page)
249 PagePanStartedEventArgs e = new PagePanStartedEventArgs();
251 // Populate all members of "e" (PagePanStartedEventArgs) with real page
252 e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
254 if (_pageTurnViewPagePanStartedEventHandler != null)
256 //here we send all page to user event handlers
257 _pageTurnViewPagePanStartedEventHandler(this, e);
261 public event DaliEventHandler<object, PagePanFinishedEventArgs> PagePanFinished
267 // Restricted to only one listener
268 if (_pageTurnViewPagePanFinishedEventHandler == null)
270 _pageTurnViewPagePanFinishedEventHandler += value;
272 _pageTurnViewPagePanFinishedCallbackDelegate = new PagePanFinishedCallbackDelegate(OnPagePanFinished);
273 this.PagePanFinishedSignal().Connect(_pageTurnViewPagePanFinishedCallbackDelegate);
282 if (_pageTurnViewPagePanFinishedEventHandler != null)
284 this.PagePanFinishedSignal().Disconnect(_pageTurnViewPagePanFinishedCallbackDelegate);
287 _pageTurnViewPagePanFinishedEventHandler -= value;
292 // Callback for PageTurnView PagePanFinished signal
293 private void OnPagePanFinished(IntPtr page)
295 PagePanFinishedEventArgs e = new PagePanFinishedEventArgs();
297 // Populate all members of "e" (PagePanFinishedEventArgs) with real page
298 e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
300 if (_pageTurnViewPagePanFinishedEventHandler != null)
302 //here we send all page to user event handlers
303 _pageTurnViewPagePanFinishedEventHandler(this, e);
308 public event DaliEventHandler<object, PageTurnStartedEventArgs> PageTurnStarted
314 // Restricted to only one listener
315 if (_pageTurnViewPageTurnStartedEventHandler == null)
317 _pageTurnViewPageTurnStartedEventHandler += value;
319 _pageTurnViewPageTurnStartedCallbackDelegate = new PageTurnStartedCallbackDelegate(OnPageTurnStarted);
320 this.PageTurnStartedSignal().Connect(_pageTurnViewPageTurnStartedCallbackDelegate);
329 if (_pageTurnViewPageTurnStartedEventHandler != null)
331 this.PageTurnStartedSignal().Disconnect(_pageTurnViewPageTurnStartedCallbackDelegate);
334 _pageTurnViewPageTurnStartedEventHandler -= value;
339 // Callback for PageTurnView PageTurnStarted signal
340 private void OnPageTurnStarted(IntPtr page, uint pageIndex, bool isTurningForward)
342 PageTurnStartedEventArgs e = new PageTurnStartedEventArgs();
344 // Populate all members of "e" (PageTurnStartedEventArgs) with real page
345 e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
346 e.PageIndex = pageIndex;
347 e.IsTurningForward = isTurningForward;
350 if (_pageTurnViewPageTurnStartedEventHandler != null)
352 //here we send all page to user event handlers
353 _pageTurnViewPageTurnStartedEventHandler(this, e);
358 public event DaliEventHandler<object, PageTurnFinishedEventArgs> PageTurnFinished
364 // Restricted to only one listener
365 if (_pageTurnViewPageTurnFinishedEventHandler == null)
367 _pageTurnViewPageTurnFinishedEventHandler += value;
369 _pageTurnViewPageTurnFinishedCallbackDelegate = new PageTurnFinishedCallbackDelegate(OnPageTurnFinished);
370 this.PageTurnFinishedSignal().Connect(_pageTurnViewPageTurnFinishedCallbackDelegate);
379 if (_pageTurnViewPageTurnFinishedEventHandler != null)
381 this.PageTurnFinishedSignal().Disconnect(_pageTurnViewPageTurnFinishedCallbackDelegate);
384 _pageTurnViewPageTurnFinishedEventHandler -= value;
389 // Callback for PageTurnView PageTurnFinished signal
390 private void OnPageTurnFinished(IntPtr page, uint pageIndex, bool isTurningForward)
392 PageTurnFinishedEventArgs e = new PageTurnFinishedEventArgs();
394 // Populate all members of "e" (PageTurnFinishedEventArgs) with real page
395 e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
396 e.PageIndex = pageIndex;
397 e.IsTurningForward = isTurningForward;
400 if (_pageTurnViewPageTurnFinishedEventHandler != null)
402 //here we send all page to user event handlers
403 _pageTurnViewPageTurnFinishedEventHandler(this, e);
407 public static PageTurnView GetPageTurnViewFromPtr(global::System.IntPtr cPtr)
409 PageTurnView ret = new PageTurnView(cPtr, false);
410 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 public class Property : global::System.IDisposable
417 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
418 protected bool swigCMemOwn;
420 internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
422 swigCMemOwn = cMemoryOwn;
423 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
426 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
428 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
431 //A Flag to check who called Dispose(). (By User or DisposeQueue)
432 private bool isDisposeQueued = false;
433 //A Flat to check if it is already disposed.
434 protected bool disposed = false;
439 if (!isDisposeQueued)
441 isDisposeQueued = true;
442 DisposeQueue.Instance.Add(this);
446 public void Dispose()
448 //Throw excpetion if Dispose() is called in separate thread.
449 if (!Window.IsInstalled())
451 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
456 Dispose(DisposeTypes.Implicit);
460 Dispose(DisposeTypes.Explicit);
461 System.GC.SuppressFinalize(this);
465 protected virtual void Dispose(DisposeTypes type)
472 if (type == DisposeTypes.Explicit)
475 //Release your own managed resources here.
476 //You should release all of your own disposable objects here.
480 //Release your own unmanaged resources here.
481 //You should not access any managed member here except static instance.
482 //because the execution order of Finalizes is non-deterministic.
484 if (swigCPtr.Handle != global::System.IntPtr.Zero)
489 NDalicPINVOKE.delete_PageTurnView_Property(swigCPtr);
491 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
497 public Property() : this(NDalicPINVOKE.new_PageTurnView_Property(), true)
499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
502 public static readonly int PAGE_SIZE = NDalicPINVOKE.PageTurnView_Property_PAGE_SIZE_get();
503 public static readonly int CURRENT_PAGE_ID = NDalicPINVOKE.PageTurnView_Property_CURRENT_PAGE_ID_get();
504 public static readonly int SPINE_SHADOW = NDalicPINVOKE.PageTurnView_Property_SPINE_SHADOW_get();
508 public PageTurnView() : this(NDalicPINVOKE.new_PageTurnView__SWIG_0(), true)
510 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
513 public PageTurnView(PageTurnView handle) : this(NDalicPINVOKE.new_PageTurnView__SWIG_1(PageTurnView.getCPtr(handle)), true)
515 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
518 public PageTurnView Assign(PageTurnView handle)
520 PageTurnView ret = new PageTurnView(NDalicPINVOKE.PageTurnView_Assign(swigCPtr, PageTurnView.getCPtr(handle)), false);
521 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
525 public new static PageTurnView DownCast(BaseHandle handle)
527 PageTurnView ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as PageTurnView;
528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
532 public PageTurnSignal PageTurnStartedSignal()
534 PageTurnSignal ret = new PageTurnSignal(NDalicPINVOKE.PageTurnView_PageTurnStartedSignal(swigCPtr), false);
535 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539 public PageTurnSignal PageTurnFinishedSignal()
541 PageTurnSignal ret = new PageTurnSignal(NDalicPINVOKE.PageTurnView_PageTurnFinishedSignal(swigCPtr), false);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 public PagePanSignal PagePanStartedSignal()
548 PagePanSignal ret = new PagePanSignal(NDalicPINVOKE.PageTurnView_PagePanStartedSignal(swigCPtr), false);
549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
553 public PagePanSignal PagePanFinishedSignal()
555 PagePanSignal ret = new PagePanSignal(NDalicPINVOKE.PageTurnView_PagePanFinishedSignal(swigCPtr), false);
556 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
561 public Vector2 PageSize
565 Vector2 temp = new Vector2(0.0f, 0.0f);
566 GetProperty(PageTurnView.Property.PAGE_SIZE).Get(temp);
571 SetProperty(PageTurnView.Property.PAGE_SIZE, new Tizen.NUI.PropertyValue(value));
574 public int CurrentPageId
579 GetProperty(PageTurnView.Property.CURRENT_PAGE_ID).Get(out temp);
584 SetProperty(PageTurnView.Property.CURRENT_PAGE_ID, new Tizen.NUI.PropertyValue(value));
587 public Vector2 SpineShadow
591 Vector2 temp = new Vector2(0.0f, 0.0f);
592 GetProperty(PageTurnView.Property.SPINE_SHADOW).Get(temp);
597 SetProperty(PageTurnView.Property.SPINE_SHADOW, new Tizen.NUI.PropertyValue(value));