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 StFontForm.cpp
19 * @brief This is the implementation file for FontForm class.
24 #include "StFontForm.h"
25 #include "StResourceManager.h"
26 #include "StSettingScenesList.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Io;
33 using namespace Tizen::Graphics;
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 char APPCONTROL_DEFAULT = 0x00;
40 static const char APPCONTROL_REQUEST_FONT_TYPE = 0x21;
41 static const char APPCONTROL_REQUEST_FONT_SIZE = 0x22;
42 static const char APPCONTROL_TYPE = 0x01;
43 static const char APPCONTROL_SIZE = 0x02;
45 static const int ID_GROUP_FONT = 0;
46 static const int ID_GROUP_FONT_ITEM_COUNT = 1;
47 static const int ID_ITEM_FONT_TYPE = 0;
49 static const int ID_GROUP_FONT_LIST = 1;
51 static const int ID_GROUP_FONT_SIZE = 2;
52 static const int ID_ITEM_FONT_SIZE = 0;
54 static const int ID_GROUP_FONT_TEXT = 3;
56 static const int ID_GROUP_COUNT = 4;
57 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_FONT_ITEM_COUNT;
59 static const int FONT_FORM_FIRST_CONTROL = 0;
60 static const int FONT_FORM_SECOND_CONTROL = 1;
61 static const int FONT_FORM_THIRD_CONTROL = 2;
63 static const wchar_t* LABEL_0 = L"Label0";
64 static const wchar_t* LABEL_2 = L"Label2";
65 static const wchar_t* FONT_TYPE = L"Font_type";
66 static const wchar_t* FONT_SIZE = L"Font_size";
68 FontForm::FontForm(void)
69 : __isAppControlRequest(APPCONTROL_DEFAULT)
70 , __categoryCheck(L"")
71 , __isFontTypeExpend(false)
77 FontForm::~FontForm(void)
82 FontForm::CreateFooter(void)
84 Footer* pFooter = GetFooter();
87 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
88 pFooter->AddActionEventListener(*this);
90 SetFormBackEventListener(this);
94 FontForm::OnInitializing(void)
96 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_FONT"));
98 __fontList = new (std::nothrow) ArrayList(SingleObjectDeleter);
99 __fontList->Construct();
100 GetFontList(*__fontList);
102 __pTableView->UpdateTableView();
103 __pTableView->CollapseGroup(ID_GROUP_FONT_LIST);
104 SettingInfo::AddSettingEventListener(*this);
105 AppLogDebug("ENTER");
111 FontForm::OnTerminating(void)
117 SettingInfo::RemoveSettingEventListener(*this);
118 SetFormBackEventListener(null);
123 FontForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
126 if (previousSceneId == IDSCN_FONT_SIZE)
128 __pTableView->RefreshAllItems();
129 __pTableView->CollapseGroup(ID_GROUP_FONT_LIST);
134 __categoryCheck = static_cast<String*>(pArgs->GetAt(0))->GetPointer();
136 if (__categoryCheck.CompareTo(L"http://tizen.org/appcontrol/data/font/type") == 0)
138 SetAppControlRequest(APPCONTROL_REQUEST_FONT_TYPE);
139 __pTableView->SetItemEnabled(ID_GROUP_FONT_SIZE, ID_ITEM_FONT_SIZE, false);
141 else if (__categoryCheck.Equals(L"http://tizen.org/appcontrol/data/font/size", false))
143 SetAppControlRequest(APPCONTROL_REQUEST_FONT_SIZE);
144 __pTableView->SetItemEnabled(ID_GROUP_FONT, ID_ITEM_FONT_TYPE, false);
150 __pTableView->UpdateTableView();
152 String currentFontType;
154 if (SettingInfo::GetValue(SETTING_INFO_KEY_FONT_TYPE, currentFontType) == E_SUCCESS)
156 for (int i = 0; i < __fontList->GetCount(); i++)
158 String itemMainText = static_cast<String*>(__fontList->GetAt(i))->GetPointer();
160 if (itemMainText.Equals(currentFontType, false))
162 __pTableView->SetItemChecked(ID_GROUP_FONT_LIST, i, true);
166 AppLogDebug("Get Font Type[%ls] :Result[%s]", currentFontType.GetPointer(), GetErrorMessage(GetLastResult()));
168 __pTableView->RefreshItem(ID_GROUP_FONT_SIZE, ID_ITEM_FONT_SIZE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
169 __pTableView->RefreshItem(ID_GROUP_FONT_LIST, ID_ITEM_FONT_TYPE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
170 __pTableView->RefreshItem(ID_GROUP_FONT, ID_ITEM_FONT_TYPE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
174 FontForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
179 FontForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
181 SceneManager* pSceneManager = SceneManager::GetInstance();
182 AppAssert(pSceneManager);
184 __pTableView->CollapseGroup(ID_GROUP_FONT_LIST);
185 if (GetAppControlRequest() != APPCONTROL_DEFAULT)
187 UiApp* pApp = UiApp::GetInstance();
189 AppControlFontResult();
194 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
199 FontForm::GetGroupCount(void)
201 AppLogDebug("ENTER");
202 return ID_GROUP_COUNT;
206 FontForm::GetItemCount(int groupIndex)
214 case ID_GROUP_FONT_SIZE:
216 itemCount = ID_GROUP_MAX_ITEM_COUNT;
220 case ID_GROUP_FONT_LIST:
222 itemCount = __fontList->GetCount();
230 AppLogDebug("GetItemCount %d", itemCount);
236 FontForm::CreateGroupItem(int groupIndex, int itemWidth)
238 AppLogDebug("ENTER");
240 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
241 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
242 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
243 Rectangle itemMainRectangle;
245 Label* pLabel = null;
246 int fontSize = GetFontSize();
248 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
254 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
255 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
259 case ID_GROUP_FONT_LIST:
265 case ID_GROUP_FONT_SIZE:
267 case ID_GROUP_FONT_TEXT:
275 yItemOffset = H_GROUP_INDEX_NO_HELP_TEXT_GAP;
276 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
281 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
282 itemMainRectangle.y = yItemOffset;
283 itemMainRectangle.width = itemWidth;
284 itemMainRectangle.height = itemHeight;
286 RelativeLayout relativeLayout;
287 relativeLayout.Construct();
289 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
290 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
292 pLabel = new (std::nothrow) Label();
293 pLabel->Construct(itemMainRectangle, groupText);
294 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
295 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
296 pLabel->SetTextConfig(fontSize, style);
297 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
299 pItem->AddControl(pLabel);
300 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
301 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
302 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
303 pItem->SetEnabled(false);
309 FontForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
311 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
313 Rectangle itemMainRectangle;
314 Rectangle itemSubRectangle;
315 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
318 String fontReturnValue;
319 Label* pLabel = null;
320 Label* pLabelArrow = null;
322 int fontSize = GetFontSize();
323 bool isItemSubText = true;
324 int itemHeight = H_GROUP_ITEM_DEFAULT;
325 Rectangle detailArrow;
326 Bitmap* pBitmap = null;
327 char appControlRequest;
329 if (groupIndex == ID_GROUP_FONT_LIST)
331 String currentFontType;
332 isItemSubText = false;
333 style = TABLE_VIEW_ANNEX_STYLE_RADIO;
336 GetTableViewItemString(groupIndex, itemIndex, itemMainText, itemSubText);
338 TableViewItem* pItem = new (std::nothrow) TableViewItem();
340 if (isItemSubText == true)
342 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
343 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
344 String name = LABEL_NAME;
346 RelativeLayout relativeLayout;
347 relativeLayout.Construct();
349 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
350 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
351 name.Append(groupIndex);
352 pLabel = new (std::nothrow) Label();
353 pLabel->Construct(itemMainRectangle, itemMainText);
354 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
355 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
356 pLabel->SetTextColor(COLOR_MAIN_TEXT);
357 pLabel->SetName(name);
358 pLabel->AddTouchEventListener(*this);
360 pItem->AddKeyEventListener(*this);
361 pItem->AddFocusEventListener(*this);
362 pItem->AddControl(pLabel);
363 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
364 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
366 if (groupIndex == ID_GROUP_FONT)
368 if (__pTableView->IsGroupExpanded(ID_GROUP_FONT_LIST))
370 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_OPENED);
374 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_CLOSED);
377 detailArrow = itemMainRectangle;
378 detailArrow.y = itemMainRectangle.y + ((itemHeight - W_DETAIL_ARROW_BUTTON) / DIVIDE_BY_TWO);
379 detailArrow.height = W_DETAIL_ARROW_BUTTON;
380 detailArrow.width = W_DETAIL_ARROW_BUTTON;
382 pLabelArrow = new (std::nothrow) Label();
383 pLabelArrow->Construct(detailArrow, L"");
384 pLabelArrow->SetName(LABEL_DETAIL_ARROW);
385 pLabelArrow->AddTouchEventListener(*this);
387 pLabelArrow->SetBackgroundBitmap(*pBitmap);
389 pItem->AddControl(pLabelArrow);
390 relativeLayout.SetMargin(*pLabelArrow, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN_DETAIL_ARROW_BUTTON, 0, 0);
391 relativeLayout.SetRelation(*pLabelArrow, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
392 relativeLayout.SetRelation(*pLabel, pLabelArrow, RECT_EDGE_RELATION_RIGHT_TO_LEFT);
396 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
399 if (groupIndex == ID_GROUP_FONT)
401 index = ID_GROUP_FONT;
403 pItem->SetName(ITEM_NAME_1);
405 else if(groupIndex == ID_GROUP_FONT_SIZE)
407 index = ID_GROUP_FONT_SIZE - 1;
409 pItem->SetName(ITEM_NAME_2);
412 __pLabel[index] = new (std::nothrow) Label();
413 __pLabel[index]->Construct(itemSubRectangle, itemSubText);
414 __pLabel[index]->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
415 __pLabel[index]->SetTextVerticalAlignment(ALIGNMENT_TOP);
416 __pLabel[index]->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
417 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
418 __pLabel[index]->SetName(name);
419 __pLabel[index]->AddTouchEventListener(*this);
421 pItem->AddControl(__pLabel[index]);
422 relativeLayout.SetMargin(*__pLabel[index], itemSubRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
423 relativeLayout.SetRelation(*__pLabel[index], pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
424 relativeLayout.SetRelation(*__pLabel[index], pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
428 RelativeLayout relativeLayout;
429 relativeLayout.Construct();
431 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
432 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
434 ItemTypeOneLine(itemMainRectangle);
435 pLabel = new (std::nothrow) Label();
436 pLabel->Construct(itemMainRectangle, itemMainText);
437 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
438 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
439 pLabel->SetTextColor(COLOR_MAIN_TEXT);
441 pItem->AddControl(pLabel);
442 relativeLayout.SetMargin(*pLabel, RELATIVE_LAYOUT_LEFT_MARGIN, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
443 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
444 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
447 if ((appControlRequest = GetAppControlRequest()) != APPCONTROL_DEFAULT)
449 if (appControlRequest & APPCONTROL_TYPE)
451 if (groupIndex == ID_GROUP_FONT_SIZE)
457 else if (appControlRequest & APPCONTROL_SIZE)
459 if ((groupIndex == ID_GROUP_FONT) || (groupIndex == ID_GROUP_FONT_LIST))
471 FontForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
473 AppLogDebug("ENTER");
482 FontForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
484 AppLogDebug("ENTER");
493 FontForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
495 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
497 SceneManager* pSceneManager = SceneManager::GetInstance();
498 AppAssert(pSceneManager);
499 String fontReturnValue;
505 if (__pTableView->IsGroupExpanded(ID_GROUP_FONT_LIST))
507 __pTableView->CollapseGroup(ID_GROUP_FONT_LIST);
511 __pTableView->ExpandGroup(ID_GROUP_FONT_LIST);
514 __pTableView->RefreshItem(groupIndex, itemIndex, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
518 case ID_GROUP_FONT_LIST:
520 int listCount = __fontList->GetCount();
522 fontReturnValue = static_cast<String*>(__fontList->GetAt(itemIndex))->GetPointer();
524 for (int count = 0; count < listCount; count++)
526 if (itemIndex == count)
528 tableView.SetItemChecked(groupIndex, count, true);
532 tableView.SetItemChecked(groupIndex, count, false);
535 if ((SettingInfo::GetValue(SETTING_INFO_KEY_FONT_TYPE, fontGetValue)) == E_SUCCESS)
537 if (fontGetValue.Equals(fontReturnValue, false))
543 if (SettingInfo::SetValue(SETTING_INFO_KEY_FONT_TYPE, fontReturnValue) != E_SUCCESS)
545 AppLogDebug("Set Font Type :Result[%s]", GetErrorMessage(GetLastResult()));
547 AppLogDebug("Set Font Type[%ls] :Result[%s]", fontReturnValue.GetPointer(), GetErrorMessage(GetLastResult()));
551 case ID_GROUP_FONT_SIZE:
553 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_FONT_SIZE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
563 FontForm::GetDefaultGroupItemHeight(void)
565 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
569 FontForm::GetDefaultItemHeight(void)
571 return H_GROUP_ITEM_DEFAULT;
575 FontForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
580 FontForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
582 Rectangle itemMainRectangle;
583 Rectangle itemSubRectangle;
584 Rectangle pItemBounds = pItem->GetBounds();
585 int fontSize = GetFontSize();
591 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
593 pItemBounds.height = itemMainRectangle.height + itemSubRectangle.height;
594 pItem->SetBounds(pItemBounds);
595 Label* pFirstLabel = static_cast<Label*>(pItem->GetControl(FONT_FORM_FIRST_CONTROL));
596 Label* pSecondLabel = static_cast<Label*>(pItem->GetControl(FONT_FORM_SECOND_CONTROL));
597 Label* pThirdLabel = static_cast<Label*>(pItem->GetControl(FONT_FORM_THIRD_CONTROL));
598 Rectangle detailArrow = pSecondLabel->GetBounds();
599 detailArrow.y = itemMainRectangle.y + ((pItemBounds.height - W_DETAIL_ARROW_BUTTON) / DIVIDE_BY_TWO);
601 pFirstLabel->SetBounds(itemMainRectangle);
602 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
603 pSecondLabel->SetBounds(detailArrow);
604 pThirdLabel->SetBounds(itemSubRectangle);
605 pThirdLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
607 Bitmap* pBitmap = null;
609 if (__pTableView->IsGroupExpanded(ID_GROUP_FONT_LIST))
611 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_OPENED);
615 pBitmap = ResourceManager::GetBitmapN(IDB_DETAIL_BUTTON_EXPAND_CLOSED);
617 pSecondLabel->SetBackgroundBitmap(*pBitmap);
618 pSecondLabel->Invalidate(false);
619 pFirstLabel->Invalidate(false);
620 pItem->Invalidate(false);
625 case ID_GROUP_FONT_SIZE:
627 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
629 pItemBounds.height = itemMainRectangle.height + itemSubRectangle.height;
630 pItem->SetBounds(pItemBounds);
631 Label* pFirstLabel = static_cast<Label*>(pItem->GetControl(FONT_FORM_FIRST_CONTROL));
632 Label* pSecondLabel = static_cast<Label*>(pItem->GetControl(FONT_FORM_SECOND_CONTROL));
634 pFirstLabel->SetBounds(itemMainRectangle);
635 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
636 pSecondLabel->SetBounds(itemSubRectangle);
637 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
639 String itemMainText = L"";
640 String itemSubText = L"";
642 GetTableViewItemString(groupIndex, itemIndex, itemMainText, itemSubText);
643 pFirstLabel->SetText(itemMainText);
644 pSecondLabel->SetText(itemSubText);
646 pFirstLabel->Invalidate(false);
647 pSecondLabel->Invalidate(false);
648 pItem->Invalidate(false);
652 case ID_GROUP_FONT_LIST:
654 ItemTypeOneLine(itemMainRectangle);
655 Label* pFirstLabel = static_cast<Label*>(pItem->GetControl(0));
656 pFirstLabel->SetBounds(itemMainRectangle);
657 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
658 pFirstLabel->Invalidate(false);
670 FontForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
675 FontForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
680 FontForm::AppControlFontResult(void)
684 AppControlProviderManager* pAppManager = AppControlProviderManager::GetInstance();
686 HashMap* hashMap = new (std::nothrow) HashMap();
687 hashMap->Construct();
689 if (GetAppControlRequest() == APPCONTROL_REQUEST_FONT_TYPE)
691 SettingInfo::GetValue(SETTING_INFO_KEY_FONT_TYPE, value);
692 hashMap->Add((new (std::nothrow) String(L"http://tizen.org/appcontrol/data/font/type")), new (std::nothrow) String(value));
694 else if (GetAppControlRequest() == APPCONTROL_REQUEST_FONT_SIZE)
696 SettingInfo::GetValue(SETTING_INFO_KEY_FONT_SIZE, value);
697 hashMap->Add((new (std::nothrow) String(L"http://tizen.org/appcontrol/data/font/size")), new (std::nothrow) String(value));
700 pAppManager->SendAppControlResult(reqId, APP_CTRL_RESULT_SUCCEEDED, hashMap);
702 hashMap->RemoveAll();
707 FontForm::GetFontList(Tizen::Base::Collection::IList& list)
709 const String FONT_DIR_PATH[] =
714 list.RemoveAll(true);
715 const int FONT_DIR_PATH_COUNT = sizeof(FONT_DIR_PATH) / sizeof(FONT_DIR_PATH[0]);
717 for (int i = 0; i < FONT_DIR_PATH_COUNT; i++)
720 result r = directory.Construct(FONT_DIR_PATH[i]);
723 std::auto_ptr<DirEnumerator>dirEnumerator(directory.ReadN());
725 while (dirEnumerator->MoveNext() == E_SUCCESS)
727 DirEntry entry = dirEnumerator->GetCurrentDirEntry();
728 if (entry.IsDirectory() == false && entry.IsHidden() == false)
730 Tizen::Base::Utility::StringTokenizer formatTok(entry.GetName(), ".");
732 while (formatTok.GetTokenCount())
734 formatTok.GetNextToken(token);
737 if (token.Equals("ttf", false) || token.Equals("ttc", false))
740 fullName.Append(FONT_DIR_PATH[i]);
741 fullName.Append(L"/");
742 fullName.Append(entry.GetName());
743 bool isNewFont = true;
745 String* pFamilyName = new (std::nothrow) String(Font::GetFaceName(fullName));
747 for (int idx = 0; idx < list.GetCount(); idx++)
749 String* pName = static_cast <String*>(list.GetAt(idx));
754 if (pFamilyName->Equals(*pName, true))
762 list.Add(pFamilyName);
778 FontForm::GetTableViewItemString(int groupIndex, int itemIndex, Tizen::Base::String& itemMainText, Tizen::Base::String& itemSubText)
784 String fontReturnValue;
785 if ((SettingInfo::GetValue(SETTING_INFO_KEY_FONT_TYPE, fontReturnValue)) == E_SUCCESS)
787 itemSubText = fontReturnValue;
789 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FONT_TYPE");
793 case ID_GROUP_FONT_LIST:
795 itemMainText = static_cast<String*>(__fontList->GetAt(itemIndex))->GetPointer();
800 case ID_GROUP_FONT_SIZE:
802 String fontReturnValue;
803 if ((SettingInfo::GetValue(SETTING_INFO_KEY_FONT_SIZE, fontReturnValue)) == E_SUCCESS)
805 if (fontReturnValue.Equals(L"giant", false))
807 itemSubText = ResourceManager::GetString(L"IDS_EMAIL_POP_GIANT_M_TEXTSIZE");
809 else if (fontReturnValue.Equals(L"huge", false))
811 itemSubText = ResourceManager::GetString(L"IDS_EMAIL_OPT_HUGE_M_TEXTSIZE");
813 else if (fontReturnValue.Equals(L"large", false))
815 itemSubText = ResourceManager::GetString(L"IDS_ST_BODY_TEXTSTYLE_LARGE");
817 else if (fontReturnValue.Equals(L"medium", false))
819 itemSubText = ResourceManager::GetString(L"IDS_ST_BODY_FONTTYPE_NORMAL");
823 itemSubText = ResourceManager::GetString(L"IDS_ST_BODY_SMALL_M_TEXTSIZE");
826 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_FONT_SIZE");
836 FontForm::OnSettingChanged (Tizen::Base::String &key)
838 AppLogDebug("FontForm::key changed [%ls]", key.GetPointer());
840 int groupCount = __pTableView->GetGroupCount();
842 for (int i = 0; i < groupCount; i++)
844 int itemCount = __pTableView->GetItemCountAt(i);
846 for (int j = 0; j < itemCount; j++)
848 __pTableView->RefreshItem(i, j, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
854 FontForm::GetAppControlRequest(void)
856 return __isAppControlRequest;
860 FontForm::SetAppControlRequest(char requestStatus)
862 __isAppControlRequest = requestStatus;
866 FontForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
869 if (source.GetName() == LABEL_0 || source.GetName() == FONT_TYPE)
873 else if (source.GetName() == LABEL_2 || source.GetName() == FONT_SIZE)
877 else if (source.GetName() == LABEL_DETAIL_ARROW)
881 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
882 __pLabel[index]->Invalidate(false);
886 FontForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
889 if (source.GetName() == LABEL_0 || source.GetName() == FONT_TYPE)
893 else if (source.GetName() == LABEL_2 || source.GetName() == FONT_SIZE)
897 else if (source.GetName() == LABEL_DETAIL_ARROW)
901 __pLabel[index]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
902 __pLabel[index]->Invalidate(false);
906 FontForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
909 if (source.GetName() == LABEL_0 || source.GetName() == FONT_TYPE)
913 else if (source.GetName() == LABEL_2 || source.GetName() == FONT_SIZE)
917 else if (source.GetName() == LABEL_DETAIL_ARROW)
921 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
922 __pLabel[index]->Invalidate(false);
926 FontForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
929 if (source.GetName() == LABEL_0 || source.GetName() == FONT_TYPE)
933 else if (source.GetName() == LABEL_2 || source.GetName() == FONT_SIZE)
937 else if (source.GetName() == LABEL_DETAIL_ARROW)
941 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
942 __pLabel[index]->Invalidate(false);
946 FontForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
949 if(keyCode == KEY_ENTER)
953 if (source.GetName() == ITEM_NAME_1)
957 else if (source.GetName() == ITEM_NAME_2)
961 __pLabel[index]->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
962 __pLabel[index]->Invalidate(false);
967 FontForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
970 if(keyCode == KEY_ENTER)
974 if (source.GetName() ==ITEM_NAME_1)
978 else if (source.GetName() == ITEM_NAME_2)
982 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
983 __pLabel[index]->Invalidate(false);
988 FontForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
993 FontForm::OnFocusLost(const Tizen::Ui::Control& source)
998 if (source.GetName() == ITEM_NAME_1)
1003 else if (source.GetName() == ITEM_NAME_2)
1008 __pLabel[index]->SetTextColor(COLOR_SUB_TEXT);
1009 __pLabel[index]->Invalidate(false);