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 <FGrpRectangle.h>
29 #include <FUiIInputConnectionEventListener.h>
30 #include <FUiIInputConnectionProvider.h>
31 #include <FUiInputConnectionTypes.h>
33 namespace Tizen { namespace Ui {
35 class _InputConnectionImpl;
40 * @class InputConnection
41 * @brief This is the header file for the %InputConnection class.
42 * This header file contains the declarations of the %InputConnection class.
45 * @final This class is not intended for extension.
49 * This is a simple editor that uses an %InputConnection.
53 // Sample code for EditorSample.h
55 #include <FUiInputConnection.h>
56 #include <FUiIInputConnectionEventListener.h>
58 namespace Tizen { namespace Ui {
61 public Tizen::Ui::Control,
62 public Tizen::Ui::IInputConnectionEventListener,
63 public Tizen::Ui::IInputConnectionProvider
68 virtual result OnInitializing();
72 virtual void OnInputConnectionPanelShowStateChanged(Tizen::Ui::InputConnection& source, Tizen::Ui::InputPanelShowState showState);
73 virtual void OnInputConnectionPanelLanguageChanged(Tizen::Ui::InputConnection& source, Tizen::Locales::LanguageCode language);
74 virtual void OnInputConnectionPanelBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds);
75 virtual void OnInputConnectionTextPredictionShowStateChanged(Tizen::Ui::InputConnection& source, bool isShown);
76 virtual void OnInputConnectionTextPredictionBoundsChanged(Tizen::Ui::InputConnection& source, const Tizen::Graphics::Rectangle& bounds);
77 virtual void OnInputConnectionTextCommitted(Tizen::Ui::InputConnection& source, const Tizen::Base::String& committedText);
78 virtual void OnInputConnectionComposingTextChanged(Tizen::Ui::InputConnection& source, const Tizen::Base::String& preEditText, int cursorPosition){};
79 virtual void DeleteSurroundingText(Tizen::Ui::InputConnection& source, int offset, int chars){};
80 virtual void GetPreviousText(Tizen::Ui::InputConnection& source, Tizen::Base::String& text, int& cursorPosition){};
83 InputConnection* __pImf;
91 // Sample code for EditorSample.cpp
92 #include "EditorSample.h"
94 using namespace Tizen::Graphics;
95 using namespace Tizen::Ui;
96 using namespace Tizen::Ui::Controls;
99 EditorSample::OnInputConnectionPanelShowStateChanged(InputConnection& source, InputPanelShowState showState)
105 EditorSample::OnInputConnectionPanelLanguageChanged(InputConnection& source, Tizen::Locales::LanguageCode language)
111 EditorSample::OnInputConnectionPanelBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds)
117 EditorSample::OnInputConnectionTextPredictionShowStateChanged(InputConnection& source, bool isShown)
123 EditorSample::OnInputConnectionTextPredictionBoundsChanged(InputConnection& source, const Tizen::Graphics::Rectangle& bounds)
129 EditorSample::OnInputConnectionTextCommitted(InputConnection& source, const Tizen::Base::String& committedText)
135 EditorSample::OnInitializing()
137 result r = E_SUCCESS;
139 __bindStatus = false;
141 // Creates an instance of InputConnection
142 __pImf = new (std::nothrow) InputConnection();
143 __pImf->Construct(this, *this, *this);
149 EditorSample::ShowKeypad()
151 result r = E_SUCCESS;
155 __pImf->BindInputMethod();
157 __pImf->ShowInputPanel();
164 EditorSample::HideKeypad()
166 result r = E_SUCCESS;
168 if (__bindStatus != false)
170 __pImf->HideInputPanel();
171 __pImf->UnbindInputMethod();
172 __bindStatus = false;
182 class _OSP_EXPORT_ InputConnection
183 : public Tizen::Base::Object
187 * 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.
191 InputConnection(void);
194 * This destructor overrides Tizen::Base::Object::~Object().
198 virtual ~InputConnection(void);
201 * Initializes this instance of the %InputConnection with the specified parameter.
204 * @return An error code
205 * @param[in] pControl The source object for connecting the Input Method.
206 * @param[in] listener An instance of the %IInputConnectionEventListener for processing the event
207 * @param[in] provider The %InputConnection provider
208 * @exception E_SUCCESS The method is successful.
209 * @exception E_INVALID_ARG A specified input parameter is invalid.
210 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
212 result Construct(const Control* pControl, IInputConnectionEventListener& listener, IInputConnectionProvider& provider);
215 * Binds the %InputConnection to the current active Input Method
218 * @return An error code
219 * @exception E_SUCCESS The method is successful.
220 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation.
221 * @see UnbindInputMethod()
222 * @remarks This method should be called when the %Control object has the input focus.
224 result BindInputMethod(void);
227 * Unbinds the %InputConnection from the current active Input Method. It will no longer be valid for the Input Method.
230 * @see BindInputMethod()
232 void UnbindInputMethod(void);
235 * Asks the current active Input Method to show the Input Panel which contains the keyboard.
238 * @return An error code
239 * @exception E_SUCCESS The method is successful.
240 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
241 * @see HideInputPanel()
243 result ShowInputPanel(void);
246 * Asks the current active Input Method to hide the active Input Panel which contains the keyboard.
249 * @return An error code
250 * @exception E_SUCCESS The method is successful.
251 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
252 * @see ShowInputPanel()
254 result HideInputPanel(void);
257 * Sets the style of the current active Input Panel.
260 * @param[in] style The style of the Input Panel.
261 * @remarks This method may not work, depending on the current active Input Method.
263 void SetInputPanelStyle(InputPanelStyle style);
266 * Sets the auto-capitalization mode.
269 * @param[in] autoCapitalizationMode The auto-capitalization mode.
270 * @remarks This method may not work, depending on the current active Input Method.
272 void SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode);
275 * Finishes text composition.
276 * This will typically cause the Input Method to exit the composing state.
279 * @return An error code
280 * @exception E_SUCCESS The method is successful.
281 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
283 result FinishTextComposition(void);
286 * Sets the type of ActionKey.
289 * @param[in] inputPanelAction The InputPanel action
290 * @remarks This method may not work, depending on the current active Input Method.
292 void SetInputPanelAction(InputPanelAction inputPanelAction);
295 * Enables or disables the ActionKey.
298 * @param[in] enable Set to @c true to enable the ActionKey, @n
300 * @remarks This method may not work, depending on the current active Input Method.
302 void SetInputPanelActionEnabled(bool enable);
305 * Sets the language of the current active Input Panel.
308 * @param[in] languageCode The language to set
309 * @exception E_SUCCESS The method is successful.
310 * @exception E_OUT_OF_MEMORY The memory is insufficient.
311 * @remarks This method may not work, depending on the current active Input Method.
313 result SetInputPanelLanguage(Tizen::Locales::LanguageCode languageCode);
316 * Sets the cursor at the specified position.
319 * @param[in] position The cursor position that is to be set
320 * @return An error code
321 * @exception E_SUCCESS The method is successful.
322 * @exception E_INVALID_ARG A specified input parameter is invalid.
323 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
325 result SetCursorPosition(int position);
328 * Sets the bounds of the cursor
331 * @param[in] rect the rectangle to be set
332 * @return An error code
333 * @exception E_SUCCESS The method is successful.
334 * @exception E_INVALID_ARG A specified input parameter is invalid.
335 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
337 result SetCursorBounds(const Tizen::Graphics::Rectangle& rect);
340 * Gets the bounds of the current active Input Panel.
343 * @return An instance of the rectangle that represents the position of the top-left corner,
344 * the width, and the height of the Input Panel.
345 * @exception E_SUCCESS The method is successful.
346 * @exception E_INVALID_STATE This exception is thrown when BindInputMethod is not called before calling this method.
347 * @remarks The specific error code can be accessed using the GetLastResult() method.
349 Tizen::Graphics::Rectangle GetInputPanelBounds(void) const;
352 * Enables or disables text prediction.
355 * @param[in] enable Set to @c true to enable text prediction, @n
357 * @remarks This method may not work, depending on the current active Input Method.
359 void SetTextPredictionEnabled(bool enable);
363 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
367 InputConnection(const InputConnection& rhs);
370 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
374 InputConnection& operator=(const InputConnection& rhs);
377 friend class _InputConnectionImpl;
378 _InputConnectionImpl* __pInputConnectionImpl;
380 }; // InputConnection
384 #endif // _FUI_INPUT_CONNECTION_H_