Merge "Implement wayland clipboard & same behaviour as EFL clipboard" into devel...
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / SWIG / dali-adaptor.i
1 /*
2  * Copyright (c) 2016 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 %ignore *::Application(Internal::Adaptor::Application*);
19 %ignore *::DragAndDropDetector(Internal::Adaptor::DragAndDropDetector*);
20 %ignore *::Timer(Internal::Adaptor::Timer*);
21 %ignore *::Window(Internal::Adaptor::Window*);
22
23 %rename(StyleChangeType) Dali::StyleChange::Type;
24
25 %include <dali/public-api/adaptor-framework/style-change.h>
26 %include <dali/public-api/adaptor-framework/timer.h>
27 %include <dali/devel-api/adaptor-framework/drag-and-drop-detector.h>
28 %include <dali/public-api/adaptor-framework/window.h>
29
30 #if defined(SWIGCSHARP)
31
32 // %include <arrays_csharp.i>
33 // CSHARP_ARRAYS(char **, string)
34 // %typemap(imtype, inattributes="[global::System.Runtime.InteropServices.In, global::System.Runtime.InteropServices.MarshalAs(global::System.Runtime.InteropServices.UnmanagedType.LPArray, SizeParamIndex=0, ArraySubType=global::System.Runtime.InteropServices.UnmanagedType.LPStr)]") char **INPUT[] "string[]"
35 // %apply int *INPUT { int *argc };
36 // %apply char **INPUT[]  { char **argv[] };
37
38 %{
39   // keep argcs and argv so they're always available to DALi
40   int argC = 1;
41   char **argV = NULL;
42 %}
43
44 // Temporary hack to generate argv. Todo... support conversions from the C# strings[] in the argv that is generated below
45
46 %typemap(in) ( int* argc, char **argv[]  ) {
47
48   // Todo generate argv data from the C# args
49   char **array;         // two dimensional array
50   int numStrings = 1;     // number of strings
51   int stringLength = 30;      // max string length.
52   array = (char **)malloc( (numStrings + 1 )* sizeof(char *) );
53   argV = array;
54
55   // allocate the string data
56   for( int i=0; i < numStrings; i++)
57   {
58     array[i]=(char *)malloc( stringLength * sizeof(char *) );
59   }
60   array[ numStrings ] =  NULL; // we allocated +1 for hold the NULL part
61
62   strcpy( array[0], "dali-csharp-app");
63
64   $1 = &argC;
65   $2 = &argV;
66 }
67
68 // add interop services to the file
69 //%typemap(csimports) Dali::Application "using System.Runtime.InteropServices;"
70
71 %csmethodmodifiers Dali::Application::New() "
72   /**
73   * Outer::outer_method(int)
74   */
75   public";
76
77 %typemap(cscode) Dali::Application %{
78
79   private static  Application instance; // singleton
80
81   public delegate void InitDelegate();
82
83   public delegate void TerminateDelegate();
84
85   public delegate void PauseDelegate();
86
87   public delegate void ResumeDelegate();
88
89   public delegate void ResizeDelegate();
90
91   public delegate void AppControlDelegate();
92
93   public delegate void LanguageChangedDelegate();
94
95   public delegate void RegionChangedDelegate();
96
97   public delegate void BatteryLowDelegate();
98
99   public delegate void MemoryLowDelegate();
100
101   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
102   internal delegate void InitDelegateInternal();
103
104   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
105   internal delegate void TerminateDelegateInternal();
106
107   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
108   internal delegate void PauseDelegateInternal();
109
110   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
111   internal delegate void ResumeDelegateInternal();
112
113   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
114   internal delegate void ResizeDelegateInternal();
115
116   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
117   internal delegate void AppControlDelegateInternal();
118
119   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
120   internal delegate void LanguageChangedDelegateInternal();
121
122   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
123   internal delegate void RegionChangedDelegateInternal();
124
125   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
126   internal delegate void BatteryLowDelegateInternal();
127
128   [System.Runtime.InteropServices.UnmanagedFunctionPointer(System.Runtime.InteropServices.CallingConvention.StdCall)]
129   internal delegate void MemoryLowDelegateInternal();
130
131   static void Initialize()
132   {
133   //    instance.InitDelegate();
134   }
135
136  public static Application ApplicationFromPtr(global::System.IntPtr cPtr) {
137     Application ret = new Application(cPtr, false);
138         if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139     return ret;
140   }
141
142   internal void SetupDelegates() {
143     InitDelegateInternal initializeCallback = new InitDelegateInternal( Initialize );
144     System.Console.WriteLine( "InitSignal connection count");
145
146     this.InitSignal().Connect( initializeCallback );
147     //Console.WriteLine( "InitSignal connection count = " + app.InitSignal().GetConnectionCount() );
148  }
149
150    public static Application NewApplication() {
151     Application ret = New(1);
152         if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153
154     // we've got an application now connect the signals
155     ret.SetupDelegates();
156     // set the singleton
157
158     return ret;
159   }
160
161 %}
162
163 %typemap(in) ( int* argc, char **argv[]  ) {
164
165   // Todo generate argv data from the C# args
166   char **array;         // two dimensional array
167   int numStrings = 1;     // number of strings
168   int stringLength = 30;      // max string length.
169   array = (char **)malloc( (numStrings + 1 )* sizeof(char *) );
170   argV = array;
171
172   // allocate the string data
173   for( int i=0; i < numStrings; i++)
174   {
175     array[i]=(char *)malloc( stringLength * sizeof(char *) );
176   }
177   array[ numStrings ] =  NULL; // we allocated +1 for hold the NULL part
178
179   strcpy( array[0], "dali-csharp-app");
180
181   $1 = &argC;
182   $2 = &argV;
183 }
184
185 %apply int* INPUT { int* argc };
186
187 #endif
188
189 %include <dali/public-api/adaptor-framework/application.h>
190
191 %template(ApplicationSignal) Dali::Signal<void(Dali::Application&)>;
192 %template(ApplicationControlSignal) Dali::Signal<void(Dali::Application&, void*)>;
193 %template(TimerSignalType) Dali::Signal<bool()>;
194
195
196 // Application specialisation
197 // Macro to convert from a void * callback to a DALi C# object
198