Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_EditModel.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                FUiCtrl_EditModel.cpp
20  * @brief               This is the implementation file for the _EditModel class.
21  */
22
23 #include <FBaseErrorDefine.h>
24 #include <FBaseSysLog.h>
25 #include <FBaseUtilTypes.h>
26 #include <FUiIKeypadEventListener.h>
27 #include "FUi_ResourceManager.h"
28 #include "FUiCtrl_EditModel.h"
29
30 using namespace Tizen::Base;
31 using namespace Tizen::Locales;
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 _EditModel::_EditModel(void)
37         : __autoLinkMask(Utility::LINK_TYPE_NONE)
38         , __keypadActionEnabled(true)
39         , __viewModeEnabled(false)
40         , __keypadStyle(KEYPAD_STYLE_NORMAL)
41         , __keypadEnabled(false)
42         , __isLowerCase(false)
43         , __isTextPredictionEnabled(true)
44         , __keypadAction(CORE_KEYPAD_ACTION_ENTER)
45         , __enablePredictiveAutoResizing(false)
46         , __maxLineCount(-1)
47         , __languageCode(LANGUAGE_ENG)
48         , __initialKeypadLanguageCode(LANGUAGE_INVALID)
49         , __leftCommandButtonActionId(100)
50         , __rightCommandButtonActionId(101)
51         , __leftCommandButtonText()
52         , __rightCommandButtonText()
53 {
54         GET_STRING_CONFIG(IDS_COM_SK_DONE, __leftCommandButtonText);
55         GET_STRING_CONFIG(IDS_COM_SK_CANCEL, __rightCommandButtonText);
56 }
57
58 _EditModel::~_EditModel(void)
59 {
60 }
61
62 result
63 _EditModel::SetAutoLinkMask(unsigned long autoLinks)
64 {
65         result r = E_SUCCESS;
66
67         __autoLinkMask = autoLinks;
68
69         return r;
70 }
71
72 unsigned long
73 _EditModel::GetAutoLinkMask(void) const
74 {
75         return __autoLinkMask;
76 }
77
78 bool
79 _EditModel::IsViewModeEnabled(void) const
80 {
81         return __viewModeEnabled;
82 }
83
84 result
85 _EditModel::SetViewModeEnabled(bool enable)
86 {
87         result r = E_SUCCESS;
88
89         __viewModeEnabled = enable;
90
91         return r;
92 }
93
94 result
95 _EditModel::SetKeypadActionEnabled(bool enable)
96 {
97         result r = E_SUCCESS;
98
99         __keypadActionEnabled = enable;
100
101         return r;
102 }
103
104 bool
105 _EditModel::IsKeypadActionEnabled(void) const
106 {
107         return __keypadActionEnabled;
108 }
109
110 CoreKeypadAction
111 _EditModel::GetKeypadAction(void) const
112 {
113         return __keypadAction;
114 }
115
116 result
117 _EditModel::SetKeypadAction(CoreKeypadAction keypadAction)
118 {
119         result r = E_SUCCESS;
120
121         __keypadAction = keypadAction;
122
123         return r;
124 }
125
126 result
127 _EditModel::SetCurrentLanguage(LanguageCode languageCode)
128 {
129         result r = E_SUCCESS;
130
131         __languageCode = languageCode;
132
133         return r;
134 }
135
136 result
137 _EditModel::GetCurrentLanguage(LanguageCode& language) const
138 {
139         result r = E_SUCCESS;
140
141         language = __languageCode;
142
143         return r;
144 }
145
146 result
147 _EditModel::SetInitialKeypadLanguage(LanguageCode languageCode)
148 {
149         result r = E_SUCCESS;
150
151         __initialKeypadLanguageCode = languageCode;
152
153         return r;
154 }
155
156 result
157 _EditModel::GetInitialKeypadLanguage(LanguageCode& language) const
158 {
159         result r = E_SUCCESS;
160
161         language = __initialKeypadLanguageCode;
162
163         return r;
164 }
165
166 result
167 _EditModel::SetTextPredictionEnabled(bool enable)
168 {
169         __isTextPredictionEnabled = enable;
170
171         return E_SUCCESS;
172 }
173
174 bool
175 _EditModel::IsTextPredictionEnabled(void) const
176 {
177         return __isTextPredictionEnabled;
178 }
179
180 void
181 _EditModel::SetKeypadEnabled(bool enable)
182 {
183         __keypadEnabled = enable;
184
185         return;
186 }
187
188 bool
189 _EditModel::IsKeypadEnabled(void) const
190 {
191         return __keypadEnabled;
192 }
193
194 void
195 _EditModel::SetLowerCaseModeEnabled(bool enable)
196 {
197         __isLowerCase = enable;
198
199         return;
200 }
201
202 bool
203 _EditModel::IsLowerCaseModeEnabled(void) const
204 {
205         return __isLowerCase;
206 }
207
208 KeypadStyle
209 _EditModel::GetKeypadStyle(void) const
210 {
211         return __keypadStyle;
212 }
213
214 result
215 _EditModel::SetKeypadStyle(KeypadStyle keypadStyle)
216 {
217         __keypadStyle = keypadStyle;
218         return E_SUCCESS;
219 }
220
221 result
222 _EditModel::SetAutoResizingEnabled(bool enable)
223 {
224         __enablePredictiveAutoResizing = enable;
225         return E_SUCCESS;
226 }
227
228 bool
229 _EditModel::IsAutoResizingEnabled(void) const
230 {
231         return __enablePredictiveAutoResizing;
232 }
233
234 void
235 _EditModel::SetMaxLineCount(int maxLineCount)
236 {
237         __maxLineCount = maxLineCount;
238
239         return;
240 }
241
242
243 int
244 _EditModel::GetMaxLineCount(void) const
245 {
246         return __maxLineCount;
247 }
248
249 result
250 _EditModel::SetCommandButtonItem(CommandButtonPosition buttonPosition, int actionId, const String& text)
251 {
252         result r = E_SUCCESS;
253         if (buttonPosition == COMMAND_BUTTON_POSITION_LEFT)
254         {
255                 __leftCommandButtonActionId = actionId;
256                 __leftCommandButtonText = text;
257         }
258         else
259         {
260                 __rightCommandButtonActionId = actionId;
261                 __rightCommandButtonText = text;
262         }
263
264         return r;
265 }
266
267 String
268 _EditModel::GetKeypadCommandButtonText(CommandButtonPosition position) const
269 {
270         if (position == COMMAND_BUTTON_POSITION_LEFT)
271         {
272                 return __leftCommandButtonText;
273         }
274         else
275         {
276                 return __rightCommandButtonText;
277         }
278 }
279
280 int
281 _EditModel::GetKeypadCommandButtonActionId(CommandButtonPosition position) const
282 {
283         if (position == COMMAND_BUTTON_POSITION_LEFT)
284         {
285                 return __leftCommandButtonActionId;
286         }
287         else
288         {
289                 return __rightCommandButtonActionId;
290         }
291 }
292
293 }}} // Tizen::Ui::Controls