Revert "[Tizen] ecore-wl2: add zxdg_shell define"
[platform/core/uifw/dali-adaptor.git] / dali / 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 <dali/devel-api/adaptor-framework/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   typedef Dali::ImfManager::KeyboardResizedSignalType KeyboardResizedSignalType;
50   typedef Dali::ImfManager::LanguageChangedSignalType LanguageChangedSignalType;
51
52 public:
53
54   /**
55    * Check whether the ImfManager is available.
56    * @return true if available, false otherwise
57    */
58   static bool IsAvailable();
59
60   /**
61    * Get the IMF manager instance, it creates the instance if it has not already been created.
62    * Internally, a check should be made using IsAvailable() before this is called as we do not want
63    * to create an instance if not needed by applications.
64    * @see IsAvailable()
65    */
66   static Dali::ImfManager Get();
67
68   /**
69    * Constructor
70    * @param[in] ecoreXwin, The window is created by application.
71    */
72   ImfManager( Ecore_X_Window ecoreXwin );
73
74   /**
75    * Connect Callbacks required for IMF.
76    * If you don't connect imf callbacks, you can't get the key events.
77    * The events are PreeditChanged, Commit and DeleteSurrounding.
78    */
79   void ConnectCallbacks();
80
81   /**
82    * Disconnect Callbacks attached to imf context.
83    */
84   void DisconnectCallbacks();
85
86   /**
87    * @copydoc Dali::ImfManager::Activate()
88    */
89   void Activate();
90
91   /**
92    * @copydoc Dali::ImfManager::Deactivate()
93    */
94   void Deactivate();
95
96   /**
97    * @copydoc Dali::ImfManager::Reset()
98    */
99   void Reset();
100
101   /**
102    * @copydoc Dali::ImfManager::GetContext()
103    */
104   Ecore_IMF_Context* GetContext();
105
106   /**
107    * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
108    */
109   bool RestoreAfterFocusLost() const;
110
111   /**
112    * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
113    */
114   void SetRestoreAfterFocusLost( bool toggle );
115
116   /**
117    * @copydoc Dali::ImfManager::PreEditChanged()
118    */
119   void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
120
121   /**
122    * @copydoc Dali::ImfManager::NotifyCursorPosition()
123    */
124   void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
125
126   /**
127    * @copydoc Dali::ImfManager::NotifyCursorPosition()
128    */
129   Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
130
131   /**
132    * @copydoc Dali::ImfManager::DeleteSurrounding()
133    */
134   void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
135
136   // Cursor related
137   /**
138    * @copydoc Dali::ImfManager::NotifyCursorPosition()
139    */
140   void NotifyCursorPosition();
141
142   /**
143    * @copydoc Dali::ImfManager::SetCursorPosition()
144    */
145   void SetCursorPosition( unsigned int cursorPosition );
146
147   /**
148    * @copydoc Dali::ImfManager::GetCursorPosition()
149    */
150   unsigned int GetCursorPosition() const;
151
152   /**
153    * @copydoc Dali::ImfManager::SetSurroundingText()
154    */
155   void SetSurroundingText( const std::string& text );
156
157   /**
158    * @copydoc Dali::ImfManager::GetSurroundingText()
159    */
160   const std::string& GetSurroundingText() const;
161
162   /**
163   * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
164   */
165   void NotifyTextInputMultiLine( bool multiLine );
166
167   /**
168   * @copydoc Dali::ImfManager::GetTextDirection()
169   */
170   Dali::ImfManager::TextDirection GetTextDirection();
171
172   /**
173   * @copydoc Dali::ImfManager::GetInputMethodArea()
174   */
175   Dali::Rect<int> GetInputMethodArea();
176
177   /**
178   * @copydoc Dali::ImfManager::ApplyOptions()
179   */
180   void ApplyOptions( const InputMethodOptions& options );
181
182   /**
183    * @copydoc Dali::ImfManager::SetInputPanelData()
184    */
185   void SetInputPanelData( const std::string& data );
186
187   /**
188    * @copydoc Dali::ImfManager::GetInputPanelData()
189    */
190   void GetInputPanelData( std::string& data );
191
192   /**
193    * @copydoc Dali::ImfManager::GetInputPanelState()
194    */
195   Dali::ImfManager::State GetInputPanelState();
196
197   /**
198    * @copydoc Dali::ImfManager::SetReturnKeyState()
199    */
200   void SetReturnKeyState( bool visible );
201
202   /**
203    * @copydoc Dali::ImfManager::AutoEnableInputPanel()
204    */
205   void AutoEnableInputPanel( bool enabled );
206
207   /**
208    * @copydoc Dali::ImfManager::ShowInputPanel()
209    */
210   void ShowInputPanel();
211
212   /**
213    * @copydoc Dali::ImfManager::HideInputPanel()
214    */
215   void HideInputPanel();
216
217   /**
218    * @copydoc Dali::ImfManager::GetKeyboardType()
219    */
220   Dali::ImfManager::KeyboardType GetKeyboardType();
221
222   /**
223    * @copydoc Dali::ImfManager::GetInputPanelLocale()
224    */
225   std::string GetInputPanelLocale();
226
227 public:  // Signals
228
229   /**
230    * @copydoc Dali::ImfManager::ActivatedSignal()
231    */
232   ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
233
234   /**
235    * @copydoc Dali::ImfManager::EventReceivedSignal()
236    */
237   ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
238
239   /**
240    * @copydoc Dali::ImfManager::StatusChangedSignal()
241    */
242   ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
243
244   /**
245    * @copydoc Dali::ImfManager::ResizedSignal()
246    */
247   KeyboardResizedSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
248
249   /**
250    * @copydoc Dali::ImfManager::LanguageChangedSignal()
251    */
252   LanguageChangedSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
253
254   /**
255    * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
256    */
257   ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
258 protected:
259
260   /**
261    * Destructor.
262    */
263   virtual ~ImfManager();
264
265 private:
266   /**
267    * Context created the first time and kept until deleted.
268    * @param[in] ecoreXwin, The window is created by application.
269    */
270   void CreateContext( Ecore_X_Window ecoreXwin );
271
272   /**
273    * @copydoc Dali::ImfManager::DeleteContext()
274    */
275   void DeleteContext();
276
277 private:
278   // Undefined
279   ImfManager( const ImfManager& );
280   ImfManager& operator=( ImfManager& );
281
282 private:
283   Ecore_IMF_Context* mIMFContext;
284   int mIMFCursorPosition;
285   std::string mSurroundingText;
286
287   bool mRestoreAfterFocusLost:1;             ///< Whether the keyboard needs to be restored (activated ) after focus regained.
288   bool mIdleCallbackConnected:1;             ///< Whether the idle callback is already connected.
289   InputMethodOptions        mOptions;
290
291   ImfManagerSignalType       mActivatedSignal;
292   ImfEventSignalType         mEventSignal;
293   ImfStatusSignalType        mKeyboardStatusSignal;
294   KeyboardResizedSignalType  mKeyboardResizeSignal;
295   LanguageChangedSignalType  mKeyboardLanguageChangedSignal;
296   ImfKeyboardTypeSignalType  mKeyboardTypeChangedSignal;
297
298 public:
299
300 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
301 {
302   DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
303
304   BaseObject& handle = imfManager.GetBaseObject();
305
306   return static_cast<Internal::Adaptor::ImfManager&>(handle);
307 }
308
309 DALI_IMPORT_API inline static const  Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
310 {
311   DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
312
313   const BaseObject& handle = imfManager.GetBaseObject();
314
315   return static_cast<const Internal::Adaptor::ImfManager&>(handle);
316 }
317
318 };
319
320
321 } // namespace Adaptor
322
323 } // namespace Internal
324
325 } // namespace Dali
326
327 #endif // __DALI_INTERNAL_IMF_MANAGER_H