[4.0] Ubuntu Build Error fix
[platform/core/uifw/dali-adaptor.git] / adaptors / integration-api / x11 / imf-manager-impl.h
1 #ifndef __DALI_INTERNAL_IMF_MANAGER_H
2 #define __DALI_INTERNAL_IMF_MANAGER_H
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <Ecore_IMF.h>
23 #include <Ecore_X.h>
24
25 #include <dali/public-api/object/base-object.h>
26
27 // INTERNAL INCLUDES
28 #include <imf-manager.h>
29
30 namespace Dali
31 {
32
33 class RenderSurface;
34
35 namespace Internal
36 {
37
38 namespace Adaptor
39 {
40
41 class DALI_IMPORT_API ImfManager : public Dali::BaseObject
42 {
43 public:
44   typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
45   typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType;
46   typedef Dali::ImfManager::StatusSignalType ImfStatusSignalType;
47   typedef Dali::ImfManager::VoidSignalType ImfVoidSignalType;
48   typedef Dali::ImfManager::KeyboardTypeSignalType ImfKeyboardTypeSignalType;
49
50 public:
51
52   /**
53    * @copydoc Dali::ImfManager::Finalize()
54    */
55   void Finalize();
56
57   /**
58    * Check whether the ImfManager is available.
59    * @return true if available, false otherwise
60    */
61   static bool IsAvailable();
62
63   /**
64    * Get the IMF manager instance, it creates the instance if it has not already been created.
65    * Internally, a check should be made using IsAvailable() before this is called as we do not want
66    * to create an instance if not needed by applications.
67    * @see IsAvailable()
68    */
69   static Dali::ImfManager Get();
70
71   /**
72    * Constructor
73    * @param[in] ecoreXwin, The window is created by application.
74    */
75   ImfManager( Ecore_X_Window ecoreXwin );
76
77   /**
78    * Connect Callbacks required for IMF.
79    * If you don't connect imf callbacks, you can't get the key events.
80    * The events are PreeditChanged, Commit and DeleteSurrounding.
81    */
82   void ConnectCallbacks();
83
84   /**
85    * Disconnect Callbacks attached to imf context.
86    */
87   void DisconnectCallbacks();
88
89   /**
90    * @copydoc Dali::ImfManager::Activate()
91    */
92   void Activate();
93
94   /**
95    * @copydoc Dali::ImfManager::Deactivate()
96    */
97   void Deactivate();
98
99   /**
100    * @copydoc Dali::ImfManager::Reset()
101    */
102   void Reset();
103
104   /**
105    * @copydoc Dali::ImfManager::GetContext()
106    */
107   Ecore_IMF_Context* GetContext();
108
109   /**
110    * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
111    */
112   bool RestoreAfterFocusLost() const;
113
114   /**
115    * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
116    */
117   void SetRestoreAfterFocusLost( bool toggle );
118
119   /**
120    * @copydoc Dali::ImfManager::PreEditChanged()
121    */
122   void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
123
124   /**
125    * @copydoc Dali::ImfManager::NotifyCursorPosition()
126    */
127   void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
128
129   /**
130    * @copydoc Dali::ImfManager::NotifyCursorPosition()
131    */
132   Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
133
134   /**
135    * @copydoc Dali::ImfManager::DeleteSurrounding()
136    */
137   void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
138
139   // Cursor related
140   /**
141    * @copydoc Dali::ImfManager::NotifyCursorPosition()
142    */
143   void NotifyCursorPosition();
144
145   /**
146    * @copydoc Dali::ImfManager::SetCursorPosition()
147    */
148   void SetCursorPosition( unsigned int cursorPosition );
149
150   /**
151    * @copydoc Dali::ImfManager::GetCursorPosition()
152    */
153   unsigned int GetCursorPosition() const;
154
155   /**
156    * @copydoc Dali::ImfManager::SetSurroundingText()
157    */
158   void SetSurroundingText( const std::string& text );
159
160   /**
161    * @copydoc Dali::ImfManager::GetSurroundingText()
162    */
163   const std::string& GetSurroundingText() const;
164
165   /**
166   * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
167   */
168   void NotifyTextInputMultiLine( bool multiLine );
169
170   /**
171   * @copydoc Dali::ImfManager::GetTextDirection()
172   */
173   Dali::ImfManager::TextDirection GetTextDirection();
174
175   /**
176   * @copydoc Dali::ImfManager::GetInputMethodArea()
177   */
178   Dali::Rect<int> GetInputMethodArea();
179
180   /**
181   * @copydoc Dali::ImfManager::ApplyOptions()
182   */
183   void ApplyOptions( const InputMethodOptions& options );
184
185   /**
186    * @copydoc Dali::ImfManager::SetInputPanelData()
187    */
188   void SetInputPanelData( const std::string& data );
189
190   /**
191    * @copydoc Dali::ImfManager::GetInputPanelData()
192    */
193   void GetInputPanelData( std::string& data );
194
195   /**
196    * @copydoc Dali::ImfManager::GetInputPanelState()
197    */
198   Dali::ImfManager::State GetInputPanelState();
199
200   /**
201    * @copydoc Dali::ImfManager::SetReturnKeyState()
202    */
203   void SetReturnKeyState( bool visible );
204
205   /**
206    * @copydoc Dali::ImfManager::AutoEnableInputPanel()
207    */
208   void AutoEnableInputPanel( bool enabled );
209
210   /**
211    * @copydoc Dali::ImfManager::ShowInputPanel()
212    */
213   void ShowInputPanel();
214
215   /**
216    * @copydoc Dali::ImfManager::HideInputPanel()
217    */
218   void HideInputPanel();
219
220   /**
221    * @copydoc Dali::ImfManager::GetKeyboardType()
222    */
223   Dali::ImfManager::KeyboardType GetKeyboardType();
224
225   /**
226    * @copydoc Dali::ImfManager::GetInputPanelLocale()
227    */
228   std::string GetInputPanelLocale();
229
230 public:  // Signals
231
232   /**
233    * @copydoc Dali::ImfManager::ActivatedSignal()
234    */
235   ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
236
237   /**
238    * @copydoc Dali::ImfManager::EventReceivedSignal()
239    */
240   ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
241
242   /**
243    * @copydoc Dali::ImfManager::StatusChangedSignal()
244    */
245   ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
246
247   /**
248    * @copydoc Dali::ImfManager::ResizedSignal()
249    */
250   ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
251
252   /**
253    * @copydoc Dali::ImfManager::LanguageChangedSignal()
254    */
255   ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
256
257   /**
258    * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
259    */
260   ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
261 protected:
262
263   /**
264    * Destructor.
265    */
266   virtual ~ImfManager();
267
268 private:
269   /**
270    * Context created the first time and kept until deleted.
271    * @param[in] ecoreXwin, The window is created by application.
272    */
273   void CreateContext( Ecore_X_Window ecoreXwin );
274
275   /**
276    * @copydoc Dali::ImfManager::DeleteContext()
277    */
278   void DeleteContext();
279
280 private:
281   // Undefined
282   ImfManager( const ImfManager& );
283   ImfManager& operator=( ImfManager& );
284
285 private:
286   Ecore_IMF_Context* mIMFContext;
287   Ecore_X_Window mEcoreXWin;
288   int mIMFCursorPosition;
289   std::string mSurroundingText;
290
291   bool mInited:1;                            ///< Whether the imf is already inited.
292   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.
293   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.
294   InputMethodOptions        mOptions;
295
296   ImfManagerSignalType       mActivatedSignal;
297   ImfEventSignalType         mEventSignal;
298   ImfStatusSignalType        mKeyboardStatusSignal;
299   ImfVoidSignalType          mKeyboardResizeSignal;
300   ImfVoidSignalType          mKeyboardLanguageChangedSignal;
301   ImfKeyboardTypeSignalType  mKeyboardTypeChangedSignal;
302
303 public:
304
305 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
306 {
307   DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
308
309   BaseObject& handle = imfManager.GetBaseObject();
310
311   return static_cast<Internal::Adaptor::ImfManager&>(handle);
312 }
313
314 DALI_IMPORT_API inline static const  Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
315 {
316   DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
317
318   const BaseObject& handle = imfManager.GetBaseObject();
319
320   return static_cast<const Internal::Adaptor::ImfManager&>(handle);
321 }
322
323 };
324
325
326 } // namespace Adaptor
327
328 } // namespace Internal
329
330 } // namespace Dali
331
332 #endif // __DALI_INTERNAL_IMF_MANAGER_H