1 #ifndef __DALI_TOOLKIT_TOOLKIT_IMF_MANAGER_H__
2 #define __DALI_TOOLKIT_TOOLKIT_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 #define __DALI_IMF_MANAGER_H__
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/signals/dali-signal-v2.h>
26 namespace Dali DALI_IMPORT_API
29 namespace Internal DALI_INTERNAL
37 typedef void* ImfContext;
40 * @brief The ImfManager class
41 * Specifically manages the ecore input method framework which enables the virtual or hardware keyboards.
43 class ImfManager : public BaseHandle
57 * This structure is used to pass on data from the IMF regarding predictive text.
62 * Default Constructor.
74 * @param[in] aEventName The name of the event from the IMF.
75 * @param[in] aPredictiveString The pre-edit or commit string.
76 * @param[in] aCursorOffset Start position from the current cursor position to start deleting characters.
77 * @param[in] aNumberOfChars The number of characters to delete from the cursorOffset.
79 ImfEventData(ImfEvent aEventName, const std::string& aPredictiveString, int aCursorOffset,int aNumberOfChars )
80 : eventName(aEventName), predictiveString(aPredictiveString), cursorOffset( aCursorOffset ), numberOfChars( aNumberOfChars )
85 ImfEvent eventName; // The name of the event from the IMF.
86 std::string predictiveString; // The pre-edit or commit string.
87 int cursorOffset; // Start position from the current cursor position to start deleting characters.
88 int numberOfChars; //number of characters to delete from the cursorOffset.
92 * Data required my IMF from the callback
94 struct ImfCallbackData
97 : update( false ), cursorPosition( 0 ), preeditResetRequired ( false )
101 ImfCallbackData(bool aUpdate, int aCursorPosition, std::string aCurrentText, bool aPreeditResetRequired )
102 : update(aUpdate), cursorPosition(aCursorPosition), currentText( aCurrentText ), preeditResetRequired( aPreeditResetRequired )
106 bool update; // if cursor position needs to be updated
107 int cursorPosition; // new position of cursor
108 std::string currentText; // current text string
109 bool preeditResetRequired; // flag if preedit reset is required.
112 typedef SignalV2< void (ImfManager&) > ImfManagerSignalV2;
114 typedef SignalV2< ImfCallbackData ( ImfManager&, const ImfEventData& ) > ImfEventSignalV2;
119 * Retrieve a handle to the instance of ImfManager.
120 * @return A handle to the ImfManager.
122 static ImfManager Get();
125 * Get the current imf context.
126 * @return current imf context.
128 ImfContext GetContext();
132 * It means that the text editing is started at somewhere.
133 * If the H/W keyboard isn't connected then it will show the virtual keyboard.
138 * Deactivate the IMF.
139 * It means that the text editing is finished at somewhere.
144 * Get the restoration status, which controls if the keyboard is restored after the focus lost then regained.
145 * If true then keyboard will be restored (activated) after focus is regained.
146 * @return restoration status.
148 bool RestoreAfterFocusLost() const;
151 * Set status whether the IMF has to restore the keyboard after losing focus.
152 * @param[in] toggle True means that keyboard should be restored after focus lost and regained.
154 void SetRestoreAferFocusLost( bool toggle );
157 * Send message reset the pred-edit state / imf module. Used to interupt pre-edit state maybe due to a touch input.
162 * Notifies IMF context that the cursor position has changed, required for features like auto-capitalisation
164 void NotifyCursorPosition();
167 * Sets cursor position stored in VirtualKeyboard, this is required by the IMF context
168 * @param[in] cursorPosition position of cursor
170 void SetCursorPosition( unsigned int cursorPosition );
173 * Gets cursor position stored in VirtualKeyboard, this is required by the IMF context
174 * @return current position of cursor
176 int GetCursorPosition();
179 * Method to store the string required by the IMF, this is used to provide predictive word suggestions.
180 * @param[in] text The text string surrounding the current cursor point.
182 void SetSurroundingText( std::string text );
185 * Gets current text string set within the IMF manager, this is used to offer predictive suggestions
186 * @return current position of cursor
188 std::string GetSurroundingText();
195 * This is emitted when the virtual keyboard is connected to or the hardware keyboard is activated.
196 * @return The IMF Activated signal.
198 ImfManagerSignalV2& ActivatedSignal();
201 * This is emitted when the IMF manager receives an event from the IMF
202 * @return The Event signal containing the event data.
204 ImfEventSignalV2& EventReceivedSignal();
206 // Construction & Destruction
214 * Non virtual destructor.
219 * This constructor is used by ImfManager::Get().
220 * @param[in] imfManager A pointer to the imf Manager.
222 ImfManager( Internal::Adaptor::ImfManager* imfManager );
227 #endif // __DALI_TOOLKIT_TOOLKIT_IMF_MANAGER_H__