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>
26 #include <imf-manager.h>
27 #include <dali/integration-api/events/key-event-integ.h>
43 class ImfManager : public Dali::BaseObject
46 typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
47 typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType;
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::GetCursorPosition()
142 int GetCursorPosition();
145 * @copydoc Dali::ImfManager::SetCursorPosition()
147 void SetCursorPosition( unsigned int cursorPosition );
150 * @copydoc Dali::ImfManager::SetSurroundingText()
152 void SetSurroundingText( std::string text );
155 * @copydoc Dali::ImfManager::GetSurroundingText()
157 std::string GetSurroundingText();
162 * @copydoc Dali::ImfManager::ActivatedSignal()
164 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
167 * @copydoc Dali::ImfManager::EventReceivedSignal()
169 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
176 virtual ~ImfManager();
180 * Context created the first time and kept until deleted.
181 * @param[in] ecoreXwin, The window is created by application.
183 void CreateContext( Ecore_X_Window ecoreXwin );
186 * @copydoc Dali::ImfManager::DeleteContext()
188 void DeleteContext();
192 ImfManager( const ImfManager& );
193 ImfManager& operator=( ImfManager& );
196 Ecore_IMF_Context* mIMFContext;
197 int mIMFCursorPosition;
198 std::string mSurroundingText;
200 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
201 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
203 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
205 ImfManagerSignalType mActivatedSignal;
206 ImfEventSignalType mEventSignal;
210 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
212 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
214 BaseObject& handle = imfManager.GetBaseObject();
216 return static_cast<Internal::Adaptor::ImfManager&>(handle);
219 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
221 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
223 const BaseObject& handle = imfManager.GetBaseObject();
225 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
231 } // namespace Adaptor
233 } // namespace Internal
237 #endif // __DALI_INTERNAL_IMF_MANAGER_H