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 );
182 * @copydoc Dali::ImfManager::ActivatedSignal()
184 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
187 * @copydoc Dali::ImfManager::EventReceivedSignal()
189 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
192 * @copydoc Dali::ImfManager::StatusChangedSignal()
194 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
197 * @copydoc Dali::ImfManager::ResizedSignal()
199 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
202 * @copydoc Dali::ImfManager::LanguageChangedSignal()
204 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
211 virtual ~ImfManager();
215 * Context created the first time and kept until deleted.
216 * @param[in] ecoreXwin, The window is created by application.
218 void CreateContext( Ecore_X_Window ecoreXwin );
221 * @copydoc Dali::ImfManager::DeleteContext()
223 void DeleteContext();
227 ImfManager( const ImfManager& );
228 ImfManager& operator=( ImfManager& );
231 Ecore_IMF_Context* mIMFContext;
232 int mIMFCursorPosition;
233 std::string mSurroundingText;
235 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
236 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
237 InputMethodOptions mOptions;
239 ImfManagerSignalType mActivatedSignal;
240 ImfEventSignalType mEventSignal;
241 ImfStatusSignalType mKeyboardStatusSignal;
242 ImfVoidSignalType mKeyboardResizeSignal;
243 ImfVoidSignalType mKeyboardLanguageChangedSignal;
247 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
249 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
251 BaseObject& handle = imfManager.GetBaseObject();
253 return static_cast<Internal::Adaptor::ImfManager&>(handle);
256 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
258 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
260 const BaseObject& handle = imfManager.GetBaseObject();
262 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
268 } // namespace Adaptor
270 } // namespace Internal
274 #endif // __DALI_INTERNAL_IMF_MANAGER_H