828af761fe862f0728fb8907d2aa558078997fb8
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / UIComponents / ScrollBar.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 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 //------------------------------------------------------------------------------
18 // <auto-generated />
19 //
20 // This file was automatically generated by SWIG (http://www.swig.org).
21 // Version 3.0.9
22 //
23 // Do not make changes to this file unless you know what you are doing--modify
24 // the SWIG interface file instead.
25 //------------------------------------------------------------------------------
26
27 namespace Tizen.NUI.UIComponents
28 {
29
30     using System;
31     using System.Runtime.InteropServices;
32     using Tizen.NUI.BaseComponents;
33
34     /// <summary>
35     /// ScrollBar is a UI component that can be linked to the scrollable objects
36     /// indicating the current scroll position of the scrollable object.<br>
37     /// </summary>
38     public class ScrollBar : View
39     {
40         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
41
42         internal ScrollBar(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ScrollBar_SWIGUpcast(cPtr), cMemoryOwn)
43         {
44             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
45             // By default, we do not want the position to use the anchor point
46             PositionUsesAnchorPoint = false;
47         }
48
49         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ScrollBar obj)
50         {
51             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
52         }
53
54         /// <summary>
55         /// To make ScrollBar instance be disposed.
56         /// </summary>
57         protected override void Dispose(DisposeTypes type)
58         {
59             if (disposed)
60             {
61                 return;
62             }
63
64             if(type == DisposeTypes.Explicit)
65             {
66                 //Called by User
67                 //Release your own managed resources here.
68                 //You should release all of your own disposable objects here.
69             }
70
71             //Release your own unmanaged resources here.
72             //You should not access any managed member here except static instance.
73             //because the execution order of Finalizes is non-deterministic.
74
75             if (swigCPtr.Handle != global::System.IntPtr.Zero)
76             {
77                 if (swigCMemOwn)
78                 {
79                     swigCMemOwn = false;
80                     NDalicPINVOKE.delete_ScrollBar(swigCPtr);
81                 }
82                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
83             }
84
85             base.Dispose(type);
86         }
87
88         /// <summary>
89         /// Event arguments that passed via PanFinished event
90         /// </summary>
91         public class PanFinishedEventArgs : EventArgs
92         {
93         }
94
95         /// <summary>
96         /// Event arguments that passed via ScrollPositionIntervalReached event
97         /// </summary>
98         public class ScrollIntervalEventArgs : EventArgs
99         {
100             private float _currentScrollPosition;
101
102             /// <summary>
103             /// current scroll position of the scrollable content
104             /// </summary>
105             public float CurrentScrollPosition
106             {
107                 get
108                 {
109                     return _currentScrollPosition;
110                 }
111                 set
112                 {
113                     _currentScrollPosition = value;
114                 }
115             }
116         }
117
118         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
119         private delegate void PanFinishedEventCallbackDelegate();
120         private EventHandler<PanFinishedEventArgs> _scrollBarPanFinishedEventHandler;
121         private PanFinishedEventCallbackDelegate _scrollBarPanFinishedEventCallbackDelegate;
122
123         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
124         private delegate void ScrollPositionIntervalReachedEventCallbackDelegate();
125         private EventHandler<ScrollIntervalEventArgs> _scrollBarScrollPositionIntervalReachedEventHandler;
126         private ScrollPositionIntervalReachedEventCallbackDelegate _scrollBarScrollPositionIntervalReachedEventCallbackDelegate;
127
128         /// <summary>
129         /// Event emitted when panning is finished on the scroll indicator.
130         /// </summary>
131         public event EventHandler<PanFinishedEventArgs> PanFinished
132         {
133             add
134             {
135                 if (_scrollBarPanFinishedEventHandler == null)
136                 {
137                     _scrollBarPanFinishedEventCallbackDelegate = (OnScrollBarPanFinished);
138                     PanFinishedSignal().Connect(_scrollBarPanFinishedEventCallbackDelegate);
139                 }
140                 _scrollBarPanFinishedEventHandler += value;
141             }
142             remove
143             {
144                 _scrollBarPanFinishedEventHandler -= value;
145                 if (_scrollBarPanFinishedEventHandler == null && PanFinishedSignal().Empty() == false)
146                 {
147                     PanFinishedSignal().Disconnect(_scrollBarPanFinishedEventCallbackDelegate);
148                 }
149             }
150         }
151
152         // Callback for ScrollBar PanFinishedSignal
153         private void OnScrollBarPanFinished()
154         {
155             PanFinishedEventArgs e = new PanFinishedEventArgs();
156
157             if (_scrollBarPanFinishedEventHandler != null)
158             {
159                 //here we send all data to user event handlers
160                 _scrollBarPanFinishedEventHandler(this, e);
161             }
162         }
163
164
165         /// <summary>
166         /// Event emitted when the current scroll position of the scrollable content
167         /// </summary>
168         public event EventHandler<ScrollIntervalEventArgs> ScrollInterval
169         {
170             add
171             {
172                 if (_scrollBarScrollPositionIntervalReachedEventHandler == null)
173                 {
174                     _scrollBarScrollPositionIntervalReachedEventCallbackDelegate = (OnScrollBarScrollPositionIntervalReached);
175                     ScrollPositionIntervalReachedSignal().Connect(_scrollBarScrollPositionIntervalReachedEventCallbackDelegate);
176                 }
177                 _scrollBarScrollPositionIntervalReachedEventHandler += value;
178             }
179             remove
180             {
181                 _scrollBarScrollPositionIntervalReachedEventHandler -= value;
182                 if (_scrollBarScrollPositionIntervalReachedEventHandler == null && ScrollPositionIntervalReachedSignal().Empty() == false)
183                 {
184                     ScrollPositionIntervalReachedSignal().Disconnect(_scrollBarScrollPositionIntervalReachedEventCallbackDelegate);
185                 }
186             }
187         }
188
189         // Callback for ScrollBar ScrollPositionIntervalReachedSignal
190         private void OnScrollBarScrollPositionIntervalReached()
191         {
192             ScrollIntervalEventArgs e = new ScrollIntervalEventArgs();
193
194             if (_scrollBarScrollPositionIntervalReachedEventHandler != null)
195             {
196                 //here we send all data to user event handlers
197                 _scrollBarScrollPositionIntervalReachedEventHandler(this, e);
198             }
199         }
200
201
202         internal class Property
203         {
204             internal static readonly int SCROLL_DIRECTION = NDalicPINVOKE.ScrollBar_Property_SCROLL_DIRECTION_get();
205             internal static readonly int INDICATOR_HEIGHT_POLICY = NDalicPINVOKE.ScrollBar_Property_INDICATOR_HEIGHT_POLICY_get();
206             internal static readonly int INDICATOR_FIXED_HEIGHT = NDalicPINVOKE.ScrollBar_Property_INDICATOR_FIXED_HEIGHT_get();
207             internal static readonly int INDICATOR_SHOW_DURATION = NDalicPINVOKE.ScrollBar_Property_INDICATOR_SHOW_DURATION_get();
208             internal static readonly int INDICATOR_HIDE_DURATION = NDalicPINVOKE.ScrollBar_Property_INDICATOR_HIDE_DURATION_get();
209             internal static readonly int SCROLL_POSITION_INTERVALS = NDalicPINVOKE.ScrollBar_Property_SCROLL_POSITION_INTERVALS_get();
210             internal static readonly int INDICATOR_MINIMUM_HEIGHT = NDalicPINVOKE.ScrollBar_Property_INDICATOR_MINIMUM_HEIGHT_get();
211             internal static readonly int INDICATOR_START_PADDING = NDalicPINVOKE.ScrollBar_Property_INDICATOR_START_PADDING_get();
212             internal static readonly int INDICATOR_END_PADDING = NDalicPINVOKE.ScrollBar_Property_INDICATOR_END_PADDING_get();
213         }
214
215         /// <summary>
216         /// Creates an initialized ScrollBar.
217         /// </summary>
218         /// <param name="direction">The direction of scroll bar (either vertically or horizontally)</param>
219         public ScrollBar(ScrollBar.Direction direction) : this(NDalicPINVOKE.ScrollBar_New__SWIG_0((int)direction), true)
220         {
221             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
222         }
223
224         /// <summary>
225         /// Creates an uninitialized ScrollBar
226         /// </summary>
227         public ScrollBar() : this(NDalicPINVOKE.ScrollBar_New__SWIG_1(), true)
228         {
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230
231         }
232         internal ScrollBar(ScrollBar scrollBar) : this(NDalicPINVOKE.new_ScrollBar__SWIG_1(ScrollBar.getCPtr(scrollBar)), true)
233         {
234             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235         }
236
237         internal void SetScrollPropertySource(Animatable handle, int propertyScrollPosition, int propertyMinScrollPosition, int propertyMaxScrollPosition, int propertyScrollContentSize)
238         {
239             NDalicPINVOKE.ScrollBar_SetScrollPropertySource(swigCPtr, Animatable.getCPtr(handle), propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize);
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241         }
242
243         internal void SetScrollIndicator(View indicator)
244         {
245             NDalicPINVOKE.ScrollBar_SetScrollIndicator(swigCPtr, View.getCPtr(indicator));
246             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247         }
248
249         internal View GetScrollIndicator()
250         {
251             View ret = new View(NDalicPINVOKE.ScrollBar_GetScrollIndicator(swigCPtr), true);
252             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253             return ret;
254         }
255
256         internal void SetScrollDirection(ScrollBar.Direction direction)
257         {
258             NDalicPINVOKE.ScrollBar_SetScrollDirection(swigCPtr, (int)direction);
259             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260         }
261
262         internal ScrollBar.Direction GetScrollDirection()
263         {
264             ScrollBar.Direction ret = (ScrollBar.Direction)NDalicPINVOKE.ScrollBar_GetScrollDirection(swigCPtr);
265             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266             return ret;
267         }
268
269         internal void SetIndicatorHeightPolicy(ScrollBar.IndicatorHeightPolicyType policy)
270         {
271             NDalicPINVOKE.ScrollBar_SetIndicatorHeightPolicy(swigCPtr, (int)policy);
272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273         }
274
275         internal ScrollBar.IndicatorHeightPolicyType GetIndicatorHeightPolicy()
276         {
277             ScrollBar.IndicatorHeightPolicyType ret = (ScrollBar.IndicatorHeightPolicyType)NDalicPINVOKE.ScrollBar_GetIndicatorHeightPolicy(swigCPtr);
278             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279             return ret;
280         }
281
282         internal void SetIndicatorFixedHeight(float height)
283         {
284             NDalicPINVOKE.ScrollBar_SetIndicatorFixedHeight(swigCPtr, height);
285             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286         }
287
288         internal float GetIndicatorFixedHeight()
289         {
290             float ret = NDalicPINVOKE.ScrollBar_GetIndicatorFixedHeight(swigCPtr);
291             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
292             return ret;
293         }
294
295         internal void SetIndicatorShowDuration(float durationSeconds)
296         {
297             NDalicPINVOKE.ScrollBar_SetIndicatorShowDuration(swigCPtr, durationSeconds);
298             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299         }
300
301         internal float GetIndicatorShowDuration()
302         {
303             float ret = NDalicPINVOKE.ScrollBar_GetIndicatorShowDuration(swigCPtr);
304             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305             return ret;
306         }
307
308         internal void SetIndicatorHideDuration(float durationSeconds)
309         {
310             NDalicPINVOKE.ScrollBar_SetIndicatorHideDuration(swigCPtr, durationSeconds);
311             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312         }
313
314         internal float GetIndicatorHideDuration()
315         {
316             float ret = NDalicPINVOKE.ScrollBar_GetIndicatorHideDuration(swigCPtr);
317             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318             return ret;
319         }
320
321         internal void ShowIndicator()
322         {
323             NDalicPINVOKE.ScrollBar_ShowIndicator(swigCPtr);
324             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325         }
326
327         internal void HideIndicator()
328         {
329             NDalicPINVOKE.ScrollBar_HideIndicator(swigCPtr);
330             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
331         }
332
333         internal VoidSignal PanFinishedSignal()
334         {
335             VoidSignal ret = new VoidSignal(NDalicPINVOKE.ScrollBar_PanFinishedSignal(swigCPtr), false);
336             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
337             return ret;
338         }
339
340         internal FloatSignal ScrollPositionIntervalReachedSignal()
341         {
342             FloatSignal ret = new FloatSignal(NDalicPINVOKE.ScrollBar_ScrollPositionIntervalReachedSignal(swigCPtr), false);
343             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344             return ret;
345         }
346
347         /// <summary>
348         /// Direction of scroll bar
349         /// </summary>
350         public enum Direction
351         {
352             Vertical = 0,
353             Horizontal
354         }
355
356         /// <summary>
357         /// Indicator height policy.
358         /// </summary>
359         public enum IndicatorHeightPolicyType
360         {
361             Variable = 0,
362             Fixed
363         }
364
365         /// <summary>
366         /// Direction of scroll bar
367         /// </summary>
368         public Direction ScrollDirection
369         {
370             get
371             {
372                 string temp;
373                 if (GetProperty(ScrollBar.Property.SCROLL_DIRECTION).Get(out temp) == false)
374                 {
375 #if DEBUG_ON
376                     Tizen.Log.Error("NUI", "ScrollDirection get error!");
377 #endif
378                 }
379
380                 switch (temp)
381                 {
382                     case "Vertical":
383                         return Direction.Vertical;
384                     case "Horizontal":
385                         return Direction.Horizontal;
386                     default:
387                         return Direction.Vertical;
388                 }
389             }
390             set
391             {
392                 string valueToString = "";
393                 switch (value)
394                 {
395                     case Direction.Vertical:
396                     {
397                         valueToString = "Vertical";
398                         break;
399                     }
400                     case Direction.Horizontal:
401                     {
402                         valueToString = "Horizontal";
403                         break;
404                     }
405                     default:
406                     {
407                         valueToString = "Vertical";
408                         break;
409                     }
410                 }
411                 SetProperty(ScrollBar.Property.SCROLL_DIRECTION, new Tizen.NUI.PropertyValue(valueToString));
412             }
413         }
414
415         /// <summary>
416         /// Indicator height policy.
417         /// </summary>
418         public IndicatorHeightPolicyType IndicatorHeightPolicy
419         {
420             get
421             {
422                 string temp;
423                 if (GetProperty(ScrollBar.Property.INDICATOR_HEIGHT_POLICY).Get(out temp) == false)
424                 {
425 #if DEBUG_ON
426                     Tizen.Log.Error("NUI", "IndicatorHeightPolicy get error!");
427 #endif
428                 }
429
430                 switch (temp)
431                 {
432                     case "Variable":
433                         return IndicatorHeightPolicyType.Variable;
434                     case "Fixed":
435                         return IndicatorHeightPolicyType.Fixed;
436                     default:
437                         return IndicatorHeightPolicyType.Variable;
438                 }
439             }
440             set
441             {
442                 string valueToString = "";
443                 switch (value)
444                 {
445                     case IndicatorHeightPolicyType.Variable:
446                     {
447                         valueToString = "Variable";
448                         break;
449                     }
450                     case IndicatorHeightPolicyType.Fixed:
451                     {
452                         valueToString = "Fixed";
453                         break;
454                     }
455                     default:
456                     {
457                         valueToString = "Variable";
458                         break;
459                     }
460                 }
461                 SetProperty(ScrollBar.Property.INDICATOR_HEIGHT_POLICY, new Tizen.NUI.PropertyValue(valueToString));
462             }
463         }
464
465         /// <summary>
466         /// the fixed height of scroll indicator.
467         /// </summary>
468         public float IndicatorFixedHeight
469         {
470             get
471             {
472                 float temp = 0.0f;
473                 GetProperty(ScrollBar.Property.INDICATOR_FIXED_HEIGHT).Get(out temp);
474                 return temp;
475             }
476             set
477             {
478                 SetProperty(ScrollBar.Property.INDICATOR_FIXED_HEIGHT, new Tizen.NUI.PropertyValue(value));
479             }
480         }
481
482         /// <summary>
483         /// the duration in seconds for the scroll indicator to become fully visible.
484         /// </summary>
485         public float IndicatorShowDuration
486         {
487             get
488             {
489                 float temp = 0.0f;
490                 GetProperty(ScrollBar.Property.INDICATOR_SHOW_DURATION).Get(out temp);
491                 return temp;
492             }
493             set
494             {
495                 SetProperty(ScrollBar.Property.INDICATOR_SHOW_DURATION, new Tizen.NUI.PropertyValue(value));
496             }
497         }
498
499         /// <summary>
500         /// the duration in seconds for the scroll indicator to become fully invisible.
501         /// </summary>
502         public float IndicatorHideDuration
503         {
504             get
505             {
506                 float temp = 0.0f;
507                 GetProperty(ScrollBar.Property.INDICATOR_HIDE_DURATION).Get(out temp);
508                 return temp;
509             }
510             set
511             {
512                 SetProperty(ScrollBar.Property.INDICATOR_HIDE_DURATION, new Tizen.NUI.PropertyValue(value));
513             }
514         }
515
516         /// <summary>
517         /// the list of values to get notification when the current scroll position of the scrollable object goes above or below any of these values.
518         /// </summary>
519         public Tizen.NUI.PropertyArray ScrollPositionIntervals
520         {
521             get
522             {
523                 Tizen.NUI.PropertyArray temp = new Tizen.NUI.PropertyArray();
524                 GetProperty(ScrollBar.Property.SCROLL_POSITION_INTERVALS).Get(temp);
525                 return temp;
526             }
527             set
528             {
529                 SetProperty(ScrollBar.Property.SCROLL_POSITION_INTERVALS, new Tizen.NUI.PropertyValue(value));
530             }
531         }
532
533         /// <summary>
534         /// The minimum height for a variable size indicator.
535         /// </summary>
536         public float IndicatorMinimumHeight
537         {
538             get
539             {
540                 float temp = 0.0f;
541                 GetProperty(ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT).Get(out temp);
542                 return temp;
543             }
544             set
545             {
546                 SetProperty(ScrollBar.Property.INDICATOR_MINIMUM_HEIGHT, new Tizen.NUI.PropertyValue(value));
547             }
548         }
549
550         /// <summary>
551         /// The padding at the start of the indicator. For example, the top if scrollDirection is Vertical.
552         /// </summary>
553         public float IndicatorStartPadding
554         {
555             get
556             {
557                 float temp = 0.0f;
558                 GetProperty(ScrollBar.Property.INDICATOR_START_PADDING).Get(out temp);
559                 return temp;
560             }
561             set
562             {
563                 SetProperty(ScrollBar.Property.INDICATOR_START_PADDING, new Tizen.NUI.PropertyValue(value));
564             }
565         }
566
567         /// <summary>
568         /// The padding at the end of the indicator. For example, the bottom if scrollDirection is Vertical.
569         /// </summary>
570         public float IndicatorEndPadding
571         {
572             get
573             {
574                 float temp = 0.0f;
575                 GetProperty(ScrollBar.Property.INDICATOR_END_PADDING).Get(out temp);
576                 return temp;
577             }
578             set
579             {
580                 SetProperty(ScrollBar.Property.INDICATOR_END_PADDING, new Tizen.NUI.PropertyValue(value));
581             }
582         }
583
584     }
585
586 }