2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 PhnSettingsMainMenuForm.cpp
19 * @brief Setting Main menu form
22 #include "PhnAppUtility.h"
23 #include "PhnSceneRegister.h"
24 #include "PhnSettingsConstants.h"
25 #include "PhnSettingsMainMenuForm.h"
26 #include "PhnSettingsPresentationModel.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::App;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33 using namespace Tizen::Ui::Scenes;
34 using namespace Tizen::Graphics;
36 static const wchar_t* IDL_SETTINGS_MAINMENU_FORM = L"IDL_SETTINGS_MAINMENU_FORM";
38 SettingsMainMenuForm::SettingsMainMenuForm(void)
42 SettingsMainMenuForm::~SettingsMainMenuForm(void)
47 SettingsMainMenuForm::Initialize(void)
49 Construct(IDL_SETTINGS_MAINMENU_FORM);
54 SettingsMainMenuForm::OnInitializing(void)
58 Footer* pFooter = GetFooter();
61 pFooter->SetBackButton();
62 pFooter->SetButtonColor(BUTTON_ITEM_STATUS_NORMAL, pFooter->GetColor());
63 // Setup back event listener
64 SetFormBackEventListener(this);
65 pFooter->AddActionEventListener(*this);
68 //initialize table view
69 r = InitializeGroupedTableView();
75 SettingsMainMenuForm::OnTerminating(void)
82 SettingsMainMenuForm::OnActionPerformed(const Control& source, int actionId)
92 SettingsMainMenuForm::OnFormBackRequested(Form& source)
94 UiApp* pApp = UiApp::GetInstance();
100 SettingsMainMenuForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
105 SettingsMainMenuForm::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
110 SettingsMainMenuForm::InitializeGroupedTableView(void)
112 result r = E_FAILURE;
113 GroupedTableView* pMainMenuTableView = static_cast<GroupedTableView*>(GetControl(IDC_GROUPEDTABLEVIEW));
114 if (pMainMenuTableView != null)
116 pMainMenuTableView->SetGroupedLookEnabled(true);
117 pMainMenuTableView->SetItemProvider(this);
118 r = pMainMenuTableView->AddGroupedTableViewItemEventListener(*this);
119 pMainMenuTableView->UpdateTableView();
120 //disabling "call forwarding" option on emulator
121 pMainMenuTableView->SetItemEnabled(GROUP_MAIN_CALL_SETTINGS, MAINCALLSETTINGS_CALLFORWARDING, false);
127 SettingsMainMenuForm::OnGroupedTableViewItemStateChanged(GroupedTableView& tableView, int groupIndex, int itemIndex, TableViewItem* pItem, TableViewItemStatus status)
129 SceneManager* pSceneManager = SceneManager::GetInstance();
130 AppAssert(pSceneManager != null);
132 if(groupIndex == GROUP_CALL_REJECTION)
134 //switch to call reject list form
135 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTLIST_MENU), null);
137 else if(groupIndex == GROUP_REJECT_MSG)
139 //switch to reject msg list form
140 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALL_REJECTMSGS_MENU), null);
142 else if(groupIndex == GROUP_MAIN_CALL_SETTINGS)
146 case MAINCALLSETTINGS_SPEEDDIAL:
148 //switch to speed dial form
149 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_SPEED_DIAL), null);
153 case MAINCALLSETTINGS_CALLFORWARDING:
156 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_CALLTYPE_FORWARD), null);
160 case MAINCALLSETTINGS_MORECALLSETTINGS:
162 //switch to speed dial form
163 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCENE_MORE_OPTIONS), null);
174 SettingsMainMenuForm::GetGroupCount(void)
176 return GROUP_TOTALCOUNT;
180 SettingsMainMenuForm::GetItemCount(int groupIndex)
185 case GROUP_CALL_REJECTION:
186 itemCount = CALLREJECTION_TOTALCOUNT;
189 case GROUP_REJECT_MSG:
190 itemCount = REJECTMSG_TOTALCOUNT;
193 case GROUP_MAIN_CALL_SETTINGS:
194 itemCount = MAINCALLSETTINGS_TOTALCOUNT;
197 case GROUP_CALL_REJECTION_HLPTXT:
198 case GROUP_REJECT_MSG_HLPTXT:
209 SettingsMainMenuForm::CreateGroupItem(int groupIndex, int itemWidth)
211 String helpText(L"");
214 case GROUP_CALL_REJECTION_HLPTXT:
216 helpText.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_HLP_STRING));
220 case GROUP_REJECT_MSG_HLPTXT:
222 helpText.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_MSG_HLP_STRING));
230 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
231 if (helpText.IsEmpty() == true)
233 pItem->Construct(Dimension(itemWidth, H_LIST_HIDDENGROUP_ITEM));
234 pItem->SetBackgroundColor(COLOR_GROUP_ITEM_BG);
238 //help text item rectangle
239 Rectangle helpItemRect(X_LIST_MENU_HLPTXT_ITEM, Y_LIST_MENU_HLPTXT_ITEM, (itemWidth - X_LIST_MENU_HLPTXT_ITEM),
240 (H_LIST_MENU_SINGLELINE_HLPTXT_ITEM - Y_LIST_MENU_HLPTXT_ITEM));
241 pItem->Construct(Dimension(itemWidth, H_LIST_MENU_SINGLELINE_HLPTXT_ITEM));
242 Label* pItemLbl = new (std::nothrow) Label();
243 pItemLbl->Construct(helpItemRect, helpText);
244 pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
245 pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
246 pItemLbl->SetTextConfig(FONT_SIZE_HELP_TXT, LABEL_TEXT_STYLE_NORMAL);
247 pItemLbl->SetTextColor(COLOR_HELP_TXT);
248 pItem->AddControl(*pItemLbl);
249 pItem->SetEnabled(false);
250 pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
251 pItem->SetBackgroundColor(COLOR_HELP_ITEM_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
257 SettingsMainMenuForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
265 SettingsMainMenuForm::UpdateGroupItem(int groupIndex, TableViewGroupItem* pItem)
271 SettingsMainMenuForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
273 TableViewItem* pItem = new (std::nothrow) TableViewItem();
274 pItem->Construct(Dimension(itemWidth, H_LIST_NORMAL_MENU_ITEM), TABLE_VIEW_ANNEX_STYLE_NORMAL);
276 //text item rectangle
277 Rectangle itemNameRect(X_LIST_MENU_TEXT_ITEM, 0, (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_NORMAL_MENU_ITEM);
278 //description text rectangle
279 Rectangle descriptionTxtRect(X_LIST_MENU_TEXT_ITEM, H_LIST_NORMAL_TXT_ITEM,
280 (itemWidth - X_LIST_MENU_TEXT_ITEM), H_LIST_SUB_TXT_ITEM);
281 String itemName(L"");
282 String descriptionText(L"");
283 if(groupIndex == GROUP_CALL_REJECTION)
285 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_STRING));
287 else if(groupIndex == GROUP_REJECT_MSG)
289 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_REJECT_MSG_STRING));
291 else if(groupIndex == GROUP_MAIN_CALL_SETTINGS)
295 case MAINCALLSETTINGS_SPEEDDIAL:
297 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_SPEEDDIAL_STRING));
301 case MAINCALLSETTINGS_CALLFORWARDING:
303 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_FORWARDING_STRING));
307 case MAINCALLSETTINGS_MORECALLSETTINGS:
309 itemName.Append(AppUtility::GetResourceString(IDS_SETTING_MORE_MAIN_STRING));
310 descriptionText.Append(AppUtility::GetResourceString(IDS_SETTING_MORE_SUB_STRING));
311 //update item Name rectangle
312 itemNameRect.y = Y_LIST_MENU_TEXT_ITEM;
313 itemNameRect.height = H_LIST_NORMAL_TXT_ITEM;
323 Label* pItemLbl = new (std::nothrow) Label();
324 pItemLbl->Construct(itemNameRect, itemName);
325 pItemLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
326 pItemLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
327 pItemLbl->SetTextConfig(FONT_SIZE_MAIN_TXT, LABEL_TEXT_STYLE_NORMAL);
328 pItemLbl->SetTextColor(COLOR_NORMAL_MAIN_TXT);//COLOR_PRESS_MAIN_TXT
329 pItem->AddControl(*pItemLbl);
331 if(descriptionText.IsEmpty() == false)
333 Label* pDescriptionLbl = new (std::nothrow) Label();
334 pDescriptionLbl->Construct(descriptionTxtRect, descriptionText);
335 pDescriptionLbl->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
336 pDescriptionLbl->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
337 pDescriptionLbl->SetTextConfig(FONT_SIZE_SUB_TXT, LABEL_TEXT_STYLE_NORMAL);
338 pDescriptionLbl->SetTextColor(COLOR_NORMAL_SUB_TXT);
339 pItem->AddControl(*pDescriptionLbl);
341 pItem->SetBackgroundColor(COLOR_LIST_MENU_ITEM, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
346 SettingsMainMenuForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
354 SettingsMainMenuForm::UpdateItem(int groupIndex, int itemIndex, TableViewItem* pItem)
360 SettingsMainMenuForm::GetDefaultGroupItemHeight(void)
362 return H_LIST_HIDDENGROUP_ITEM;
366 SettingsMainMenuForm::GetDefaultItemHeight(void)
368 return H_LIST_NORMAL_MENU_ITEM;