1 #ifndef __DALI_INTERNAL_IMF_MANAGER_H
2 #define __DALI_INTERNAL_IMF_MANAGER_H
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <Ecore_IMF.h>
25 #include <dali/public-api/object/base-object.h>
28 #include <dali/devel-api/adaptor-framework/imf-manager.h>
41 class DALI_IMPORT_API ImfManager : public Dali::BaseObject
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;
55 * Check whether the ImfManager is available.
56 * @return true if available, false otherwise
58 static bool IsAvailable();
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.
66 static Dali::ImfManager Get();
70 * @param[in] ecoreXwin, The window is created by application.
72 ImfManager( Ecore_X_Window ecoreXwin );
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.
79 void ConnectCallbacks();
82 * Disconnect Callbacks attached to imf context.
84 void DisconnectCallbacks();
87 * @copydoc Dali::ImfManager::Activate()
92 * @copydoc Dali::ImfManager::Deactivate()
97 * @copydoc Dali::ImfManager::Reset()
102 * @copydoc Dali::ImfManager::GetContext()
104 Ecore_IMF_Context* GetContext();
107 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
109 bool RestoreAfterFocusLost() const;
112 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
114 void SetRestoreAfterFocusLost( bool toggle );
117 * @copydoc Dali::ImfManager::PreEditChanged()
119 void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
122 * @copydoc Dali::ImfManager::NotifyCursorPosition()
124 void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
127 * @copydoc Dali::ImfManager::NotifyCursorPosition()
129 Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
132 * @copydoc Dali::ImfManager::DeleteSurrounding()
134 void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
138 * @copydoc Dali::ImfManager::NotifyCursorPosition()
140 void NotifyCursorPosition();
143 * @copydoc Dali::ImfManager::SetCursorPosition()
145 void SetCursorPosition( unsigned int cursorPosition );
148 * @copydoc Dali::ImfManager::GetCursorPosition()
150 unsigned int GetCursorPosition() const;
153 * @copydoc Dali::ImfManager::SetSurroundingText()
155 void SetSurroundingText( const std::string& text );
158 * @copydoc Dali::ImfManager::GetSurroundingText()
160 const std::string& GetSurroundingText() const;
163 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
165 void NotifyTextInputMultiLine( bool multiLine );
168 * @copydoc Dali::ImfManager::GetTextDirection()
170 Dali::ImfManager::TextDirection GetTextDirection();
173 * @copydoc Dali::ImfManager::GetInputMethodArea()
175 Dali::Rect<int> GetInputMethodArea();
178 * @copydoc Dali::ImfManager::ApplyOptions()
180 void ApplyOptions( const InputMethodOptions& options );
183 * @copydoc Dali::ImfManager::SetInputPanelData()
185 void SetInputPanelData( const std::string& data );
188 * @copydoc Dali::ImfManager::GetInputPanelData()
190 void GetInputPanelData( std::string& data );
193 * @copydoc Dali::ImfManager::GetInputPanelState()
195 Dali::ImfManager::State GetInputPanelState();
198 * @copydoc Dali::ImfManager::SetReturnKeyState()
200 void SetReturnKeyState( bool visible );
203 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
205 void AutoEnableInputPanel( bool enabled );
208 * @copydoc Dali::ImfManager::ShowInputPanel()
210 void ShowInputPanel();
213 * @copydoc Dali::ImfManager::HideInputPanel()
215 void HideInputPanel();
218 * @copydoc Dali::ImfManager::GetKeyboardType()
220 Dali::ImfManager::KeyboardType GetKeyboardType();
223 * @copydoc Dali::ImfManager::GetInputPanelLocale()
225 std::string GetInputPanelLocale();
230 * @copydoc Dali::ImfManager::ActivatedSignal()
232 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
235 * @copydoc Dali::ImfManager::EventReceivedSignal()
237 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
240 * @copydoc Dali::ImfManager::StatusChangedSignal()
242 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
245 * @copydoc Dali::ImfManager::ResizedSignal()
247 KeyboardResizedSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
250 * @copydoc Dali::ImfManager::LanguageChangedSignal()
252 LanguageChangedSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
255 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
257 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
263 virtual ~ImfManager();
267 * Context created the first time and kept until deleted.
268 * @param[in] ecoreXwin, The window is created by application.
270 void CreateContext( Ecore_X_Window ecoreXwin );
273 * @copydoc Dali::ImfManager::DeleteContext()
275 void DeleteContext();
279 ImfManager( const ImfManager& );
280 ImfManager& operator=( ImfManager& );
283 Ecore_IMF_Context* mIMFContext;
284 int mIMFCursorPosition;
285 std::string mSurroundingText;
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;
291 ImfManagerSignalType mActivatedSignal;
292 ImfEventSignalType mEventSignal;
293 ImfStatusSignalType mKeyboardStatusSignal;
294 KeyboardResizedSignalType mKeyboardResizeSignal;
295 LanguageChangedSignalType mKeyboardLanguageChangedSignal;
296 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
300 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
302 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
304 BaseObject& handle = imfManager.GetBaseObject();
306 return static_cast<Internal::Adaptor::ImfManager&>(handle);
309 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
311 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
313 const BaseObject& handle = imfManager.GetBaseObject();
315 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
321 } // namespace Adaptor
323 } // namespace Internal
327 #endif // __DALI_INTERNAL_IMF_MANAGER_H