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 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;
40 NotificationForm::NotificationForm(void)
44 NotificationForm::~NotificationForm(void)
49 NotificationForm::CreateFooter(void)
51 Footer* pFooter = GetFooter();
54 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
55 pFooter->AddActionEventListener(*this);
57 SetFormBackEventListener(this);
61 NotificationForm::OnInitializing(void)
63 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_EVENTS_NOTIFICATIONS"));
72 NotificationForm::OnTerminating(void)
76 SetFormBackEventListener(null);
81 NotificationForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
83 __pTableView->UpdateTableView();
87 NotificationForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
92 NotificationForm::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 NotificationForm::GetGroupCount(void)
103 AppLogDebug("ENTER");
104 return ID_GROUP_COUNT;
108 NotificationForm::GetItemCount(int groupIndex)
112 if (groupIndex == ID_GROUP_NOTIFICATION)
114 itemCount = ID_GROUP_NOTIFICATION_ITEM_COUNT;
117 AppLogDebug("GetItemCount %d", itemCount);
123 NotificationForm::CreateGroupItem(int groupIndex, int itemWidth)
125 AppLogDebug("ENTER");
127 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
128 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
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 NotificationForm::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();
174 case ID_ITEM_NOTIFICATION_EMAIL:
176 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_EMAIL");
180 case ID_ITEM_NOTOFICATION_MESSAGE:
182 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SIDEBAR_MESSAGES");
186 case ID_ITEM_NOTOFICATION_INSTANT_MESSENGER:
188 itemMainText = ResourceManager::GetString(L"IDS_COM_BODY_INSTANT_MESSENGER");
196 ItemTypeOneLine(itemMainRectangle);
197 TableViewItem* pItem = new (std::nothrow) TableViewItem();
199 RelativeLayout relativeLayout;
200 relativeLayout.Construct();
202 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
203 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
205 pLabel = new (std::nothrow) Label();
206 pLabel->Construct(itemMainRectangle, itemMainText);
207 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
208 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
209 pLabel->SetTextColor(COLOR_MAIN_TEXT);
211 pItem->AddControl(pLabel);
212 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
213 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
214 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
220 NotificationForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
222 AppLogDebug("ENTER");
231 NotificationForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
233 AppLogDebug("ENTER");
242 NotificationForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
244 SceneManager* pSceneManager = SceneManager::GetInstance();
245 AppAssert(pSceneManager);
247 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
251 case ID_ITEM_NOTIFICATION_EMAIL:
253 // TODO: make scene or call appControl.
254 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
258 case ID_ITEM_NOTOFICATION_MESSAGE:
260 // TODO: make scene or call appControl.
261 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
265 case ID_ITEM_NOTOFICATION_INSTANT_MESSENGER:
267 // TODO: make scene or call appControl
268 ShowMessageBox(ResourceManager::GetString(L"IDS_EMAIL_POP_ALERT"), ResourceManager::GetString(L"IDS_ST_POP_NOT_SUPPORTED"));
278 NotificationForm::GetDefaultGroupItemHeight(void)
280 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
284 NotificationForm::GetDefaultItemHeight(void)
286 return H_GROUP_ITEM_DEFAULT;
290 NotificationForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
295 NotificationForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
300 NotificationForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
305 NotificationForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)