2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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 StEventsNotificationForm.cpp
19 * @brief This is the implementation file for EventsNotificationForm class.
22 #include "StEventsNotificationForm.h"
23 #include "StResourceManager.h"
26 using namespace Tizen::Base;
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Ui;
29 using namespace Tizen::Ui::Controls;
30 using namespace Tizen::Ui::Scenes;
32 static const int ID_GROUP_NOTIFICATION = 0;
33 static const int ID_GROUP_NOTIFICATION_ITEM_COUNT = 3;
34 static const int ID_ITEM_NOTIFICATION_EMAIL = 0;
35 static const int ID_ITEM_NOTOFICATION_MESSAGE = 1;
36 static const int ID_ITEM_NOTOFICATION_INSTANT_MESSENGER = 2;
38 static const int ID_GROUP_COUNT = 1;
39 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_NOTIFICATION_ITEM_COUNT;
41 NotificationForm::NotificationForm(void)
45 NotificationForm::~NotificationForm(void)
50 NotificationForm::CreateFooter(void)
52 Footer* pFooter = GetFooter();
55 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
56 pFooter->SetBackButton();
57 pFooter->AddActionEventListener(*this);
59 SetFormBackEventListener(this);
63 NotificationForm::OnInitializing(void)
65 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_EVENTS_NOTIFICATIONS"));
75 NotificationForm::OnTerminating(void)
79 SetFormBackEventListener(null);
84 NotificationForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
86 __pTableView->UpdateTableView();
90 NotificationForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
95 NotificationForm::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 NotificationForm::GetGroupCount(void)
106 AppLogDebug("ENTER");
107 return ID_GROUP_COUNT;
111 NotificationForm::GetItemCount(int groupIndex)
115 if (groupIndex == ID_GROUP_NOTIFICATION)
117 itemCount = ID_GROUP_NOTIFICATION_ITEM_COUNT;
120 AppLogDebug("GetItemCount %d", itemCount);
126 NotificationForm::CreateGroupItem(int groupIndex, int itemWidth)
128 AppLogDebug("ENTER");
130 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
131 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
132 Rectangle itemRectangle;
134 Label* pLabel = null;
136 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
138 itemRectangle.x = X_GROUP_INDEX_DEFAULT_LABEL;
139 itemRectangle.y = Y_GROUP_INDEX_DEFAULT_LABEL;
140 itemRectangle.width = itemWidth;
141 itemRectangle.height = itemHeight;
143 RelativeLayout relativeLayout;
144 relativeLayout.Construct();
146 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
147 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
149 pLabel = new (std::nothrow) Label();
150 pLabel->Construct(itemRectangle, groupText);
151 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
152 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
153 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
155 pItem->AddControl(*pLabel);
156 relativeLayout.SetMargin(*pLabel, itemRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
157 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
158 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
159 pItem->SetEnabled(false);
165 NotificationForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
167 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
169 Rectangle itemRectangle;
170 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
172 Label* pLabel = null;
173 int fontSize = GetFontSize();
177 case ID_ITEM_NOTIFICATION_EMAIL:
179 itemText = ResourceManager::GetString(L"IDS_ST_BODY_EMAIL");
183 case ID_ITEM_NOTOFICATION_MESSAGE:
185 itemText = ResourceManager::GetString(L"IDS_ST_BODY_SIDEBAR_MESSAGES");
189 case ID_ITEM_NOTOFICATION_INSTANT_MESSENGER:
191 itemText = ResourceManager::GetString(L"IDS_COM_BODY_INSTANT_MESSENGER");
199 ItemTypeOneLine(itemRectangle);
200 TableViewItem* pItem = new (std::nothrow) TableViewItem();
202 RelativeLayout relativeLayout;
203 relativeLayout.Construct();
205 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
206 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
208 pLabel = new (std::nothrow) Label();
209 pLabel->Construct(itemRectangle, itemText);
210 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
211 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
212 pLabel->SetTextColor(COLOR_MAIN_TEXT);
214 pItem->AddControl(*pLabel);
215 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
216 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
217 relativeLayout.SetRelation(*pLabel, *pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
223 NotificationForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
225 AppLogDebug("ENTER");
234 NotificationForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
236 AppLogDebug("ENTER");
245 NotificationForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
247 SceneManager* pSceneManager = SceneManager::GetInstance();
248 AppAssert(pSceneManager);
250 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
254 case ID_ITEM_NOTIFICATION_EMAIL:
256 // TODO: make scene or call appControl.
257 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
261 case ID_ITEM_NOTOFICATION_MESSAGE:
263 // TODO: make scene or call appControl.
264 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
268 case ID_ITEM_NOTOFICATION_INSTANT_MESSENGER:
270 // TODO: make scene or call appControl
271 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
281 NotificationForm::GetDefaultGroupItemHeight(void)
283 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
287 NotificationForm::GetDefaultItemHeight(void)
289 return H_GROUP_ITEM_DEFAULT;
293 NotificationForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
298 NotificationForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
303 NotificationForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
308 NotificationForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)