Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUiCtrl_Keypad.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17 /**
18 * @file                 FUiCtrl_Keypad.h
19 * @brief                This is the header file for the _Keypad class.
20 *
21 * This header file contains the declarations of the _Keypad class.
22 */
23 #ifndef _FUI_CTRL_INTERNAL_KEYPAD_H_
24 #define _FUI_CTRL_INTERNAL_KEYPAD_H_
25
26 #include <FUiCtrlEditTypes.h>
27 #include "FUi_Window.h"
28 #include "FUiCtrl_Button.h"
29 #include "FUiCtrl_Edit.h"
30 #include "FUiCtrl_IActionEventListener.h"
31 #include "FUiCtrl_IKeypadEventListener.h"
32 #include "FUiCtrl_ITextEventListener.h"
33 #include "FUiCtrl_TextEvent.h"
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37
38 struct _KeypadStyleInfo
39 {
40         KeypadStyle keypadStyle;
41         bool textPredictionEnabled;
42         bool isNormalNumberStyle;
43         bool enterActionEnabled;
44         bool isLowerCaseModeEnabled;
45 };
46
47 class _OSP_EXPORT_ _Keypad
48         : virtual public Tizen::Base::Runtime::IEventListener
49         , virtual public Tizen::Ui::_IUiEventListener
50         , virtual public Tizen::Ui::_IUiEventPreviewer
51         , public Tizen::Ui::_Window
52         , public _IActionEventListener
53         , public _IKeypadEventListener
54 {
55         DECLARE_CLASS_BEGIN(_Keypad, _Control);
56         DECLARE_PROPERTY("singleLineEnabled", GetPropertySingleLineEnabled, SetPropertySingleLineEnabled);
57         DECLARE_PROPERTY("text", GetPropertyText, SetPropertyText);
58         DECLARE_CLASS_END();
59
60         result SetPropertySingleLineEnabled(const Tizen::Ui::Variant& enabled);
61         Tizen::Ui::Variant GetPropertySingleLineEnabled(void) const;
62
63         result SetPropertyText(const Tizen::Ui::Variant& text);
64         Tizen::Ui::Variant GetPropertyText(void) const;
65
66 public:
67         static _Keypad* CreateKeypadN(void);
68         virtual ~_Keypad(void);
69
70         result Initialize(int editStyle, _KeypadStyleInfo styleInfo, int limitLength, _Edit* pCallerEdit = null);
71         virtual void OnDraw(void);
72
73         result SetSingleLineEnabled(bool enabled);
74         bool IsSingleLineEnabled(void) const;
75
76         Tizen::Base::String GetText(void) const;
77         void SetText(const Tizen::Base::String& text);
78
79         result AddTextEventListener(const _ITextEventListener& listener);
80         result RemoveTextEventListener(const _ITextEventListener& listener);
81
82         virtual result OnAttachedToMainTree(void);
83         virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
84         virtual void OnKeypadWillOpen(void);
85         virtual void OnKeypadOpened(void);
86         virtual void OnKeypadClosed(void);
87         virtual void OnKeypadBoundsChanged(void);
88         virtual void OnKeypadActionPerformed(CoreKeypadAction keypadAction);
89         virtual void OnChangeLayout(_ControlOrientation orientation);
90         virtual void OnNativeWindowActivated(void);
91
92 #if defined(MULTI_WINDOW)
93         virtual result OnBoundsChanging(const Tizen::Graphics::Rectangle& bounds);
94         virtual bool IsLayoutChangable(void) const;
95 #endif
96
97
98 private:
99         _Keypad(void);
100         _Keypad(const _Keypad&);
101         _Keypad& operator =(const _Keypad&);
102
103         result Dispose(void);
104         result ChangeLayoutInternal(void);
105         Tizen::Graphics::Rectangle GetIndicatorBounds(void) const;
106         _Button* CreateButtonItemN(int actionId, const Tizen::Base::String& text);
107         _Toolbar* CreateHeaderForSIP(void);
108
109 private:
110         bool __isInitialized;
111         bool __isSingleLineEnabled;
112         _Control* __pOwner;
113         _Edit* __pCallerEdit;
114         _Edit* __pChildEdit;
115         _Toolbar* __pHeaderForSIP;
116         Tizen::Base::String __text;
117         _TextEvent* __pTextEvent;
118         bool __isCommandButtonPressed;
119         bool __isPredictionWindowOpendInUSBMode;
120 }; // _Keypad
121
122 } } } // Tizen::Ui::Controls
123 #endif // _FUI_CTRL_INTERNAL_KEYPAD_H_