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->SetBackButton();
60 pFooter->AddActionEventListener(*this);
62 SetFormBackEventListener(this);
66 ResetterForm::OnInitializing(void)
68 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_RESET"));
78 ResetterForm::OnTerminating(void)
82 SetFormBackEventListener(null);
87 ResetterForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
89 __pTableView->UpdateTableView();
93 ResetterForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
98 ResetterForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
100 SceneManager* pSceneManager = SceneManager::GetInstance();
101 AppAssert(pSceneManager);
103 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
107 ResetterForm::GetGroupCount(void)
109 AppLogDebug("ENTER");
110 return ID_GROUP_COUNT;
114 ResetterForm::GetItemCount(int groupIndex)
120 case ID_GROUP_RESET_MAIN:
122 itemCount = ID_GROUP_RESET_MAIN_ITEM_COUNT;
130 AppLogDebug("GetItemCount %d", itemCount);
135 ResetterForm::CreateGroupItem(int groupIndex, int itemWidth)
137 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
138 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
139 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
140 Rectangle itemMainRectangle;
142 Label* pLabel = null;
144 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
148 case ID_GROUP_RESET_MAIN:
150 yItemOffset = Y_GROUP_INDEX_DEFAULT;
151 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
155 case ID_GROUP_RESET_MAIN_TEXT:
157 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
158 itemHeight = ((H_GROUP_INDEX_HELP_TEXT * LINE_COUNT_2) + H_GROUP_INDEX_NO_TITLE_TEXT_GAP);
159 groupText = ResourceManager::GetString(L"IDS_ST_BODY_AFTER_RESETTING_PHONE_WILL_RESTART_AUTOMATICALLY");
165 yItemOffset = Y_GROUP_INDEX_DEFAULT;
166 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
171 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
172 itemMainRectangle.y = yItemOffset;
173 itemMainRectangle.width = itemWidth;
174 itemMainRectangle.height = itemHeight;
176 RelativeLayout relativeLayout;
177 relativeLayout.Construct();
179 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
180 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
182 pLabel = new (std::nothrow) Label();
183 pLabel->Construct(itemMainRectangle, groupText);
184 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
185 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
186 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
187 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
189 pItem->AddControl(pLabel);
190 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
191 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
192 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
193 pItem->SetEnabled(false);
199 ResetterForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
201 Rectangle itemMainRectangle;
202 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
204 Label* pLabel = null;
205 int fontSize = GetFontSize();
209 case ID_GROUP_RESET_MAIN:
213 case ID_ITEM_RESET_MAIN_RESET_SETTING:
215 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_RESET_SETTINGS");
219 case ID_ITEM_RESET_MAIN_FACTORY_RESET:
221 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_FACTORY_RESET");
235 ItemTypeOneLine(itemMainRectangle);
237 TableViewItem* pItem = new (std::nothrow) TableViewItem();
239 RelativeLayout relativeLayout;
240 relativeLayout.Construct();
242 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
243 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
245 pLabel = new (std::nothrow) Label();
246 pLabel->Construct(itemMainRectangle, itemMainText);
247 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
248 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
249 pLabel->SetTextColor(COLOR_MAIN_TEXT);
251 pItem->AddControl(pLabel);
252 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
253 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
254 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
260 ResetterForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
262 AppLogDebug("ENTER");
271 ResetterForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
273 AppLogDebug("ENTER");
282 ResetterForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
284 SceneManager* pSceneManager = SceneManager::GetInstance();
285 AppAssert(pSceneManager);
287 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
291 case ID_GROUP_RESET_MAIN:
293 if (itemIndex == ID_ITEM_RESET_MAIN_RESET_SETTING)
295 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_RESETTER_SETTING, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
298 if (itemIndex == ID_ITEM_RESET_MAIN_FACTORY_RESET)
300 // TODO: make Factory reset sequence.
301 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
312 ResetterForm::GetDefaultGroupItemHeight(void)
314 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
318 ResetterForm::GetDefaultItemHeight(void)
320 return H_GROUP_ITEM_DEFAULT;
324 ResetterForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
329 ResetterForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
334 ResetterForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
339 ResetterForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)