Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrlKeypad.cpp
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                 FUiCtrlKeypad.cpp
19 * @brief                This file contains implementation of Keypad class
20 *
21 * This file contains implementation of Keypad class.
22 */
23
24 #include <FBaseSysLog.h>
25 #include <FUiCtrlKeypad.h>
26 #include "FUiCtrl_KeypadImpl.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Runtime;
30
31 namespace Tizen { namespace Ui { namespace Controls
32 {
33
34 Keypad::Keypad(void)
35 {
36
37 }
38
39 Keypad::~Keypad(void)
40 {
41
42 }
43
44 result
45 Keypad::Construct(KeypadStyle keypadStyle, int limitLength)
46 {
47         return Construct(keypadStyle, KEYPAD_MODE_ALPHA, limitLength);
48 }
49
50 result
51 Keypad::Construct(KeypadStyle keypadStyle, KeypadInputModeCategory category, int limitLength)
52 {
53         result r = E_SUCCESS;
54
55         _KeypadImpl* pImpl = _KeypadImpl::GetInstance(*this);
56         SysAssertf(pImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
57         SysTryReturn(NID_UI_CTRL, limitLength > 0, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid argument is given.");
58
59         pImpl = _KeypadImpl::CreateKeypadImplN(this);
60         r = GetLastResult();
61         SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
62
63         _pControlImpl = pImpl;
64
65         r = pImpl->Initialize(keypadStyle, category, limitLength);
66         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
67
68         return r;
69
70 CATCH:
71         delete pImpl;
72         _pControlImpl = null;
73
74         return r;
75 }
76
77 bool
78 Keypad::IsTextPredictionEnabled(void) const
79 {
80         const _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
81         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
82
83         return pKeypadImpl->IsTextPredictionEnabled();
84 }
85
86 result
87 Keypad::SetTextPredictionEnabled(bool enable)
88 {
89         _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
90         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
91
92         pKeypadImpl->SetTextPredictionEnabled(enable);
93
94         return E_SUCCESS;
95 }
96
97 result
98 Keypad::SetSingleLineEnabled(bool enabled)
99 {
100         _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
101         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
102         return pKeypadImpl->SetSingleLineEnabled(enabled);
103 }
104
105 bool
106 Keypad::IsSingleLineEnabled(void) const
107 {
108         const _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
109         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
110         return pKeypadImpl->IsSingleLineEnabled();
111 }
112
113 void
114 Keypad::AddTextEventListener(ITextEventListener& listener)
115 {
116         _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
117         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
118         pKeypadImpl->AddTextEventListener(listener);
119 }
120
121 void
122 Keypad::RemoveTextEventListener(ITextEventListener& listener)
123 {
124         _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
125         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
126         pKeypadImpl->RemoveTextEventListener(listener);
127 }
128
129 String
130 Keypad::GetText(void) const
131 {
132         const _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
133         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
134         return pKeypadImpl->GetText();
135 }
136
137 void
138 Keypad::SetText(String text)
139 {
140         _KeypadImpl* pKeypadImpl = _KeypadImpl::GetInstance(*this);
141         SysAssertf(pKeypadImpl != null, "Not yet constructed. Construct() should be called before use.");
142         return pKeypadImpl->SetText(text);
143 }
144
145 }}} // Tizen::Ui::Controls