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 * Create the IMF manager.
55 static Dali::ImfManager Get();
58 * Connect Callbacks required for IMF.
59 * If you don't connect imf callbacks, you can't get the key events.
60 * The events are PreeditChanged, Commit and DeleteSurrounding.
62 void ConnectCallbacks();
65 * Disconnect Callbacks attached to imf context.
67 void DisconnectCallbacks();
70 * @copydoc Dali::ImfManager::Activate()
75 * @copydoc Dali::ImfManager::Deactivate()
80 * @copydoc Dali::ImfManager::Reset()
85 * @copydoc Dali::ImfManager::GetContext()
87 Ecore_IMF_Context* GetContext();
90 * @copydoc Dali::ImfManager::RestoreAfterFocusLost()
92 bool RestoreAfterFocusLost() const;
95 * @copydoc Dali::ImfManager::SetRestoreAferFocusLost()
97 void SetRestoreAferFocusLost( bool toggle );
100 * @copydoc Dali::ImfManager::PreEditChanged()
102 void PreEditChanged( void *data, Ecore_IMF_Context *imfContext, void *event_info );
105 * @copydoc Dali::ImfManager::NotifyCursorPosition()
107 void CommitReceived( void *data, Ecore_IMF_Context *imfContext, void *event_info );
110 * @copydoc Dali::ImfManager::NotifyCursorPosition()
112 Eina_Bool RetrieveSurrounding( void *data, Ecore_IMF_Context *imfContext, char** text, int* cursorPosition );
115 * @copydoc Dali::ImfManager::DeleteSurrounding()
117 void DeleteSurrounding( void *data, Ecore_IMF_Context *imfContext, void *event_info );
121 * @copydoc Dali::ImfManager::NotifyCursorPosition()
123 void NotifyCursorPosition();
126 * @copydoc Dali::ImfManager::GetCursorPosition()
128 int GetCursorPosition();
131 * @copydoc Dali::ImfManager::SetCursorPosition()
133 void SetCursorPosition( unsigned int cursorPosition );
136 * @copydoc Dali::ImfManager::SetSurroundingText()
138 void SetSurroundingText( std::string text );
141 * @copydoc Dali::ImfManager::GetSurroundingText()
143 std::string GetSurroundingText();
148 * @copydoc Dali::ImfManager::ActivatedSignal()
150 ImfManagerSignalV2& ActivatedSignal() { return mActivatedSignalV2; }
153 * @copydoc Dali::ImfManager::EventReceivedSignal()
155 ImfEventSignalV2& EventReceivedSignal() { return mEventSignalV2; }
162 virtual ~ImfManager();
166 * @copydoc Dali::ImfManager::DeleteContext()
168 void DeleteContext();
172 ImfManager( const ImfManager& );
173 ImfManager& operator=( ImfManager& );
176 Ecore_IMF_Context* mIMFContext;
177 int mIMFCursorPosition;
178 std::string mSurroundingText;
180 bool mRestoreAfterFocusLost:1; ///< Whether the keyboard needs to be restored (activated ) after focus regained.
181 bool mIdleCallbackConnected:1; ///< Whether the idle callback is already connected.
183 std::vector<Dali::Integration::KeyEvent> mKeyEvents; ///< Stores key events to be sent from idle call-back.
185 ImfManagerSignalV2 mActivatedSignalV2;
186 ImfEventSignalV2 mEventSignalV2;
190 inline static Internal::Adaptor::ImfManager& GetImplementation(Dali::ImfManager& imfManager)
192 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
194 BaseObject& handle = imfManager.GetBaseObject();
196 return static_cast<Internal::Adaptor::ImfManager&>(handle);
199 inline static const Internal::Adaptor::ImfManager& GetImplementation(const Dali::ImfManager& imfManager)
201 DALI_ASSERT_ALWAYS( imfManager && "ImfManager handle is empty" );
203 const BaseObject& handle = imfManager.GetBaseObject();
205 return static_cast<const Internal::Adaptor::ImfManager&>(handle);
211 } // namespace Adaptor
213 } // namespace Internal
217 #endif // __DALI_INTERNAL_IMF_MANAGER_H