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.
18 * @file FUiCtrlKeypad.h
19 * @brief This is the header file for the %Keypad class.
21 * This header file contains the declarations of the %Keypad class.
24 #ifndef _FUI_CTRL_KEYPAD_H_
25 #define _FUI_CTRL_KEYPAD_H_
27 #include <FUiCtrlInputTypes.h>
28 #include <FUiCtrlEditTypes.h>
29 #include <FUiITextEventListener.h>
30 #include <FUiWindow.h>
32 namespace Tizen { namespace Ui { namespace Controls
37 * @enum KeypadInputModeCategory
39 * Defines the keypad input mode.
41 * @brief <i> [Deprecated] </i>
42 * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to, @n
43 * or the current mode to initially set the keypad to, from this list. It is recommended to use the styles offered KeypadStyle enumeration instead.
47 enum KeypadInputModeCategory
49 KEYPAD_MODE_ALPHA = 0x0001, /**< @if OSPDEPREC The alphabetic input mode @endif */
50 KEYPAD_MODE_PREDICTIVE = 0x0002, /**< @if OSPDEPREC The predictive input mode @endif*/
51 KEYPAD_MODE_NUMERIC = 0x0004, /**< @if OSPDEPREC The numeric input mode @endif */
52 KEYPAD_MODE_SYMBOL = 0x0008 /**< @if OSPDEPREC The symbolic input mode @endif */
57 * @brief This class displays a keypad on top of the screen.
61 * The %Keypad class displays the full screen keypad without using an EditField or EditArea.
63 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_keypad.htm">Keypad</a>.
65 * The following example demonstrates how to use the %Keypad class.
68 // Sample code for KeypadSample.h
72 : public Tizen::Ui::Controls::Form
73 , public Tizen::Ui::IActionEventListener
74 , public Tizen::Ui::ITextEventListener
80 bool Initialize(void);
81 void ShowKeypad(bool show);
82 virtual result OnInitializing(void);
83 virtual result OnTerminating(void);
85 // IActionEventListener
86 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
89 virtual void OnTextValueChanged(const Tizen::Ui::Control& source);
90 virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source);
94 static const int ID_BUTTON = 101;
96 Tizen::Ui::Controls::Keypad *__pKeypad;
99 // Sample code for KeypadSample.cpp
100 #include "KeypadSample.h"
102 using namespace Tizen::Graphics;
103 using namespace Tizen::Ui::Controls;
106 KeypadSample::Initialize(void)
108 Construct(FORM_STYLE_NORMAL);
113 KeypadSample::OnInitializing(void)
115 result r = E_SUCCESS;
117 // Creates an instance of Button and adds it to the form
118 Button* pButton = new Button();
119 pButton->Construct(Rectangle(50, 50, 150, 150), L"Show Keypad");
120 pButton->SetActionId(ID_BUTTON);
121 pButton->AddActionEventListener(*this);
122 AddControl(*pButton);
124 // Creates an instance of Keypad
125 __pKeypad = new Keypad();
126 __pKeypad->Construct(KEYPAD_STYLE_NORMAL, KEYPAD_MODE_ALPHA);
128 // Adds an instance of ITextEventListener
129 __pKeypad->AddTextEventListener(*this);
135 KeypadSample::ShowKeypad(bool show)
137 // Changes to desired show state
138 __pKeypad->SetShowState(show);
140 //Calls Show() of the control
145 // Calls Invalidate() of the container
153 KeypadSample::OnTerminating(void)
155 result r = E_SUCCESS;
157 // Deallocates the keypad
163 // IActionEventListener implementation
165 KeypadSample::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
180 // ITextEventListener implementation
182 KeypadSample::OnTextValueChanged(const Tizen::Ui::Control& source)
188 KeypadSample::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
195 class _OSP_EXPORT_ Keypad
196 : public Tizen::Ui::Window
201 * This is the default constructor for this class.
208 * This is the destructor for this class.
212 virtual ~Keypad(void);
215 * Initializes this instance of %Keypad with the specified parameters.
219 * @return An error code
220 * @param[in] keypadStyle The style of %Keypad
221 * @param[in] limitLength The limit of the length of text in EditField
222 * @exception E_SUCCESS The method is successful.
223 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
224 * the specified @c limitLength is less than or equal to @c 0.
225 * @exception E_SYSTEM A system error has occurred.
226 * @remarks If the keypad style is set to password, the input mode category is ignored.
227 * @remarks The orientation mode of the keypad is decided based on the G-sensor value.
229 result Construct(KeypadStyle keypadStyle, int limitLength);
233 * Initializes this instance of %Keypad with input styles.
235 * @brief <i> [Deprecated] </i>
236 * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to. @n
237 * It is recommended to use the other Construct() method and the KeypadStyle enumeration instead.
240 * @return An error code
241 * @param[in] keypadStyle The style of %Keypad
242 * @param[in] category The initial category that the keypad would show first
243 * @param[in] limitLength The limit of the length of text in EditField
244 * @exception E_SUCCESS The method is successful.
245 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
246 * the specified @c limitLength is less than or equal to @c 0.
247 * @exception E_SYSTEM A system error has occurred.
248 * @remarks If the keypad style is set to password, the input mode category is ignored.
249 * @remarks The orientation mode of the keypad is decided based on the G-sensor value.
252 result Construct(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength = 100);
255 * Checks whether the text prediction is enabled.
258 * @return @c true if the text prediction is enabled, @n
260 * @see SetTextPredictionEnabled()
262 bool IsTextPredictionEnabled(void) const;
265 * Enables or disables the text prediction.
268 * @param[in] enable Set to @c true to enable the text prediction, @n
270 * @return An error code
271 * @exception E_SUCCESS The method is successful.
272 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
273 * @see IsTextPredictionEnabled()
275 result SetTextPredictionEnabled(bool enable);
278 * Enables single-line editing.
282 * @return An error code
283 * @param[in] enabled Set to @c true to enable single-line editing, @n
285 * @exception E_SUCCESS The method is successful.
286 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
287 * The %Keypad control is currently visible.
288 * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n
289 * The password style does not support multi-line editing.
290 * @exception E_SYSTEM A system error has occurred.
291 * @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).
293 result SetSingleLineEnabled(bool enabled);
296 * Checks whether single-line editing is enabled.
300 * @return @c true if single-line editing is enabled, @n
303 bool IsSingleLineEnabled(void) const;
306 * Adds a ITextEventListener instance. @n
307 * The added listener can listen to text changed events when they are fired.
311 * @param[in] listener The listener to be added
313 void AddTextEventListener(Tizen::Ui::ITextEventListener& listener);
316 * Removes a ITextEventListener instance. @n
317 * The removed listener cannot listen to events when they are fired.
321 * @param[in] listener The listener to be removed
323 void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener);
326 * Gets the text of the %Keypad control.
330 * @return The string value
332 Tizen::Base::String GetText(void) const;
335 * Sets the text of the %Keypad control.
339 * @param[in] text The text to be set
341 void SetText(Tizen::Base::String text);
344 friend class _KeypadImpl;
347 Keypad(const Keypad&);
348 Keypad& operator =(const Keypad&);
352 }}} // Tizen::Ui::Controls
354 #endif // _FUI_CTRL_KEYPAD_H_