Changes required after TextField Devel properties made public
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / key-grab.cpp
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 #include "common.h"
18
19 #include <dali/integration-api/debug.h>
20 #include <dali/public-api/adaptor-framework/key-grab.h>
21 #include <dali/devel-api/adaptor-framework/window-devel.h>
22
23 #ifdef TIZEN_BUILD
24 #include <Ecore_Wayland.h>
25 #endif
26
27 #undef LOG
28 //#define LOG DALI_LOG_ERROR
29 #define LOG(a...)
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKeyTopmost(void * window, int daliKey)
37 {
38   Dali::Window *_win = (Dali::Window *)window;
39   bool ret;
40
41   LOG("CSharp_Dali_GrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
42
43   {
44     try {
45       ret = Dali::KeyGrab::GrabKeyTopmost(*_win, (Dali::KEY)daliKey);
46     } catch (std::out_of_range& e) {
47     {
48       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
49     };
50     } catch (std::exception& e) {
51     {
52       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
53     };
54     } catch (...) {
55     {
56       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
57     };
58     }
59   }
60
61   LOG("CSharp_Dali_GrabKeyTopmost() [DP2] ret=%d", ret);
62
63   return ret;
64 }
65
66 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKeyTopmost(void * window, int daliKey)
67 {
68   Dali::Window *_win = (Dali::Window *)window;
69   bool ret;
70
71   LOG("CSharp_Dali_UngrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
72
73   {
74     try {
75       ret = Dali::KeyGrab::UngrabKeyTopmost(*_win, (Dali::KEY)daliKey);
76     } catch (std::out_of_range& e) {
77     {
78       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
79     };
80     } catch (std::exception& e) {
81     {
82       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
83     };
84     } catch (...) {
85     {
86       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
87     };
88     }
89   }
90
91   LOG("CSharp_Dali_UngrabKeyTopmost() [DP2] ret=%d", ret);
92
93   return ret;
94 }
95
96 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKey(void * window, int daliKey, int grabMode)
97 {
98   Dali::Window *_win = (Dali::Window *)window;
99   bool ret;
100
101   LOG("CSharp_Dali_GrabKey() [DP1] window=%d, dalikey=%d, grabmode=%d", window, daliKey, grabMode);
102
103   {
104     try {
105       ret = Dali::KeyGrab::GrabKey(*_win, (Dali::KEY)daliKey, (Dali::KeyGrab::KeyGrabMode)grabMode);
106     } catch (std::out_of_range& e) {
107     {
108       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
109     };
110     } catch (std::exception& e) {
111     {
112       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
113     };
114     } catch (...) {
115     {
116       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
117     };
118     }
119   }
120
121   DALI_LOG_ERROR("CSharp_Dali_GrabKey() [DP2] ret=%d", ret);
122
123   return ret;
124 }
125
126 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKey(void * window, int daliKey)
127 {
128   Dali::Window *_win = (Dali::Window *)window;
129   bool ret;
130
131   LOG("CSharp_Dali_UngrabKey() [DP1] window=%d, dalikey=%d", window, daliKey);
132
133   {
134     try {
135       ret = Dali::KeyGrab::UngrabKey(*_win, (Dali::KEY)daliKey);
136     } catch (std::out_of_range& e) {
137     {
138       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
139     };
140     } catch (std::exception& e) {
141     {
142       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
143     };
144     } catch (...) {
145     {
146       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
147     };
148     }
149   }
150
151   LOG("CSharp_Dali_UngrabKey() [DP2] ret=%d", ret);
152
153   return ret;
154 }
155
156 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_GetNativeWindowHandler( void* window )
157 {
158   Dali::Window *_win = (Dali::Window *)window;
159   void * ret = NULL;
160
161   LOG("CSharp_Dali_GetNativeWindowHandler() [DP1] window=%d", window);
162
163   {
164     Dali::Any result;
165     try {
166       result = _win->GetNativeHandle();
167
168       Ecore_Wl_Window * ecore_win = Dali::AnyCast<Ecore_Wl_Window*>(result);
169       ret = (void*)ecore_win;
170
171     } catch (std::out_of_range& e) {
172     {
173       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return NULL;
174     };
175     } catch (std::exception& e) {
176     {
177       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return NULL;
178     };
179     } catch (...) {
180     {
181       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return NULL;
182     };
183     }
184   }
185
186   if(ret != NULL)
187   {
188     LOG("CSharp_Dali_GetNativeWindowHandler() [DP2] ret=%d", ret);
189   }
190
191   return ret;
192 }
193
194
195 #ifdef __cplusplus
196 }
197 #endif
198