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>
24 #include <Ecore_Wayland.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/object/base-object.h>
28 #include <dali/integration-api/events/key-event-integ.h>
31 #include <imf-manager.h>
44 class DALI_IMPORT_API ImfManager : public Dali::BaseObject
47 typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
48 typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType;
49 typedef Dali::ImfManager::StatusSignalType ImfStatusSignalType;
50 typedef Dali::ImfManager::VoidSignalType ImfVoidSignalType;
51 typedef Dali::ImfManager::KeyboardTypeSignalType ImfKeyboardTypeSignalType;
56 * @copydoc Dali::ImfManager::Finalize()
61 * Check whether the ImfManager is available.
62 * @return true if available, false otherwise
64 static bool IsAvailable();
67 * Get the IMF manager instance, it creates the instance if it has not already been created.
68 * Internally, a check should be made using IsAvailable() before this is called as we do not want
69 * to create an instance if not needed by applications.
72 static Dali::ImfManager Get();
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, DeleteSurrounding and PrivateCommand.
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 );
137 * @copydoc Dali::ImfManager::SendPrivateCommand()
139 void SendPrivateCommand( 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::SetInputPanelUserData()
190 void SetInputPanelUserData( const std::string& data );
193 * @copydoc Dali::ImfManager::GetInputPanelUserData()
195 void GetInputPanelUserData( 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 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
255 * @copydoc Dali::ImfManager::LanguageChangedSignal()
257 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
260 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
262 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
269 virtual ~ImfManager();
273 * Context created the first time and kept until deleted.
274 * @param[in] ecoreWlwin, The window is created by application.
276 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
279 * @copydoc Dali::ImfManager::DeleteContext()
281 void DeleteContext();
285 ImfManager( Ecore_Wl_Window *ecoreWlwin );
286 ImfManager( const ImfManager& );
287 ImfManager& operator=( ImfManager& );
290 Ecore_IMF_Context* mIMFContext;
291 Ecore_Wl_Window *mEcoreWlwin;
292 int mIMFCursorPosition;
293 std::string mSurroundingText;
295 bool mInited:1; ///< Whether the imf is already inited.
296 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
297 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
299 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
300 InputMethodOptions mOptions;
302 ImfManagerSignalType mActivatedSignal;
303 ImfEventSignalType mEventSignal;
304 ImfStatusSignalType mKeyboardStatusSignal;
305 ImfVoidSignalType mKeyboardResizeSignal;
306 ImfVoidSignalType mKeyboardLanguageChangedSignal;
307 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
311 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
313 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
315 BaseObject& handle = imfManager.GetBaseObject();
317 return static_cast<Internal::Adaptor::ImfManager&>(handle);
320 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
322 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
324 const BaseObject& handle = imfManager.GetBaseObject();
326 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
332 } // namespace Adaptor
334 } // namespace Internal
338 #endif // __DALI_INTERNAL_IMF_MANAGER_H