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 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);
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.
229 * - If the keypad style is set to password, the input mode category is ignored.
230 * - The orientation mode of the keypad is decided based on the G-sensor value.
231 * - The default owner will be the current Form (or Frame). It is possible that this control may not be visible
232 * due to this ownership relationship. @n In this case, use the SetOwner() method to change the ownership to the top-most window.
234 result Construct(KeypadStyle keypadStyle, int limitLength);
238 * Initializes this instance of %Keypad with input styles.
240 * @brief <i> [Deprecated] </i>
241 * @deprecated We no longer provide a method to specify the list of styles which the user can set the keypad to. @n
242 * It is recommended to use the other Construct() method and the KeypadStyle enumeration instead.
245 * @return An error code
246 * @param[in] keypadStyle The style of %Keypad
247 * @param[in] category The initial category that the keypad would show first
248 * @param[in] limitLength The limit of the length of text in EditField
249 * @exception E_SUCCESS The method is successful.
250 * @exception E_INVALID_ARG A specified input parameter is invalid, or @n
251 * the specified @c limitLength is less than or equal to @c 0.
252 * @exception E_SYSTEM A system error has occurred.
254 * - If the keypad style is set to password, the input mode category is ignored.
255 * - The orientation mode of the keypad is decided based on the G-sensor value.
258 result Construct(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength = 100);
261 * Checks whether the text prediction is enabled.
264 * @return @c true if the text prediction is enabled, @n
266 * @see SetTextPredictionEnabled()
268 bool IsTextPredictionEnabled(void) const;
271 * Enables or disables the text prediction.
274 * @param[in] enable Set to @c true to enable the text prediction, @n
276 * @return An error code
277 * @exception E_SUCCESS The method is successful.
278 * @exception E_UNSUPPORTED_OPERATION This operation is not supported.
279 * @see IsTextPredictionEnabled()
281 result SetTextPredictionEnabled(bool enable);
284 * Enables single-line editing.
288 * @return An error code
289 * @param[in] enabled Set to @c true to enable single-line editing, @n
291 * @exception E_SUCCESS The method is successful.
292 * @exception E_INVALID_OPERATION The current state of the instance prohibits the execution of the specified operation. @n
293 * The %Keypad control is currently visible.
294 * @exception E_UNSUPPORTED_OPERATION The current state of the instance does not support the execution of the specified operation. @n
295 * The password style does not support multi-line editing.
296 * @exception E_SYSTEM A system error has occurred.
297 * @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).
299 result SetSingleLineEnabled(bool enabled);
302 * Checks whether single-line editing is enabled.
306 * @return @c true if single-line editing is enabled, @n
309 bool IsSingleLineEnabled(void) const;
312 * Adds a ITextEventListener instance. @n
313 * The added listener can listen to text changed events when they are fired.
317 * @param[in] listener The listener to add
319 void AddTextEventListener(Tizen::Ui::ITextEventListener& listener);
322 * Removes a ITextEventListener instance. @n
323 * The removed listener cannot listen to events when they are fired.
327 * @param[in] listener The listener to remove
329 void RemoveTextEventListener(Tizen::Ui::ITextEventListener& listener);
332 * Gets the text of the %Keypad control.
336 * @return The string value
338 Tizen::Base::String GetText(void) const;
341 * Sets the text of the %Keypad control.
345 * @param[in] text The text to set
347 void SetText(Tizen::Base::String text);
350 * Sets the text filter.
354 * @param[in] pFilter The filter
355 * @remarks The %Keypad control checks with the registered filter to decide whether the user-entered text should be replaced.
357 void SetEditTextFilter(IEditTextFilter* pFilter);
360 * Sends opaque command to the input method.
364 * @param[in] command The opaque command
366 * - This method can be used to provide domain-specific features that are only known between certain input methods and their clients.
367 * - This method may not work, depending on the active Input Method.
369 void SendOpaqueCommand (const Tizen::Base::String& command);
372 friend class _KeypadImpl;
375 Keypad(const Keypad&);
376 Keypad& operator =(const Keypad&);
380 }}} // Tizen::Ui::Controls
382 #endif // _FUI_CTRL_KEYPAD_H_