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 <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 * @copydoc Dali::ImfManager::Finalize()
60 * Check whether the ImfManager is available.
61 * @return true if available, false otherwise
63 static bool IsAvailable();
66 * Get the IMF manager instance, it creates the instance if it has not already been created.
67 * Internally, a check should be made using IsAvailable() before this is called as we do not want
68 * to create an instance if not needed by applications.
71 static Dali::ImfManager Get();
75 * @param[in] ecoreXwin, The window is created by application.
77 ImfManager( Ecore_X_Window ecoreXwin );
80 * Connect Callbacks required for IMF.
81 * If you don't connect imf callbacks, you can't get the key events.
82 * The events are PreeditChanged, Commit and DeleteSurrounding.
84 void ConnectCallbacks();
87 * Disconnect Callbacks attached to imf context.
89 void DisconnectCallbacks();
92 * @copydoc Dali::ImfManager::Activate()
97 * @copydoc Dali::ImfManager::Deactivate()
102 * @copydoc Dali::ImfManager::Reset()
107 * @copydoc Dali::ImfManager::GetContext()
109 Ecore_IMF_Context* GetContext();
112 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
114 bool RestoreAfterFocusLost() const;
117 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
119 void SetRestoreAfterFocusLost( bool toggle );
122 * @copydoc Dali::ImfManager::PreEditChanged()
124 void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
127 * @copydoc Dali::ImfManager::NotifyCursorPosition()
129 void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
132 * @copydoc Dali::ImfManager::NotifyCursorPosition()
134 Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
137 * @copydoc Dali::ImfManager::DeleteSurrounding()
139 void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
143 * @copydoc Dali::ImfManager::NotifyCursorPosition()
145 void NotifyCursorPosition();
148 * @copydoc Dali::ImfManager::SetCursorPosition()
150 void SetCursorPosition( unsigned int cursorPosition );
153 * @copydoc Dali::ImfManager::GetCursorPosition()
155 unsigned int GetCursorPosition() const;
158 * @copydoc Dali::ImfManager::SetSurroundingText()
160 void SetSurroundingText( const std::string& text );
163 * @copydoc Dali::ImfManager::GetSurroundingText()
165 const std::string& GetSurroundingText() const;
168 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
170 void NotifyTextInputMultiLine( bool multiLine );
173 * @copydoc Dali::ImfManager::GetTextDirection()
175 Dali::ImfManager::TextDirection GetTextDirection();
178 * @copydoc Dali::ImfManager::GetInputMethodArea()
180 Dali::Rect<int> GetInputMethodArea();
183 * @copydoc Dali::ImfManager::ApplyOptions()
185 void ApplyOptions( const InputMethodOptions& options );
188 * @copydoc Dali::ImfManager::SetInputPanelData()
190 void SetInputPanelData( const std::string& data );
193 * @copydoc Dali::ImfManager::GetInputPanelData()
195 void GetInputPanelData( std::string& data );
198 * @copydoc Dali::ImfManager::GetInputPanelState()
200 Dali::ImfManager::State GetInputPanelState();
203 * @copydoc Dali::ImfManager::SetReturnKeyState()
205 void SetReturnKeyState( bool visible );
208 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
210 void AutoEnableInputPanel( bool enabled );
213 * @copydoc Dali::ImfManager::ShowInputPanel()
215 void ShowInputPanel();
218 * @copydoc Dali::ImfManager::HideInputPanel()
220 void HideInputPanel();
223 * @copydoc Dali::ImfManager::GetKeyboardType()
225 Dali::ImfManager::KeyboardType GetKeyboardType();
228 * @copydoc Dali::ImfManager::GetInputPanelLocale()
230 std::string GetInputPanelLocale();
235 * @copydoc Dali::ImfManager::ActivatedSignal()
237 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
240 * @copydoc Dali::ImfManager::EventReceivedSignal()
242 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
245 * @copydoc Dali::ImfManager::StatusChangedSignal()
247 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
250 * @copydoc Dali::ImfManager::ResizedSignal()
252 KeyboardResizedSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
255 * @copydoc Dali::ImfManager::LanguageChangedSignal()
257 LanguageChangedSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
260 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
262 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
268 virtual ~ImfManager();
272 * Context created the first time and kept until deleted.
273 * @param[in] ecoreXwin, The window is created by application.
275 void CreateContext( Ecore_X_Window ecoreXwin );
278 * @copydoc Dali::ImfManager::DeleteContext()
280 void DeleteContext();
284 ImfManager( const ImfManager& );
285 ImfManager& operator=( ImfManager& );
288 Ecore_IMF_Context* mIMFContext;
289 Ecore_X_Window mEcoreXWin;
290 int mIMFCursorPosition;
291 std::string mSurroundingText;
293 bool mInited:1; ///< Whether the imf is already inited.
294 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
295 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
296 InputMethodOptions mOptions;
298 ImfManagerSignalType mActivatedSignal;
299 ImfEventSignalType mEventSignal;
300 ImfStatusSignalType mKeyboardStatusSignal;
301 KeyboardResizedSignalType mKeyboardResizeSignal;
302 LanguageChangedSignalType mKeyboardLanguageChangedSignal;
303 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
307 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
309 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
311 BaseObject& handle = imfManager.GetBaseObject();
313 return static_cast<Internal::Adaptor::ImfManager&>(handle);
316 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
318 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
320 const BaseObject& handle = imfManager.GetBaseObject();
322 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
328 } // namespace Adaptor
330 } // namespace Internal
334 #endif // __DALI_INTERNAL_IMF_MANAGER_H