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 TEXTEDITOR_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
27 %define TEXTEDITOR_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
31 * @brief Event arguments that passed via TextChanged signal
34 public class TextChangedEventArgs : EventArgs
36 private TextEditor _textEditor;
38 * @brief TextEditor - is the texteditor control which has the text contents changed.
41 public TextEditor TextEditor
54 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
55 private delegate void TextChangedCallbackDelegate(IntPtr textEditor);
56 private DaliEventHandler<object,TextChangedEventArgs> _textEditorTextChangedEventHandler;
57 private TextChangedCallbackDelegate _textEditorTextChangedCallbackDelegate;
60 * @brief Event for TextChanged signal which can be used to subscribe/unsubscribe the event handler
61 * (in the type of TextChangedEventHandler-DaliEventHandler<object,TextChangedEventArgs>)
62 * provided by the user. TextChanged signal is emitted when the text changes.
64 public event DaliEventHandler<object,TextChangedEventArgs> TextChanged
70 // Restricted to only one listener
71 if (_textEditorTextChangedEventHandler == null)
73 _textEditorTextChangedEventHandler += value;
75 _textEditorTextChangedCallbackDelegate = new TextChangedCallbackDelegate(OnTextChanged);
76 this.TextChangedSignal().Connect(_textEditorTextChangedCallbackDelegate);
85 if (_textEditorTextChangedEventHandler != null)
87 this.TextChangedSignal().Disconnect(_textEditorTextChangedCallbackDelegate);
90 _textEditorTextChangedEventHandler -= value;
95 private void OnTextChanged(IntPtr textEditor)
97 TextChangedEventArgs e = new TextChangedEventArgs();
99 // Populate all members of "e" (TextChangedEventArgs) with real data
100 e.TextEditor = Dali.TextEditor.GetTextEditorFromPtr(textEditor);
102 if (_textEditorTextChangedEventHandler != null)
104 //here we send all data to user event handlers
105 _textEditorTextChangedEventHandler(this, e);
110 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
111 ClassName ret = new ClassName(cPtr, false);
112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120 %define DALI_TEXTEDITOR_EVENTHANDLER_PARAM( NameSpace, ClassName)
122 TEXTEDITOR_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
123 TEXTEDITOR_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
129 DALI_TEXTEDITOR_EVENTHANDLER_PARAM( Dali::Toolkit, TextEditor);