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 and DeleteSurrounding.
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 );
132 * @copydoc Dali::ImfManager::NotifyCursorPosition()
134 void NotifyCursorPosition();
137 * @copydoc Dali::ImfManager::SetCursorPosition()
139 void SetCursorPosition( unsigned int cursorPosition );
142 * @copydoc Dali::ImfManager::GetCursorPosition()
144 unsigned int GetCursorPosition() const;
147 * @copydoc Dali::ImfManager::SetSurroundingText()
149 void SetSurroundingText( const std::string& text );
152 * @copydoc Dali::ImfManager::GetSurroundingText()
154 const std::string& GetSurroundingText() const;
157 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
159 void NotifyTextInputMultiLine( bool multiLine );
162 * @copydoc Dali::ImfManager::GetTextDirection()
164 Dali::ImfManager::TextDirection GetTextDirection();
167 * @copydoc Dali::ImfManager::GetInputMethodArea()
169 Dali::Rect<int> GetInputMethodArea();
172 * @copydoc Dali::ImfManager::ApplyOptions()
174 void ApplyOptions( const InputMethodOptions& options );
179 * @copydoc Dali::ImfManager::ActivatedSignal()
181 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
184 * @copydoc Dali::ImfManager::EventReceivedSignal()
186 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
189 * @copydoc Dali::ImfManager::StatusChangedSignal()
191 ImfStatusSignalType& StatusChangedSignal() { return mKeyboardStatusSignal; }
194 * @copydoc Dali::ImfManager::ResizedSignal()
196 ImfVoidSignalType& ResizedSignal() { return mKeyboardResizeSignal; }
199 * @copydoc Dali::ImfManager::LanguageChangedSignal()
201 ImfVoidSignalType& LanguageChangedSignal() { return mKeyboardLanguageChangedSignal; }
209 virtual ~ImfManager();
213 * Context created the first time and kept until deleted.
214 * @param[in] ecoreWlwin, The window is created by application.
216 void CreateContext( Ecore_Wl_Window *ecoreWlwin );
219 * @copydoc Dali::ImfManager::DeleteContext()
221 void DeleteContext();
225 ImfManager( Ecore_Wl_Window *ecoreWlwin );
226 ImfManager( const ImfManager& );
227 ImfManager& operator=( ImfManager& );
230 Ecore_IMF_Context* mIMFContext;
231 int mIMFCursorPosition;
232 std::string mSurroundingText;
234 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
235 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
237 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
238 InputMethodOptions mOptions;
240 ImfManagerSignalType mActivatedSignal;
241 ImfEventSignalType mEventSignal;
242 ImfStatusSignalType mKeyboardStatusSignal;
243 ImfVoidSignalType mKeyboardResizeSignal;
244 ImfVoidSignalType mKeyboardLanguageChangedSignal;
248 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
250 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
252 BaseObject& handle = imfManager.GetBaseObject();
254 return static_cast<Internal::Adaptor::ImfManager&>(handle);
257 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
259 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
261 const BaseObject& handle = imfManager.GetBaseObject();
263 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
269 } // namespace Adaptor
271 } // namespace Internal
275 #endif // __DALI_INTERNAL_IMF_MANAGER_H