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->AddActionEventListener(*this);
57 SetFormBackEventListener(this);
61 MemoryForm::OnInitializing(void)
63 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_MEMORY"));
72 MemoryForm::OnTerminating(void)
76 SetFormBackEventListener(null);
81 MemoryForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
83 __pTableView->UpdateTableView();
87 MemoryForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
92 MemoryForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
94 SceneManager* pSceneManager = SceneManager::GetInstance();
95 AppAssert(pSceneManager);
97 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
101 MemoryForm::GetGroupCount(void)
103 AppLogDebug("ENTER");
104 return ID_GROUP_COUNT;
108 MemoryForm::GetItemCount(int groupIndex)
112 if (groupIndex == ID_GROUP_MEMORY_MAIN)
114 itemCount = ID_GROUP_MEMORY_MAIN_ITEM_COUNT;
121 MemoryForm::CreateGroupItem(int groupIndex, int itemWidth)
123 AppLogDebug("ENTER");
125 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
126 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
127 Rectangle itemMainRectangle;
129 Label* pLabel = null;
131 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
133 itemMainRectangle.x = X_GROUP_INDEX_DEFAULT_LABEL;
134 itemMainRectangle.y = Y_GROUP_INDEX_DEFAULT_LABEL;
135 itemMainRectangle.width = itemWidth;
136 itemMainRectangle.height = itemHeight;
138 RelativeLayout relativeLayout;
139 relativeLayout.Construct();
141 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
142 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
144 pLabel = new (std::nothrow) Label();
145 pLabel->Construct(itemMainRectangle, groupText);
146 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
147 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
148 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
150 pItem->AddControl(pLabel);
151 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
152 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
153 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
154 pItem->SetEnabled(false);
160 MemoryForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
162 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
164 Rectangle itemMainRectangle;
165 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
167 Label* pLabel = null;
168 int fontSize = GetFontSize();
170 ItemTypeOneLine(itemMainRectangle);
172 if (itemIndex == ID_ITEM_MEMORY_MAIN_MEMORY_STATUS)
174 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MEMORY_STATUS");
177 TableViewItem* pItem = new (std::nothrow) TableViewItem();
179 RelativeLayout relativeLayout;
180 relativeLayout.Construct();
182 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
183 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
185 pLabel = new (std::nothrow) Label();
186 pLabel->Construct(itemMainRectangle, itemMainText);
187 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
188 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
189 pLabel->SetTextColor(COLOR_MAIN_TEXT);
191 pItem->AddControl(pLabel);
192 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
193 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
194 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
200 MemoryForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
202 AppLogDebug("ENTER");
211 MemoryForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
213 AppLogDebug("ENTER");
222 MemoryForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
224 SceneManager* pSceneManager = SceneManager::GetInstance();
225 AppAssert(pSceneManager);
227 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
229 if (itemIndex == ID_ITEM_MEMORY_MAIN_MEMORY_STATUS)
231 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_MEMORY_STATUS, SCENE_TRANSITION_ANIMATION_TYPE_LEFT));
236 MemoryForm::GetDefaultGroupItemHeight(void)
238 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
242 MemoryForm::GetDefaultItemHeight(void)
244 return H_GROUP_ITEM_DEFAULT;
248 MemoryForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
253 MemoryForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
258 MemoryForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
263 MemoryForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)