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 FUiCtrlKeypad.h
20 * @brief This is the header file for the %Keypad class.
22 * This header file contains the declarations of the %Keypad class.
25 #ifndef _FUI_CTRL_KEYPAD_H_
26 #define _FUI_CTRL_KEYPAD_H_
28 #include <FUiCtrlInputTypes.h>
29 #include <FUiCtrlEditTypes.h>
30 #include <FUiCtrlIEditTextFilter.h>
31 #include <FUiITextEventListener.h>
32 #include <FUiWindow.h>
34 namespace Tizen { namespace Ui { namespace Controls
39 * @enum KeypadInputModeCategory
41 * Defines the keypad input mode.
43 * @brief <i> [Deprecated] </i>
44 * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n
45 * or the current mode to initially set the keypad to, from this list. It is recommended to use the styles offered KeypadStyle enumeration instead.
49 enum KeypadInputModeCategory
51 KEYPAD_MODE_ALPHA = 0x0001, /**< @if OSPDEPREC The alphabetic input mode @endif */
52 KEYPAD_MODE_PREDICTIVE = 0x0002, /**< @if OSPDEPREC The predictive input mode @endif */
53 KEYPAD_MODE_NUMERIC = 0x0004, /**< @if OSPDEPREC The numeric input mode @endif */
54 KEYPAD_MODE_SYMBOL = 0x0008 /**< @if OSPDEPREC The symbolic input mode @endif */
59 * @brief This class displays a keypad on top of the screen.
63 * The %Keypad class displays the full screen keypad without using an EditField or EditArea.
65 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_keypad.htm">Keypad</a>.
67 * The following example demonstrates how to use the %Keypad class.
70 // Sample code for KeypadSample.h
74 : public Tizen::Ui::Controls::Form
75 , public Tizen::Ui::IActionEventListener
76 , public Tizen::Ui::ITextEventListener
82 bool Initialize(void);
83 void ShowKeypad(bool show);
84 virtual result OnInitializing(void);
85 virtual result OnTerminating(void);
87 // IActionEventListener
88 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
91 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
92 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);
96 static const int ID_BUTTON = 101;
98 Tizen::Ui::Controls::Keypad *__pKeypad;
101 // Sample code for KeypadSample.cpp
102 #include "KeypadSample.h"
104 using namespace Tizen::Graphics;
105 using namespace Tizen::Ui::Controls;
108 KeypadSample::Initialize(void)
110 Construct(FORM_STYLE_NORMAL);
115 KeypadSample::OnInitializing(void)
117 result r = E_SUCCESS;
119 // Creates an instance of Button and adds it to the form
120 Button* pButton = new Button();
121 pButton->Construct(Rectangle(50, 50, 150, 150), L"Show Keypad");
122 pButton->SetActionId(ID_BUTTON);
123 pButton->AddActionEventListener(*this);
124 AddControl(*pButton);
126 // Creates an instance of Keypad
127 __pKeypad = new Keypad();
128 __pKeypad->Construct(KEYPAD_STYLE_NORMAL, KEYPAD_MODE_ALPHA);
130 // Adds an instance of ITextEventListener
131 __pKeypad->AddTextEventListener(*this);
137 KeypadSample::ShowKeypad(bool show)
139 // Changes to desired show state
140 __pKeypad->SetShowState(show);
142 //Calls Show() of the control
147 // Calls Invalidate() of the container
155 KeypadSample::OnTerminating(void)
157 result r = E_SUCCESS;
159 // Deallocates the keypad
160 __pKeypad->Destroy();
165 // IActionEventListener implementation
167 KeypadSample::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
182 // ITextEventListener implementation
184 KeypadSample::OnTextValueChanged(const Tizen::Ui::Control& source)
190 KeypadSample::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
197 class _OSP_EXPORT_ Keypad
198 : public Tizen::Ui::Window
203 * This is the default constructor for this class.
210 * This is the destructor for this class.
214 virtual ~Keypad(void);
217 * Initializes this instance of %Keypad with the specified parameters.
221 * @return An error code
222 * @param[in] keypadStyle The style of %Keypad
223 * @param[in] limitLength The limit of the length of text in EditField
224 * @exception E_SUCCESS The method is successful.
225 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
226 * the specified @c limitLength is less than or equal to @c 0.
227 * @exception E_SYSTEM A system error has occurred.
228 * @remarks If the keypad style is set to password, the input mode category is ignored.
229 * @remarks The orientation mode of the keypad is decided based on the G-sensor value.
231 result Construct(KeypadStyle keypadStyle, int limitLength);
235 * Initializes this instance of %Keypad with input styles.
237 * @brief <i> [Deprecated] </i>
238 * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to. @n
239 * It is recommended to use the other Construct() method and the KeypadStyle enumeration instead.
242 * @return An error code
243 * @param[in] keypadStyle The style of %Keypad
244 * @param[in] category The initial category that the keypad would show first
245 * @param[in] limitLength The limit of the length of text in EditField
246 * @exception E_SUCCESS The method is successful.
247 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
248 * the specified @c limitLength is less than or equal to @c 0.
249 * @exception E_SYSTEM A system error has occurred.
250 * @remarks If the keypad style is set to password, the input mode category is ignored.
251 * @remarks The orientation mode of the keypad is decided based on the G-sensor value.
254 result Construct(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength = 100);
257 * Checks whether the text prediction is enabled.
260 * @return @c true if the text prediction is enabled, @n
262 * @see SetTextPredictionEnabled()
264 bool IsTextPredictionEnabled(void) const;
267 * Enables or disables the text prediction.
270 * @param[in] enable Set to @c true to enable the text prediction, @n
272 * @return An error code
273 * @exception E_SUCCESS The method is successful.
274 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
275 * @see IsTextPredictionEnabled()
277 result SetTextPredictionEnabled(bool enable);
280 * Enables single-line editing.
284 * @return An error code
285 * @param[in] enabled Set to @c true to enable single-line editing, @n
287 * @exception E_SUCCESS The method is successful.
288 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
289 * The %Keypad control is currently visible.
290 * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n
291 * The password style does not support multi-line editing.
292 * @exception E_SYSTEM A system error has occurred.
293 * @remarks By default, the single-line editing is disabled and the %Keypad control supports multi-lines (except the password style that only supports single-line editing).
295 result SetSingleLineEnabled(bool enabled);
298 * Checks whether single-line editing is enabled.
302 * @return @c true if single-line editing is enabled, @n
305 bool IsSingleLineEnabled(void) const;
308 * Adds a ITextEventListener instance. @n
309 * The added listener can listen to text changed events when they are fired.
313 * @param[in] listener The listener to add
315 void AddTextEventListener(Tizen::Ui::ITextEventListener& listener);
318 * Removes a ITextEventListener instance. @n
319 * The removed listener cannot listen to events when they are fired.
323 * @param[in] listener The listener to remove
325 void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener);
328 * Gets the text of the %Keypad control.
332 * @return The string value
334 Tizen::Base::String GetText(void) const;
337 * Sets the text of the %Keypad control.
341 * @param[in] text The text to set
343 void SetText(Tizen::Base::String text);
346 * Sets the text filter.
350 * @param[in] pFilter The filter
351 * @remarks The %Keypad control checks with the registered filter to decide whether the user-entered text should be replaced.
353 void SetEditTextFilter(IEditTextFilter* pFilter);
356 * Sends opaque command to the input method.
360 * @param[in] command The opaque command
361 * @remarks This method can be used to provide domain-specific features that are only known between certain input methods and their clients.
362 * This method may not work, depending on the active Input Method.
364 void SendOpaqueCommand (const Tizen::Base::String& command);
367 friend class _KeypadImpl;
370 Keypad(const Keypad&);
371 Keypad& operator =(const Keypad&);
375 }}} // Tizen::Ui::Controls
377 #endif // _FUI_CTRL_KEYPAD_H_