2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 %define SCROLLABLE_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define SCROLLABLE_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
29 public class StartedEventArgs : EventArgs
31 private Vector2 _vector2;
33 public Vector2 Vector2
46 public class UpdatedEventArgs : EventArgs
48 private Vector2 _vector2;
50 public Vector2 Vector2
63 public class CompletedEventArgs : EventArgs
65 private Vector2 _vector2;
67 public Vector2 Vector2
80 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81 private delegate void StartedCallbackDelegate(IntPtr vector2);
82 private DaliEventHandler<object,StartedEventArgs> _scrollableStartedEventHandler;
83 private StartedCallbackDelegate _scrollableStartedCallbackDelegate;
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void UpdatedCallbackDelegate(IntPtr vector2);
87 private DaliEventHandler<object,UpdatedEventArgs> _scrollableUpdatedEventHandler;
88 private UpdatedCallbackDelegate _scrollableUpdatedCallbackDelegate;
90 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91 private delegate void CompletedCallbackDelegate(IntPtr vector2);
92 private DaliEventHandler<object,CompletedEventArgs> _scrollableCompletedEventHandler;
93 private CompletedCallbackDelegate _scrollableCompletedCallbackDelegate;
95 public event DaliEventHandler<object,StartedEventArgs> ScrollStarted
101 // Restricted to only one listener
102 if (_scrollableStartedEventHandler == null)
104 _scrollableStartedEventHandler += value;
106 _scrollableStartedCallbackDelegate = new StartedCallbackDelegate(OnStarted);
107 this.ScrollStartedSignal().Connect(_scrollableStartedCallbackDelegate);
116 if (_scrollableStartedEventHandler != null)
118 this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
121 _scrollableStartedEventHandler -= value;
126 private void OnStarted(IntPtr vector2)
128 StartedEventArgs e = new StartedEventArgs();
130 // Populate all members of "e" (StartedEventArgs) with real data
131 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
133 if (_scrollableStartedEventHandler != null)
135 //here we send all data to user event handlers
136 _scrollableStartedEventHandler(this, e);
141 public event DaliEventHandler<object,UpdatedEventArgs> ScrollUpdated
147 // Restricted to only one listener
148 if (_scrollableUpdatedEventHandler == null)
150 _scrollableUpdatedEventHandler += value;
152 _scrollableUpdatedCallbackDelegate = new UpdatedCallbackDelegate(OnUpdated);
153 this.ScrollUpdatedSignal().Connect(_scrollableUpdatedCallbackDelegate);
162 if (_scrollableUpdatedEventHandler != null)
164 this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
167 _scrollableUpdatedEventHandler -= value;
172 private void OnUpdated(IntPtr vector2)
174 UpdatedEventArgs e = new UpdatedEventArgs();
176 // Populate all members of "e" (UpdatedEventArgs) with real data
177 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
179 if (_scrollableUpdatedEventHandler != null)
181 //here we send all data to user event handlers
182 _scrollableUpdatedEventHandler(this, e);
187 public event DaliEventHandler<object,CompletedEventArgs> ScrollCompleted
193 // Restricted to only one listener
194 if (_scrollableCompletedEventHandler == null)
196 _scrollableCompletedEventHandler += value;
198 _scrollableCompletedCallbackDelegate = new CompletedCallbackDelegate(OnCompleted);
199 this.ScrollCompletedSignal().Connect(_scrollableCompletedCallbackDelegate);
208 if (_scrollableCompletedEventHandler != null)
210 this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
213 _scrollableCompletedEventHandler -= value;
218 private void OnCompleted(IntPtr vector2)
220 CompletedEventArgs e = new CompletedEventArgs();
222 // Populate all members of "e" (CompletedEventArgs) with real data
223 e.Vector2 = Dali.Vector2.GetVector2FromPtr(vector2);
225 if (_scrollableCompletedEventHandler != null)
227 //here we send all data to user event handlers
228 _scrollableCompletedEventHandler(this, e);
237 %define DALI_SCROLLABLE_EVENTHANDLER_PARAM( NameSpace, ClassName)
239 SCROLLABLE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
240 SCROLLABLE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
246 DALI_SCROLLABLE_EVENTHANDLER_PARAM( Dali::Toolkit, Scrollable);