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;
48 typedef Dali::ImfManager::KeyboardTypeSignalType ImfKeyboardTypeSignalType;
53 * @copydoc Dali::ImfManager::Finalize()
58 * Check whether the ImfManager is available.
59 * @return true if available, false otherwise
61 static bool IsAvailable();
64 * Get the IMF manager instance, it creates the instance if it has not already been created.
65 * Internally, a check should be made using IsAvailable() before this is called as we do not want
66 * to create an instance if not needed by applications.
69 static Dali::ImfManager Get();
73 * @param[in] ecoreXwin, The window is created by application.
75 ImfManager( Ecore_X_Window* ecoreXwin );
78 * Connect Callbacks required for IMF.
79 * If you don't connect imf callbacks, you can't get the key events.
80 * The events are PreeditChanged, Commit and DeleteSurrounding.
82 void ConnectCallbacks();
85 * Disconnect Callbacks attached to imf context.
87 void DisconnectCallbacks();
90 * @copydoc Dali::ImfManager::Activate()
95 * @copydoc Dali::ImfManager::Deactivate()
100 * @copydoc Dali::ImfManager::Reset()
105 * @copydoc Dali::ImfManager::GetContext()
107 Ecore_IMF_Context* GetContext();
110 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
112 bool RestoreAfterFocusLost() const;
115 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
117 void SetRestoreAfterFocusLost( bool toggle );
120 * @copydoc Dali::ImfManager::PreEditChanged()
122 void PreEditChanged( void* data, Ecore_IMF_Context* imfContext, void* event_info );
125 * @copydoc Dali::ImfManager::NotifyCursorPosition()
127 void CommitReceived( void* data, Ecore_IMF_Context* imfContext, void* event_info );
130 * @copydoc Dali::ImfManager::NotifyCursorPosition()
132 Eina_Bool RetrieveSurrounding( void* data, Ecore_IMF_Context* imfContext, char** text, int* cursorPosition );
135 * @copydoc Dali::ImfManager::DeleteSurrounding()
137 void DeleteSurrounding( void* data, Ecore_IMF_Context* imfContext, void* event_info );
141 * @copydoc Dali::ImfManager::NotifyCursorPosition()
143 void NotifyCursorPosition();
146 * @copydoc Dali::ImfManager::SetCursorPosition()
148 void SetCursorPosition( unsigned int cursorPosition );
151 * @copydoc Dali::ImfManager::GetCursorPosition()
153 unsigned int GetCursorPosition() const;
156 * @copydoc Dali::ImfManager::SetSurroundingText()
158 void SetSurroundingText( const std::string& text );
161 * @copydoc Dali::ImfManager::GetSurroundingText()
163 const std::string& GetSurroundingText() const;
166 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
168 void NotifyTextInputMultiLine( bool multiLine );
171 * @copydoc Dali::ImfManager::GetTextDirection()
173 Dali::ImfManager::TextDirection GetTextDirection();
176 * @copydoc Dali::ImfManager::GetInputMethodArea()
178 Dali::Rect<int> GetInputMethodArea();
181 * @copydoc Dali::ImfManager::ApplyOptions()
183 void ApplyOptions( const InputMethodOptions& options );
186 * @copydoc Dali::ImfManager::SetInputPanelData()
188 void SetInputPanelData( const std::string& data );
191 * @copydoc Dali::ImfManager::GetInputPanelData()
193 void GetInputPanelData( std::string& data );
196 * @copydoc Dali::ImfManager::GetInputPanelState()
198 Dali::ImfManager::State GetInputPanelState();
201 * @copydoc Dali::ImfManager::SetReturnKeyState()
203 void SetReturnKeyState( bool visible );
206 * @copydoc Dali::ImfManager::AutoEnableInputPanel()
208 void AutoEnableInputPanel( bool enabled );
211 * @copydoc Dali::ImfManager::ShowInputPanel()
213 void ShowInputPanel();
216 * @copydoc Dali::ImfManager::HideInputPanel()
218 void HideInputPanel();
221 * @copydoc Dali::ImfManager::GetKeyboardType()
223 Dali::ImfManager::KeyboardType GetKeyboardType();
226 * @copydoc Dali::ImfManager::GetInputPanelLocale()
228 std::string GetInputPanelLocale();
233 * @copydoc Dali::ImfManager::ActivatedSignal()
235 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
238 * @copydoc Dali::ImfManager::EventReceivedSignal()
240 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
243 * @copydoc Dali::ImfManager::StatusChangedSignal()
245 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
248 * @copydoc Dali::ImfManager::ResizedSignal()
250 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
253 * @copydoc Dali::ImfManager::LanguageChangedSignal()
255 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
258 * @copydoc Dali::ImfManager::KeyboardTypeChangedSignal()
260 ImfKeyboardTypeSignalType& KeyboardTypeChangedSignal() { return mKeyboardTypeChangedSignal; }
266 virtual ~ImfManager();
270 * Context created the first time and kept until deleted.
271 * @param[in] ecoreXwin, The window is created by application.
273 void CreateContext( Ecore_X_Window* ecoreXwin );
276 * @copydoc Dali::ImfManager::DeleteContext()
278 void DeleteContext();
282 ImfManager( const ImfManager& );
283 ImfManager& operator=( ImfManager& );
286 Ecore_IMF_Context* mIMFContext;
287 Ecore_X_Window* mEcoreXWin;
288 int mIMFCursorPosition;
289 std::string mSurroundingText;
291 bool mInited:1; ///< Whether the imf is already inited.
292 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
293 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
294 InputMethodOptions mOptions;
296 ImfManagerSignalType mActivatedSignal;
297 ImfEventSignalType mEventSignal;
298 ImfStatusSignalType mKeyboardStatusSignal;
299 ImfVoidSignalType mKeyboardResizeSignal;
300 ImfVoidSignalType mKeyboardLanguageChangedSignal;
301 ImfKeyboardTypeSignalType mKeyboardTypeChangedSignal;
305 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
307 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
309 BaseObject& handle = imfManager.GetBaseObject();
311 return static_cast<Internal::Adaptor::ImfManager&>(handle);
314 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
316 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
318 const BaseObject& handle = imfManager.GetBaseObject();
320 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
326 } // namespace Adaptor
328 } // namespace Internal
332 #endif // __DALI_INTERNAL_IMF_MANAGER_H