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 * Check whether the ImfManager is available.
57 * @return true if available, false otherwise
59 static bool IsAvailable();
62 * Get the IMF manager instance, it creates the instance if it has not already been created.
63 * Internally, a check should be made using IsAvailable() before this is called as we do not want
64 * to create an instance if not needed by applications.
67 static Dali::ImfManager Get();
70 * Connect Callbacks required for IMF.
71 * If you don't connect imf callbacks, you can't get the key events.
72 * The events are PreeditChanged, Commit, DeleteSurrounding and PrivateCommand.
74 void ConnectCallbacks();
77 * Disconnect Callbacks attached to imf context.
79 void DisconnectCallbacks();
82 * @copydoc Dali::ImfManager::Activate()
87 * @copydoc Dali::ImfManager::Deactivate()
92 * @copydoc Dali::ImfManager::Reset()
97 * @copydoc Dali::ImfManager::GetContext()
99 Ecore_IMF_Context* GetContext();
102 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
104 bool RestoreAfterFocusLost() const;
107 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
109 void SetRestoreAfterFocusLost( bool toggle );
112 * @copydoc Dali::ImfManager::PreEditChanged()
114 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
117 * @copydoc Dali::ImfManager::NotifyCursorPosition()
119 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
122 * @copydoc Dali::ImfManager::NotifyCursorPosition()
124 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
127 * @copydoc Dali::ImfManager::DeleteSurrounding()
129 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
132 * @copydoc Dali::ImfManager::SendPrivateCommand()
134 void SendPrivateCommand( void* data, Ecore_IMF_Context* imfContext, void* event_info );
138 * @copydoc Dali::ImfManager::NotifyCursorPosition()
140 void NotifyCursorPosition();
143 * @copydoc Dali::ImfManager::SetCursorPosition()
145 void SetCursorPosition( unsigned int cursorPosition );
148 * @copydoc Dali::ImfManager::GetCursorPosition()
150 unsigned int GetCursorPosition() const;
153 * @copydoc Dali::ImfManager::SetSurroundingText()
155 void SetSurroundingText( const std::string& text );
158 * @copydoc Dali::ImfManager::GetSurroundingText()
160 const std::string& GetSurroundingText() const;
163 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
165 void NotifyTextInputMultiLine( bool multiLine );
168 * @copydoc Dali::ImfManager::GetTextDirection()
170 Dali::ImfManager::TextDirection GetTextDirection();
173 * @copydoc Dali::ImfManager::GetInputMethodArea()
175 Dali::Rect<int> GetInputMethodArea();
178 * @copydoc Dali::ImfManager::ApplyOptions()
180 void ApplyOptions( const InputMethodOptions& options );
183 * @copydoc Dali::ImfManager::SetInputPanelData()
185 void SetInputPanelData( const std::string& data );
188 * @copydoc Dali::ImfManager::GetInputPanelData()
190 void GetInputPanelData( std::string& data );
193 * @copydoc Dali::ImfManager::GetInputPanelState()
195 Dali::ImfManager::State GetInputPanelState();
198 * @copydoc Dali::ImfManager::SetReturnKeyState()
200 void SetReturnKeyState( bool visible );
203 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
205 void AutoEnableInputPanel( bool enabled );
208 * @copydoc Dali::ImfManager::ShowInputPanel()
210 void ShowInputPanel();
213 * @copydoc Dali::ImfManager::HideInputPanel()
215 void HideInputPanel();
218 * @copydoc Dali::ImfManager::GetKeyboardType()
220 Dali::ImfManager::KeyboardType GetKeyboardType();
223 * @copydoc Dali::ImfManager::GetInputPanelLocale()
225 std::string GetInputPanelLocale();
230 * @copydoc Dali::ImfManager::ActivatedSignal()
232 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
235 * @copydoc Dali::ImfManager::EventReceivedSignal()
237 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
240 * @copydoc Dali::ImfManager::StatusChangedSignal()
242 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
245 * @copydoc Dali::ImfManager::ResizedSignal()
247 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
250 * @copydoc Dali::ImfManager::LanguageChangedSignal()
252 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
255 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
257 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
264 virtual ~ImfManager();
268 * Context created the first time and kept until deleted.
269 * @param[in] ecoreWlwin, The window is created by application.
271 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
274 * @copydoc Dali::ImfManager::DeleteContext()
276 void DeleteContext();
280 ImfManager( Ecore_Wl_Window *ecoreWlwin );
281 ImfManager( const ImfManager& );
282 ImfManager& operator=( ImfManager& );
285 Ecore_IMF_Context* mIMFContext;
286 int mIMFCursorPosition;
287 std::string mSurroundingText;
289 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
290 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
292 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
293 InputMethodOptions mOptions;
295 ImfManagerSignalType mActivatedSignal;
296 ImfEventSignalType mEventSignal;
297 ImfStatusSignalType mKeyboardStatusSignal;
298 ImfVoidSignalType mKeyboardResizeSignal;
299 ImfVoidSignalType mKeyboardLanguageChangedSignal;
300 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
304 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
306 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
308 BaseObject& handle = imfManager.GetBaseObject();
310 return static_cast<Internal::Adaptor::ImfManager&>(handle);
313 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
315 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
317 const BaseObject& handle = imfManager.GetBaseObject();
319 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
325 } // namespace Adaptor
327 } // namespace Internal
331 #endif // __DALI_INTERNAL_IMF_MANAGER_H