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;
53 * Check whether the ImfManager is available.
54 * @return true if available, false otherwise
56 static bool IsAvailable();
59 * Get the IMF manager instance, it creates the instance if it has not already been created.
60 * Internally, a check should be made using IsAvailable() before this is called as we do not want
61 * to create an instance if not needed by applications.
64 static Dali::ImfManager Get();
68 * @param[in] ecoreXwin, The window is created by application.
70 ImfManager( Ecore_X_Window ecoreXwin );
73 * Connect Callbacks required for IMF.
74 * If you don't connect imf callbacks, you can't get the key events.
75 * The events are PreeditChanged, Commit and DeleteSurrounding.
77 void ConnectCallbacks();
80 * Disconnect Callbacks attached to imf context.
82 void DisconnectCallbacks();
85 * @copydoc Dali::ImfManager::Activate()
90 * @copydoc Dali::ImfManager::Deactivate()
95 * @copydoc Dali::ImfManager::Reset()
100 * @copydoc Dali::ImfManager::GetContext()
102 Ecore_IMF_Context* GetContext();
105 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
107 bool RestoreAfterFocusLost() const;
110 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
112 void SetRestoreAfterFocusLost( bool toggle );
115 * @copydoc Dali::ImfManager::PreEditChanged()
117 void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
120 * @copydoc Dali::ImfManager::NotifyCursorPosition()
122 void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
125 * @copydoc Dali::ImfManager::NotifyCursorPosition()
127 Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
130 * @copydoc Dali::ImfManager::DeleteSurrounding()
132 void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
136 * @copydoc Dali::ImfManager::NotifyCursorPosition()
138 void NotifyCursorPosition();
141 * @copydoc Dali::ImfManager::SetCursorPosition()
143 void SetCursorPosition( unsigned int cursorPosition );
146 * @copydoc Dali::ImfManager::GetCursorPosition()
148 unsigned int GetCursorPosition() const;
151 * @copydoc Dali::ImfManager::SetSurroundingText()
153 void SetSurroundingText( const std::string& text );
156 * @copydoc Dali::ImfManager::GetSurroundingText()
158 const std::string& GetSurroundingText() const;
161 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
163 void NotifyTextInputMultiLine( bool multiLine );
166 * @copydoc Dali::ImfManager::GetTextDirection()
168 Dali::ImfManager::TextDirection GetTextDirection();
171 * @copydoc Dali::ImfManager::GetInputMethodArea()
173 Dali::Rect<int> GetInputMethodArea();
176 * @copydoc Dali::ImfManager::ApplyOptions()
178 void ApplyOptions( const InputMethodOptions& options );
181 * @copydoc Dali::ImfManager::SetInputPanelUserData()
183 void SetInputPanelUserData( const std::string& data );
186 * @copydoc Dali::ImfManager::GetInputPanelUserData()
188 void GetInputPanelUserData( std::string& data );
191 * @copydoc Dali::ImfManager::GetInputPanelState()
193 Dali::ImfManager::State GetInputPanelState();
196 * @copydoc Dali::ImfManager::SetReturnKeyState()
198 void SetReturnKeyState( bool visible );
201 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
203 void AutoEnableInputPanel( bool enabled );
206 * @copydoc Dali::ImfManager::ShowInputPanel()
208 void ShowInputPanel();
211 * @copydoc Dali::ImfManager::HideInputPanel()
213 void HideInputPanel();
216 * @copydoc Dali::ImfManager::GetKeyboardType()
218 Dali::ImfManager::KeyboardType GetKeyboardType();
221 * @copydoc Dali::ImfManager::GetInputPanelLocale()
223 std::string GetInputPanelLocale();
228 * @copydoc Dali::ImfManager::ActivatedSignal()
230 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
233 * @copydoc Dali::ImfManager::EventReceivedSignal()
235 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
238 * @copydoc Dali::ImfManager::StatusChangedSignal()
240 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
243 * @copydoc Dali::ImfManager::ResizedSignal()
245 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
248 * @copydoc Dali::ImfManager::LanguageChangedSignal()
250 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
253 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
255 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
261 virtual ~ImfManager();
265 * Context created the first time and kept until deleted.
266 * @param[in] ecoreXwin, The window is created by application.
268 void CreateContext( Ecore_X_Window ecoreXwin );
271 * @copydoc Dali::ImfManager::DeleteContext()
273 void DeleteContext();
277 ImfManager( const ImfManager& );
278 ImfManager& operator=( ImfManager& );
281 Ecore_IMF_Context* mIMFContext;
282 int mIMFCursorPosition;
283 std::string mSurroundingText;
285 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
286 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
287 InputMethodOptions mOptions;
289 ImfManagerSignalType mActivatedSignal;
290 ImfEventSignalType mEventSignal;
291 ImfStatusSignalType mKeyboardStatusSignal;
292 ImfVoidSignalType mKeyboardResizeSignal;
293 ImfVoidSignalType mKeyboardLanguageChangedSignal;
294 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
298 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
300 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
302 BaseObject& handle = imfManager.GetBaseObject();
304 return static_cast<Internal::Adaptor::ImfManager&>(handle);
307 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
309 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
311 const BaseObject& handle = imfManager.GetBaseObject();
313 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
319 } // namespace Adaptor
321 } // namespace Internal
325 #endif // __DALI_INTERNAL_IMF_MANAGER_H