Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUiInputConnection.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                 FUiInputConnection.cpp
20 * @brief                This is the implementation file for InputConnection class.
21 */
22
23 #include <FBaseSysLog.h>
24 #include <FGrpRectangle.h>
25 #include <FLclLocale.h>
26 #include <FUiInputConnection.h>
27 #include "FUi_ControlImpl.h"
28 #include "FUi_InputConnectionImpl.h"
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Locales;
33 using namespace Tizen::Security;
34
35 namespace Tizen { namespace Ui {
36
37 InputConnection::InputConnection(void)
38 :__pInputConnectionImpl(null)
39 {
40
41 }
42
43 InputConnection::~InputConnection(void)
44 {
45         if (__pInputConnectionImpl)
46         {
47                 delete __pInputConnectionImpl;
48                 __pInputConnectionImpl = null;
49         }
50 }
51
52 result
53 InputConnection::Construct(const Control* pControl, IInputConnectionEventListener& listener, IInputConnectionProvider& provider)
54 {
55         SysTryReturnResult(NID_UI, pControl, E_INVALID_ARG, "The argument is invalid.");
56
57         __pInputConnectionImpl = _InputConnectionImpl::CreateInputConnectionImplN(this);
58         result r = GetLastResult();
59         SysTryReturn(NID_UI, __pInputConnectionImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
60
61         r = __pInputConnectionImpl->Initialize(_ControlImpl::GetInstance(*pControl)->GetCore(), listener, provider);
62         SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
63
64         return r;
65
66 CATCH:
67         delete __pInputConnectionImpl;
68         __pInputConnectionImpl = null;
69         return r;
70 }
71
72 result
73 InputConnection::Construct(const Control* pControl, IInputConnectionEventListenerF& listener, IInputConnectionProvider& provider)
74 {
75         SysTryReturnResult(NID_UI, pControl, E_INVALID_ARG, "The argument is invalid.");
76
77         __pInputConnectionImpl = _InputConnectionImpl::CreateInputConnectionImplN(this);
78         result r = GetLastResult();
79         SysTryReturn(NID_UI, __pInputConnectionImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
80
81         r = __pInputConnectionImpl->Initialize(_ControlImpl::GetInstance(*pControl)->GetCore(), listener, provider);
82         SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
83
84         return r;
85
86 CATCH:
87         delete __pInputConnectionImpl;
88         __pInputConnectionImpl = null;
89         return r;
90 }
91
92 result
93 InputConnection::BindInputMethod(void)
94 {
95         result r = E_SUCCESS;
96
97         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
98
99         r = __pInputConnectionImpl->BindInputMethod();
100         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
101
102         return r;
103 }
104
105 void
106 InputConnection::UnbindInputMethod(void)
107 {
108         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
109
110         __pInputConnectionImpl->UnbindInputMethod();
111
112         return;
113 }
114
115 result
116 InputConnection::ShowInputPanel(void)
117 {
118         result r = E_SUCCESS;
119
120         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
121
122         r = __pInputConnectionImpl->ShowInputPanel();
123         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
124
125         return r;
126 }
127
128 result
129 InputConnection::HideInputPanel(void)
130 {
131         result r = E_SUCCESS;
132
133         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
134
135         r = __pInputConnectionImpl->HideInputPanel();
136         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
137
138         return r;
139 }
140
141 void
142 InputConnection::SetInputPanelStyle(InputPanelStyle style)
143 {
144         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
145
146         __pInputConnectionImpl->SetInputPanelStyle(style);
147
148         return;
149 }
150
151 void
152 InputConnection::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode)
153 {
154         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
155
156         __pInputConnectionImpl->SetAutoCapitalizationMode(autoCapitalizationMode);
157
158         return;
159 }
160
161 result
162 InputConnection::FinishTextComposition(void)
163 {
164         result r = E_SUCCESS;
165
166         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
167
168         r = __pInputConnectionImpl->FinishTextComposition();
169         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
170
171         return r;
172 }
173
174 void
175 InputConnection::SetInputPanelAction(InputPanelAction inputPanelAction)
176 {
177         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
178
179         __pInputConnectionImpl->SetInputPanelAction(inputPanelAction);
180
181         return;
182 }
183
184 void
185 InputConnection::SetInputPanelActionEnabled(bool enable)
186 {
187         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
188
189         __pInputConnectionImpl->SetInputPanelActionEnabled(enable);
190
191         return;
192 }
193
194 result
195 InputConnection::SetInputPanelLanguage(LanguageCode languageCode)
196 {
197         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
198
199         return __pInputConnectionImpl->SetInputPanelLanguage(languageCode);
200 }
201
202 result
203 InputConnection::SetCursorPosition(int position)
204 {
205         result r = E_SUCCESS;
206
207         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
208
209         r = __pInputConnectionImpl->SetCursorPosition(position);
210         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
211
212         return r;
213 }
214
215 result
216 InputConnection::SetCursorBounds(const Rectangle& rect)
217 {
218         result r = E_SUCCESS;
219
220         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
221
222         r = __pInputConnectionImpl->SetCursorBounds(rect);
223         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
224
225         return r;
226 }
227
228 result
229 InputConnection::SetCursorBounds(const FloatRectangle& rect)
230 {
231         result r = E_SUCCESS;
232
233         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
234
235         r = __pInputConnectionImpl->SetCursorBounds(rect);
236         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
237
238         return r;
239 }
240
241 Rectangle
242 InputConnection::GetInputPanelBounds(void) const
243 {
244         result r = E_SUCCESS;
245
246         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
247
248         Rectangle bounds = __pInputConnectionImpl->GetInputPanelBounds();
249         r = GetLastResult();
250         SysTryReturn(NID_UI, r == E_SUCCESS, Rectangle(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r));
251
252         return bounds;
253 }
254
255 FloatRectangle
256 InputConnection::GetInputPanelBoundsF(void) const
257 {
258         result r = E_SUCCESS;
259
260         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
261
262         FloatRectangle bounds = __pInputConnectionImpl->GetInputPanelBoundsF();
263         r = GetLastResult();
264         SysTryReturn(NID_UI, r == E_SUCCESS, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), r, "[%s] Propagating.", GetErrorMessage(r));
265
266         return bounds;
267 }
268
269 void
270 InputConnection::SetTextPredictionEnabled(bool enable)
271 {
272         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
273
274         __pInputConnectionImpl->SetTextPredictionEnabled(enable);
275
276         return;
277 }
278
279 void
280 InputConnection::SendOpaqueCommand(const String& command)
281 {
282         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
283
284         __pInputConnectionImpl->SendOpaqueCommand(command);
285
286         return;
287 }
288
289 }} //Tizen::Ui