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 TEXTFIELD_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
27 %define TEXTFIELD_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
30 public class TextChangedEventArgs : EventArgs
32 private TextField _textField;
34 public TextField TextField
47 public class MaxLengthReachedEventArgs : EventArgs
49 private TextField _textField;
51 public TextField TextField
65 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
66 private delegate void TextChangedCallbackDelegate(IntPtr textField);
67 private DaliEventHandler<object,TextChangedEventArgs> _textFieldTextChangedEventHandler;
68 private TextChangedCallbackDelegate _textFieldTextChangedCallbackDelegate;
70 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71 private delegate void MaxLengthReachedCallbackDelegate(IntPtr textField);
72 private DaliEventHandler<object,MaxLengthReachedEventArgs> _textFieldMaxLengthReachedEventHandler;
73 private MaxLengthReachedCallbackDelegate _textFieldMaxLengthReachedCallbackDelegate;
75 public event DaliEventHandler<object,TextChangedEventArgs> TextChanged
81 // Restricted to only one listener
82 if (_textFieldTextChangedEventHandler == null)
84 _textFieldTextChangedEventHandler += value;
86 _textFieldTextChangedCallbackDelegate = new TextChangedCallbackDelegate(OnTextChanged);
87 this.TextChangedSignal().Connect(_textFieldTextChangedCallbackDelegate);
96 if (_textFieldTextChangedEventHandler != null)
98 this.TextChangedSignal().Disconnect(_textFieldTextChangedCallbackDelegate);
101 _textFieldTextChangedEventHandler -= value;
106 private void OnTextChanged(IntPtr textField)
108 TextChangedEventArgs e = new TextChangedEventArgs();
110 // Populate all members of "e" (TextChangedEventArgs) with real data
111 e.TextField = Dali.TextField.GetTextFieldFromPtr(textField);
113 if (_textFieldTextChangedEventHandler != null)
115 //here we send all data to user event handlers
116 _textFieldTextChangedEventHandler(this, e);
121 public event DaliEventHandler<object,MaxLengthReachedEventArgs> MaxLengthReached
127 // Restricted to only one listener
128 if (_textFieldMaxLengthReachedEventHandler == null)
130 _textFieldMaxLengthReachedEventHandler += value;
132 _textFieldMaxLengthReachedCallbackDelegate = new MaxLengthReachedCallbackDelegate(OnMaxLengthReached);
133 this.MaxLengthReachedSignal().Connect(_textFieldMaxLengthReachedCallbackDelegate);
142 if (_textFieldMaxLengthReachedEventHandler != null)
144 this.MaxLengthReachedSignal().Disconnect(_textFieldMaxLengthReachedCallbackDelegate);
147 _textFieldMaxLengthReachedEventHandler -= value;
152 private void OnMaxLengthReached(IntPtr textField)
154 MaxLengthReachedEventArgs e = new MaxLengthReachedEventArgs();
156 // Populate all members of "e" (MaxLengthReachedEventArgs) with real data
157 e.TextField = Dali.TextField.GetTextFieldFromPtr(textField);
159 if (_textFieldMaxLengthReachedEventHandler != null)
161 //here we send all data to user event handlers
162 _textFieldMaxLengthReachedEventHandler(this, e);
167 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
168 ClassName ret = new ClassName(cPtr, false);
169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 %define DALI_TEXTFIELD_EVENTHANDLER_PARAM( NameSpace, ClassName)
179 TEXTFIELD_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
180 TEXTFIELD_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
186 DALI_TEXTFIELD_EVENTHANDLER_PARAM( Dali::Toolkit, TextField);