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/object/base-object.h>
27 #include <imf-manager.h>
28 #include <dali/integration-api/events/key-event-integ.h>
44 class ImfManager : public Dali::BaseObject
47 typedef Dali::ImfManager::ImfManagerSignalV2 ImfManagerSignalV2;
48 typedef Dali::ImfManager::ImfEventSignalV2 ImfEventSignalV2;
53 * Check whether the ImfManager is available.
54 * @return true if available, false otherwise
56 static bool IsAvailable();
59 * Get the IMF manager instance, it creates the instance if it has not already been created.
60 * Internally, a check should be made using IsAvailable() before this is called as we do not want
61 * to create an instance if not needed by applications.
64 static Dali::ImfManager Get();
67 * Connect Callbacks required for IMF.
68 * If you don't connect imf callbacks, you can't get the key events.
69 * The events are PreeditChanged, Commit and DeleteSurrounding.
71 void ConnectCallbacks();
74 * Disconnect Callbacks attached to imf context.
76 void DisconnectCallbacks();
79 * @copydoc Dali::ImfManager::Activate()
84 * @copydoc Dali::ImfManager::Deactivate()
89 * @copydoc Dali::ImfManager::Reset()
94 * @copydoc Dali::ImfManager::GetContext()
96 Ecore_IMF_Context* GetContext();
99 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
101 bool RestoreAfterFocusLost() const;
104 * @copydoc Dali::ImfManager::SetRestoreAferFocusLost()
106 void SetRestoreAferFocusLost( bool toggle );
109 * @copydoc Dali::ImfManager::PreEditChanged()
111 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
114 * @copydoc Dali::ImfManager::NotifyCursorPosition()
116 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
119 * @copydoc Dali::ImfManager::NotifyCursorPosition()
121 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
124 * @copydoc Dali::ImfManager::DeleteSurrounding()
126 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
130 * @copydoc Dali::ImfManager::NotifyCursorPosition()
132 void NotifyCursorPosition();
135 * @copydoc Dali::ImfManager::GetCursorPosition()
137 int GetCursorPosition();
140 * @copydoc Dali::ImfManager::SetCursorPosition()
142 void SetCursorPosition( unsigned int cursorPosition );
145 * @copydoc Dali::ImfManager::SetSurroundingText()
147 void SetSurroundingText( std::string text );
150 * @copydoc Dali::ImfManager::GetSurroundingText()
152 std::string GetSurroundingText();
157 * @copydoc Dali::ImfManager::ActivatedSignal()
159 ImfManagerSignalV2& ActivatedSignal() { return mActivatedSignalV2; }
162 * @copydoc Dali::ImfManager::EventReceivedSignal()
164 ImfEventSignalV2& EventReceivedSignal() { return mEventSignalV2; }
171 virtual ~ImfManager();
175 * @copydoc Dali::ImfManager::DeleteContext()
177 void DeleteContext();
181 ImfManager( const ImfManager& );
182 ImfManager& operator=( ImfManager& );
185 Ecore_IMF_Context* mIMFContext;
186 int mIMFCursorPosition;
187 std::string mSurroundingText;
189 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
190 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
192 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
194 ImfManagerSignalV2 mActivatedSignalV2;
195 ImfEventSignalV2 mEventSignalV2;
199 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
201 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
203 BaseObject& handle = imfManager.GetBaseObject();
205 return static_cast<Internal::Adaptor::ImfManager&>(handle);
208 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
210 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
212 const BaseObject& handle = imfManager.GetBaseObject();
214 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
220 } // namespace Adaptor
222 } // namespace Internal
226 #endif // __DALI_INTERNAL_IMF_MANAGER_H