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 StCertificateForm.cpp
19 * @brief This is the implementation file for CertificateForm class.
22 #include "StCertificateForm.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_CERTIFICATES_MAIN = 0;
34 static const int ID_GROUP_CERTIFICATES_MAIN_ITEM_COUNT = 2;
35 static const int ID_ITEM_TRUSTED_ROOT_CERTIFICATES = 0;
36 static const int ID_ITEM_USER_CERTIFICATES = 1;
38 static const int ID_GROUP_COUNT = 1;
39 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_CERTIFICATES_MAIN_ITEM_COUNT;
41 CertificateForm::CertificateForm(void)
45 CertificateForm::~CertificateForm(void)
50 CertificateForm::CreateFooter(void)
52 Footer* pFooter = GetFooter();
55 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
56 pFooter->SetBackButton();
57 pFooter->AddActionEventListener(*this);
59 SetFormBackEventListener(this);
63 CertificateForm::OnInitializing(void)
65 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_CERTIFICATES"));
75 CertificateForm::CreateTableView(void)
77 Rectangle tableViewBounds = GetClientAreaBounds();
78 tableViewBounds.y = Y_GROUP_DEFAULT;
80 __pTableView = new (std::nothrow) GroupedTableView();
82 __pTableView->Construct(tableViewBounds, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
83 __pTableView->SetItemProvider(this);
85 AddControl(__pTableView);
86 __pTableView->SetGroupedLookEnabled(true);
87 __pTableView->AddGroupedTableViewItemEventListener(*this);
88 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(this->GetLayoutN());
89 if (pRelativeLayout != null)
91 pRelativeLayout->SetHorizontalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
92 pRelativeLayout->SetVerticalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
93 delete pRelativeLayout;
98 CertificateForm::OnTerminating(void)
102 SetFormBackEventListener(null);
107 CertificateForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
109 __pTableView->UpdateTableView();
113 CertificateForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
118 CertificateForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
120 SceneManager* pSceneManager = SceneManager::GetInstance();
121 AppAssert(pSceneManager);
123 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
127 CertificateForm::GetGroupCount(void)
129 AppLogDebug("ENTER");
130 return ID_GROUP_COUNT;
134 CertificateForm::GetItemCount(int groupIndex)
136 int itemCount = ID_GROUP_MAX_ITEM_COUNT;
141 CertificateForm::CreateGroupItem(int groupIndex, int itemWidth)
143 AppLogDebug("ENTER");
145 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
146 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
147 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
148 Rectangle itemMainRectangle;
150 Label* pLabel = null;
152 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
154 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
155 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
157 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
158 itemMainRectangle.y = yItemOffset;
159 itemMainRectangle.width = itemWidth;
160 itemMainRectangle.height = itemHeight;
162 RelativeLayout relativeLayout;
163 relativeLayout.Construct();
165 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
166 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
168 pLabel = new (std::nothrow) Label();
169 pLabel->Construct(itemMainRectangle, groupText);
170 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
171 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
172 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
173 pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
175 pItem->AddControl(pLabel);
176 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
177 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
178 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
179 pItem->SetEnabled(false);
185 CertificateForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
187 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
189 Rectangle itemMainRectangle;
190 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
192 Label* pLabel = null;
193 int fontSize = GetFontSize();
197 case ID_ITEM_TRUSTED_ROOT_CERTIFICATES:
199 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_TRUSTED_ROOT_CERTIFICATES");
203 case ID_ITEM_USER_CERTIFICATES:
205 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_USER_CERTIFICATES");
212 TableViewItem* pItem = new (std::nothrow) TableViewItem();
214 ItemTypeOneLine(itemMainRectangle);
216 RelativeLayout relativeLayout;
217 relativeLayout.Construct();
219 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
220 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
222 pLabel = new (std::nothrow) Label();
223 pLabel->Construct(itemMainRectangle, itemMainText);
224 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
225 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
226 pLabel->SetTextColor(COLOR_MAIN_TEXT);
228 pItem->AddControl(pLabel);
229 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
230 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
231 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
237 CertificateForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
239 AppLogDebug("ENTER");
248 CertificateForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
250 AppLogDebug("ENTER");
259 CertificateForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
261 SceneManager* pSceneManager = SceneManager::GetInstance();
262 AppAssert(pSceneManager);
266 case ID_ITEM_USER_CERTIFICATES:
268 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_USER, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
274 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
278 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
282 CertificateForm::GetDefaultGroupItemHeight(void)
284 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
288 CertificateForm::GetDefaultItemHeight(void)
290 return H_GROUP_ITEM_DEFAULT;
294 CertificateForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
299 CertificateForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
304 CertificateForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
309 CertificateForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)