sync with tizen branch to finalize API
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / PageTurnView.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
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
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     using System;
21     using System.Runtime.InteropServices;
22     using Tizen.NUI.BaseComponents;
23
24     internal class PageTurnView : View
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27
28         internal PageTurnView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.PageTurnView_SWIGUpcast(cPtr), cMemoryOwn)
29         {
30             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
31         }
32
33         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PageTurnView obj)
34         {
35             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36         }
37
38         protected override void Dispose(DisposeTypes type)
39         {
40             if (disposed)
41             {
42                 return;
43             }
44
45             if (type == DisposeTypes.Explicit)
46             {
47                 //Called by User
48                 //Release your own managed resources here.
49                 //You should release all of your own disposable objects here.
50
51             }
52
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.
56
57             if (swigCPtr.Handle != global::System.IntPtr.Zero)
58             {
59                 if (swigCMemOwn)
60                 {
61                     swigCMemOwn = false;
62                     NDalicPINVOKE.delete_PageTurnView(swigCPtr);
63                 }
64                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65             }
66
67             base.Dispose(type);
68         }
69
70
71
72
73         public class PagePanStartedEventArgs : EventArgs
74         {
75             private PageTurnView _pageTurnView;
76
77             public PageTurnView PageTurnView
78             {
79                 get
80                 {
81                     return _pageTurnView;
82                 }
83                 set
84                 {
85                     _pageTurnView = value;
86                 }
87             }
88         }
89
90         public class PagePanFinishedEventArgs : EventArgs
91         {
92             private PageTurnView _pageTurnView;
93
94             public PageTurnView PageTurnView
95             {
96                 get
97                 {
98                     return _pageTurnView;
99                 }
100                 set
101                 {
102                     _pageTurnView = value;
103                 }
104             }
105         }
106
107         public class PageTurnStartedEventArgs : EventArgs
108         {
109             private PageTurnView _pageTurnView;
110             private uint _pageIndex;
111             private bool _isTurningForward;
112
113             public PageTurnView PageTurnView
114             {
115                 get
116                 {
117                     return _pageTurnView;
118                 }
119                 set
120                 {
121                     _pageTurnView = value;
122                 }
123             }
124
125             public uint PageIndex
126             {
127                 get
128                 {
129                     return _pageIndex;
130                 }
131                 set
132                 {
133                     _pageIndex = value;
134                 }
135             }
136
137             public bool IsTurningForward
138             {
139                 get
140                 {
141                     return _isTurningForward;
142                 }
143                 set
144                 {
145                     _isTurningForward = value;
146                 }
147             }
148
149         }
150
151         public class PageTurnFinishedEventArgs : EventArgs
152         {
153             private PageTurnView _pageTurnView;
154             private uint _pageIndex;
155             private bool _isTurningForward;
156
157             public PageTurnView PageTurnView
158             {
159                 get
160                 {
161                     return _pageTurnView;
162                 }
163                 set
164                 {
165                     _pageTurnView = value;
166                 }
167             }
168
169             public uint PageIndex
170             {
171                 get
172                 {
173                     return _pageIndex;
174                 }
175                 set
176                 {
177                     _pageIndex = value;
178                 }
179             }
180
181             public bool IsTurningForward
182             {
183                 get
184                 {
185                     return _isTurningForward;
186                 }
187                 set
188                 {
189                     _isTurningForward = value;
190                 }
191             }
192
193         }
194
195         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
196         private delegate void PagePanStartedCallbackDelegate(IntPtr page);
197         private DaliEventHandler<object, PagePanStartedEventArgs> _pageTurnViewPagePanStartedEventHandler;
198         private PagePanStartedCallbackDelegate _pageTurnViewPagePanStartedCallbackDelegate;
199
200         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
201         private delegate void PagePanFinishedCallbackDelegate(IntPtr page);
202         private DaliEventHandler<object, PagePanFinishedEventArgs> _pageTurnViewPagePanFinishedEventHandler;
203         private PagePanFinishedCallbackDelegate _pageTurnViewPagePanFinishedCallbackDelegate;
204
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;
209
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;
214
215         public event DaliEventHandler<object, PagePanStartedEventArgs> PagePanStarted
216         {
217             add
218             {
219                 lock (this)
220                 {
221                     // Restricted to only one listener
222                     if (_pageTurnViewPagePanStartedEventHandler == null)
223                     {
224                         _pageTurnViewPagePanStartedEventHandler += value;
225
226                         _pageTurnViewPagePanStartedCallbackDelegate = new PagePanStartedCallbackDelegate(OnPagePanStarted);
227                         this.PagePanStartedSignal().Connect(_pageTurnViewPagePanStartedCallbackDelegate);
228                     }
229                 }
230             }
231
232             remove
233             {
234                 lock (this)
235                 {
236                     if (_pageTurnViewPagePanStartedEventHandler != null)
237                     {
238                         this.PagePanStartedSignal().Disconnect(_pageTurnViewPagePanStartedCallbackDelegate);
239                     }
240
241                     _pageTurnViewPagePanStartedEventHandler -= value;
242                 }
243             }
244         }
245
246         // Callback for PageTurnView PagePanStarted signal
247         private void OnPagePanStarted(IntPtr page)
248         {
249             PagePanStartedEventArgs e = new PagePanStartedEventArgs();
250
251             // Populate all members of "e" (PagePanStartedEventArgs) with real page
252             e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
253
254             if (_pageTurnViewPagePanStartedEventHandler != null)
255             {
256                 //here we send all page to user event handlers
257                 _pageTurnViewPagePanStartedEventHandler(this, e);
258             }
259         }
260
261         public event DaliEventHandler<object, PagePanFinishedEventArgs> PagePanFinished
262         {
263             add
264             {
265                 lock (this)
266                 {
267                     // Restricted to only one listener
268                     if (_pageTurnViewPagePanFinishedEventHandler == null)
269                     {
270                         _pageTurnViewPagePanFinishedEventHandler += value;
271
272                         _pageTurnViewPagePanFinishedCallbackDelegate = new PagePanFinishedCallbackDelegate(OnPagePanFinished);
273                         this.PagePanFinishedSignal().Connect(_pageTurnViewPagePanFinishedCallbackDelegate);
274                     }
275                 }
276             }
277
278             remove
279             {
280                 lock (this)
281                 {
282                     if (_pageTurnViewPagePanFinishedEventHandler != null)
283                     {
284                         this.PagePanFinishedSignal().Disconnect(_pageTurnViewPagePanFinishedCallbackDelegate);
285                     }
286
287                     _pageTurnViewPagePanFinishedEventHandler -= value;
288                 }
289             }
290         }
291
292         // Callback for PageTurnView PagePanFinished signal
293         private void OnPagePanFinished(IntPtr page)
294         {
295             PagePanFinishedEventArgs e = new PagePanFinishedEventArgs();
296
297             // Populate all members of "e" (PagePanFinishedEventArgs) with real page
298             e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
299
300             if (_pageTurnViewPagePanFinishedEventHandler != null)
301             {
302                 //here we send all page to user event handlers
303                 _pageTurnViewPagePanFinishedEventHandler(this, e);
304             }
305         }
306
307
308         public event DaliEventHandler<object, PageTurnStartedEventArgs> PageTurnStarted
309         {
310             add
311             {
312                 lock (this)
313                 {
314                     // Restricted to only one listener
315                     if (_pageTurnViewPageTurnStartedEventHandler == null)
316                     {
317                         _pageTurnViewPageTurnStartedEventHandler += value;
318
319                         _pageTurnViewPageTurnStartedCallbackDelegate = new PageTurnStartedCallbackDelegate(OnPageTurnStarted);
320                         this.PageTurnStartedSignal().Connect(_pageTurnViewPageTurnStartedCallbackDelegate);
321                     }
322                 }
323             }
324
325             remove
326             {
327                 lock (this)
328                 {
329                     if (_pageTurnViewPageTurnStartedEventHandler != null)
330                     {
331                         this.PageTurnStartedSignal().Disconnect(_pageTurnViewPageTurnStartedCallbackDelegate);
332                     }
333
334                     _pageTurnViewPageTurnStartedEventHandler -= value;
335                 }
336             }
337         }
338
339         // Callback for PageTurnView PageTurnStarted signal
340         private void OnPageTurnStarted(IntPtr page, uint pageIndex, bool isTurningForward)
341         {
342             PageTurnStartedEventArgs e = new PageTurnStartedEventArgs();
343
344             // Populate all members of "e" (PageTurnStartedEventArgs) with real page
345             e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
346             e.PageIndex = pageIndex;
347             e.IsTurningForward = isTurningForward;
348
349
350             if (_pageTurnViewPageTurnStartedEventHandler != null)
351             {
352                 //here we send all page to user event handlers
353                 _pageTurnViewPageTurnStartedEventHandler(this, e);
354             }
355         }
356
357
358         public event DaliEventHandler<object, PageTurnFinishedEventArgs> PageTurnFinished
359         {
360             add
361             {
362                 lock (this)
363                 {
364                     // Restricted to only one listener
365                     if (_pageTurnViewPageTurnFinishedEventHandler == null)
366                     {
367                         _pageTurnViewPageTurnFinishedEventHandler += value;
368
369                         _pageTurnViewPageTurnFinishedCallbackDelegate = new PageTurnFinishedCallbackDelegate(OnPageTurnFinished);
370                         this.PageTurnFinishedSignal().Connect(_pageTurnViewPageTurnFinishedCallbackDelegate);
371                     }
372                 }
373             }
374
375             remove
376             {
377                 lock (this)
378                 {
379                     if (_pageTurnViewPageTurnFinishedEventHandler != null)
380                     {
381                         this.PageTurnFinishedSignal().Disconnect(_pageTurnViewPageTurnFinishedCallbackDelegate);
382                     }
383
384                     _pageTurnViewPageTurnFinishedEventHandler -= value;
385                 }
386             }
387         }
388
389         // Callback for PageTurnView PageTurnFinished signal
390         private void OnPageTurnFinished(IntPtr page, uint pageIndex, bool isTurningForward)
391         {
392             PageTurnFinishedEventArgs e = new PageTurnFinishedEventArgs();
393
394             // Populate all members of "e" (PageTurnFinishedEventArgs) with real page
395             e.PageTurnView = PageTurnView.GetPageTurnViewFromPtr(page);
396             e.PageIndex = pageIndex;
397             e.IsTurningForward = isTurningForward;
398
399
400             if (_pageTurnViewPageTurnFinishedEventHandler != null)
401             {
402                 //here we send all page to user event handlers
403                 _pageTurnViewPageTurnFinishedEventHandler(this, e);
404             }
405         }
406
407         public static PageTurnView GetPageTurnViewFromPtr(global::System.IntPtr cPtr)
408         {
409             PageTurnView ret = new PageTurnView(cPtr, false);
410             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411             return ret;
412         }
413
414
415         public class Property : global::System.IDisposable
416         {
417             private global::System.Runtime.InteropServices.HandleRef swigCPtr;
418             protected bool swigCMemOwn;
419
420             internal Property(global::System.IntPtr cPtr, bool cMemoryOwn)
421             {
422                 swigCMemOwn = cMemoryOwn;
423                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
424             }
425
426             internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Property obj)
427             {
428                 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
429             }
430
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;
435
436
437             ~Property()
438             {
439                 if (!isDisposeQueued)
440                 {
441                     isDisposeQueued = true;
442                     DisposeQueue.Instance.Add(this);
443                 }
444             }
445
446             public void Dispose()
447             {
448                 //Throw excpetion if Dispose() is called in separate thread.
449                 if (!Window.IsInstalled())
450                 {
451                     throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
452                 }
453
454                 if (isDisposeQueued)
455                 {
456                     Dispose(DisposeTypes.Implicit);
457                 }
458                 else
459                 {
460                     Dispose(DisposeTypes.Explicit);
461                     System.GC.SuppressFinalize(this);
462                 }
463             }
464
465             protected virtual void Dispose(DisposeTypes type)
466             {
467                 if (disposed)
468                 {
469                     return;
470                 }
471
472                 if (type == DisposeTypes.Explicit)
473                 {
474                     //Called by User
475                     //Release your own managed resources here.
476                     //You should release all of your own disposable objects here.
477
478                 }
479
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.
483
484                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
485                 {
486                     if (swigCMemOwn)
487                     {
488                         swigCMemOwn = false;
489                         NDalicPINVOKE.delete_PageTurnView_Property(swigCPtr);
490                     }
491                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
492                 }
493
494                 disposed = true;
495             }
496
497             public Property() : this(NDalicPINVOKE.new_PageTurnView_Property(), true)
498             {
499                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
500             }
501
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();
505
506         }
507
508         public PageTurnView() : this(NDalicPINVOKE.new_PageTurnView__SWIG_0(), true)
509         {
510             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
511         }
512
513         public PageTurnView(PageTurnView handle) : this(NDalicPINVOKE.new_PageTurnView__SWIG_1(PageTurnView.getCPtr(handle)), true)
514         {
515             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
516         }
517
518         public PageTurnView Assign(PageTurnView handle)
519         {
520             PageTurnView ret = new PageTurnView(NDalicPINVOKE.PageTurnView_Assign(swigCPtr, PageTurnView.getCPtr(handle)), false);
521             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522             return ret;
523         }
524
525         public new static PageTurnView DownCast(BaseHandle handle)
526         {
527             PageTurnView ret = new PageTurnView(NDalicPINVOKE.PageTurnView_DownCast(BaseHandle.getCPtr(handle)), true);
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529             return ret;
530         }
531
532         public PageTurnSignal PageTurnStartedSignal()
533         {
534             PageTurnSignal ret = new PageTurnSignal(NDalicPINVOKE.PageTurnView_PageTurnStartedSignal(swigCPtr), false);
535             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536             return ret;
537         }
538
539         public PageTurnSignal PageTurnFinishedSignal()
540         {
541             PageTurnSignal ret = new PageTurnSignal(NDalicPINVOKE.PageTurnView_PageTurnFinishedSignal(swigCPtr), false);
542             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543             return ret;
544         }
545
546         public PagePanSignal PagePanStartedSignal()
547         {
548             PagePanSignal ret = new PagePanSignal(NDalicPINVOKE.PageTurnView_PagePanStartedSignal(swigCPtr), false);
549             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550             return ret;
551         }
552
553         public PagePanSignal PagePanFinishedSignal()
554         {
555             PagePanSignal ret = new PagePanSignal(NDalicPINVOKE.PageTurnView_PagePanFinishedSignal(swigCPtr), false);
556             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557             return ret;
558         }
559
560
561         public Vector2 PageSize
562         {
563             get
564             {
565                 Vector2 temp = new Vector2(0.0f, 0.0f);
566                 GetProperty(PageTurnView.Property.PAGE_SIZE).Get(temp);
567                 return temp;
568             }
569             set
570             {
571                 SetProperty(PageTurnView.Property.PAGE_SIZE, new Tizen.NUI.PropertyValue(value));
572             }
573         }
574         public int CurrentPageId
575         {
576             get
577             {
578                 int temp = 0;
579                 GetProperty(PageTurnView.Property.CURRENT_PAGE_ID).Get(out temp);
580                 return temp;
581             }
582             set
583             {
584                 SetProperty(PageTurnView.Property.CURRENT_PAGE_ID, new Tizen.NUI.PropertyValue(value));
585             }
586         }
587         public Vector2 SpineShadow
588         {
589             get
590             {
591                 Vector2 temp = new Vector2(0.0f, 0.0f);
592                 GetProperty(PageTurnView.Property.SPINE_SHADOW).Get(temp);
593                 return temp;
594             }
595             set
596             {
597                 SetProperty(PageTurnView.Property.SPINE_SHADOW, new Tizen.NUI.PropertyValue(value));
598             }
599         }
600
601     }
602
603 }