(Automated Tests) Update test suite after changes to PlatformAbstraction
[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
40 public:
41   static Dali::ImfManager Get();
42
43   ImfManager( /* Ecore_X_Window ecoreXwin */ );
44   void ConnectCallbacks();
45   void DisconnectCallbacks();
46   void Activate();
47   void Deactivate();
48   void Reset();
49
50   bool RestoreAfterFocusLost() const;
51   void SetRestoreAfterFocusLost( bool toggle );
52   void NotifyCursorPosition();
53   void SetCursorPosition( unsigned int cursorPosition );
54   unsigned int GetCursorPosition() const;
55   void SetSurroundingText( const std::string& text );
56   const std::string& GetSurroundingText() const;
57
58 public:  // Signals
59   ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
60   ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
61
62 protected:
63   virtual ~ImfManager();
64
65 private:
66   void CreateContext( /*Ecore_X_Window ecoreXwin*/ );
67   void DeleteContext();
68
69 private:
70   // Undefined
71   ImfManager( const ImfManager& );
72   ImfManager& operator=( ImfManager& );
73
74 private:
75   int mIMFCursorPosition;
76   std::string mSurroundingText;
77   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.
78   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.
79
80   ImfManagerSignalType      mActivatedSignal;
81   ImfEventSignalType        mEventSignal;
82
83
84   static Dali::ImfManager mToolkitImfManager;
85
86 public:
87
88 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
89 {
90   Dali::ImfManager actualImfManager = ImfManager::Get();
91
92   BaseObject& handle = actualImfManager.GetBaseObject();
93   return static_cast<Internal::Adaptor::ImfManager&>(handle);
94 }
95
96 inline static const  Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
97 {
98   Dali::ImfManager actualImfManager = ImfManager::Get();
99
100   const BaseObject& handle = imfManager.GetBaseObject();
101   return static_cast<const Internal::Adaptor::ImfManager&>(handle);
102 }
103
104 };
105
106 Dali::ImfManager Dali::Internal::Adaptor::ImfManager::mToolkitImfManager;
107
108 Dali::ImfManager ImfManager::Get()
109 {
110   Dali::ImfManager manager;
111
112   if( ! mToolkitImfManager )
113   {
114     mToolkitImfManager = Dali::ImfManager( new Dali::Internal::Adaptor::ImfManager() );
115   }
116   return mToolkitImfManager;
117 }
118
119 ImfManager::ImfManager( /*Ecore_X_Window ecoreXwin*/ )
120 : mIMFCursorPosition( 0 ),
121   mSurroundingText(),
122   mRestoreAfterFocusLost( false ),
123   mIdleCallbackConnected( false )
124 {
125   CreateContext( /*ecoreXwin*/ );
126   ConnectCallbacks();
127 }
128
129 ImfManager::~ImfManager()
130 {
131   DisconnectCallbacks();
132   DeleteContext();
133 }
134
135 void ImfManager::CreateContext( /*Ecore_X_Window ecoreXwin*/ )
136 {
137 }
138
139 void ImfManager::DeleteContext()
140 {
141 }
142
143 // Callbacks for predicitive text support.
144 void ImfManager::ConnectCallbacks()
145 {
146 }
147
148 void ImfManager::DisconnectCallbacks()
149 {
150 }
151
152 void ImfManager::Activate()
153 {
154 }
155
156 void ImfManager::Deactivate()
157 {
158 }
159
160 void ImfManager::Reset()
161 {
162 }
163
164 bool ImfManager::RestoreAfterFocusLost() const
165 {
166   return mRestoreAfterFocusLost;
167 }
168
169 void ImfManager::SetRestoreAfterFocusLost( bool toggle )
170 {
171   mRestoreAfterFocusLost = toggle;
172 }
173
174 void ImfManager::NotifyCursorPosition()
175 {
176 }
177
178 void ImfManager::SetCursorPosition( unsigned int cursorPosition )
179 {
180   mIMFCursorPosition = static_cast< int >( cursorPosition );
181 }
182
183 unsigned int ImfManager::GetCursorPosition() const
184 {
185   return static_cast<unsigned int>( mIMFCursorPosition );
186 }
187
188 void ImfManager::SetSurroundingText( const std::string& text )
189 {
190   mSurroundingText = text;
191 }
192
193 const std::string& ImfManager::GetSurroundingText() const
194 {
195   return mSurroundingText;
196 }
197
198 } // Adaptor
199
200 } // Internal
201
202
203 /********************************************************************************/
204 /*********************************  PUBLIC CLASS  *******************************/
205 /********************************************************************************/
206
207 ImfManager::ImfManager()
208 {
209 }
210
211 ImfManager::~ImfManager()
212 {
213 }
214
215 ImfManager ImfManager::Get()
216 {
217   return Internal::Adaptor::ImfManager::Get();
218 }
219
220 void ImfManager::Activate()
221 {
222   Internal::Adaptor::ImfManager::GetImplementation(*this).Activate();
223 }
224
225 void ImfManager::Deactivate()
226 {
227   Internal::Adaptor::ImfManager::GetImplementation(*this).Deactivate();
228 }
229
230 bool ImfManager::RestoreAfterFocusLost() const
231 {
232   return Internal::Adaptor::ImfManager::GetImplementation(*this).RestoreAfterFocusLost();
233 }
234
235 void ImfManager::SetRestoreAfterFocusLost( bool toggle )
236 {
237   Internal::Adaptor::ImfManager::GetImplementation(*this).SetRestoreAfterFocusLost( toggle );
238 }
239
240 void ImfManager::Reset()
241 {
242   Internal::Adaptor::ImfManager::GetImplementation(*this).Reset();
243 }
244
245 void ImfManager::NotifyCursorPosition()
246 {
247   Internal::Adaptor::ImfManager::GetImplementation(*this).NotifyCursorPosition();
248 }
249
250 void ImfManager::SetCursorPosition( unsigned int SetCursorPosition )
251 {
252   Internal::Adaptor::ImfManager::GetImplementation(*this).SetCursorPosition( SetCursorPosition );
253 }
254
255 unsigned int ImfManager::GetCursorPosition() const
256 {
257   return Internal::Adaptor::ImfManager::GetImplementation(*this).GetCursorPosition();
258 }
259
260 void ImfManager::SetSurroundingText( const std::string& text )
261 {
262   Internal::Adaptor::ImfManager::GetImplementation(*this).SetSurroundingText( text );
263 }
264
265 const std::string& ImfManager::GetSurroundingText() const
266 {
267   return Internal::Adaptor::ImfManager::GetImplementation(*this).GetSurroundingText();
268 }
269
270 ImfManager::ImfManagerSignalType& ImfManager::ActivatedSignal()
271 {
272   return Internal::Adaptor::ImfManager::GetImplementation(*this).ActivatedSignal();
273 }
274
275 ImfManager::ImfEventSignalType& ImfManager::EventReceivedSignal()
276 {
277   return Internal::Adaptor::ImfManager::GetImplementation(*this).EventReceivedSignal();
278 }
279
280 ImfManager::ImfManager(Internal::Adaptor::ImfManager *impl)
281   : BaseHandle(impl)
282 {
283 }
284
285 } // namespace Dali