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::ImfManagerSignalV2 ImfManagerSignalV2;
47 typedef Dali::ImfManager::ImfEventSignalV2 ImfEventSignalV2;
52 * Create the IMF manager.
54 static Dali::ImfManager Get();
58 * @param[in] ecoreXwin, The window is created by application.
60 ImfManager( Ecore_X_Window ecoreXwin );
63 * Connect Callbacks required for IMF.
64 * If you don't connect imf callbacks, you can't get the key events.
65 * The events are PreeditChanged, Commit and DeleteSurrounding.
67 void ConnectCallbacks();
70 * Disconnect Callbacks attached to imf context.
72 void DisconnectCallbacks();
75 * @copydoc Dali::ImfManager::Activate()
80 * @copydoc Dali::ImfManager::Deactivate()
85 * @copydoc Dali::ImfManager::Reset()
90 * @copydoc Dali::ImfManager::GetContext()
92 Ecore_IMF_Context* GetContext();
95 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
97 bool RestoreAfterFocusLost() const;
100 * @copydoc Dali::ImfManager::SetRestoreAferFocusLost()
102 void SetRestoreAferFocusLost( bool toggle );
105 * @copydoc Dali::ImfManager::PreEditChanged()
107 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
110 * @copydoc Dali::ImfManager::NotifyCursorPosition()
112 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
115 * @copydoc Dali::ImfManager::NotifyCursorPosition()
117 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
120 * @copydoc Dali::ImfManager::DeleteSurrounding()
122 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
126 * @copydoc Dali::ImfManager::NotifyCursorPosition()
128 void NotifyCursorPosition();
131 * @copydoc Dali::ImfManager::GetCursorPosition()
133 int GetCursorPosition();
136 * @copydoc Dali::ImfManager::SetCursorPosition()
138 void SetCursorPosition( unsigned int cursorPosition );
141 * @copydoc Dali::ImfManager::SetSurroundingText()
143 void SetSurroundingText( std::string text );
146 * @copydoc Dali::ImfManager::GetSurroundingText()
148 std::string GetSurroundingText();
153 * @copydoc Dali::ImfManager::ActivatedSignal()
155 ImfManagerSignalV2& ActivatedSignal() { return mActivatedSignalV2; }
158 * @copydoc Dali::ImfManager::EventReceivedSignal()
160 ImfEventSignalV2& EventReceivedSignal() { return mEventSignalV2; }
167 virtual ~ImfManager();
171 * Context created the first time and kept until deleted.
172 * @param[in] ecoreXwin, The window is created by application.
174 void CreateContext( Ecore_X_Window ecoreXwin );
177 * @copydoc Dali::ImfManager::DeleteContext()
179 void DeleteContext();
183 ImfManager( const ImfManager& );
184 ImfManager& operator=( ImfManager& );
187 Ecore_IMF_Context* mIMFContext;
188 int mIMFCursorPosition;
189 std::string mSurroundingText;
191 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
192 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
194 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
196 ImfManagerSignalV2 mActivatedSignalV2;
197 ImfEventSignalV2 mEventSignalV2;
201 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
203 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
205 BaseObject& handle = imfManager.GetBaseObject();
207 return static_cast<Internal::Adaptor::ImfManager&>(handle);
210 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
212 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
214 const BaseObject& handle = imfManager.GetBaseObject();
216 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
222 } // namespace Adaptor
224 } // namespace Internal
228 #endif // __DALI_INTERNAL_IMF_MANAGER_H