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 StWallpaperForm.cpp
19 * @brief This is the implementation file for WallpaperForm class.
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
26 #include "StWallpaperForm.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Io;
33 using namespace Tizen::System;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Controls;
36 using namespace Tizen::Ui::Scenes;
38 static const int ID_GROUP_WALLPAPER_COUNT = 1;
39 static const int ID_GROUP_WALLPAPER_ITEM_COUNT = 3;
40 static const int ID_HOME_SCREEN_WALLPAPER = 0;
41 static const int ID_LOCK_SCREEN_WALLPAPER = 1;
42 static const int ID_HOME_AND_LOCK_SCREEN_WALLPAPER = 2;
44 WallpaperForm::WallpaperForm(void)
48 WallpaperForm::~WallpaperForm(void)
53 WallpaperForm::CreateFooter(void)
55 Footer* pFooter = GetFooter();
58 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
59 pFooter->SetBackButton();
60 pFooter->AddActionEventListener(*this);
62 SetFormBackEventListener(this);
66 WallpaperForm::OnInitializing(void)
68 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_MAINDISPLAY_WALLPAPER"));
79 WallpaperForm::OnTerminating(void)
81 SetFormBackEventListener(null);
86 WallpaperForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
88 __pTableView->UpdateTableView();
92 WallpaperForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
97 WallpaperForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
99 SceneManager* pSceneManager = SceneManager::GetInstance();
100 AppAssert(pSceneManager);
102 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
106 WallpaperForm::GetGroupCount(void)
108 AppLogDebug("ENTER");
109 return ID_GROUP_WALLPAPER_COUNT;
113 WallpaperForm::GetItemCount(int groupIndex)
115 return ID_GROUP_WALLPAPER_ITEM_COUNT;
119 WallpaperForm::CreateGroupItem(int groupIndex, int itemWidth)
121 AppLogDebug("ENTER");
123 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
124 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
125 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
126 Rectangle itemRectangle;
128 Label* pLabel = null;
129 int fontSize = GetFontSize();
131 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
133 itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
134 itemRectangle.y = yItemOffset;
135 itemRectangle.width = itemWidth;
136 itemRectangle.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(itemRectangle, groupText);
146 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
147 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
148 pLabel->SetTextConfig(fontSize, style);
149 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
151 pItem->AddControl(pLabel);
152 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
153 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
154 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
155 pItem->SetEnabled(false);
161 WallpaperForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
163 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
164 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
165 int itemHeight = H_GROUP_ITEM_DEFAULT;
167 Rectangle itemRectangle;
168 Label* pLabel = null;
169 int fontSize = GetFontSize();
173 case ID_HOME_SCREEN_WALLPAPER:
175 itemText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
179 case ID_LOCK_SCREEN_WALLPAPER:
181 itemText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
185 case ID_HOME_AND_LOCK_SCREEN_WALLPAPER:
187 itemText = L"Home and lock screen wallpaper";
195 TableViewItem* pItem = new (std::nothrow) TableViewItem();
197 RelativeLayout relativeLayout;
198 relativeLayout.Construct();
200 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
201 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
203 ItemTypeOneLine(itemRectangle);
204 pLabel = new (std::nothrow) Label();
205 pLabel->Construct(itemRectangle, itemText);
206 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
207 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
208 pLabel->SetTextColor(COLOR_MAIN_TEXT);
210 pItem->AddControl(pLabel);
211 relativeLayout.SetMargin(*pLabel, 0, 0, 0, 0);
212 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
213 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
219 WallpaperForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
221 AppLogDebug("ENTER");
230 WallpaperForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
232 AppLogDebug("ENTER");
241 WallpaperForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
243 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
244 SceneManager* pSceneManager = SceneManager::GetInstance();
245 AppAssert(pSceneManager);
247 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
250 AppLogDebug("pArgs is null");
254 result r = pArgs->Construct();
259 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
263 pArgs->Add(*(new (std::nothrow) String(Integer::ToString(itemIndex))));
266 case ID_HOME_SCREEN_WALLPAPER:
268 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
272 case ID_LOCK_SCREEN_WALLPAPER:
274 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
278 case ID_HOME_AND_LOCK_SCREEN_WALLPAPER:
280 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
286 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
293 WallpaperForm::GetDefaultGroupItemHeight(void)
295 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
299 WallpaperForm::GetDefaultItemHeight(void)
301 return H_GROUP_ITEM_DEFAULT;
305 WallpaperForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
310 WallpaperForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
315 WallpaperForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
320 WallpaperForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)