[dali_1.2.30] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-imf-manager.cpp
1 /*
2  * Copyright (c) 2014 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 // CLASS HEADER
19 #include "toolkit-imf-manager.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/integration-api/debug.h>
24
25 namespace Dali
26 {
27 namespace Internal
28 {
29 namespace Adaptor
30 {
31 class RenderSurface;
32
33
34 class ImfManager : public Dali::BaseObject
35 {
36 public:
37   typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
38   typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType;
39   typedef Dali::ImfManager::StatusSignalType ImfStatusSignalType;
40   typedef Dali::ImfManager::VoidSignalType ImfVoidSignalType;
41
42 public:
43   static Dali::ImfManager Get();
44
45   ImfManager( /* Ecore_X_Window ecoreXwin */ );
46   void ConnectCallbacks();
47   void DisconnectCallbacks();
48   void Activate();
49   void Deactivate();
50   void Reset();
51
52   bool RestoreAfterFocusLost() const;
53   void SetRestoreAfterFocusLost( bool toggle );
54   void NotifyCursorPosition();
55   void SetCursorPosition( unsigned int cursorPosition );
56   unsigned int GetCursorPosition() const;
57   void SetSurroundingText( const std::string& text );
58   const std::string& GetSurroundingText() const;
59   void ApplyOptions( const InputMethodOptions& options );
60
61 public:  // Signals
62   ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
63   ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
64   ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
65   ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
66   ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
67
68 protected:
69   virtual ~ImfManager();
70
71 private:
72   void CreateContext( /*Ecore_X_Window ecoreXwin*/ );
73   void DeleteContext();
74
75 private:
76   // Undefined
77   ImfManager( const ImfManager& );
78   ImfManager& operator=( ImfManager& );
79
80 private:
81   int mIMFCursorPosition;
82   std::string mSurroundingText;
83   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.
84   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.
85   InputMethodOptions        mOptions;
86
87   ImfManagerSignalType      mActivatedSignal;
88   ImfEventSignalType        mEventSignal;
89   ImfStatusSignalType       mKeyboardStatusSignal;
90   ImfVoidSignalType         mKeyboardResizeSignal;
91   ImfVoidSignalType         mKeyboardLanguageChangedSignal;
92
93   static Dali::ImfManager mToolkitImfManager;
94
95 public:
96
97 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
98 {
99   Dali::ImfManager actualImfManager = ImfManager::Get();
100
101   BaseObject& handle = actualImfManager.GetBaseObject();
102   return static_cast<Internal::Adaptor::ImfManager&>(handle);
103 }
104
105 inline static const  Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
106 {
107   Dali::ImfManager actualImfManager = ImfManager::Get();
108
109   const BaseObject& handle = imfManager.GetBaseObject();
110   return static_cast<const Internal::Adaptor::ImfManager&>(handle);
111 }
112
113 };
114
115 Dali::ImfManager Dali::Internal::Adaptor::ImfManager::mToolkitImfManager;
116
117 Dali::ImfManager ImfManager::Get()
118 {
119   Dali::ImfManager manager;
120
121   if( ! mToolkitImfManager )
122   {
123     mToolkitImfManager = Dali::ImfManager( new Dali::Internal::Adaptor::ImfManager() );
124   }
125   return mToolkitImfManager;
126 }
127
128 ImfManager::ImfManager( /*Ecore_X_Window ecoreXwin*/ )
129 : mIMFCursorPosition( 0 ),
130   mSurroundingText(),
131   mRestoreAfterFocusLost( false ),
132   mIdleCallbackConnected( false )
133 {
134   CreateContext( /*ecoreXwin*/ );
135   ConnectCallbacks();
136 }
137
138 ImfManager::~ImfManager()
139 {
140   DisconnectCallbacks();
141   DeleteContext();
142 }
143
144 void ImfManager::CreateContext( /*Ecore_X_Window ecoreXwin*/ )
145 {
146 }
147
148 void ImfManager::DeleteContext()
149 {
150 }
151
152 // Callbacks for predicitive text support.
153 void ImfManager::ConnectCallbacks()
154 {
155 }
156
157 void ImfManager::DisconnectCallbacks()
158 {
159 }
160
161 void ImfManager::Activate()
162 {
163 }
164
165 void ImfManager::Deactivate()
166 {
167 }
168
169 void ImfManager::Reset()
170 {
171 }
172
173 bool ImfManager::RestoreAfterFocusLost() const
174 {
175   return mRestoreAfterFocusLost;
176 }
177
178 void ImfManager::SetRestoreAfterFocusLost( bool toggle )
179 {
180   mRestoreAfterFocusLost = toggle;
181 }
182
183 void ImfManager::NotifyCursorPosition()
184 {
185 }
186
187 void ImfManager::SetCursorPosition( unsigned int cursorPosition )
188 {
189   mIMFCursorPosition = static_cast< int >( cursorPosition );
190 }
191
192 unsigned int ImfManager::GetCursorPosition() const
193 {
194   return static_cast<unsigned int>( mIMFCursorPosition );
195 }
196
197 void ImfManager::SetSurroundingText( const std::string& text )
198 {
199   mSurroundingText = text;
200 }
201
202 const std::string& ImfManager::GetSurroundingText() const
203 {
204   return mSurroundingText;
205 }
206
207 void ImfManager::ApplyOptions( const InputMethodOptions& options )
208 {
209 }
210
211 } // Adaptor
212
213 } // Internal
214
215
216 /********************************************************************************/
217 /*********************************  PUBLIC CLASS  *******************************/
218 /********************************************************************************/
219
220 ImfManager::ImfManager()
221 {
222 }
223
224 ImfManager::~ImfManager()
225 {
226 }
227
228 ImfManager ImfManager::Get()
229 {
230   return Internal::Adaptor::ImfManager::Get();
231 }
232
233 void ImfManager::Activate()
234 {
235   Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
236 }
237
238 void ImfManager::Deactivate()
239 {
240   Internal::Adaptor::ImfManager::GetImplementation(*this).Deactivate();
241 }
242
243 bool ImfManager::RestoreAfterFocusLost() const
244 {
245   return Internal::Adaptor::ImfManager::GetImplementation(*this).RestoreAfterFocusLost();
246 }
247
248 void ImfManager::SetRestoreAfterFocusLost( bool toggle )
249 {
250   Internal::Adaptor::ImfManager::GetImplementation(*this).SetRestoreAfterFocusLost( toggle );
251 }
252
253 void ImfManager::Reset()
254 {
255   Internal::Adaptor::ImfManager::GetImplementation(*this).Reset();
256 }
257
258 void ImfManager::NotifyCursorPosition()
259 {
260   Internal::Adaptor::ImfManager::GetImplementation(*this).NotifyCursorPosition();
261 }
262
263 void ImfManager::SetCursorPosition( unsigned int SetCursorPosition )
264 {
265   Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
266 }
267
268 unsigned int ImfManager::GetCursorPosition() const
269 {
270   return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
271 }
272
273 void ImfManager::SetSurroundingText( const std::string& text )
274 {
275   Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
276 }
277
278 const std::string& ImfManager::GetSurroundingText() const
279 {
280   return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
281 }
282
283 void ImfManager::NotifyTextInputMultiLine( bool multiLine )
284 {
285 }
286
287 void ImfManager::ApplyOptions( const InputMethodOptions& options )
288 {
289   Internal::Adaptor::ImfManager::GetImplementation(*this).ApplyOptions( options );
290 }
291
292 ImfManager::ImfManagerSignalType& ImfManager::ActivatedSignal()
293 {
294   return Internal::Adaptor::ImfManager::GetImplementation(*this).ActivatedSignal();
295 }
296
297 ImfManager::ImfEventSignalType& ImfManager::EventReceivedSignal()
298 {
299   return Internal::Adaptor::ImfManager::GetImplementation(*this).EventReceivedSignal();
300 }
301
302 ImfManager::StatusSignalType& ImfManager::StatusChangedSignal()
303 {
304   return Internal::Adaptor::ImfManager::GetImplementation(*this).StatusChangedSignal();
305 }
306
307 ImfManager::VoidSignalType& ImfManager::ResizedSignal()
308 {
309   return Internal::Adaptor::ImfManager::GetImplementation(*this).ResizedSignal();
310 }
311
312 ImfManager::VoidSignalType& ImfManager::LanguageChangedSignal()
313 {
314   return Internal::Adaptor::ImfManager::GetImplementation(*this).LanguageChangedSignal();
315 }
316
317 ImfManager::ImfManager(Internal::Adaptor::ImfManager *impl)
318   : BaseHandle(impl)
319 {
320 }
321
322 } // namespace Dali