2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 FUiInputConnection.h
20 * @brief This is the header file for the %InputConnection class.
22 * This header file contains the declarations of the %InputConnection class.
25 #ifndef _FUI_INPUT_CONNECTION_H_
26 #define _FUI_INPUT_CONNECTION_H_
28 #include <FGrpFloatRectangle.h>
29 #include <FGrpRectangle.h>
30 #include <FUiIInputConnectionEventListener.h>
31 #include <FUiIInputConnectionEventListenerF.h>
32 #include <FUiIInputConnectionProvider.h>
33 #include <FUiInputConnectionTypes.h>
35 namespace Tizen { namespace Ui {
37 class _InputConnectionImpl;
42 * @class InputConnection
43 * @brief This is the header file for the %InputConnection class.
44 * This header file contains the declarations of the %InputConnection class.
47 * @final This class is not intended for extension.
49 * The following examples demonstrate how to use the %InputConnection class.
51 * This is a simple editor that uses an %InputConnection.
55 // Sample code for EditorSample.h
57 #include <FUiInputConnection.h>
58 #include <FUiIInputConnectionEventListener.h>
60 namespace Tizen { namespace Ui {
63 public Tizen::Ui::Control,
64 public Tizen::Ui::IInputConnectionEventListener,
65 public Tizen::Ui::IInputConnectionProvider
70 virtual result OnInitializing();
74 virtual void OnInputConnectionPanelShowStateChanged(Tizen::Ui::InputConnection& source, Tizen::Ui::InputPanelShowState showState);
75 virtual void OnInputConnectionPanelLanguageChanged(Tizen::Ui::InputConnection& source, Tizen::Locales::LanguageCode language);
76 virtual void OnInputConnectionPanelBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds);
77 virtual void OnInputConnectionTextPredictionShowStateChanged(Tizen::Ui::InputConnection& source, bool isShown);
78 virtual void OnInputConnectionTextPredictionBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds);
79 virtual void OnInputConnectionTextCommitted(Tizen::Ui::InputConnection& source, const Tizen::Base::String& committedText);
80 virtual void OnInputConnectionComposingTextChanged(Tizen::Ui::InputConnection& source, const Tizen::Base::String& preEditText, int cursorPosition){};
81 virtual void DeleteSurroundingText(Tizen::Ui::InputConnection& source, int offset, int chars){};
82 virtual void GetPreviousText(Tizen::Ui::InputConnection& source, Tizen::Base::String& text, int& cursorPosition){};
85 InputConnection* __pImf;
93 // Sample code for EditorSample.cpp
94 #include "EditorSample.h"
96 using namespace Tizen::Graphics;
97 using namespace Tizen::Ui;
98 using namespace Tizen::Ui::Controls;
101 EditorSample::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
107 EditorSample::OnInputConnectionPanelLanguageChanged(InputConnection& source, Tizen::Locales::LanguageCode language)
113 EditorSample::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds)
119 EditorSample::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
125 EditorSample::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds)
131 EditorSample::OnInputConnectionTextCommitted(InputConnection& source, const Tizen::Base::String& committedText)
137 EditorSample::OnInitializing()
139 result r = E_SUCCESS;
141 __bindStatus = false;
143 // Creates an instance of InputConnection
144 __pImf = new (std::nothrow) InputConnection();
145 __pImf->Construct(this, *this, *this);
151 EditorSample::ShowKeypad()
153 result r = E_SUCCESS;
157 __pImf->BindInputMethod();
159 __pImf->ShowInputPanel();
166 EditorSample::HideKeypad()
168 result r = E_SUCCESS;
170 if (__bindStatus != false)
172 __pImf->HideInputPanel();
173 __pImf->UnbindInputMethod();
174 __bindStatus = false;
184 class _OSP_EXPORT_ InputConnection
185 : public Tizen::Base::Object
189 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
193 InputConnection(void);
196 * This destructor overrides Tizen::Base::Object::~Object().
200 virtual ~InputConnection(void);
203 * Initializes this instance of the %InputConnection with the specified parameter.
206 * @return An error code
207 * @param[in] pControl The source object for connecting the Input Method.
208 * @param[in] listener An instance of the %IInputConnectionEventListener for processing the event
209 * @param[in] provider The %InputConnection provider
210 * @exception E_SUCCESS The method is successful.
211 * @exception E_INVALID_ARG A specified input parameter is invalid.
212 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
214 result Construct(const Control* pControl, IInputConnectionEventListener& listener, IInputConnectionProvider& provider);
217 * Initializes this instance of the %InputConnection with the specified parameter.
220 * @return An error code
221 * @param[in] pControl The source object for connecting the Input Method.
222 * @param[in] listener An instance of the %IInputConnectionEventListenerF for processing the event
223 * @param[in] provider The %InputConnection provider
224 * @exception E_SUCCESS The method is successful.
225 * @exception E_INVALID_ARG A specified input parameter is invalid.
226 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
228 result Construct(const Control* pControl, IInputConnectionEventListenerF& listener, IInputConnectionProvider& provider);
231 * Binds the %InputConnection to the current active Input Method
234 * @return An error code
235 * @exception E_SUCCESS The method is successful.
236 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
237 * @see UnbindInputMethod()
238 * @remarks This method should be called when the %Control object has the input focus.
240 result BindInputMethod(void);
243 * Unbinds the %InputConnection from the current active Input Method. It will no longer be valid for the Input Method.
246 * @see BindInputMethod()
248 void UnbindInputMethod(void);
251 * Asks the current active Input Method to show the Input Panel which contains the keyboard.
254 * @return An error code
255 * @exception E_SUCCESS The method is successful.
256 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
257 * @see HideInputPanel()
259 result ShowInputPanel(void);
262 * Asks the current active Input Method to hide the active Input Panel which contains the keyboard.
265 * @return An error code
266 * @exception E_SUCCESS The method is successful.
267 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
268 * @see ShowInputPanel()
270 result HideInputPanel(void);
273 * Sets the style of the current active Input Panel.
276 * @param[in] style The style of the Input Panel.
277 * @remarks This method may not work, depending on the current active Input Method.
279 void SetInputPanelStyle(InputPanelStyle style);
282 * Sets the auto-capitalization mode.
285 * @param[in] autoCapitalizationMode The auto-capitalization mode.
286 * @remarks This method may not work, depending on the current active Input Method.
288 void SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode);
291 * Finishes text composition.
292 * This will typically cause the Input Method to exit the composing state.
295 * @return An error code
296 * @exception E_SUCCESS The method is successful.
297 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
299 result FinishTextComposition(void);
302 * Sets the type of ActionKey.
305 * @param[in] inputPanelAction The InputPanel action
306 * @remarks This method may not work, depending on the current active Input Method.
308 void SetInputPanelAction(InputPanelAction inputPanelAction);
311 * Enables or disables the ActionKey.
314 * @param[in] enable Set to @c true to enable the ActionKey, @n
316 * @remarks This method may not work, depending on the current active Input Method.
318 void SetInputPanelActionEnabled(bool enable);
321 * Sets the language of the current active Input Panel.
324 * @param[in] languageCode The language to set
325 * @exception E_SUCCESS The method is successful.
326 * @exception E_OUT_OF_MEMORY The memory is insufficient.
327 * @remarks This method may not work, depending on the current active Input Method.
329 result SetInputPanelLanguage(Tizen::Locales::LanguageCode languageCode);
332 * Sets the cursor at the specified position.
335 * @param[in] position The cursor position that is to set
336 * @return An error code
337 * @exception E_SUCCESS The method is successful.
338 * @exception E_INVALID_ARG A specified input parameter is invalid.
339 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
341 result SetCursorPosition(int position);
344 * Sets the bounds of the cursor.
347 * @param[in] rect The rectangle to set
348 * @return An error code
349 * @exception E_SUCCESS The method is successful.
350 * @exception E_INVALID_ARG A specified input parameter is invalid.
351 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
353 result SetCursorBounds(const Tizen::Graphics::Rectangle& rect);
356 * Sets the bounds of the cursor.
359 * @param[in] rect The rectangle to set
360 * @return An error code
361 * @exception E_SUCCESS The method is successful.
362 * @exception E_INVALID_ARG A specified input parameter is invalid.
363 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
365 result SetCursorBounds(const Tizen::Graphics::FloatRectangle& rect);
368 * Gets the bounds of the current active Input Panel.
371 * @return An instance of the rectangle that represents the position of the top-left corner,
372 * the width, and the height of the Input Panel.
373 * @exception E_SUCCESS The method is successful.
374 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
375 * @remarks The specific error code can be accessed using the GetLastResult() method.
377 Tizen::Graphics::Rectangle GetInputPanelBounds(void) const;
380 * Gets the bounds of the current active Input Panel.
383 * @return An instance of the rectangle that represents the position of the top-left corner,
384 * the width, and the height of the Input Panel.
385 * @exception E_SUCCESS The method is successful.
386 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
387 * @remarks The specific error code can be accessed using the GetLastResult() method.
389 Tizen::Graphics::FloatRectangle GetInputPanelBoundsF(void) const;
392 * Enables or disables text prediction.
395 * @param[in] enable Set to @c true to enable text prediction, @n
397 * @remarks This method may not work, depending on the current active Input Method.
399 void SetTextPredictionEnabled(bool enable);
402 * Sends opaque command to the input method.
406 * @param[in] command The opaque command
407 * @remarks This method can be used to provide domain-specific features that are only known between certain input methods and their clients.
408 * This method may not work, depending on the active Input Method.
410 void SendOpaqueCommand (const Tizen::Base::String& command);
414 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
418 InputConnection(const InputConnection& rhs);
421 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
425 InputConnection& operator=(const InputConnection& rhs);
428 friend class _InputConnectionImpl;
429 _InputConnectionImpl* __pInputConnectionImpl;
431 }; // InputConnection
435 #endif // _FUI_INPUT_CONNECTION_H_