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 StResetForm.cpp
19 * @brief This is the implementation file for ResetterForm class.
22 #include "StResetForm.h"
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29 using namespace Tizen::Ui;
30 using namespace Tizen::Ui::Controls;
31 using namespace Tizen::Ui::Scenes;
33 static const int ID_GROUP_RESET_MAIN = 0;
34 static const int ID_GROUP_RESET_MAIN_ITEM_COUNT = 2;
35 static const int ID_ITEM_RESET_MAIN_RESET_SETTING = 0;
36 static const int ID_ITEM_RESET_MAIN_FACTORY_RESET = 1;
38 static const int ID_GROUP_RESET_MAIN_TEXT = 1;
39 static const int ID_GROUP_RESET_MAIN_TEXT_ITEM_COUNT = 0;
41 static const int ID_GROUP_COUNT = 2;
42 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_RESET_MAIN_ITEM_COUNT;
44 ResetterForm::ResetterForm(void)
48 ResetterForm::~ResetterForm(void)
53 ResetterForm::CreateFooter(void)
55 Footer* pFooter = GetFooter();
58 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
59 pFooter->AddActionEventListener(*this);
61 SetFormBackEventListener(this);
65 ResetterForm::OnInitializing(void)
67 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_RESET"));
76 ResetterForm::OnTerminating(void)
80 SetFormBackEventListener(null);
85 ResetterForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
87 __pTableView->UpdateTableView();
91 ResetterForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
96 ResetterForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
98 SceneManager* pSceneManager = SceneManager::GetInstance();
99 AppAssert(pSceneManager);
101 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
105 ResetterForm::GetGroupCount(void)
107 AppLogDebug("ENTER");
108 return ID_GROUP_COUNT;
112 ResetterForm::GetItemCount(int groupIndex)
118 case ID_GROUP_RESET_MAIN:
120 itemCount = ID_GROUP_RESET_MAIN_ITEM_COUNT;
128 AppLogDebug("GetItemCount %d", itemCount);
133 ResetterForm::CreateGroupItem(int groupIndex, int itemWidth)
135 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
136 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
137 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
138 Rectangle itemMainRectangle;
140 Label* pLabel = null;
142 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
146 case ID_GROUP_RESET_MAIN:
148 yItemOffset = Y_GROUP_INDEX_DEFAULT;
149 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
153 case ID_GROUP_RESET_MAIN_TEXT:
155 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
156 itemHeight = ((H_GROUP_INDEX_HELP_TEXT * LINE_COUNT_2) + H_GROUP_INDEX_NO_TITLE_TEXT_GAP);
157 groupText = ResourceManager::GetString(L"IDS_ST_BODY_AFTER_RESETTING_PHONE_WILL_RESTART_AUTOMATICALLY");
163 yItemOffset = Y_GROUP_INDEX_DEFAULT;
164 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
169 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
170 itemMainRectangle.y = yItemOffset;
171 itemMainRectangle.width = itemWidth;
172 itemMainRectangle.height = itemHeight;
174 RelativeLayout relativeLayout;
175 relativeLayout.Construct();
177 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
178 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
180 pLabel = new (std::nothrow) Label();
181 pLabel->Construct(itemMainRectangle, groupText);
182 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
183 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
184 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
185 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
187 pItem->AddControl(pLabel);
188 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
189 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
190 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
191 pItem->SetEnabled(false);
197 ResetterForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
199 Rectangle itemMainRectangle;
200 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
202 Label* pLabel = null;
203 int fontSize = GetFontSize();
207 case ID_GROUP_RESET_MAIN:
211 case ID_ITEM_RESET_MAIN_RESET_SETTING:
213 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_RESET_SETTINGS");
217 case ID_ITEM_RESET_MAIN_FACTORY_RESET:
219 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_FACTORY_RESET");
233 ItemTypeOneLine(itemMainRectangle);
235 TableViewItem* pItem = new (std::nothrow) TableViewItem();
237 RelativeLayout relativeLayout;
238 relativeLayout.Construct();
240 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
241 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
243 pLabel = new (std::nothrow) Label();
244 pLabel->Construct(itemMainRectangle, itemMainText);
245 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
246 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
247 pLabel->SetTextColor(COLOR_MAIN_TEXT);
249 pItem->AddControl(pLabel);
250 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
251 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
252 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
258 ResetterForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
260 AppLogDebug("ENTER");
269 ResetterForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
271 AppLogDebug("ENTER");
280 ResetterForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
282 SceneManager* pSceneManager = SceneManager::GetInstance();
283 AppAssert(pSceneManager);
285 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
289 case ID_GROUP_RESET_MAIN:
291 if (itemIndex == ID_ITEM_RESET_MAIN_RESET_SETTING)
293 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_RESETTER_SETTING, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
296 if (itemIndex == ID_ITEM_RESET_MAIN_FACTORY_RESET)
298 // TODO: make Factory reset sequence.
299 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
310 ResetterForm::GetDefaultGroupItemHeight(void)
312 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
316 ResetterForm::GetDefaultItemHeight(void)
318 return H_GROUP_ITEM_DEFAULT;
322 ResetterForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
327 ResetterForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
332 ResetterForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
337 ResetterForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)