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;
50 * Check whether the ImfManager is available.
51 * @return true if available, false otherwise
53 static bool IsAvailable();
56 * Get the IMF manager instance, it creates the instance if it has not already been created.
57 * Internally, a check should be made using IsAvailable() before this is called as we do not want
58 * to create an instance if not needed by applications.
61 static Dali::ImfManager Get();
65 * @param[in] ecoreXwin, The window is created by application.
67 ImfManager( Ecore_X_Window ecoreXwin );
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 and DeleteSurrounding.
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 );
133 * @copydoc Dali::ImfManager::NotifyCursorPosition()
135 void NotifyCursorPosition();
138 * @copydoc Dali::ImfManager::SetCursorPosition()
140 void SetCursorPosition( unsigned int cursorPosition );
143 * @copydoc Dali::ImfManager::GetCursorPosition()
145 unsigned int GetCursorPosition() const;
148 * @copydoc Dali::ImfManager::SetSurroundingText()
150 void SetSurroundingText( const std::string& text );
153 * @copydoc Dali::ImfManager::GetSurroundingText()
155 const std::string& GetSurroundingText() const;
158 * @copydoc Dali::ImfManager::NotifyTextInputMultiLine()
160 void NotifyTextInputMultiLine( bool multiLine );
165 * @copydoc Dali::ImfManager::ActivatedSignal()
167 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
170 * @copydoc Dali::ImfManager::EventReceivedSignal()
172 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
179 virtual ~ImfManager();
183 * Context created the first time and kept until deleted.
184 * @param[in] ecoreXwin, The window is created by application.
186 void CreateContext( Ecore_X_Window ecoreXwin );
189 * @copydoc Dali::ImfManager::DeleteContext()
191 void DeleteContext();
195 ImfManager( const ImfManager& );
196 ImfManager& operator=( ImfManager& );
199 Ecore_IMF_Context* mIMFContext;
200 int mIMFCursorPosition;
201 std::string mSurroundingText;
203 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
204 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
206 ImfManagerSignalType mActivatedSignal;
207 ImfEventSignalType mEventSignal;
211 DALI_IMPORT_API inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
213 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
215 BaseObject& handle = imfManager.GetBaseObject();
217 return static_cast<Internal::Adaptor::ImfManager&>(handle);
220 DALI_IMPORT_API inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
222 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
224 const BaseObject& handle = imfManager.GetBaseObject();
226 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
232 } // namespace Adaptor
234 } // namespace Internal
238 #endif // __DALI_INTERNAL_IMF_MANAGER_H