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 <dali/integration-api/events/key-event-integ.h>
29 #include <imf-manager.h>
42 class ImfManager : public Dali::BaseObject
45 typedef Dali::ImfManager::ImfManagerSignalType ImfManagerSignalType;
46 typedef Dali::ImfManager::ImfEventSignalType ImfEventSignalType;
51 * Check whether the ImfManager is available.
52 * @return true if available, false otherwise
54 static bool IsAvailable();
57 * Get the IMF manager instance, it creates the instance if it has not already been created.
58 * Internally, a check should be made using IsAvailable() before this is called as we do not want
59 * to create an instance if not needed by applications.
62 static Dali::ImfManager Get();
66 * @param[in] ecoreXwin, The window is created by application.
68 ImfManager( Ecore_X_Window ecoreXwin );
71 * Connect Callbacks required for IMF.
72 * If you don't connect imf callbacks, you can't get the key events.
73 * The events are PreeditChanged, Commit and DeleteSurrounding.
75 void ConnectCallbacks();
78 * Disconnect Callbacks attached to imf context.
80 void DisconnectCallbacks();
83 * @copydoc Dali::ImfManager::Activate()
88 * @copydoc Dali::ImfManager::Deactivate()
93 * @copydoc Dali::ImfManager::Reset()
98 * @copydoc Dali::ImfManager::GetContext()
100 Ecore_IMF_Context* GetContext();
103 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
105 bool RestoreAfterFocusLost() const;
108 * @copydoc Dali::ImfManager::SetRestoreAfterFocusLost()
110 void SetRestoreAfterFocusLost( bool toggle );
113 * @copydoc Dali::ImfManager::PreEditChanged()
115 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
118 * @copydoc Dali::ImfManager::NotifyCursorPosition()
120 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
123 * @copydoc Dali::ImfManager::NotifyCursorPosition()
125 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
128 * @copydoc Dali::ImfManager::DeleteSurrounding()
130 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
134 * @copydoc Dali::ImfManager::NotifyCursorPosition()
136 void NotifyCursorPosition();
139 * @copydoc Dali::ImfManager::GetCursorPosition()
141 int GetCursorPosition();
144 * @copydoc Dali::ImfManager::SetCursorPosition()
146 void SetCursorPosition( unsigned int cursorPosition );
149 * @copydoc Dali::ImfManager::SetSurroundingText()
151 void SetSurroundingText( std::string text );
154 * @copydoc Dali::ImfManager::GetSurroundingText()
156 std::string GetSurroundingText();
161 * @copydoc Dali::ImfManager::ActivatedSignal()
163 ImfManagerSignalType& ActivatedSignal() { return mActivatedSignal; }
166 * @copydoc Dali::ImfManager::EventReceivedSignal()
168 ImfEventSignalType& EventReceivedSignal() { return mEventSignal; }
175 virtual ~ImfManager();
179 * Context created the first time and kept until deleted.
180 * @param[in] ecoreXwin, The window is created by application.
182 void CreateContext( Ecore_X_Window ecoreXwin );
185 * @copydoc Dali::ImfManager::DeleteContext()
187 void DeleteContext();
191 ImfManager( const ImfManager& );
192 ImfManager& operator=( ImfManager& );
195 Ecore_IMF_Context* mIMFContext;
196 int mIMFCursorPosition;
197 std::string mSurroundingText;
199 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
200 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
202 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
204 ImfManagerSignalType mActivatedSignal;
205 ImfEventSignalType mEventSignal;
209 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
211 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
213 BaseObject& handle = imfManager.GetBaseObject();
215 return static_cast<Internal::Adaptor::ImfManager&>(handle);
218 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
220 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
222 const BaseObject& handle = imfManager.GetBaseObject();
224 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
230 } // namespace Adaptor
232 } // namespace Internal
236 #endif // __DALI_INTERNAL_IMF_MANAGER_H