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 <dali/integration-api/events/key-event-integ.h>
30 #include <imf-manager.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();
66 * Connect Callbacks required for IMF.
67 * If you don't connect imf callbacks, you can't get the key events.
68 * The events are PreeditChanged, Commit and DeleteSurrounding.
70 void ConnectCallbacks();
73 * Disconnect Callbacks attached to imf context.
75 void DisconnectCallbacks();
78 * @copydoc Dali::ImfManager::Activate()
83 * @copydoc Dali::ImfManager::Deactivate()
88 * @copydoc Dali::ImfManager::Reset()
93 * @copydoc Dali::ImfManager::GetContext()
95 Ecore_IMF_Context* GetContext();
98 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
100 bool RestoreAfterFocusLost() const;
103 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
105 void SetRestoreAfterFocusLost( bool toggle );
108 * @copydoc Dali::ImfManager::PreEditChanged()
110 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
113 * @copydoc Dali::ImfManager::NotifyCursorPosition()
115 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
118 * @copydoc Dali::ImfManager::NotifyCursorPosition()
120 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
123 * @copydoc Dali::ImfManager::DeleteSurrounding()
125 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
129 * @copydoc Dali::ImfManager::NotifyCursorPosition()
131 void NotifyCursorPosition();
134 * @copydoc Dali::ImfManager::GetCursorPosition()
136 int GetCursorPosition();
139 * @copydoc Dali::ImfManager::SetCursorPosition()
141 void SetCursorPosition( unsigned int cursorPosition );
144 * @copydoc Dali::ImfManager::SetSurroundingText()
146 void SetSurroundingText( std::string text );
149 * @copydoc Dali::ImfManager::GetSurroundingText()
151 std::string GetSurroundingText();
156 * @copydoc Dali::ImfManager::ActivatedSignal()
158 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
161 * @copydoc Dali::ImfManager::EventReceivedSignal()
163 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
170 virtual ~ImfManager();
174 * @copydoc Dali::ImfManager::DeleteContext()
176 void DeleteContext();
180 ImfManager( const ImfManager& );
181 ImfManager& operator=( ImfManager& );
184 Ecore_IMF_Context* mIMFContext;
185 int mIMFCursorPosition;
186 std::string mSurroundingText;
188 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
189 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
191 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
193 ImfManagerSignalType mActivatedSignal;
194 ImfEventSignalType mEventSignal;
198 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
200 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
202 BaseObject& handle = imfManager.GetBaseObject();
204 return static_cast<Internal::Adaptor::ImfManager&>(handle);
207 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
209 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
211 const BaseObject& handle = imfManager.GetBaseObject();
213 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
219 } // namespace Adaptor
221 } // namespace Internal
225 #endif // __DALI_INTERNAL_IMF_MANAGER_H