2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiImeInputMethod.h
20 * @brief This is the header file for the %InputMethod class.
22 * This header file contains the declarations of the %InputMethod class.
25 #ifndef _FUI_IME_INPUT_METHOD_H_
26 #define _FUI_IME_INPUT_METHOD_H_
28 #include <FBaseDataType.h>
29 #include <FBaseObject.h>
30 #include <FBaseString.h>
31 #include <FOspConfig.h>
32 #include <FUiIKeyEventListener.h>
33 #include <FUiImeIInputMethodListener.h>
34 #include <FUiImeIInputMethodProvider.h>
36 namespace Tizen { namespace Ui { namespace Ime {
38 class _InputMethodImpl;
43 * @brief This class provides a standard implementation of the %InputMethod.
46 * @final This class is not intended for extension.
47 * @remarks IME application developers can use the %InputMethod to communicate with the associated text input UI control. First, set the provider which
48 * provides attributes of the soft input panel. Next, set the listener which lets the IME application receive asynchronous callbacks from the input service. These
49 * allow the IME application to interact with the associated text input UI control properly. After that, request the %InputMethod to send a text or a key event
50 * which is to be displayed in the associated text input UI control.
53 * @privilege http://tizen.org/privilege/ime
55 * The %InputMethod provides a standard implementation of the %InputMethod.
57 * The following example demonstrates how to use the %InputMethod class.
62 * using namespace Tizen::Ui::Ime;
65 * : public IInputMethodProvider
71 * : public IInputMethodListener
84 * MyImeApp::Construct()
86 * // Gets an instance of InputMethod
87 * InputMethod* pInputMethod = InputMethod::GetInstance();
89 * // Creates an instance of MyProvider and sets it as a provider
90 * MyProvider* pMyProvider = new(std::nothrow) MyProvider();
91 * pInputMethod->SetInputMethodProvider(pMyProvider);
93 * // Creates an instance of MyListener and adds it to the input method
94 * MyListener* pMyListener = new(std::nothrow) MyListener();
95 * pInputMethod->SetInputMethodListener(pMyListener);
102 class _OSP_EXPORT_ InputMethod
103 : public Tizen::Base::Object
108 * Gets an instance of the %InputMethod.
111 * @visibility partner
112 * @privilege http://tizen.org/privilege/ime
114 * @return An instance of the %InputMethod
115 * @exception E_SUCCESS The method is successful.
116 * @exception E_CONNECTION_FAILED The connection to the input service fails.
117 * @exception E_SYSTEM A failure occurs from the underlying system.
118 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
119 * @remarks The specific error code can be accessed using the GetLastResult() method and OOM might be thrown by this method.
122 static InputMethod* GetInstance(void);
126 * Sets an instance of the IInputMethodProvider.
129 * @visibility partner
130 * @privilege http://tizen.org/privilege/ime
132 * @param[in] pProvider An instance of the IInputMethodProvider
133 * @exception E_SUCCESS The method is successful.
134 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
135 * @remarks The %InputMethod accepts only one provider. So users should unregister the provider by setting @c pProvider as @c null before
136 * deallocating an instance of the provider.
137 * @remarks The specific error code can be accessed using the GetLastResult() method.
140 void SetInputMethodProvider(IInputMethodProvider* pProvider);
144 * Sets an instance of the IInputMethodListener.
147 * @visibility partner
148 * @privilege http://tizen.org/privilege/ime
150 * @param[in] pListener An instance of the IInputMethodListener
151 * @exception E_SUCCESS The method is successful.
152 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
153 * @remarks The %InputMethod accepts only one listener. So users should unregister the listener by setting @c pListener as @c null before
154 * deallocating an instance of the listener.
155 * @remarks The specific error code can be accessed using the GetLastResult() method.
158 void SetInputMethodListener(IInputMethodListener* pListener);
162 * Deletes text at the position of the cursor.
165 * @visibility partner
166 * @privilege http://tizen.org/privilege/ime
168 * @return An error code
169 * @param[in] cursorOffset The offset value from the cursor position
170 * @param[in] length The length of the text to delete
171 * @exception E_SUCCESS The method is successful.
172 * @exception E_INVALID_ARG The @c length is less than or equal to @c 0.
173 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
176 result DeleteText(int cursorOffset, int length);
180 * Notifies the state of the input panel to the associated text input UI control when the state of an input panel changes.
183 * @visibility partner
184 * @privilege http://tizen.org/privilege/ime
186 * @return An error code
187 * @param[in] state The state of the input panel
188 * @exception E_SUCCESS The method is successful.
189 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
192 result NotifyInputPanelState(Tizen::Ui::InputPanelShowState state);
196 * Requests the surrounding text from the position of the cursor.
199 * @visibility partner
200 * @privilege http://tizen.org/privilege/ime
202 * @return An error code
203 * @param[in] lengthBeforeCursor The length of the surrounding text before the cursor
204 * @param[in] lengthAfterCursor The length of the surrounding text after the cursor
205 * @exception E_SUCCESS The method is successful.
206 * @exception E_INVALID_ARG The arguments are less than @c 0.
207 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
208 * @remarks The requested surrounding text can be received using the Tizen::Ui::Ime::IInputMethodListener::OnSurroundingTextReceived() method.
211 result RequestSurroundingText(int lengthBeforeCursor, int lengthAfterCursor);
215 * Sends a composite text to the associated text input UI control.
218 * @visibility partner
219 * @privilege http://tizen.org/privilege/ime
221 * @return An error code
222 * @param[in] text The composite text to send
223 * @exception E_SUCCESS The method is successful.
224 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
225 * @remarks The composite text means a text which is being modified.
228 result SendCompositeText(const Tizen::Base::String& text);
232 * Sends a key event directly to the associated text input UI control.
235 * @visibility partner
236 * @privilege http://tizen.org/privilege/ime
238 * @return An error code
239 * @param[in] code The key code
240 * @param[in] state The key state
241 * @exception E_SUCCESS The method is successful.
242 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
245 result SendKeyEvent(Tizen::Ui::KeyCode code, Tizen::Ui::KeyState state);
249 * Sends text to the associated text input UI control.
252 * @visibility partner
253 * @privilege http://tizen.org/privilege/ime
255 * @return An error code
256 * @param[in] text The text to send
257 * @exception E_SUCCESS The method is successful.
258 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
261 result SendText(const Tizen::Base::String& text);
265 // This Construct() is intentionally declared as private so that only the platform can create an instance.
269 // @return An error code
270 // @exception E_SUCCESS The method is successful.
271 // @exception E_CONNECTION_FAILED The connection to the input service fails.
272 // @exception E_SYSTEM A failure occurs from the underlying system.
273 // @remarks OOM might be thrown by this method.
275 result Construct(void);
278 // This default constructor is intentionally declared as private to implement the Singleton semantic.
285 // This destructor is intentionally declared as private to implement the Singleton semantic.
289 virtual ~InputMethod(void);
292 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
296 InputMethod(const InputMethod& rhs);
299 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
303 InputMethod& operator=(const InputMethod& rhs);
306 _InputMethodImpl* __pInputMethodImpl;
309 }}} // Tizen::Ui::Ime
311 #endif // _FUI_IME_INPUT_METHOD_H_