1 #ifndef _DALI_ADAPTOR_IMF_MANAGER_H_
2 #define _DALI_ADAPTOR_IMF_MANAGER_H_
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/signals/dali-signal-v2.h>
25 namespace Dali DALI_IMPORT_API
28 namespace Internal DALI_INTERNAL
36 typedef void* ImfContext;
39 * @brief The ImfManager class
40 * Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
42 class ImfManager : public BaseHandle
56 * This structure is used to pass on data from the IMF regarding predictive text.
61 * Default Constructor.
73 * @param[in] aEventName The name of the event from the IMF.
74 * @param[in] aPredictiveString The pre-edit or commit string.
75 * @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
76 * @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
78 ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
79 : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
84 ImfEvent eventName; // The name of the event from the IMF.
85 std::string predictiveString; // The pre-edit or commit string.
86 int cursorOffset; // Start position from the current cursor position to start deleting characters.
87 int numberOfChars; //number of characters to delete from the cursorOffset.
91 * Data required my IMF from the callback
93 struct ImfCallbackData
96 : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
100 ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
101 : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
105 bool update; // if cursor position needs to be updated
106 int cursorPosition; // new position of cursor
107 std::string currentText; // current text string
108 bool preeditResetRequired; // flag if preedit reset is required.
111 typedef SignalV2< void (ImfManager&) > ImfManagerSignalV2;
113 typedef SignalV2< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalV2;
118 * Retrieve a handle to the instance of ImfManager.
119 * @return A handle to the ImfManager.
121 static ImfManager Get();
124 * Get the current imf context.
125 * @return current imf context.
127 ImfContext GetContext();
131 * It means that the text editing is started at somewhere.
132 * If the H/W keyboard isn't connected then it will show the virtual keyboard.
137 * Deactivate the IMF.
138 * It means that the text editing is finished at somewhere.
143 * Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.
144 * If true then keyboard will be restored (activated) after focus is regained.
145 * @return restoration status.
147 bool RestoreAfterFocusLost() const;
150 * Set status whether the IMF has to restore the keyboard after losing focus.
151 * @param[in] toggle True means that keyboard should be restored after focus lost and regained.
153 void SetRestoreAferFocusLost( bool toggle );
156 * Send message reset the pred-edit state / imf module. Used to interupt pre-edit state maybe due to a touch input.
161 * Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation
163 void NotifyCursorPosition();
166 * Sets cursor position stored in VirtualKeyboard, this is required by the IMF context
167 * @param[in] cursorPosition position of cursor
169 void SetCursorPosition( unsigned int cursorPosition );
172 * Gets cursor position stored in VirtualKeyboard, this is required by the IMF context
173 * @return current position of cursor
175 int GetCursorPosition();
178 * Method to store the string required by the IMF, this is used to provide predictive word suggestions.
179 * @param[in] text The text string surrounding the current cursor point.
181 void SetSurroundingText( std::string text );
184 * Gets current text string set within the IMF manager, this is used to offer predictive suggestions
185 * @return current position of cursor
187 std::string GetSurroundingText();
194 * This is emitted when the virtual keyboard is connected to or the hardware keyboard is activated.
195 * @return The IMF Activated signal.
197 ImfManagerSignalV2& ActivatedSignal();
200 * This is emitted when the IMF manager receives an event from the IMF
201 * @return The Event signal containing the event data.
203 ImfEventSignalV2& EventReceivedSignal();
205 // Construction & Destruction
213 * Virtual destructor.
215 virtual ~ImfManager();
218 * This constructor is used by ImfManager::Get().
219 * @param[in] imfManager A pointer to the imf Manager.
221 ImfManager( Internal::Adaptor::ImfManager* imfManager );
226 #endif // _DALI_ADAPTOR_IMF_MANAGER_H_