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 StMemoryForm.cpp
19 * @brief This is the implementation file for MemoryForm class.
22 #include "StMemoryForm.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_MEMORY_MAIN = 0;
35 static const int ID_GROUP_MEMORY_MAIN_ITEM_COUNT = 1;
36 static const int ID_ITEM_MEMORY_MAIN_MEMORY_STATUS = 0;
38 static const int ID_GROUP_COUNT = 1;
40 MemoryForm::MemoryForm(void)
44 MemoryForm::~MemoryForm(void)
49 MemoryForm::CreateFooter(void)
51 Footer* pFooter = GetFooter();
54 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
55 pFooter->SetBackButton();
56 pFooter->AddActionEventListener(*this);
58 SetFormBackEventListener(this);
62 MemoryForm::OnInitializing(void)
64 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_MEMORY"));
74 MemoryForm::OnTerminating(void)
78 SetFormBackEventListener(null);
83 MemoryForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
85 __pTableView->UpdateTableView();
89 MemoryForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
94 MemoryForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
96 SceneManager* pSceneManager = SceneManager::GetInstance();
97 AppAssert(pSceneManager);
99 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
103 MemoryForm::GetGroupCount(void)
105 AppLogDebug("ENTER");
106 return ID_GROUP_COUNT;
110 MemoryForm::GetItemCount(int groupIndex)
114 if (groupIndex == ID_GROUP_MEMORY_MAIN)
116 itemCount = ID_GROUP_MEMORY_MAIN_ITEM_COUNT;
123 MemoryForm::CreateGroupItem(int groupIndex, int itemWidth)
125 AppLogDebug("ENTER");
127 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
128 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
129 Rectangle itemMainRectangle;
131 Label* pLabel = null;
133 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
135 itemMainRectangle.x = X_GROUP_INDEX_DEFAULT_LABEL;
136 itemMainRectangle.y = Y_GROUP_INDEX_DEFAULT_LABEL;
137 itemMainRectangle.width = itemWidth;
138 itemMainRectangle.height = itemHeight;
140 RelativeLayout relativeLayout;
141 relativeLayout.Construct();
143 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
144 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
146 pLabel = new (std::nothrow) Label();
147 pLabel->Construct(itemMainRectangle, groupText);
148 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
149 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
150 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
152 pItem->AddControl(pLabel);
153 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
154 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
155 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
156 pItem->SetEnabled(false);
162 MemoryForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
164 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
166 Rectangle itemMainRectangle;
167 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
169 Label* pLabel = null;
170 int fontSize = GetFontSize();
172 ItemTypeOneLine(itemMainRectangle);
174 if (itemIndex == ID_ITEM_MEMORY_MAIN_MEMORY_STATUS)
176 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MEMORY_STATUS");
179 TableViewItem* pItem = new (std::nothrow) TableViewItem();
181 RelativeLayout relativeLayout;
182 relativeLayout.Construct();
184 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
185 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
187 pLabel = new (std::nothrow) Label();
188 pLabel->Construct(itemMainRectangle, itemMainText);
189 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
190 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
191 pLabel->SetTextColor(COLOR_MAIN_TEXT);
193 pItem->AddControl(pLabel);
194 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
195 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
196 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
202 MemoryForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
204 AppLogDebug("ENTER");
213 MemoryForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
215 AppLogDebug("ENTER");
224 MemoryForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
226 SceneManager* pSceneManager = SceneManager::GetInstance();
227 AppAssert(pSceneManager);
229 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
231 if (itemIndex == ID_ITEM_MEMORY_MAIN_MEMORY_STATUS)
233 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MEMORY_STATUS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
238 MemoryForm::GetDefaultGroupItemHeight(void)
240 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
244 MemoryForm::GetDefaultItemHeight(void)
246 return H_GROUP_ITEM_DEFAULT;
250 MemoryForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
255 MemoryForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
260 MemoryForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
265 MemoryForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)