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