Tizen 2.1 base
[framework/osp/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 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 /**
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
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::BindInputMethod(void)
74 {
75         result r = E_SUCCESS;
76
77         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
78
79         r = __pInputConnectionImpl->BindInputMethod();
80         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
81
82         return r;
83 }
84
85 void
86 InputConnection::UnbindInputMethod(void)
87 {
88         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
89
90         __pInputConnectionImpl->UnbindInputMethod();
91
92         return;
93 }
94
95 result
96 InputConnection::ShowInputPanel(void)
97 {
98         result r = E_SUCCESS;
99
100         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
101
102         r = __pInputConnectionImpl->ShowInputPanel();
103         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
104
105         return r;
106 }
107
108 result
109 InputConnection::HideInputPanel(void)
110 {
111         result r = E_SUCCESS;
112
113         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
114
115         r = __pInputConnectionImpl->HideInputPanel();
116         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
117
118         return r;
119 }
120
121 void
122 InputConnection::SetInputPanelStyle(InputPanelStyle style)
123 {
124         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
125
126         __pInputConnectionImpl->SetInputPanelStyle(style);
127
128         return;
129 }
130
131 void
132 InputConnection::SetAutoCapitalizationMode(AutoCapitalizationMode autoCapitalizationMode)
133 {
134         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
135
136         __pInputConnectionImpl->SetAutoCapitalizationMode(autoCapitalizationMode);
137
138         return;
139 }
140
141 result
142 InputConnection::FinishTextComposition(void)
143 {
144         result r = E_SUCCESS;
145
146         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
147
148         r = __pInputConnectionImpl->FinishTextComposition();
149         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
150
151         return r;
152 }
153
154 void
155 InputConnection::SetInputPanelAction(InputPanelAction inputPanelAction)
156 {
157         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
158
159         __pInputConnectionImpl->SetInputPanelAction(inputPanelAction);
160
161         return;
162 }
163
164 void
165 InputConnection::SetInputPanelActionEnabled(bool enable)
166 {
167         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
168
169         __pInputConnectionImpl->SetInputPanelActionEnabled(enable);
170
171         return;
172 }
173
174 result
175 InputConnection::SetInputPanelLanguage(LanguageCode languageCode)
176 {
177         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
178
179         return __pInputConnectionImpl->SetInputPanelLanguage(languageCode);
180 }
181
182 result
183 InputConnection::SetCursorPosition(int position)
184 {
185         result r = E_SUCCESS;
186
187         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
188
189         r = __pInputConnectionImpl->SetCursorPosition(position);
190         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
191
192         return r;
193 }
194
195 result
196 InputConnection::SetCursorBounds(const Rectangle& rect)
197 {
198         result r = E_SUCCESS;
199
200         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
201
202         r = __pInputConnectionImpl->SetCursorBounds(rect);
203         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
204
205         return r;
206 }
207
208 Rectangle
209 InputConnection::GetInputPanelBounds(void) const
210 {
211         result r = E_SUCCESS;
212
213         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
214
215         Rectangle bounds = __pInputConnectionImpl->GetInputPanelBounds();
216         r = GetLastResult();
217         SysTryReturn(NID_UI, r == E_SUCCESS, Rectangle(0, 0, 0, 0), r, "[%s] Propagating.", GetErrorMessage(r));
218
219         return bounds;
220 }
221
222 void
223 InputConnection::SetTextPredictionEnabled(bool enable)
224 {
225         SysAssertf(__pInputConnectionImpl, "Not yet constructed. Construct() should be called before use.");
226
227         __pInputConnectionImpl->SetTextPredictionEnabled(enable);
228
229         return;
230 }
231
232 }} //Tizen::Ui