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 FUiInputConnection.cpp
20 * @brief This is the implementation file for InputConnection class.
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"
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Locales;
33 using namespace Tizen::Security;
35 namespace Tizen { namespace Ui {
37 InputConnection::InputConnection(void)
38 :__pInputConnectionImpl(null)
43 InputConnection::~InputConnection(void)
45 if (__pInputConnectionImpl)
47 delete __pInputConnectionImpl;
48 __pInputConnectionImpl = null;
53 InputConnection::Construct(const Control* pControl, IInputConnectionEventListener& listener, IInputConnectionProvider& provider)
55 SysTryReturnResult(NID_UI, pControl, E_INVALID_ARG, "The argument is invalid.");
57 __pInputConnectionImpl = _InputConnectionImpl::CreateInputConnectionImplN(this);
58 result r = GetLastResult();
59 SysTryReturn(NID_UI, __pInputConnectionImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
61 r = __pInputConnectionImpl->Initialize(_ControlImpl::GetInstance(*pControl)->GetCore(), listener, provider);
62 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
67 delete __pInputConnectionImpl;
68 __pInputConnectionImpl = null;
73 InputConnection::Construct(const Control* pControl, IInputConnectionEventListenerF& listener, IInputConnectionProvider& provider)
75 SysTryReturnResult(NID_UI, pControl, E_INVALID_ARG, "The argument is invalid.");
77 __pInputConnectionImpl = _InputConnectionImpl::CreateInputConnectionImplN(this);
78 result r = GetLastResult();
79 SysTryReturn(NID_UI, __pInputConnectionImpl, r, r, "[%s] Propagating.", GetErrorMessage(r));
81 r = __pInputConnectionImpl->Initialize(_ControlImpl::GetInstance(*pControl)->GetCore(), listener, provider);
82 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
87 delete __pInputConnectionImpl;
88 __pInputConnectionImpl = null;
93 InputConnection::BindInputMethod(void)
97 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
99 r = __pInputConnectionImpl->BindInputMethod();
100 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
106 InputConnection::UnbindInputMethod(void)
108 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
110 __pInputConnectionImpl->UnbindInputMethod();
116 InputConnection::ShowInputPanel(void)
118 result r = E_SUCCESS;
120 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
122 r = __pInputConnectionImpl->ShowInputPanel();
123 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
129 InputConnection::HideInputPanel(void)
131 result r = E_SUCCESS;
133 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
135 r = __pInputConnectionImpl->HideInputPanel();
136 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
142 InputConnection::SetInputPanelStyle(InputPanelStyle style)
144 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
146 __pInputConnectionImpl->SetInputPanelStyle(style);
152 InputConnection::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode)
154 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
156 __pInputConnectionImpl->SetAutoCapitalizationMode(autoCapitalizationMode);
162 InputConnection::FinishTextComposition(void)
164 result r = E_SUCCESS;
166 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
168 r = __pInputConnectionImpl->FinishTextComposition();
169 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
175 InputConnection::SetInputPanelAction(InputPanelAction inputPanelAction)
177 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
179 __pInputConnectionImpl->SetInputPanelAction(inputPanelAction);
185 InputConnection::SetInputPanelActionEnabled(bool enable)
187 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
189 __pInputConnectionImpl->SetInputPanelActionEnabled(enable);
195 InputConnection::SetInputPanelLanguage(LanguageCode languageCode)
197 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
199 return __pInputConnectionImpl->SetInputPanelLanguage(languageCode);
203 InputConnection::SetCursorPosition(int position)
205 result r = E_SUCCESS;
207 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
209 r = __pInputConnectionImpl->SetCursorPosition(position);
210 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
216 InputConnection::SetCursorBounds(const Rectangle& rect)
218 result r = E_SUCCESS;
220 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
222 r = __pInputConnectionImpl->SetCursorBounds(rect);
223 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
229 InputConnection::SetCursorBounds(const FloatRectangle& rect)
231 result r = E_SUCCESS;
233 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
235 r = __pInputConnectionImpl->SetCursorBounds(rect);
236 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
242 InputConnection::GetInputPanelBounds(void) const
244 result r = E_SUCCESS;
246 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
248 Rectangle bounds = __pInputConnectionImpl->GetInputPanelBounds();
250 SysTryReturn(NID_UI, r == E_SUCCESS, Rectangle(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r));
256 InputConnection::GetInputPanelBoundsF(void) const
258 result r = E_SUCCESS;
260 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
262 FloatRectangle bounds = __pInputConnectionImpl->GetInputPanelBoundsF();
264 SysTryReturn(NID_UI, r == E_SUCCESS, FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f), r, "[%s] Propagating.", GetErrorMessage(r));
270 InputConnection::SetTextPredictionEnabled(bool enable)
272 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
274 __pInputConnectionImpl->SetTextPredictionEnabled(enable);
280 InputConnection::SendOpaqueCommand(const String& command)
282 SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
284 __pInputConnectionImpl->SendOpaqueCommand(command);