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;
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();
69 * Connect Callbacks required for IMF.
70 * If you don't connect imf callbacks, you can't get the key events.
71 * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
73 void ConnectCallbacks();
76 * Disconnect Callbacks attached to imf context.
78 void DisconnectCallbacks();
81 * @copydoc Dali::ImfManager::Activate()
86 * @copydoc Dali::ImfManager::Deactivate()
91 * @copydoc Dali::ImfManager::Reset()
96 * @copydoc Dali::ImfManager::GetContext()
98 Ecore_IMF_Context* GetContext();
101 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
103 bool RestoreAfterFocusLost() const;
106 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
108 void SetRestoreAfterFocusLost( bool toggle );
111 * @copydoc Dali::ImfManager::PreEditChanged()
113 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
116 * @copydoc Dali::ImfManager::NotifyCursorPosition()
118 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
121 * @copydoc Dali::ImfManager::NotifyCursorPosition()
123 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
126 * @copydoc Dali::ImfManager::DeleteSurrounding()
128 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
131 * @copydoc Dali::ImfManager::SendPrivateCommand()
133 void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
137 * @copydoc Dali::ImfManager::NotifyCursorPosition()
139 void NotifyCursorPosition();
142 * @copydoc Dali::ImfManager::SetCursorPosition()
144 void SetCursorPosition( unsigned int cursorPosition );
147 * @copydoc Dali::ImfManager::GetCursorPosition()
149 unsigned int GetCursorPosition() const;
152 * @copydoc Dali::ImfManager::SetSurroundingText()
154 void SetSurroundingText( const std::string& text );
157 * @copydoc Dali::ImfManager::GetSurroundingText()
159 const std::string& GetSurroundingText() const;
162 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
164 void NotifyTextInputMultiLine( bool multiLine );
167 * @copydoc Dali::ImfManager::GetTextDirection()
169 Dali::ImfManager::TextDirection GetTextDirection();
172 * @copydoc Dali::ImfManager::GetInputMethodArea()
174 Dali::Rect<int> GetInputMethodArea();
177 * @copydoc Dali::ImfManager::ApplyOptions()
179 void ApplyOptions( const InputMethodOptions& options );
182 * @copydoc Dali::ImfManager::SetInputPanelUserData()
184 void SetInputPanelUserData( const std::string& data );
187 * @copydoc Dali::ImfManager::GetInputPanelUserData()
189 void GetInputPanelUserData( std::string& data );
192 * @copydoc Dali::ImfManager::GetInputPanelState()
194 Dali::ImfManager::State GetInputPanelState();
197 * @copydoc Dali::ImfManager::SetReturnKeyState()
199 void SetReturnKeyState( bool visible );
202 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
204 void AutoEnableInputPanel( bool enabled );
207 * @copydoc Dali::ImfManager::ShowInputPanel()
209 void ShowInputPanel();
212 * @copydoc Dali::ImfManager::HideInputPanel()
214 void HideInputPanel();
219 * @copydoc Dali::ImfManager::ActivatedSignal()
221 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
224 * @copydoc Dali::ImfManager::EventReceivedSignal()
226 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
229 * @copydoc Dali::ImfManager::StatusChangedSignal()
231 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
234 * @copydoc Dali::ImfManager::ResizedSignal()
236 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
239 * @copydoc Dali::ImfManager::LanguageChangedSignal()
241 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
249 virtual ~ImfManager();
253 * Context created the first time and kept until deleted.
254 * @param[in] ecoreWlwin, The window is created by application.
256 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
259 * @copydoc Dali::ImfManager::DeleteContext()
261 void DeleteContext();
265 ImfManager( Ecore_Wl_Window *ecoreWlwin );
266 ImfManager( const ImfManager& );
267 ImfManager& operator=( ImfManager& );
270 Ecore_IMF_Context* mIMFContext;
271 int mIMFCursorPosition;
272 std::string mSurroundingText;
274 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
275 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
277 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
278 InputMethodOptions mOptions;
280 ImfManagerSignalType mActivatedSignal;
281 ImfEventSignalType mEventSignal;
282 ImfStatusSignalType mKeyboardStatusSignal;
283 ImfVoidSignalType mKeyboardResizeSignal;
284 ImfVoidSignalType mKeyboardLanguageChangedSignal;
288 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
290 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
292 BaseObject& handle = imfManager.GetBaseObject();
294 return static_cast<Internal::Adaptor::ImfManager&>(handle);
297 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
299 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
301 const BaseObject& handle = imfManager.GetBaseObject();
303 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
309 } // namespace Adaptor
311 } // namespace Internal
315 #endif // __DALI_INTERNAL_IMF_MANAGER_H