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;
52 * Check whether the ImfManager is available.
53 * @return true if available, false otherwise
55 static bool IsAvailable();
58 * Get the IMF manager instance, it creates the instance if it has not already been created.
59 * Internally, a check should be made using IsAvailable() before this is called as we do not want
60 * to create an instance if not needed by applications.
63 static Dali::ImfManager Get();
67 * @param[in] ecoreXwin, The window is created by application.
69 ImfManager( Ecore_X_Window ecoreXwin );
72 * Connect Callbacks required for IMF.
73 * If you don't connect imf callbacks, you can't get the key events.
74 * The events are PreeditChanged, Commit and DeleteSurrounding.
76 void ConnectCallbacks();
79 * Disconnect Callbacks attached to imf context.
81 void DisconnectCallbacks();
84 * @copydoc Dali::ImfManager::Activate()
89 * @copydoc Dali::ImfManager::Deactivate()
94 * @copydoc Dali::ImfManager::Reset()
99 * @copydoc Dali::ImfManager::GetContext()
101 Ecore_IMF_Context* GetContext();
104 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
106 bool RestoreAfterFocusLost() const;
109 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
111 void SetRestoreAfterFocusLost( bool toggle );
114 * @copydoc Dali::ImfManager::PreEditChanged()
116 void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
119 * @copydoc Dali::ImfManager::NotifyCursorPosition()
121 void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
124 * @copydoc Dali::ImfManager::NotifyCursorPosition()
126 Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
129 * @copydoc Dali::ImfManager::DeleteSurrounding()
131 void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
135 * @copydoc Dali::ImfManager::NotifyCursorPosition()
137 void NotifyCursorPosition();
140 * @copydoc Dali::ImfManager::SetCursorPosition()
142 void SetCursorPosition( unsigned int cursorPosition );
145 * @copydoc Dali::ImfManager::GetCursorPosition()
147 unsigned int GetCursorPosition() const;
150 * @copydoc Dali::ImfManager::SetSurroundingText()
152 void SetSurroundingText( const std::string& text );
155 * @copydoc Dali::ImfManager::GetSurroundingText()
157 const std::string& GetSurroundingText() const;
160 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
162 void NotifyTextInputMultiLine( bool multiLine );
165 * @copydoc Dali::ImfManager::GetTextDirection()
167 Dali::ImfManager::TextDirection GetTextDirection();
170 * @copydoc Dali::ImfManager::GetInputMethodArea()
172 Dali::Rect<int> GetInputMethodArea();
175 * @copydoc Dali::ImfManager::ApplyOptions()
177 void ApplyOptions( const InputMethodOptions& options );
180 * @copydoc Dali::ImfManager::SetInputPanelUserData()
182 void SetInputPanelUserData( const std::string& data );
185 * @copydoc Dali::ImfManager::GetInputPanelUserData()
187 void GetInputPanelUserData( std::string& data );
190 * @copydoc Dali::ImfManager::GetInputPanelState()
192 Dali::ImfManager::State GetInputPanelState();
195 * @copydoc Dali::ImfManager::SetReturnKeyState()
197 void SetReturnKeyState( bool visible );
200 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
202 void AutoEnableInputPanel( bool enabled );
205 * @copydoc Dali::ImfManager::ShowInputPanel()
207 void ShowInputPanel();
210 * @copydoc Dali::ImfManager::HideInputPanel()
212 void HideInputPanel();
217 * @copydoc Dali::ImfManager::ActivatedSignal()
219 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
222 * @copydoc Dali::ImfManager::EventReceivedSignal()
224 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
227 * @copydoc Dali::ImfManager::StatusChangedSignal()
229 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
232 * @copydoc Dali::ImfManager::ResizedSignal()
234 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
237 * @copydoc Dali::ImfManager::LanguageChangedSignal()
239 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
246 virtual ~ImfManager();
250 * Context created the first time and kept until deleted.
251 * @param[in] ecoreXwin, The window is created by application.
253 void CreateContext( Ecore_X_Window ecoreXwin );
256 * @copydoc Dali::ImfManager::DeleteContext()
258 void DeleteContext();
262 ImfManager( const ImfManager& );
263 ImfManager& operator=( ImfManager& );
266 Ecore_IMF_Context* mIMFContext;
267 int mIMFCursorPosition;
268 std::string mSurroundingText;
270 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
271 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
272 InputMethodOptions mOptions;
274 ImfManagerSignalType mActivatedSignal;
275 ImfEventSignalType mEventSignal;
276 ImfStatusSignalType mKeyboardStatusSignal;
277 ImfVoidSignalType mKeyboardResizeSignal;
278 ImfVoidSignalType mKeyboardLanguageChangedSignal;
282 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
284 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
286 BaseObject& handle = imfManager.GetBaseObject();
288 return static_cast<Internal::Adaptor::ImfManager&>(handle);
291 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
293 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
295 const BaseObject& handle = imfManager.GetBaseObject();
297 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
303 } // namespace Adaptor
305 } // namespace Internal
309 #endif // __DALI_INTERNAL_IMF_MANAGER_H