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 if (__isRunningAppControl == true)
965 SceneManager* pSceneManager = SceneManager::GetInstance();
966 AppAssert(pSceneManager);
968 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
972 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
974 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE)
976 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_LANGUAGE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __languageDataList);
978 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION)
980 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_REGION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
985 case ID_GROUP_KEYBOARD:
988 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
990 if (AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/setting/ime", null, null, null, null, null) == E_SUCCESS)
992 __isRunningAppControl = true;
1004 LocaleForm::GetDefaultGroupItemHeight(void)
1006 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1010 LocaleForm::GetDefaultItemHeight(void)
1012 return H_GROUP_ITEM_DEFAULT;
1016 LocaleForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1020 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
1022 Rectangle pItemBounds = pItem->GetBounds();
1023 Rectangle pBounds = GetClientAreaBounds();
1024 Label* pGroupLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1025 int labelWidth = pItemBounds.width - MAIN_TEXT_WIDTH_GAP;
1028 String formattedString;
1029 String numberFormat;
1031 long inputNumber = DEFAULT_INPUT_NUMBER;
1034 int fontSize = GetFontSize();
1036 LocaleManager localeManager;
1037 localeManager.Construct();
1039 Locale systemLocale = localeManager.GetSystemLocale();
1040 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
1041 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
1044 SystemTime::GetCurrentTime(dateTime);
1046 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
1052 tempHeight = GetLineheight(groupText, labelWidth, fontSize, lineCount, lineHeight);
1053 itemHeight += tempHeight;
1055 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
1056 pDateFormatter->Format(dateTime, formattedString);
1057 formattedString = L"Date : " + formattedString;
1058 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1060 tmpText.Remove(0, tmpText.GetLength());
1061 tmpText.Insert(formattedString, tmpText.GetLength());
1062 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1063 itemHeight += tempHeight;
1065 formattedString.Remove(0, formattedString.GetLength());
1066 bool timeFormat = false;
1067 pDateFormatter->ApplyPattern("hh : mm aa");
1068 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
1070 if (timeFormat == true)
1072 pDateFormatter->ApplyPattern("HH : mm");
1075 pDateFormatter->Format(dateTime, formattedString);
1076 formattedString = L"Time : " + formattedString;
1077 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1079 tmpText.Remove(0, tmpText.GetLength());
1080 tmpText.Insert(formattedString, tmpText.GetLength());
1082 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1083 itemHeight += tempHeight;
1085 formattedString.Remove(0, formattedString.GetLength());
1086 pNumberFormatter->Format(inputNumber, formattedString);
1087 groupText.Insert(L"\nNumber : " + formattedString, groupText.GetLength());
1089 tmpText.Remove(0, tmpText.GetLength());
1090 tmpText.Insert(formattedString, tmpText.GetLength());
1091 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1094 tempHeight = (lineCount + 1) * lineHeight;
1098 formattedString = L"Number : " + formattedString;
1099 tmpText.Remove(0, tmpText.GetLength());
1100 tmpText.Insert(formattedString, tmpText.GetLength());
1101 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1103 itemHeight += tempHeight;
1105 tmpText.Remove(0, tmpText.GetLength());
1107 pItemBounds.height = itemHeight;
1108 pItem->SetBounds(pItemBounds);
1109 AppLogDebug("%d %d %d %d", pItemBounds.x, pItemBounds.y, pItemBounds.width, pItemBounds.height);
1110 pItemBounds.y = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
1111 pGroupLabel->SetBounds(pItemBounds);
1112 pGroupLabel->SetText(groupText);
1113 pGroupLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1114 pGroupLabel->Invalidate(false);
1115 pItem->Invalidate(false);
1125 LocaleForm::GetLineheight(Tizen::Base::String& src, int labelWidth, int fontSize, int& lineCount, int& lineHeight)
1130 font.Construct(FONT_STYLE_PLAIN, fontSize);
1131 font.GetTextExtent(src, src.GetLength(), dim);
1133 lineHeight = dim.height;
1134 if (dim.width > labelWidth)
1136 lineCount = (dim.width / labelWidth);
1138 if (dim.width % labelWidth)
1140 lineCount += DEFAULT_COUNT;
1145 lineCount = DEFAULT_COUNT;
1147 return (lineCount* dim.height);
1151 LocaleForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1153 String firstLineText;
1156 Rectangle pItemBounds = pItem->GetBounds();
1157 Rectangle firstLineRect;
1158 Rectangle secondLineRect;
1160 Label* pFirstLabel = null;
1161 Label* pSecondLabel = null;
1163 int fontSize = GetFontSize();
1167 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
1169 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1170 pSecondLabel = static_cast<Label*>(pItem->GetControl(SECOND_CONTROL));
1172 ItemTypeTwoLine(firstLineRect, secondLineRect, fontSize);
1173 pItemBounds.height = (firstLineRect.height + secondLineRect.height);
1177 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
1179 firstLineText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
1181 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
1183 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
1187 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
1189 if (itemSubText.Equals(languageCode[i], false))
1191 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
1193 StringTokenizer stringTokenizer(*pKey, L"/");
1194 stringTokenizer.GetNextToken(itemSubText);
1199 pItem->SetBounds(pItemBounds);
1200 pFirstLabel->SetText(firstLineText);
1201 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1203 pSecondLabel->SetText(itemSubText);
1204 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1206 pFirstLabel->Invalidate(false);
1207 pSecondLabel->Invalidate(false);
1208 pItem->Invalidate(false);
1212 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
1214 LocaleManager localeManager;
1215 localeManager.Construct();
1216 Locale locale = localeManager.GetSystemLocale();
1217 String systemLocaleString;
1219 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
1221 String localeLanguage;
1222 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
1224 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
1225 localeLanguage = L"eng_GB";
1228 LanguageCode langCode = LANGUAGE_INVALID;
1229 CountryCode countryCode = COUNTRY_INVALID;
1230 StringTokenizer strTok(localeLanguage, L"_");
1233 if (strTok.HasMoreTokens())
1235 strTok.GetNextToken(token);
1236 langCode = Locale::StringToLanguageCode(token);
1239 if (strTok.HasMoreTokens())
1241 strTok.GetNextToken(token);
1242 countryCode = Locale::StringToCountryCode(token);
1245 Locale currentLocale(langCode, countryCode);
1247 locale.GetLanguageName(currentLocale, systemLocaleString);
1248 itemSubText.Append(systemLocaleString + L"(");
1249 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1251 locale.GetCountryName(currentLocale, systemLocaleString);
1252 itemSubText.Append(systemLocaleString + L")");
1253 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1255 pItem->SetBounds(pItemBounds);
1256 pFirstLabel->SetText(firstLineText);
1257 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1259 pSecondLabel->SetText(itemSubText);
1260 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1262 pFirstLabel->Invalidate(false);
1263 pSecondLabel->Invalidate(false);
1264 pItem->Invalidate(false);
1274 case ID_GROUP_KEYBOARD:
1276 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1278 ItemTypeOneLine(firstLineRect);
1279 pItemBounds.height = firstLineRect.height;
1281 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
1282 pItem->SetBounds(pItemBounds);
1283 pFirstLabel->SetText(firstLineText);
1284 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1285 pFirstLabel->Invalidate(false);
1286 pItem->Invalidate(false);
1296 LocaleForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1301 LocaleForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1306 LocaleForm::RefreshTableViewGroupItem(int groupIndex)
1308 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1310 for (int index = REFRESH_GROUP_ITEM_INDEX; index < itemCount; index++)
1312 __pTableView->RefreshItem(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1317 LocaleForm::RefreshTableViewItem(void)
1319 if (__pTableView == null)
1324 int groupCount = __pTableView->GetGroupCount();
1326 for (int index = 0; index < groupCount; index++)
1328 RefreshTableViewGroupItem(index);
1333 LocaleForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1335 RefreshTableViewItem();
1340 LocaleForm::OnFocusGained(const Tizen::Ui::Control& source)
1342 __isRunningAppControl = false;
1346 LocaleForm::OnFocusLost(const Tizen::Ui::Control& source)