Manual merge for dali-csharp-binder v0.2.36
[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
24 #undef LOG
25 //#define LOG DALI_LOG_ERROR
26 #define LOG(a...)
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33
34 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKeyTopmost(void * window, int daliKey)
35 {
36   Dali::Window *_win = (Dali::Window *)window;
37   bool ret;
38
39   LOG("CSharp_Dali_GrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
40
41   {
42     try {
43       ret = Dali::KeyGrab::GrabKeyTopmost(*_win, (Dali::KEY)daliKey);
44     } catch (std::out_of_range& e) {
45     {
46       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
47     };
48     } catch (std::exception& e) {
49     {
50       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
51     };
52     } catch (...) {
53     {
54       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
55     };
56     }
57   }
58
59   LOG("CSharp_Dali_GrabKeyTopmost() [DP2] ret=%d", ret);
60
61   return ret;
62 }
63
64 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKeyTopmost(void * window, int daliKey)
65 {
66   Dali::Window *_win = (Dali::Window *)window;
67   bool ret;
68
69   LOG("CSharp_Dali_UngrabKeyTopmost() [DP1] window=%d, dalikey=%d", window, daliKey);
70
71   {
72     try {
73       ret = Dali::KeyGrab::UngrabKeyTopmost(*_win, (Dali::KEY)daliKey);
74     } catch (std::out_of_range& e) {
75     {
76       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
77     };
78     } catch (std::exception& e) {
79     {
80       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
81     };
82     } catch (...) {
83     {
84       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
85     };
86     }
87   }
88
89   LOG("CSharp_Dali_UngrabKeyTopmost() [DP2] ret=%d", ret);
90
91   return ret;
92 }
93
94 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_GrabKey(void * window, int daliKey, int grabMode)
95 {
96   Dali::Window *_win = (Dali::Window *)window;
97   bool ret;
98
99   LOG("CSharp_Dali_GrabKey() [DP1] window=%d, dalikey=%d, grabmode=%d", window, daliKey, grabMode);
100
101   {
102     try {
103       ret = Dali::KeyGrab::GrabKey(*_win, (Dali::KEY)daliKey, (Dali::KeyGrab::KeyGrabMode)grabMode);
104     } catch (std::out_of_range& e) {
105     {
106       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
107     };
108     } catch (std::exception& e) {
109     {
110       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
111     };
112     } catch (...) {
113     {
114       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
115     };
116     }
117   }
118
119   DALI_LOG_ERROR("CSharp_Dali_GrabKey() [DP2] ret=%d", ret);
120
121   return ret;
122 }
123
124 SWIGEXPORT bool SWIGSTDCALL CSharp_Dali_UngrabKey(void * window, int daliKey)
125 {
126   Dali::Window *_win = (Dali::Window *)window;
127   bool ret;
128
129   LOG("CSharp_Dali_UngrabKey() [DP1] window=%d, dalikey=%d", window, daliKey);
130
131   {
132     try {
133       ret = Dali::KeyGrab::UngrabKey(*_win, (Dali::KEY)daliKey);
134     } catch (std::out_of_range& e) {
135     {
136       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return false;
137     };
138     } catch (std::exception& e) {
139     {
140       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return false;
141     };
142     } catch (...) {
143     {
144       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return false;
145     };
146     }
147   }
148
149   LOG("CSharp_Dali_UngrabKey() [DP2] ret=%d", ret);
150
151   return ret;
152 }
153
154 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_GetNativeWindowHandler( void* window )
155 {
156   Dali::Window *_win = (Dali::Window *)window;
157   void * ret = NULL;
158
159   LOG("CSharp_Dali_GetNativeWindowHandler() [DP1] window=%d", window);
160
161   {
162     try {
163       ret = Dali::DevelWindow::GetNativeWindowHandler(*_win);
164     } catch (std::out_of_range& e) {
165     {
166       SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return NULL;
167     };
168     } catch (std::exception& e) {
169     {
170       SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return NULL;
171     };
172     } catch (...) {
173     {
174       SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return NULL;
175     };
176     }
177   }
178
179   if(ret != NULL)
180   {
181     LOG("CSharp_Dali_GetNativeWindowHandler() [DP2] ret=%d", ret);
182   }
183
184   return ret;
185 }
186
187
188 #ifdef __cplusplus
189 }
190 #endif
191