Bind AnimatedVectorImageVisual action : SET_DYNAMIC_PROPERTY
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / dali-adaptor / drag-and-drop-wrap.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #define SWIGSTDCALL
19
20 // INCLUDES
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>
24
25 using namespace Dali;
26
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;
30
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";
34
35 using DnDCallback = void(SWIGSTDCALL *)(const Dali::DragAndDrop::DragEvent&);
36 DnDCallback dndCallback;
37
38 using SourceCallback = void(SWIGSTDCALL *)(enum Dali::DragAndDrop::SourceEventType);
39 SourceCallback sourceCallback;
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 SWIGEXPORT void *SWIGSTDCALL CSharp_Dali_DragAndDrop_New__SWIG_0() {
46   void *jresult = nullptr;
47   Dali::DragAndDrop result;
48   try {
49       result = Dali::DragAndDrop::Get();
50       jresult = new Dali::DragAndDrop((const Dali::DragAndDrop &)result);
51
52   } CALL_CATCH_EXCEPTION(0);
53
54  return jresult;
55 }
56
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;
59
60   if (!dnd) {
61     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
62     return false;
63   }
64
65   Dali::Actor *pSource;
66   Dali::Window *pShadow;
67   Dali::Actor source;
68   Dali::Window shadow;
69
70   pSource = (Dali::Actor *)argSource;
71   if (!pSource) {
72     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
73     return false;
74   }
75
76   pShadow = (Dali::Window *)argShadowWindow;
77   if (!pShadow) {
78     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
79     return false;
80   }
81
82   source = *pSource;
83   shadow = *pShadow;
84
85   Dali::DragAndDrop::DragData dragData;
86   dragData.SetMimeType((const char*)argMimeType);
87   dragData.SetData(argData);
88
89   bool result = false;
90   {
91     try {
92       sourceCallback = (SourceCallback)argSourceCallback;
93       result = dnd->StartDragAndDrop(source, shadow, dragData, sourceCallback);
94     }
95     CALL_CATCH_EXCEPTION(0);
96   }
97   return result;
98 }
99
100 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_AddListener(void * jarg1, void * jarg2, void * jarg3) {
101   Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)jarg1;
102   if (!dnd) {
103     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
104     return false;
105   }
106
107   Dali::Actor *argp2;
108   Dali::Actor target;
109
110   argp2 = (Dali::Actor *)jarg2;
111   if (!argp2) {
112     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
113     return false;
114   }
115
116   target = *argp2;
117   bool result = false;
118   {
119     try {
120       dndCallback = (DnDCallback)jarg3;
121       result = dnd->AddListener(target, dndCallback);
122     }
123     CALL_CATCH_EXCEPTION(0);
124   }
125   return result;
126 }
127
128 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_DragAndDrop_RemoveListener(void * argDnD, void * argTarget, void * argCallback) {
129   Dali::DragAndDrop *dnd = (Dali::DragAndDrop *)argDnD;
130   if (!dnd) {
131     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
132     return false;
133   }
134
135   Dali::Actor *pTarget;
136   Dali::Actor target;
137
138   pTarget = (Dali::Actor *)argTarget;
139   if (!pTarget) {
140     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
141     return false;
142   }
143
144   target = *pTarget;
145   bool result = false;
146   {
147     try {
148       //TODO: use argCallback to remove target listener
149       result = dnd->RemoveListener(target);
150     }
151     CALL_CATCH_EXCEPTION(0);
152   }
153   return result;
154 }
155
156 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_DragEvent_GetAction(void * jarg) {
157   int jresult;
158   Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)jarg;
159
160   if (!dragEvent) {
161     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
162     return 0;
163   }
164   {
165     try {
166       jresult = (int)((Dali::DragAndDrop::DragEvent &)*dragEvent).GetAction();
167     }
168     CALL_CATCH_EXCEPTION(0);
169   }
170
171   return jresult;
172 }
173
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;
178
179   if (!dragEvent) {
180     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
181     return 0;
182   }
183   {
184     try {
185       result = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetPosition();
186     }
187     CALL_CATCH_EXCEPTION(0);
188   }
189
190   jresult = new Dali::Vector2((const Dali::Vector2 &)result);
191   return jresult;
192 }
193
194 SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetMimeType(void * argDragEvent) {
195   char * jresult = nullptr;
196   Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)argDragEvent;
197   std::string result;
198
199   if (!dragEvent) {
200     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
201     return 0;
202   }
203   {
204     try {
205       const char* mimeType = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetMimeType();
206       if (mimeType != nullptr)
207       {
208         result = mimeType;
209       }
210       else
211       {
212         result = mimeTypeEmptyMsg;
213       }
214     }
215     CALL_CATCH_EXCEPTION(0);
216   }
217
218   jresult = SWIG_csharp_string_callback((&result)->c_str());
219   return jresult;
220 }
221
222 SWIGEXPORT char * SWIGSTDCALL CSharp_Dali_DragEvent_GetData(void * argDragEvent) {
223   char * jresult = nullptr;
224   Dali::DragAndDrop::DragEvent *dragEvent = (Dali::DragAndDrop::DragEvent *)argDragEvent;
225   std::string result;
226
227   if (!dragEvent) {
228     SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, nullExceptMsg, 0);
229     return 0;
230   }
231   {
232     try {
233       const char* data = ((Dali::DragAndDrop::DragEvent &)*dragEvent).GetData();
234       if (data != nullptr)
235       {
236         result = data;
237       }
238       else
239       {
240         result = dataEmptyMsg;
241       }
242     }
243     CALL_CATCH_EXCEPTION(0);
244   }
245
246   jresult = SWIG_csharp_string_callback((&result)->c_str());
247   return jresult;
248 }
249
250 #ifdef __cplusplus
251 } // end extern "C"
252 #endif