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_GROUP_KEYBOARD_ITEM_COUNT = 1;
48 static const int ID_GROUP_COUNT = 3;
50 static const int ID_GROUP_LANGUAGE_ITEM_COUNT = 51;
51 static const int FIRST_CONTROL = 0;
52 static const int SECOND_CONTROL = 1;
53 static const int REFRESH_GROUP_ITEM_INDEX = -1;
54 static const int BASE_FORM_DEFAULT_MARGIN = 40;
56 static const int NUMBER_TEXT_HEIGHT_GAP = 5;
58 static const long DEFAULT_INPUT_NUMBER = 123456789;
60 static const wchar_t* LABEL_0 = L"Label0";
61 static const wchar_t* LABEL_1 = L"Label1";
62 static const wchar_t* LABEL_LANGUAGE = L"Label_language";
63 static const wchar_t* LABEL_REGION = L"Label_region";
65 static const wchar_t* languageCode[ID_GROUP_LANGUAGE_ITEM_COUNT] =
123 LocaleForm::LocaleForm(void)
124 : __languageDataList(null)
125 , __isRunningAppControl(false)
131 LocaleForm::~LocaleForm(void)
137 LocaleForm::InitLanguageList(void)
144 if (__languageDataList != null)
146 delete __languageDataList;
147 __languageDataList = null;
150 __languageDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
151 __languageDataList->Construct();
155 key = languageCode[i++];
156 displayName = ResourceManager::GetString(L"IDS_IME_BODY_ARABIC");
157 data.Append(displayName + L"/" + key);
158 __languageDataList->Add(new (std::nothrow) String(data));
162 key = languageCode[i++];
163 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_AZERBAIJANI");
164 data.Append(displayName + L"/" + key);
165 __languageDataList->Add(new (std::nothrow) String(data));
169 key = languageCode[i++];
170 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_BULGARIAN");
171 data.Append(displayName + L"/" + key);
172 __languageDataList->Add(new (std::nothrow) String(data));
176 key = languageCode[i++];
177 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_CATALAN");
178 data.Append(displayName + L"/" + key);
179 __languageDataList->Add(new (std::nothrow) String(data));
183 key = languageCode[i++];
184 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_CZECH");
185 data.Append(displayName + L"/" + key);
186 __languageDataList->Add(new (std::nothrow) String(data));
190 key = languageCode[i++];
191 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_DANISH");
192 data.Append(displayName + L"/" + key);
193 __languageDataList->Add(new (std::nothrow) String(data));
197 key = languageCode[i++];
198 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_GERMAN");
199 data.Append(displayName + L"/" + key);
200 __languageDataList->Add(new (std::nothrow) String(data));
204 key = languageCode[i++];
205 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_GREEK");
206 data.Append(displayName + L"/" + key);
207 __languageDataList->Add(new (std::nothrow) String(data));
211 key = languageCode[i++];
212 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ENGLISH_HUNITED_KINGDOM");
213 data.Append(displayName + L"/" + key);
214 __languageDataList->Add(new (std::nothrow) String(data));
218 key = languageCode[i++];
219 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_ENGLISH");
220 displayName.Append(L" (");
221 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_PHILIPPINES"));
222 displayName.Append(L")");
223 data.Append(displayName + L"/" + key);
224 __languageDataList->Add(new (std::nothrow) String(data));
228 key = languageCode[i++];
229 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ENGLISH_HUNITED_STATES");
230 data.Append(displayName + L"/" + key);
231 __languageDataList->Add(new (std::nothrow) String(data));
235 key = languageCode[i++];
236 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ESTONIAN");
237 data.Append(displayName + L"/" + key);
238 __languageDataList->Add(new (std::nothrow) String(data));
242 key = languageCode[i++];
243 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_BASQUE");
244 data.Append(displayName + L"/" + key);
245 __languageDataList->Add(new (std::nothrow) String(data));
249 key = languageCode[i++];
250 displayName = ResourceManager::GetString(L"IDS_IME_BODY_FARSI");
251 data.Append(displayName + L"/" + key);
252 __languageDataList->Add(new (std::nothrow) String(data));
256 key = languageCode[i++];
257 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FINNISH");
258 data.Append(displayName + L"/" + key);
259 __languageDataList->Add(new (std::nothrow) String(data));
263 key = languageCode[i++];
264 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FRENCH");
265 displayName.Append(L" (");
266 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_CANADA"));
267 displayName.Append(L")");
268 data.Append(displayName + L"/" + key);
269 __languageDataList->Add(new (std::nothrow) String(data));
273 key = languageCode[i++];
274 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FRENCH");
275 data.Append(displayName + L"/" + key);
276 __languageDataList->Add(new (std::nothrow) String(data));
280 key = languageCode[i++];
281 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_IRISH");
282 data.Append(displayName + L"/" + key);
283 __languageDataList->Add(new (std::nothrow) String(data));
287 key = languageCode[i++];
288 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_GALICIAN");
289 data.Append(displayName + L"/" + key);
290 __languageDataList->Add(new (std::nothrow) String(data));
294 key = languageCode[i++];
295 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_HINDI");
296 data.Append(displayName + L"/" + key);
297 __languageDataList->Add(new (std::nothrow) String(data));
301 key = languageCode[i++];
302 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_CROATIAN");
303 data.Append(displayName + L"/" + key);
304 __languageDataList->Add(new (std::nothrow) String(data));
308 key = languageCode[i++];
309 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_HUNGARIAN");
310 data.Append(displayName + L"/" + key);
311 __languageDataList->Add(new (std::nothrow) String(data));
315 key = languageCode[i++];
316 displayName = ResourceManager::GetString(L"IDS_IME_BODY_ARMENIAN");
317 data.Append(displayName + L"/" + key);
318 __languageDataList->Add(new (std::nothrow) String(data));
322 key = languageCode[i++];
323 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ICELANDIC");
324 data.Append(displayName + L"/" + key);
325 __languageDataList->Add(new (std::nothrow) String(data));
329 key = languageCode[i++];
330 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ITALIAN");
331 data.Append(displayName + L"/" + key);
332 __languageDataList->Add(new (std::nothrow) String(data));
336 key = languageCode[i++];
337 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_JAPANESE");
338 data.Append(displayName + L"/" + key);
339 __languageDataList->Add(new (std::nothrow) String(data));
343 key = languageCode[i++];
344 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_GEORGIAN");
345 data.Append(displayName + L"/" + key);
346 __languageDataList->Add(new (std::nothrow) String(data));
350 key = languageCode[i++];
351 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_KAZAKH");
352 data.Append(displayName + L"/" + key);
353 __languageDataList->Add(new (std::nothrow) String(data));
357 key = languageCode[i++];
358 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_KOREAN");
359 data.Append(displayName + L"/" + key);
360 __languageDataList->Add(new (std::nothrow) String(data));
364 key = languageCode[i++];
365 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_LATVIAN");
366 data.Append(displayName + L"/" + key);
367 __languageDataList->Add(new (std::nothrow) String(data));
371 key = languageCode[i++];
372 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_LITHUANIAN");
373 data.Append(displayName + L"/" + key);
374 __languageDataList->Add(new (std::nothrow) String(data));
378 key = languageCode[i++];
379 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_MACEDONIAN");
380 data.Append(displayName + L"/" + key);
381 __languageDataList->Add(new (std::nothrow) String(data));
385 key = languageCode[i++];
386 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_DUTCH");
387 data.Append(displayName + L"/" + key);
388 __languageDataList->Add(new (std::nothrow) String(data));
392 key = languageCode[i++];
393 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_NORWEGIAN");
394 data.Append(displayName + L"/" + key);
395 __languageDataList->Add(new (std::nothrow) String(data));
399 key = languageCode[i++];
400 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_POLISH");
401 data.Append(displayName + L"/" + key);
402 __languageDataList->Add(new (std::nothrow) String(data));
406 key = languageCode[i++];
407 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_PORTUGUESE");
408 displayName.Append(L" (");
409 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_BRAZIL"));
410 displayName.Append(L")");
411 data.Append(displayName + L"/" + key);
412 __languageDataList->Add(new (std::nothrow) String(data));
416 key = languageCode[i++];
417 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_PORTUGUESE");
418 data.Append(displayName + L"/" + key);
419 __languageDataList->Add(new (std::nothrow) String(data));
423 key = languageCode[i++];
424 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ROMANIAN");
425 data.Append(displayName + L"/" + key);
426 __languageDataList->Add(new (std::nothrow) String(data));
430 key = languageCode[i++];
431 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_RUSSIAN");
432 data.Append(displayName + L"/" + key);
433 __languageDataList->Add(new (std::nothrow) String(data));
437 key = languageCode[i++];
438 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SLOVAK");
439 data.Append(displayName + L"/" + key);
440 __languageDataList->Add(new (std::nothrow) String(data));
444 key = languageCode[i++];
445 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SLOVENIAN");
446 data.Append(displayName + L"/" + key);
447 __languageDataList->Add(new (std::nothrow) String(data));
451 key = languageCode[i++];
452 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SPANISH");
453 data.Append(displayName + L"/" + key);
454 __languageDataList->Add(new (std::nothrow) String(data));
458 key = languageCode[i++];
459 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SPANISH");
460 displayName.Append(L" (");
461 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_MEXICO"));
462 displayName.Append(L")");
463 data.Append(displayName + L"/" + key);
464 __languageDataList->Add(new (std::nothrow) String(data));
468 key = languageCode[i++];
469 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SERBIAN");
470 data.Append(displayName + L"/" + key);
471 __languageDataList->Add(new (std::nothrow) String(data));
475 key = languageCode[i++];
476 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SWEDISH");
477 data.Append(displayName + L"/" + key);
478 __languageDataList->Add(new (std::nothrow) String(data));
482 key = languageCode[i++];
483 displayName = ResourceManager::GetString(L"IDS_IME_BODY_THAI");
484 data.Append(displayName + L"/" + key);
485 __languageDataList->Add(new (std::nothrow) String(data));
489 key = languageCode[i++];
490 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_TURKISH");
491 data.Append(displayName + L"/" + key);
492 __languageDataList->Add(new (std::nothrow) String(data));
496 key = languageCode[i++];
497 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_UKRAINIAN");
498 data.Append(displayName + L"/" + key);
499 __languageDataList->Add(new (std::nothrow) String(data));
503 key = languageCode[i++];
504 displayName = ResourceManager::GetString(L"IDS_IME_BODY_URDU");
505 data.Append(displayName + L"/" + key);
506 __languageDataList->Add(new (std::nothrow) String(data));
510 key = languageCode[i++];
511 displayName = ResourceManager::GetString(L"IDS_IME_BODY_UZBEK");
512 data.Append(displayName + L"/" + key);
513 __languageDataList->Add(new (std::nothrow) String(data));
517 key = languageCode[i++];
518 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_SIMPLIFIED");
519 data.Append(displayName + L"/" + key);
520 __languageDataList->Add(new (std::nothrow) String(data));
524 key = languageCode[i++];
525 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_TRADITIONAL_HONGKONG");
526 data.Append(displayName + L"/" + key);
527 __languageDataList->Add(new (std::nothrow) String(data));
531 key = languageCode[i++];
532 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_SINGAPORE");
533 data.Append(displayName + L"/" + key);
534 __languageDataList->Add(new (std::nothrow) String(data));
538 key = languageCode[i++];
539 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_TRADITIONAL_TAIWAN");
540 data.Append(displayName + L"/" + key);
541 __languageDataList->Add(new (std::nothrow) String(data));
545 LocaleForm::CreateFooter(void)
547 Footer* pFooter = GetFooter();
550 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
551 pFooter->AddActionEventListener(*this);
553 SetFormBackEventListener(this);
557 LocaleForm::OnInitializing(void)
560 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
562 __pTableView->UpdateTableView();
563 AppLogDebug("ENTER");
569 LocaleForm::OnTerminating(void)
573 RemoveFocusEventListener(*this);
574 SetFormBackEventListener(null);
579 LocaleForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
582 Header* pHeader = GetHeader();
583 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
585 if (previousSceneId.Equals(IDSCN_LOCALE_LANGUAGE, false) || previousSceneId.Equals(IDSCN_LOCALE_REGION, false))
588 __pTableView->Draw();
589 RefreshTableViewItem();
594 LocaleForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
599 LocaleForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
601 if (__isRunningAppControl)
603 AppLogDebug("busy status");
606 SceneManager* pSceneManager = SceneManager::GetInstance();
607 AppAssert(pSceneManager);
609 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
613 LocaleForm::GetGroupCount(void)
615 AppLogDebug("ENTER");
616 return ID_GROUP_COUNT;
620 LocaleForm::GetItemCount(int groupIndex)
626 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
628 itemCount = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
632 case ID_GROUP_KEYBOARD:
634 itemCount = ID_GROUP_KEYBOARD_ITEM_COUNT;
641 AppLogDebug("GetItemCount %d", itemCount);
647 LocaleForm::CreateGroupItem(int groupIndex, int itemWidth)
649 AppLogDebug("ENTER");
650 itemWidth = GetClientAreaBounds().width;
653 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
654 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
655 Rectangle itemMainRectangle;
660 Label* pLabel = null;
661 int fontSize = GetFontSize();
663 const wchar_t LRE = 0x202A;
664 const wchar_t PDF = 0x202C;
665 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
669 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
671 String formattedString;
673 long inputNumber = DEFAULT_INPUT_NUMBER;
675 LocaleManager localeManager;
676 localeManager.Construct();
678 Locale systemLocale = localeManager.GetSystemLocale();
679 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
680 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
683 SystemTime::GetCurrentTime(TIME_MODE_WALL, dateTime);
685 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
686 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
687 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
688 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
692 tempHeight = GetHeightForStringArea(groupText, itemWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
693 itemHeight += tempHeight;
695 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
697 pDateFormatter->ApplyPattern(localPattern);
701 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
704 pDateFormatter->Format(dateTime, formattedString);
705 formattedString = dateText + L" : " + LRE + formattedString + PDF;
706 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
707 tempHeight = GetHeightForStringArea(formattedString, itemWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
708 itemHeight += tempHeight;
709 formattedString.Remove(0, formattedString.GetLength());
711 bool timeFormat = false;
712 pDateFormatter->ApplyPattern("hh:mm aa");
713 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
715 if (timeFormat == true)
717 pDateFormatter->ApplyPattern("HH:mm");
720 pDateFormatter->Format(dateTime, formattedString);
721 formattedString = timeText + L" : " + LRE + formattedString + PDF;
722 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
723 tempHeight = GetHeightForStringArea(formattedString, itemWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
724 itemHeight += tempHeight;
725 formattedString.Remove(0, formattedString.GetLength());
727 pNumberFormatter->Format(inputNumber, formattedString);
728 formattedString = numberText + L" : " + LRE + formattedString + PDF;
729 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
730 tempHeight = GetHeightForStringArea(formattedString, itemWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
731 itemHeight += tempHeight;
733 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
745 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
746 itemMainRectangle.y = yItemOffset;
747 itemMainRectangle.width = itemWidth;
748 itemMainRectangle.height = itemHeight;
750 RelativeLayout relativeLayout;
751 relativeLayout.Construct();
753 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
754 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
756 pLabel = new (std::nothrow) Label();
757 pLabel->Construct(itemMainRectangle, groupText);
758 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
759 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
760 pLabel->SetTextConfig(fontSize, style);
761 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
763 pItem->AddControl(pLabel);
764 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
765 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
766 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
767 pItem->SetEnabled(false);
773 LocaleForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
775 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
776 bool isItemSubText = false;
777 Rectangle itemMainRectangle;
778 Rectangle itemSubRectangle;
779 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
782 String name = LABEL_NAME;
784 String systemLocaleString;
785 Label* pLabel = null;
786 int fontSize = GetFontSize();
787 LocaleManager localeManager;
788 localeManager.Construct();
789 Locale locale = localeManager.GetSystemLocale();
790 int itemHeight = H_GROUP_ITEM_DEFAULT;
794 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
796 isItemSubText = true;
800 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
802 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
803 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
805 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
809 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
811 if (itemSubText.Equals(languageCode[i], false))
813 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
815 StringTokenizer stringTokenizer(*pKey, L"/");
816 stringTokenizer.GetNextToken(itemSubText);
824 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
826 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
827 String localeLanguage;
828 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
830 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
831 localeLanguage = L"eng_GB";
834 LanguageCode langCode = LANGUAGE_INVALID;
835 CountryCode countryCode = COUNTRY_INVALID;
836 StringTokenizer strTok(localeLanguage, L"_");
839 if (strTok.HasMoreTokens())
841 strTok.GetNextToken(token);
842 langCode = Locale::StringToLanguageCode(token);
845 if (strTok.HasMoreTokens())
847 strTok.GetNextToken(token);
848 countryCode = Locale::StringToCountryCode(token);
851 Locale currentLocale(langCode, countryCode);
853 locale.GetLanguageName(currentLocale, systemLocaleString);
854 itemSubText.Append(systemLocaleString + L" (");
855 systemLocaleString.Remove(0, systemLocaleString.GetLength());
857 locale.GetCountryName(currentLocale, systemLocaleString);
858 itemSubText.Append(systemLocaleString + L")");
859 systemLocaleString.Remove(0, systemLocaleString.GetLength());
869 case ID_GROUP_KEYBOARD:
871 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
879 ItemTypeOneLine(itemMainRectangle);
881 TableViewItem* pItem = new (std::nothrow) TableViewItem();
883 if (isItemSubText == true)
885 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
886 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
887 RelativeLayout relativeLayout;
888 relativeLayout.Construct();
889 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
890 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
892 name.Append(itemIndex);
893 pLabel = new (std::nothrow) Label();
894 pLabel->Construct(itemMainRectangle, itemMainText);
895 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
896 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
897 pLabel->SetTextColor(COLOR_MAIN_TEXT);
898 pLabel->SetName(name);
899 pLabel->AddTouchEventListener(*this);
901 pItem->AddControl(pLabel);
902 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
903 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
904 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
909 name = LABEL_LANGUAGE;
910 pItem->SetName(ITEM_NAME_1);
912 else if (itemIndex == 1)
916 pItem->SetName(ITEM_NAME_2);
918 __pLabel[index] = new (std::nothrow) Label();
919 __pLabel[index]->Construct(itemSubRectangle, itemSubText);
920 __pLabel[index]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
921 __pLabel[index]->SetTextVerticalAlignment(ALIGNMENT_TOP);
922 __pLabel[index]->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
923 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
924 __pLabel[index]->SetName(name);
925 __pLabel[index]->AddTouchEventListener(*this);
926 __pLabel[index]->AddFocusEventListener(*this);
928 pItem->AddControl(__pLabel[index]);
929 pItem->AddKeyEventListener(*this);
930 pItem->AddFocusEventListener(*this);
931 relativeLayout.SetMargin(*__pLabel[index], 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
932 relativeLayout.SetRelation(*__pLabel[index], pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
933 relativeLayout.SetRelation(*__pLabel[index], pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
937 RelativeLayout relativeLayout;
938 relativeLayout.Construct();
940 pItem->Construct(relativeLayout, Dimension(W_GROUP_ITEM_DEFAULT, H_GROUP_ITEM_DEFAULT), style);
941 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
943 pLabel = new (std::nothrow) Label();
944 pLabel->Construct(itemMainRectangle, itemMainText);
945 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
946 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
947 pLabel->SetTextColor(COLOR_MAIN_TEXT);
949 pItem->AddControl(pLabel);
950 relativeLayout.SetMargin(*pLabel, 0, 0, 0, 0);
951 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
952 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
959 LocaleForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
961 AppLogDebug("ENTER");
970 LocaleForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
972 AppLogDebug("ENTER");
981 LocaleForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
983 if (__isRunningAppControl == true)
985 AppLog("busy status");
989 SceneManager* pSceneManager = SceneManager::GetInstance();
990 AppAssert(pSceneManager);
992 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
996 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
998 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE)
1000 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_LANGUAGE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __languageDataList);
1002 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION)
1004 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_REGION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1009 case ID_GROUP_KEYBOARD:
1012 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1014 FocusManager* pFocusManager = Tizen::Ui::FocusManager::GetInstance();
1015 Control* __pFocusedControl = pFocusManager->GetCurrentFocusOwner();
1016 __pFocusedControl->AddFocusEventListener(*this);
1017 if (AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/setting/ime", null, null, null, null, null) == E_SUCCESS)
1019 __isRunningAppControl = true;
1031 LocaleForm::GetDefaultGroupItemHeight(void)
1033 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1037 LocaleForm::GetDefaultItemHeight(void)
1039 return H_GROUP_ITEM_DEFAULT;
1043 LocaleForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1047 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
1049 Rectangle pItemBounds = pItem->GetBounds();
1050 Rectangle pBounds = GetClientAreaBounds();
1051 Label* pGroupLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1052 int labelWidth = pItemBounds.width;
1058 String formattedString;
1059 String numberFormat;
1060 long inputNumber = DEFAULT_INPUT_NUMBER;
1063 int fontSize = GetFontSize();
1065 LocaleManager localeManager;
1066 localeManager.Construct();
1068 Locale systemLocale = localeManager.GetSystemLocale();
1069 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
1070 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
1073 SystemTime::GetCurrentTime(TIME_MODE_WALL, dateTime);
1075 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
1076 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
1077 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
1078 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
1082 const wchar_t LRE = 0x202A;
1083 const wchar_t PDF = 0x202C;
1084 tempHeight = GetHeightForStringArea(groupText, labelWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
1085 itemHeight += tempHeight;
1086 String localPattern;
1087 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
1089 pDateFormatter->ApplyPattern(localPattern);
1093 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
1095 pDateFormatter->Format(dateTime, formattedString);
1096 formattedString = dateText + L" : " + LRE + formattedString + PDF;
1097 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1098 tempHeight = GetHeightForStringArea(formattedString, labelWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
1099 itemHeight += tempHeight;
1100 formattedString.Remove(0, formattedString.GetLength());
1102 bool timeFormat = false;
1103 pDateFormatter->ApplyPattern("hh:mm aa");
1104 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
1106 if (timeFormat == true)
1108 pDateFormatter->ApplyPattern("HH:mm");
1111 pDateFormatter->Format(dateTime, formattedString);
1112 formattedString = timeText + L" : " + LRE + formattedString + PDF;
1113 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1114 tempHeight = GetHeightForStringArea(formattedString, labelWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
1115 itemHeight += tempHeight;
1116 formattedString.Remove(0, formattedString.GetLength());
1118 pNumberFormatter->Format(inputNumber, formattedString);
1119 formattedString = numberText + L" : " + LRE + formattedString + PDF;
1120 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1121 tempHeight = GetHeightForStringArea(formattedString, labelWidth - X_GROUP_ITEM_DEFAULT_LABEL, fontSize);
1122 itemHeight += tempHeight;
1124 pItemBounds.height = itemHeight + NUMBER_TEXT_HEIGHT_GAP;
1125 pItem->SetBounds(pItemBounds);
1126 AppLogDebug("%d %d %d %d", pItemBounds.x, pItemBounds.y, pItemBounds.width, pItemBounds.height);
1127 pItemBounds.y = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
1128 pGroupLabel->SetBounds(Rectangle(pGroupLabel->GetBounds().x, pGroupLabel->GetBounds().y, pGroupLabel->GetBounds().width, itemHeight));
1129 pGroupLabel->SetText(groupText);
1130 pGroupLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1131 pGroupLabel->Invalidate(false);
1132 pItem->Invalidate(false);
1142 LocaleForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1144 String firstLineText;
1147 Rectangle pItemBounds = pItem->GetBounds();
1148 Rectangle firstLineRect;
1149 Rectangle secondLineRect;
1151 Label* pFirstLabel = null;
1152 Label* pSecondLabel = null;
1154 int fontSize = GetFontSize();
1158 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
1160 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1161 pSecondLabel = static_cast<Label*>(pItem->GetControl(SECOND_CONTROL));
1163 ItemTypeTwoLine(firstLineRect, secondLineRect, fontSize);
1164 pItemBounds.height = (firstLineRect.height + secondLineRect.height);
1168 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
1170 firstLineText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
1172 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
1174 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
1178 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
1180 if (itemSubText.Equals(languageCode[i], false))
1182 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
1184 StringTokenizer stringTokenizer(*pKey, L"/");
1185 stringTokenizer.GetNextToken(itemSubText);
1190 pItem->SetBounds(pItemBounds);
1191 pFirstLabel->SetText(firstLineText);
1192 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1194 pSecondLabel->SetText(itemSubText);
1195 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1197 pFirstLabel->Invalidate(false);
1198 pSecondLabel->Invalidate(false);
1199 pItem->Invalidate(false);
1203 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
1205 LocaleManager localeManager;
1206 localeManager.Construct();
1207 Locale locale = localeManager.GetSystemLocale();
1208 String systemLocaleString;
1210 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
1212 String localeLanguage;
1213 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
1215 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
1216 localeLanguage = L"eng_GB";
1219 LanguageCode langCode = LANGUAGE_INVALID;
1220 CountryCode countryCode = COUNTRY_INVALID;
1221 StringTokenizer strTok(localeLanguage, L"_");
1224 if (strTok.HasMoreTokens())
1226 strTok.GetNextToken(token);
1227 langCode = Locale::StringToLanguageCode(token);
1230 if (strTok.HasMoreTokens())
1232 strTok.GetNextToken(token);
1233 countryCode = Locale::StringToCountryCode(token);
1236 Locale currentLocale(langCode, countryCode);
1238 locale.GetLanguageName(currentLocale, systemLocaleString);
1239 itemSubText.Append(systemLocaleString + L" (");
1240 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1242 locale.GetCountryName(currentLocale, systemLocaleString);
1243 itemSubText.Append(systemLocaleString + L")");
1244 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1246 pItem->SetBounds(pItemBounds);
1247 pFirstLabel->SetText(firstLineText);
1248 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1250 pSecondLabel->SetText(itemSubText);
1251 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1253 pFirstLabel->Invalidate(false);
1254 pSecondLabel->Invalidate(false);
1255 pItem->Invalidate(false);
1265 case ID_GROUP_KEYBOARD:
1267 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1269 ItemTypeOneLine(firstLineRect);
1270 pItemBounds.height = firstLineRect.height;
1272 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
1273 pItem->SetBounds(pItemBounds);
1274 pFirstLabel->SetText(firstLineText);
1275 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1276 pFirstLabel->Invalidate(false);
1277 pItem->Invalidate(false);
1287 LocaleForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1292 LocaleForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1297 LocaleForm::RefreshTableViewGroupItem(int groupIndex)
1299 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1301 for (int index = REFRESH_GROUP_ITEM_INDEX; index < itemCount; index++)
1303 __pTableView->RefreshItem(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1308 LocaleForm::RefreshTableViewItem(void)
1310 if (__pTableView == null)
1315 int groupCount = __pTableView->GetGroupCount();
1317 for (int index = 0; index < groupCount; index++)
1319 RefreshTableViewGroupItem(index);
1324 LocaleForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1326 RefreshTableViewItem();
1330 LocaleForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1332 if (requestId == REFRESH_REQUEST_EVENT)
1335 __isRunningAppControl = false;
1340 LocaleForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1343 if (source.GetName() == LABEL_0 || source.GetName() == LABEL_LANGUAGE)
1347 else if (source.GetName() == LABEL_1 || source.GetName() == LABEL_REGION)
1351 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
1352 __pLabel[index]->Invalidate(false);
1356 LocaleForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1359 if (source.GetName() == LABEL_0 || source.GetName() == LABEL_LANGUAGE)
1363 else if (source.GetName() == LABEL_1 || source.GetName() == LABEL_REGION)
1367 __pLabel[index]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1368 __pLabel[index]->Invalidate(false);
1372 LocaleForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1375 if (source.GetName() == LABEL_0 || source.GetName() == LABEL_LANGUAGE)
1379 else if (source.GetName() == LABEL_1 || source.GetName() == LABEL_REGION)
1383 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
1384 __pLabel[index]->Invalidate(false);
1388 LocaleForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
1391 if (source.GetName() == LABEL_0 || source.GetName() == LABEL_LANGUAGE)
1395 else if (source.GetName() == LABEL_1 || source.GetName() == LABEL_REGION)
1399 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
1400 __pLabel[index]->Invalidate(false);
1404 LocaleForm::OnFocusLost(const Tizen::Ui::Control& source)
1409 if (source.GetName() == LABEL_0 || source.GetName() == LABEL_LANGUAGE || source.GetName() == ITEM_NAME_1)
1414 else if (source.GetName() == LABEL_1 || source.GetName() == LABEL_REGION || source.GetName() == ITEM_NAME_2)
1419 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
1420 __pLabel[index]->Invalidate(false);
1424 LocaleForm::OnFocusGained(const Tizen::Ui::Control& source)
1427 __isRunningAppControl = false;
1431 LocaleForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1434 if(keyCode == KEY_ENTER)
1438 if (source.GetName() == ITEM_NAME_1)
1442 else if (source.GetName() == ITEM_NAME_2)
1446 __pLabel[index]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
1447 __pLabel[index]->Invalidate(false);
1452 LocaleForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
1455 if(keyCode == KEY_ENTER)
1459 if (source.GetName() ==ITEM_NAME_1)
1463 else if (source.GetName() == ITEM_NAME_2)
1467 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
1468 __pLabel[index]->Invalidate(false);
1473 LocaleForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)