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;
52 typedef Dali::ImfManager::KeyboardResizedSignalType KeyboardResizedSignalType;
53 typedef Dali::ImfManager::LanguageChangedSignalType LanguageChangedSignalType;
58 * @copydoc Dali::ImfManager::Finalize()
63 * Check whether the ImfManager is available.
64 * @return true if available, false otherwise
66 static bool IsAvailable();
69 * Get the IMF manager instance, it creates the instance if it has not already been created.
70 * Internally, a check should be made using IsAvailable() before this is called as we do not want
71 * to create an instance if not needed by applications.
74 static Dali::ImfManager Get();
77 * Connect Callbacks required for IMF.
78 * If you don't connect imf callbacks, you can't get the key events.
79 * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
81 void ConnectCallbacks();
84 * Disconnect Callbacks attached to imf context.
86 void DisconnectCallbacks();
89 * @copydoc Dali::ImfManager::Activate()
94 * @copydoc Dali::ImfManager::Deactivate()
99 * @copydoc Dali::ImfManager::Reset()
104 * @copydoc Dali::ImfManager::GetContext()
106 Ecore_IMF_Context* GetContext();
109 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
111 bool RestoreAfterFocusLost() const;
114 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
116 void SetRestoreAfterFocusLost( bool toggle );
119 * @copydoc Dali::ImfManager::PreEditChanged()
121 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
124 * @copydoc Dali::ImfManager::NotifyCursorPosition()
126 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
129 * @copydoc Dali::ImfManager::NotifyCursorPosition()
131 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
134 * @copydoc Dali::ImfManager::DeleteSurrounding()
136 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
139 * @copydoc Dali::ImfManager::SendPrivateCommand()
141 void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
145 * @copydoc Dali::ImfManager::NotifyCursorPosition()
147 void NotifyCursorPosition();
150 * @copydoc Dali::ImfManager::SetCursorPosition()
152 void SetCursorPosition( unsigned int cursorPosition );
155 * @copydoc Dali::ImfManager::GetCursorPosition()
157 unsigned int GetCursorPosition() const;
160 * @copydoc Dali::ImfManager::SetSurroundingText()
162 void SetSurroundingText( const std::string& text );
165 * @copydoc Dali::ImfManager::GetSurroundingText()
167 const std::string& GetSurroundingText() const;
170 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
172 void NotifyTextInputMultiLine( bool multiLine );
175 * @copydoc Dali::ImfManager::GetTextDirection()
177 Dali::ImfManager::TextDirection GetTextDirection();
180 * @copydoc Dali::ImfManager::GetInputMethodArea()
182 Dali::Rect<int> GetInputMethodArea();
185 * @copydoc Dali::ImfManager::ApplyOptions()
187 void ApplyOptions( const InputMethodOptions& options );
190 * @copydoc Dali::ImfManager::SetInputPanelData()
192 void SetInputPanelData( const std::string& data );
195 * @copydoc Dali::ImfManager::GetInputPanelData()
197 void GetInputPanelData( std::string& data );
200 * @copydoc Dali::ImfManager::GetInputPanelState()
202 Dali::ImfManager::State GetInputPanelState();
205 * @copydoc Dali::ImfManager::SetReturnKeyState()
207 void SetReturnKeyState( bool visible );
210 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
212 void AutoEnableInputPanel( bool enabled );
215 * @copydoc Dali::ImfManager::ShowInputPanel()
217 void ShowInputPanel();
220 * @copydoc Dali::ImfManager::HideInputPanel()
222 void HideInputPanel();
225 * @copydoc Dali::ImfManager::GetKeyboardType()
227 Dali::ImfManager::KeyboardType GetKeyboardType();
230 * @copydoc Dali::ImfManager::GetInputPanelLocale()
232 std::string GetInputPanelLocale();
237 * @copydoc Dali::ImfManager::ActivatedSignal()
239 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
242 * @copydoc Dali::ImfManager::EventReceivedSignal()
244 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
247 * @copydoc Dali::ImfManager::StatusChangedSignal()
249 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
252 * @copydoc Dali::ImfManager::ResizedSignal()
254 KeyboardResizedSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
257 * @copydoc Dali::ImfManager::LanguageChangedSignal()
259 LanguageChangedSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
262 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
264 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
271 virtual ~ImfManager();
275 * Context created the first time and kept until deleted.
276 * @param[in] ecoreWlwin, The window is created by application.
278 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
281 * @copydoc Dali::ImfManager::DeleteContext()
283 void DeleteContext();
286 * Set default input method options when context was re-created.
288 void SetDefaultOptions();
292 ImfManager( Ecore_Wl_Window *ecoreWlwin );
293 ImfManager( const ImfManager& );
294 ImfManager& operator=( ImfManager& );
297 Ecore_IMF_Context* mIMFContext;
298 Ecore_Wl_Window *mEcoreWlwin;
299 int mIMFCursorPosition;
300 std::string mSurroundingText;
302 bool mInited:1; ///< Whether the imf is already inited.
303 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
304 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
306 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
307 InputMethodOptions mOptions;
309 ImfManagerSignalType mActivatedSignal;
310 ImfEventSignalType mEventSignal;
311 ImfStatusSignalType mKeyboardStatusSignal;
312 KeyboardResizedSignalType mKeyboardResizeSignal;
313 LanguageChangedSignalType mKeyboardLanguageChangedSignal;
314 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
318 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
320 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
322 BaseObject& handle = imfManager.GetBaseObject();
324 return static_cast<Internal::Adaptor::ImfManager&>(handle);
327 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
329 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
331 const BaseObject& handle = imfManager.GetBaseObject();
333 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
339 } // namespace Adaptor
341 } // namespace Internal
345 #endif // __DALI_INTERNAL_IMF_MANAGER_H