2 * Copyright (c) 2022 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.
21 #include <dali-csharp-binder/common/common.h>
22 #include <dali/devel-api/adaptor-framework/drag-and-drop.h>
23 #include <dali/integration-api/debug.h>
27 /* Callback for returning strings to C# without leaking memory */
28 typedef char * (SWIGSTDCALL* SWIG_CSharpStringHelperCallback)(const char *);
29 extern SWIG_CSharpStringHelperCallback SWIG_csharp_string_callback;
31 static char mimeTypeEmptyMsg[] = "Mime Type is Empty!";
32 static char dataEmptyMsg[] = "Data is Empty!";
33 static const char * nullExceptMsg = "Attempt to dereference null Dali::Adaptor::DragAndDrop";
35 using DnDCallback = void(SWIGSTDCALL *)(const Dali::DragAndDrop::DragEvent&);
36 DnDCallback dndCallback;
38 using SourceCallback = void(SWIGSTDCALL *)(enum Dali::DragAndDrop::SourceEventType);
39 SourceCallback sourceCallback;
45 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_DragAndDrop_New__SWIG_0() {
46 void *jresult = nullptr;
47 Dali::DragAndDrop result;
49 result = Dali::DragAndDrop::Get();
50 jresult = new Dali::DragAndDrop((const Dali::DragAndDrop &)result);
52 } CALL_CATCH_EXCEPTION(0);
57 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_StartDragAndDrop(void * argDnD, void * argSource, void * argShadowWindow, void * argMimeType, char * argData, void * argSourceCallback) {
58 Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)argDnD;
61 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
66 Dali::Window *pShadow;
70 pSource = (Dali::Actor *)argSource;
72 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
76 pShadow = (Dali::Window *)argShadowWindow;
78 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
85 Dali::DragAndDrop::DragData dragData;
86 dragData.SetMimeType((const char*)argMimeType);
87 dragData.SetData(argData);
92 sourceCallback = (SourceCallback)argSourceCallback;
93 result = dnd->StartDragAndDrop(source, shadow, dragData, sourceCallback);
95 CALL_CATCH_EXCEPTION(0);
100 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_AddListener(void * jarg1, void * jarg2, void * jarg3) {
101 Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)jarg1;
103 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
110 argp2 = (Dali::Actor *)jarg2;
112 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
120 dndCallback = (DnDCallback)jarg3;
121 result = dnd->AddListener(target, dndCallback);
123 CALL_CATCH_EXCEPTION(0);
128 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_RemoveListener(void * argDnD, void * argTarget, void * argCallback) {
129 Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)argDnD;
131 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
135 Dali::Actor *pTarget;
138 pTarget = (Dali::Actor *)argTarget;
140 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
148 //TODO: use argCallback to remove target listener
149 result = dnd->RemoveListener(target);
151 CALL_CATCH_EXCEPTION(0);
156 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_Window_AddListener(void * argDnD, void * argTarget, void * argCallback) {
157 Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)argDnD;
159 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
163 Dali::Window *pTarget;
166 pTarget = (Dali::Window *)argTarget;
168 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
176 dndCallback = (DnDCallback)argCallback;
177 result = dnd->AddListener(target, dndCallback);
179 CALL_CATCH_EXCEPTION(0);
184 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_Window_RemoveListener(void * argDnD, void * argTarget, void * argCallback) {
185 Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)argDnD;
187 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
191 Dali::Window *pTarget;
194 pTarget = (Dali::Window *)argTarget;
196 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
204 //TODO: use argCallback to remove target listener
205 result = dnd->RemoveListener(target);
207 CALL_CATCH_EXCEPTION(0);
212 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_DragEvent_GetAction(void * jarg) {
214 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
217 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
222 jresult = (int)((Dali::DragAndDrop::DragEvent &)*dragEvent).GetAction();
224 CALL_CATCH_EXCEPTION(0);
230 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_DragEvent_GetPosition(void * jarg) {
231 void * jresult = nullptr;
232 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
233 Dali::Vector2 result;
236 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
241 result = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetPosition();
243 CALL_CATCH_EXCEPTION(0);
246 jresult = new Dali::Vector2((const Dali::Vector2 &)result);
250 SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetMimeType(void * argDragEvent) {
251 char * jresult = nullptr;
252 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)argDragEvent;
256 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
261 const char* mimeType = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetMimeType();
262 if (mimeType != nullptr)
268 result = mimeTypeEmptyMsg;
271 CALL_CATCH_EXCEPTION(0);
274 jresult = SWIG_csharp_string_callback((&result)->c_str());
278 SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetData(void * argDragEvent) {
279 char * jresult = nullptr;
280 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)argDragEvent;
284 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
289 const char* data = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetData();
296 result = dataEmptyMsg;
299 CALL_CATCH_EXCEPTION(0);
302 jresult = SWIG_csharp_string_callback((&result)->c_str());