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->AddActionEventListener(*this);
61 SetFormBackEventListener(this);
65 WallpaperForm::OnInitializing(void)
67 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_MAINDISPLAY_WALLPAPER"));
77 WallpaperForm::OnTerminating(void)
79 SetFormBackEventListener(null);
84 WallpaperForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
86 __pTableView->UpdateTableView();
90 WallpaperForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
95 WallpaperForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
97 SceneManager* pSceneManager = SceneManager::GetInstance();
98 AppAssert(pSceneManager);
100 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
104 WallpaperForm::GetGroupCount(void)
106 AppLogDebug("ENTER");
107 return ID_GROUP_WALLPAPER_COUNT;
111 WallpaperForm::GetItemCount(int groupIndex)
113 return ID_GROUP_WALLPAPER_ITEM_COUNT;
117 WallpaperForm::CreateGroupItem(int groupIndex, int itemWidth)
119 AppLogDebug("ENTER");
121 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
122 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
123 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
124 Rectangle itemRectangle;
126 Label* pLabel = null;
127 int fontSize = GetFontSize();
129 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
131 itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
132 itemRectangle.y = yItemOffset;
133 itemRectangle.width = itemWidth;
134 itemRectangle.height = itemHeight;
136 RelativeLayout relativeLayout;
137 relativeLayout.Construct();
139 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
140 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
142 pLabel = new (std::nothrow) Label();
143 pLabel->Construct(itemRectangle, groupText);
144 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
145 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
146 pLabel->SetTextConfig(fontSize, style);
147 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
149 pItem->AddControl(pLabel);
150 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
151 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
152 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
153 pItem->SetEnabled(false);
159 WallpaperForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
161 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
162 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
163 int itemHeight = H_GROUP_ITEM_DEFAULT;
165 Rectangle itemRectangle;
166 Label* pLabel = null;
167 int fontSize = GetFontSize();
171 case ID_HOME_SCREEN_WALLPAPER:
173 itemText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
177 case ID_LOCK_SCREEN_WALLPAPER:
179 itemText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
183 case ID_HOME_AND_LOCK_SCREEN_WALLPAPER:
185 itemText = L"Home and lock screen wallpaper";
193 TableViewItem* pItem = new (std::nothrow) TableViewItem();
195 RelativeLayout relativeLayout;
196 relativeLayout.Construct();
198 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
199 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
201 ItemTypeOneLine(itemRectangle);
202 pLabel = new (std::nothrow) Label();
203 pLabel->Construct(itemRectangle, itemText);
204 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
205 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
206 pLabel->SetTextColor(COLOR_MAIN_TEXT);
208 pItem->AddControl(pLabel);
209 relativeLayout.SetMargin(*pLabel, 0, 0, 0, 0);
210 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
211 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
217 WallpaperForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
219 AppLogDebug("ENTER");
228 WallpaperForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
230 AppLogDebug("ENTER");
239 WallpaperForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
241 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
242 SceneManager* pSceneManager = SceneManager::GetInstance();
243 AppAssert(pSceneManager);
245 ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
248 AppLogDebug("pArgs is null");
252 result r = pArgs->Construct();
257 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
261 pArgs->Add(new (std::nothrow) String(Integer::ToString(itemIndex)));
264 case ID_HOME_SCREEN_WALLPAPER:
266 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
270 case ID_LOCK_SCREEN_WALLPAPER:
272 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
276 case ID_HOME_AND_LOCK_SCREEN_WALLPAPER:
278 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
284 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_WALLPAPER_ALBUM_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
291 WallpaperForm::GetDefaultGroupItemHeight(void)
293 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
297 WallpaperForm::GetDefaultItemHeight(void)
299 return H_GROUP_ITEM_DEFAULT;
303 WallpaperForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
308 WallpaperForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
313 WallpaperForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
318 WallpaperForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)