2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file StLanguageAndRegionForm.cpp
19 * @brief This is the implementation file for LocaleForm class.
23 #include "StLanguageAndRegionForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Locales;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 static const int ID_GROUP_LANGUAGE_AND_REGION_MAIN = 0;
40 static const int ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT = 2;
41 static const int ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE = 0;
42 static const int ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION = 1;
44 static const int ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT = 1;
46 static const int ID_GROUP_KEYBOARD = 2;
47 static const int ID_ITEM_KEYBOARD = 0;
48 static const int ID_GROUP_KEYBOARD_ITEM_COUNT = 1;
50 static const int ID_GROUP_COUNT = 3;
51 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
52 static const int H_HELP_TEXT_GAP = 4;
54 static const int ID_GROUP_LANGUAGE_ITEM_COUNT = 51;
55 static const int DEFAULT_COUNT = 1;
56 static const int FIRST_CONTROL = 0;
57 static const int SECOND_CONTROL = 1;
58 static const int REFRESH_GROUP_ITEM_INDEX = -1;
59 static const int MAIN_TEXT_WIDTH_GAP = 32;
61 static const long DEFAULT_INPUT_NUMBER = 123456789;
63 static const wchar_t* languageCode[ID_GROUP_LANGUAGE_ITEM_COUNT] =
121 LocaleForm::LocaleForm(void)
122 : __languageDataList(null)
123 , __isRunningAppControl(false)
127 LocaleForm::~LocaleForm(void)
133 LocaleForm::InitLanguageList(void)
140 if (__languageDataList != null)
142 delete __languageDataList;
143 __languageDataList = null;
146 __languageDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
147 __languageDataList->Construct();
151 key = languageCode[i++];
152 displayName = ResourceManager::GetString(L"IDS_IME_BODY_ARABIC");
153 data.Append(displayName + L"/" + key);
154 __languageDataList->Add(*(new (std::nothrow) String(data)));
158 key = languageCode[i++];
159 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_AZERBAIJANI");
160 data.Append(displayName + L"/" + key);
161 __languageDataList->Add(*(new (std::nothrow) String(data)));
165 key = languageCode[i++];
166 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_BULGARIAN");
167 data.Append(displayName + L"/" + key);
168 __languageDataList->Add(*(new (std::nothrow) String(data)));
172 key = languageCode[i++];
173 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_CATALAN");
174 data.Append(displayName + L"/" + key);
175 __languageDataList->Add(*(new (std::nothrow) String(data)));
179 key = languageCode[i++];
180 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_CZECH");
181 data.Append(displayName + L"/" + key);
182 __languageDataList->Add(*(new (std::nothrow) String(data)));
186 key = languageCode[i++];
187 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_DANISH");
188 data.Append(displayName + L"/" + key);
189 __languageDataList->Add(*(new (std::nothrow) String(data)));
193 key = languageCode[i++];
194 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_GERMAN");
195 data.Append(displayName + L"/" + key);
196 __languageDataList->Add(*(new (std::nothrow) String(data)));
200 key = languageCode[i++];
201 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_GREEK");
202 data.Append(displayName + L"/" + key);
203 __languageDataList->Add(*(new (std::nothrow) String(data)));
207 key = languageCode[i++];
208 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ENGLISH_HUNITED_KINGDOM");
209 data.Append(displayName + L"/" + key);
210 __languageDataList->Add(*(new (std::nothrow) String(data)));
214 key = languageCode[i++];
215 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_ENGLISH");
216 displayName.Append(L" (");
217 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_PHILIPPINES"));
218 displayName.Append(L")");
219 data.Append(displayName + L"/" + key);
220 __languageDataList->Add(*(new (std::nothrow) String(data)));
224 key = languageCode[i++];
225 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ENGLISH_HUNITED_STATES");
226 data.Append(displayName + L"/" + key);
227 __languageDataList->Add(*(new (std::nothrow) String(data)));
231 key = languageCode[i++];
232 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ESTONIAN");
233 data.Append(displayName + L"/" + key);
234 __languageDataList->Add(*(new (std::nothrow) String(data)));
238 key = languageCode[i++];
239 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_BASQUE");
240 data.Append(displayName + L"/" + key);
241 __languageDataList->Add(*(new (std::nothrow) String(data)));
245 key = languageCode[i++];
246 displayName = ResourceManager::GetString(L"IDS_IME_BODY_FARSI");
247 data.Append(displayName + L"/" + key);
248 __languageDataList->Add(*(new (std::nothrow) String(data)));
252 key = languageCode[i++];
253 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FINNISH");
254 data.Append(displayName + L"/" + key);
255 __languageDataList->Add(*(new (std::nothrow) String(data)));
259 key = languageCode[i++];
260 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FRENCH");
261 displayName.Append(L" (");
262 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_CANADA"));
263 displayName.Append(L")");
264 data.Append(displayName + L"/" + key);
265 __languageDataList->Add(*(new (std::nothrow) String(data)));
269 key = languageCode[i++];
270 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FRENCH");
271 data.Append(displayName + L"/" + key);
272 __languageDataList->Add(*(new (std::nothrow) String(data)));
276 key = languageCode[i++];
277 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_IRISH");
278 data.Append(displayName + L"/" + key);
279 __languageDataList->Add(*(new (std::nothrow) String(data)));
283 key = languageCode[i++];
284 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_GALICIAN");
285 data.Append(displayName + L"/" + key);
286 __languageDataList->Add(*(new (std::nothrow) String(data)));
290 key = languageCode[i++];
291 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_HINDI");
292 data.Append(displayName + L"/" + key);
293 __languageDataList->Add(*(new (std::nothrow) String(data)));
297 key = languageCode[i++];
298 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_CROATIAN");
299 data.Append(displayName + L"/" + key);
300 __languageDataList->Add(*(new (std::nothrow) String(data)));
304 key = languageCode[i++];
305 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_HUNGARIAN");
306 data.Append(displayName + L"/" + key);
307 __languageDataList->Add(*(new (std::nothrow) String(data)));
311 key = languageCode[i++];
312 displayName = ResourceManager::GetString(L"IDS_IME_BODY_ARMENIAN");
313 data.Append(displayName + L"/" + key);
314 __languageDataList->Add(*(new (std::nothrow) String(data)));
318 key = languageCode[i++];
319 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ICELANDIC");
320 data.Append(displayName + L"/" + key);
321 __languageDataList->Add(*(new (std::nothrow) String(data)));
325 key = languageCode[i++];
326 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ITALIAN");
327 data.Append(displayName + L"/" + key);
328 __languageDataList->Add(*(new (std::nothrow) String(data)));
332 key = languageCode[i++];
333 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_JAPANESE");
334 data.Append(displayName + L"/" + key);
335 __languageDataList->Add(*(new (std::nothrow) String(data)));
339 key = languageCode[i++];
340 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_GEORGIAN");
341 data.Append(displayName + L"/" + key);
342 __languageDataList->Add(*(new (std::nothrow) String(data)));
346 key = languageCode[i++];
347 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_KAZAKH");
348 data.Append(displayName + L"/" + key);
349 __languageDataList->Add(*(new (std::nothrow) String(data)));
353 key = languageCode[i++];
354 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_KOREAN");
355 data.Append(displayName + L"/" + key);
356 __languageDataList->Add(*(new (std::nothrow) String(data)));
360 key = languageCode[i++];
361 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_LATVIAN");
362 data.Append(displayName + L"/" + key);
363 __languageDataList->Add(*(new (std::nothrow) String(data)));
367 key = languageCode[i++];
368 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_LITHUANIAN");
369 data.Append(displayName + L"/" + key);
370 __languageDataList->Add(*(new (std::nothrow) String(data)));
374 key = languageCode[i++];
375 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_MACEDONIAN");
376 data.Append(displayName + L"/" + key);
377 __languageDataList->Add(*(new (std::nothrow) String(data)));
381 key = languageCode[i++];
382 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_DUTCH");
383 data.Append(displayName + L"/" + key);
384 __languageDataList->Add(*(new (std::nothrow) String(data)));
388 key = languageCode[i++];
389 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_NORWEGIAN");
390 data.Append(displayName + L"/" + key);
391 __languageDataList->Add(*(new (std::nothrow) String(data)));
395 key = languageCode[i++];
396 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_POLISH");
397 data.Append(displayName + L"/" + key);
398 __languageDataList->Add(*(new (std::nothrow) String(data)));
402 key = languageCode[i++];
403 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_PORTUGUESE");
404 displayName.Append(L" (");
405 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_BRAZIL"));
406 displayName.Append(L")");
407 data.Append(displayName + L"/" + key);
408 __languageDataList->Add(*(new (std::nothrow) String(data)));
412 key = languageCode[i++];
413 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_PORTUGUESE");
414 data.Append(displayName + L"/" + key);
415 __languageDataList->Add(*(new (std::nothrow) String(data)));
419 key = languageCode[i++];
420 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ROMANIAN");
421 data.Append(displayName + L"/" + key);
422 __languageDataList->Add(*(new (std::nothrow) String(data)));
426 key = languageCode[i++];
427 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_RUSSIAN");
428 data.Append(displayName + L"/" + key);
429 __languageDataList->Add(*(new (std::nothrow) String(data)));
433 key = languageCode[i++];
434 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SLOVAK");
435 data.Append(displayName + L"/" + key);
436 __languageDataList->Add(*(new (std::nothrow) String(data)));
440 key = languageCode[i++];
441 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SLOVENIAN");
442 data.Append(displayName + L"/" + key);
443 __languageDataList->Add(*(new (std::nothrow) String(data)));
447 key = languageCode[i++];
448 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SPANISH");
449 data.Append(displayName + L"/" + key);
450 __languageDataList->Add(*(new (std::nothrow) String(data)));
454 key = languageCode[i++];
455 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SPANISH");
456 displayName.Append(L" (");
457 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_MEXICO"));
458 displayName.Append(L")");
459 data.Append(displayName + L"/" + key);
460 __languageDataList->Add(*(new (std::nothrow) String(data)));
464 key = languageCode[i++];
465 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SERBIAN");
466 data.Append(displayName + L"/" + key);
467 __languageDataList->Add(*(new (std::nothrow) String(data)));
471 key = languageCode[i++];
472 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SWEDISH");
473 data.Append(displayName + L"/" + key);
474 __languageDataList->Add(*(new (std::nothrow) String(data)));
478 key = languageCode[i++];
479 displayName = ResourceManager::GetString(L"IDS_IME_BODY_THAI");
480 data.Append(displayName + L"/" + key);
481 __languageDataList->Add(*(new (std::nothrow) String(data)));
485 key = languageCode[i++];
486 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_TURKISH");
487 data.Append(displayName + L"/" + key);
488 __languageDataList->Add(*(new (std::nothrow) String(data)));
492 key = languageCode[i++];
493 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_UKRAINIAN");
494 data.Append(displayName + L"/" + key);
495 __languageDataList->Add(*(new (std::nothrow) String(data)));
499 key = languageCode[i++];
500 displayName = ResourceManager::GetString(L"IDS_IME_BODY_URDU");
501 data.Append(displayName + L"/" + key);
502 __languageDataList->Add(*(new (std::nothrow) String(data)));
506 key = languageCode[i++];
507 displayName = ResourceManager::GetString(L"IDS_IME_BODY_UZBEK");
508 data.Append(displayName + L"/" + key);
509 __languageDataList->Add(*(new (std::nothrow) String(data)));
513 key = languageCode[i++];
514 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_SIMPLIFIED");
515 data.Append(displayName + L"/" + key);
516 __languageDataList->Add(*(new (std::nothrow) String(data)));
520 key = languageCode[i++];
521 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_TRADITIONAL_HONGKONG");
522 data.Append(displayName + L"/" + key);
523 __languageDataList->Add(*(new (std::nothrow) String(data)));
527 key = languageCode[i++];
528 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_SINGAPORE");
529 data.Append(displayName + L"/" + key);
530 __languageDataList->Add(*(new (std::nothrow) String(data)));
534 key = languageCode[i++];
535 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_TRADITIONAL_TAIWAN");
536 data.Append(displayName + L"/" + key);
537 __languageDataList->Add(*(new (std::nothrow) String(data)));
541 LocaleForm::CreateFooter(void)
543 Footer* pFooter = GetFooter();
546 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
547 pFooter->SetBackButton();
548 pFooter->AddActionEventListener(*this);
550 SetFormBackEventListener(this);
554 LocaleForm::OnInitializing(void)
557 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
561 AddFocusEventListener(*this);
563 AppLogDebug("ENTER");
569 LocaleForm::OnTerminating(void)
573 SetFormBackEventListener(null);
578 LocaleForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
580 Header* pHeader = GetHeader();
581 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
583 if (previousSceneId.Equals(IDSCN_LOCALE_LANGUAGE, false))
587 __pTableView->Draw();
588 RefreshTableViewItem();
592 LocaleForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
597 LocaleForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
599 SceneManager* pSceneManager = SceneManager::GetInstance();
600 AppAssert(pSceneManager);
602 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
606 LocaleForm::GetGroupCount(void)
608 AppLogDebug("ENTER");
609 return ID_GROUP_COUNT;
613 LocaleForm::GetItemCount(int groupIndex)
619 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
621 itemCount = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
625 case ID_GROUP_KEYBOARD:
627 itemCount = ID_GROUP_KEYBOARD_ITEM_COUNT;
634 AppLogDebug("GetItemCount %d", itemCount);
640 LocaleForm::CreateGroupItem(int groupIndex, int itemWidth)
642 AppLogDebug("ENTER");
644 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
645 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
646 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
647 Rectangle itemMainRectangle;
649 Label* pLabel = null;
650 int fontSize = GetFontSize();
653 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
657 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
659 String formattedString;
661 long inputNumber = DEFAULT_INPUT_NUMBER;
663 LocaleManager localeManager;
664 localeManager.Construct();
666 Locale systemLocale = localeManager.GetSystemLocale();
667 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
668 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
671 SystemTime::GetCurrentTime(dateTime);
673 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
677 tmpHeight = GetHeightForStringArea(groupText, itemWidth, fontSize);
678 itemHeight += tmpHeight;
680 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
681 pDateFormatter->Format(dateTime, formattedString);
682 formattedString = L"Date : " + formattedString;
683 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
685 tmpText.Insert(formattedString, tmpText.GetLength());
686 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
687 tmpText.Remove(0, tmpText.GetLength());
688 itemHeight += tmpHeight;
690 formattedString.Remove(0, formattedString.GetLength());
691 bool timeFormat = false;
692 pDateFormatter->ApplyPattern("hh : mm aa");
693 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
695 if (timeFormat == true)
697 pDateFormatter->ApplyPattern("HH : mm");
700 pDateFormatter->Format(dateTime, formattedString);
701 formattedString = L"Time : " + formattedString;
702 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
704 tmpText.Insert(formattedString, tmpText.GetLength());
705 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
706 tmpText.Remove(0, tmpText.GetLength());
707 itemHeight += tmpHeight;
709 formattedString.Remove(0, formattedString.GetLength());
710 pNumberFormatter->Format(inputNumber, formattedString);
711 groupText.Insert(L"\nNumber : " + formattedString, groupText.GetLength());
713 tmpText.Insert(formattedString, tmpText.GetLength());
716 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
717 tmpText.Remove(0, tmpText.GetLength());
720 tmpHeight = (lineCount + 1) * lineHeight;
724 formattedString = L"Number : " + formattedString;
725 tmpText.Remove(0, tmpText.GetLength());
726 tmpText.Insert(formattedString, tmpText.GetLength());
727 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
729 itemHeight += tmpHeight;
731 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
743 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
744 itemMainRectangle.y = yItemOffset;
745 itemMainRectangle.width = itemWidth;
746 itemMainRectangle.height = itemHeight;
748 RelativeLayout relativeLayout;
749 relativeLayout.Construct();
751 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
752 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
754 pLabel = new (std::nothrow) Label();
755 pLabel->Construct(itemMainRectangle, groupText);
756 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
757 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
758 pLabel->SetTextConfig(fontSize, style);
759 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
761 pItem->AddControl(pLabel);
762 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
763 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
764 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
765 pItem->SetEnabled(false);
771 LocaleForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
773 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
774 bool isItemSubText = false;
775 Rectangle itemMainRectangle;
776 Rectangle itemSubRectangle;
777 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
780 String systemLocaleString;
781 Label* pLabel = null;
782 int fontSize = GetFontSize();
783 LocaleManager localeManager;
784 localeManager.Construct();
785 Locale locale = localeManager.GetSystemLocale();
786 int itemHeight = H_GROUP_ITEM_DEFAULT;
790 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
792 isItemSubText = true;
796 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
798 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
799 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
801 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
805 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
807 if (itemSubText.Equals(languageCode[i], false))
809 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
811 StringTokenizer stringTokenizer(*pKey, L"/");
812 stringTokenizer.GetNextToken(itemSubText);
820 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
822 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
823 String localeLanguage;
824 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
826 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
827 localeLanguage = L"eng_GB";
830 LanguageCode langCode = LANGUAGE_INVALID;
831 CountryCode countryCode = COUNTRY_INVALID;
832 StringTokenizer strTok(localeLanguage, L"_");
835 if (strTok.HasMoreTokens())
837 strTok.GetNextToken(token);
838 langCode = Locale::StringToLanguageCode(token);
841 if (strTok.HasMoreTokens())
843 strTok.GetNextToken(token);
844 countryCode = Locale::StringToCountryCode(token);
847 Locale currentLocale(langCode, countryCode);
849 locale.GetLanguageName(currentLocale, systemLocaleString);
850 itemSubText.Append(systemLocaleString + L"(");
851 systemLocaleString.Remove(0, systemLocaleString.GetLength());
853 locale.GetCountryName(currentLocale, systemLocaleString);
854 itemSubText.Append(systemLocaleString + L")");
855 systemLocaleString.Remove(0, systemLocaleString.GetLength());
865 case ID_GROUP_KEYBOARD:
867 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
875 ItemTypeOneLine(itemMainRectangle);
877 TableViewItem* pItem = new (std::nothrow) TableViewItem();
879 if (isItemSubText == true)
881 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
882 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
883 RelativeLayout relativeLayout;
884 relativeLayout.Construct();
886 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
887 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
889 pLabel = new (std::nothrow) Label();
890 pLabel->Construct(itemMainRectangle, itemMainText);
891 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
892 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
893 pLabel->SetTextColor(COLOR_MAIN_TEXT);
895 pItem->AddControl(pLabel);
896 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
897 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
898 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
900 pLabel = new (std::nothrow) Label();
901 pLabel->Construct(itemSubRectangle, itemSubText);
902 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
903 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
904 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
905 pLabel->SetTextColor(COLOR_SUB_TEXT);
907 pItem->AddControl(pLabel);
908 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
909 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
910 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
914 RelativeLayout relativeLayout;
915 relativeLayout.Construct();
917 pItem->Construct(relativeLayout, Dimension(W_GROUP_ITEM_DEFAULT, H_GROUP_ITEM_DEFAULT), style);
918 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
920 pLabel = new (std::nothrow) Label();
921 pLabel->Construct(itemMainRectangle, itemMainText);
922 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
923 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
924 pLabel->SetTextColor(COLOR_MAIN_TEXT);
926 pItem->AddControl(pLabel);
927 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
928 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
929 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
936 LocaleForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
938 AppLogDebug("ENTER");
947 LocaleForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
949 AppLogDebug("ENTER");
958 LocaleForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
960 SceneManager* pSceneManager = SceneManager::GetInstance();
961 AppAssert(pSceneManager);
963 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
967 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
969 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE)
971 // TODO: Set display language. does not yet support
972 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_LANGUAGE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __languageDataList);
974 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION)
976 // TODO: Set region. does not yet support
977 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_REGION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
982 case ID_GROUP_KEYBOARD:
985 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
988 if (__isRunningAppControl == true)
993 if (AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/setting/ime", null, null, null, null, null) == E_SUCCESS)
995 __isRunningAppControl = true;
1007 LocaleForm::GetDefaultGroupItemHeight(void)
1009 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1013 LocaleForm::GetDefaultItemHeight(void)
1015 return H_GROUP_ITEM_DEFAULT;
1019 LocaleForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1023 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
1025 Rectangle pItemBounds = pItem->GetBounds();
1026 Rectangle pBounds = GetClientAreaBounds();
1027 Label* pGroupLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1028 int labelWidth = pItemBounds.width - MAIN_TEXT_WIDTH_GAP;
1031 String formattedString;
1032 String numberFormat;
1034 long inputNumber = DEFAULT_INPUT_NUMBER;
1037 int fontSize = GetFontSize();
1039 LocaleManager localeManager;
1040 localeManager.Construct();
1042 Locale systemLocale = localeManager.GetSystemLocale();
1043 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
1044 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
1047 SystemTime::GetCurrentTime(dateTime);
1049 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
1055 tempHeight = GetLineheight(groupText, labelWidth, fontSize, lineCount, lineHeight);
1056 itemHeight += tempHeight;
1058 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
1059 pDateFormatter->Format(dateTime, formattedString);
1060 formattedString = L"Date : " + formattedString;
1061 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1063 tmpText.Remove(0, tmpText.GetLength());
1064 tmpText.Insert(formattedString, tmpText.GetLength());
1065 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1066 itemHeight += tempHeight;
1068 formattedString.Remove(0, formattedString.GetLength());
1069 bool timeFormat = false;
1070 pDateFormatter->ApplyPattern("hh : mm aa");
1071 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
1073 if (timeFormat == true)
1075 pDateFormatter->ApplyPattern("HH : mm");
1078 pDateFormatter->Format(dateTime, formattedString);
1079 formattedString = L"Time : " + formattedString;
1080 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1082 tmpText.Remove(0, tmpText.GetLength());
1083 tmpText.Insert(formattedString, tmpText.GetLength());
1085 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1086 itemHeight += tempHeight;
1088 formattedString.Remove(0, formattedString.GetLength());
1089 pNumberFormatter->Format(inputNumber, formattedString);
1090 groupText.Insert(L"\nNumber : " + formattedString, groupText.GetLength());
1092 tmpText.Remove(0, tmpText.GetLength());
1093 tmpText.Insert(formattedString, tmpText.GetLength());
1094 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1097 tempHeight = (lineCount + 1) * lineHeight;
1101 formattedString = L"Number : " + formattedString;
1102 tmpText.Remove(0, tmpText.GetLength());
1103 tmpText.Insert(formattedString, tmpText.GetLength());
1104 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1106 itemHeight += tempHeight;
1108 tmpText.Remove(0, tmpText.GetLength());
1110 pItemBounds.height = itemHeight;
1111 pItem->SetBounds(pItemBounds);
1112 AppLogDebug("%d %d %d %d", pItemBounds.x, pItemBounds.y, pItemBounds.width, pItemBounds.height);
1113 pItemBounds.y = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
1114 pGroupLabel->SetBounds(pItemBounds);
1115 pGroupLabel->SetText(groupText);
1116 pGroupLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1117 pGroupLabel->Invalidate(false);
1118 pItem->Invalidate(false);
1128 LocaleForm::GetLineheight(Tizen::Base::String& src, int labelWidth, int fontSize, int& lineCount, int& lineHeight)
1133 font.Construct(FONT_STYLE_PLAIN, fontSize);
1134 font.GetTextExtent(src, src.GetLength(), dim);
1136 lineHeight = dim.height;
1137 if (dim.width > labelWidth)
1139 lineCount = (dim.width / labelWidth);
1141 if (dim.width % labelWidth)
1143 lineCount += DEFAULT_COUNT;
1148 lineCount = DEFAULT_COUNT;
1150 return (lineCount* dim.height);
1154 LocaleForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1156 String firstLineText;
1159 Rectangle pItemBounds = pItem->GetBounds();
1160 Rectangle firstLineRect;
1161 Rectangle secondLineRect;
1163 Label* pFirstLabel = null;
1164 Label* pSecondLabel = null;
1166 int fontSize = GetFontSize();
1170 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
1172 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1173 pSecondLabel = static_cast<Label*>(pItem->GetControl(SECOND_CONTROL));
1175 ItemTypeTwoLine(firstLineRect, secondLineRect, fontSize);
1176 pItemBounds.height = (firstLineRect.height + secondLineRect.height);
1180 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
1182 firstLineText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
1184 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
1186 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
1190 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
1192 if (itemSubText.Equals(languageCode[i], false))
1194 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
1196 StringTokenizer stringTokenizer(*pKey, L"/");
1197 stringTokenizer.GetNextToken(itemSubText);
1202 pItem->SetBounds(pItemBounds);
1203 pFirstLabel->SetText(firstLineText);
1204 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1206 pSecondLabel->SetText(itemSubText);
1207 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1209 pFirstLabel->Invalidate(false);
1210 pSecondLabel->Invalidate(false);
1211 pItem->Invalidate(false);
1215 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
1217 LocaleManager localeManager;
1218 localeManager.Construct();
1219 Locale locale = localeManager.GetSystemLocale();
1220 String systemLocaleString;
1222 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
1224 String localeLanguage;
1225 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
1227 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
1228 localeLanguage = L"eng_GB";
1231 LanguageCode langCode = LANGUAGE_INVALID;
1232 CountryCode countryCode = COUNTRY_INVALID;
1233 StringTokenizer strTok(localeLanguage, L"_");
1236 if (strTok.HasMoreTokens())
1238 strTok.GetNextToken(token);
1239 langCode = Locale::StringToLanguageCode(token);
1242 if (strTok.HasMoreTokens())
1244 strTok.GetNextToken(token);
1245 countryCode = Locale::StringToCountryCode(token);
1248 Locale currentLocale(langCode, countryCode);
1250 locale.GetLanguageName(currentLocale, systemLocaleString);
1251 itemSubText.Append(systemLocaleString + L"(");
1252 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1254 locale.GetCountryName(currentLocale, systemLocaleString);
1255 itemSubText.Append(systemLocaleString + L")");
1256 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1258 pItem->SetBounds(pItemBounds);
1259 pFirstLabel->SetText(firstLineText);
1260 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1262 pSecondLabel->SetText(itemSubText);
1263 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1265 pFirstLabel->Invalidate(false);
1266 pSecondLabel->Invalidate(false);
1267 pItem->Invalidate(false);
1277 case ID_GROUP_KEYBOARD:
1279 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1281 ItemTypeOneLine(firstLineRect);
1282 pItemBounds.height = firstLineRect.height;
1284 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
1285 pItem->SetBounds(pItemBounds);
1286 pFirstLabel->SetText(firstLineText);
1287 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1288 pFirstLabel->Invalidate(false);
1289 pItem->Invalidate(false);
1299 LocaleForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1304 LocaleForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1309 LocaleForm::RefreshTableViewGroupItem(int groupIndex)
1311 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1313 for (int index = REFRESH_GROUP_ITEM_INDEX; index < itemCount; index++)
1315 __pTableView->RefreshItem(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1320 LocaleForm::RefreshTableViewItem(void)
1322 if (__pTableView == null)
1327 int groupCount = __pTableView->GetGroupCount();
1329 for (int index = 0; index < groupCount; index++)
1331 RefreshTableViewGroupItem(index);
1336 LocaleForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1338 RefreshTableViewItem();
1343 LocaleForm::OnFocusGained(const Tizen::Ui::Control& source)
1345 __isRunningAppControl = false;
1349 LocaleForm::OnFocusLost(const Tizen::Ui::Control& source)