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 int SWIGSTDCALL CSharp_Dali_DragEvent_GetAction(void * jarg) {
158 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
161 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
166 jresult = (int)((Dali::DragAndDrop::DragEvent &)*dragEvent).GetAction();
168 CALL_CATCH_EXCEPTION(0);
174 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_DragEvent_GetPosition(void * jarg) {
175 void * jresult = nullptr;
176 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
177 Dali::Vector2 result;
180 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
185 result = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetPosition();
187 CALL_CATCH_EXCEPTION(0);
190 jresult = new Dali::Vector2((const Dali::Vector2 &)result);
194 SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetMimeType(void * argDragEvent) {
195 char * jresult = nullptr;
196 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)argDragEvent;
200 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
205 const char* mimeType = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetMimeType();
206 if (mimeType != nullptr)
212 result = mimeTypeEmptyMsg;
215 CALL_CATCH_EXCEPTION(0);
218 jresult = SWIG_csharp_string_callback((&result)->c_str());
222 SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetData(void * argDragEvent) {
223 char * jresult = nullptr;
224 Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)argDragEvent;
228 SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
233 const char* data = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetData();
240 result = dataEmptyMsg;
243 CALL_CATCH_EXCEPTION(0);
246 jresult = SWIG_csharp_string_callback((&result)->c_str());