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->AddActionEventListener(*this);
58 SetFormBackEventListener(this);
62 CertificateForm::OnInitializing(void)
64 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_CERTIFICATES"));
73 CertificateForm::CreateTableView(void)
75 Rectangle tableViewBounds = GetClientAreaBounds();
76 tableViewBounds.y = Y_GROUP_DEFAULT;
78 __pTableView = new (std::nothrow) GroupedTableView();
80 __pTableView->Construct(tableViewBounds, true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
81 __pTableView->SetItemProvider(this);
83 AddControl(__pTableView);
84 __pTableView->SetGroupedLookEnabled(true);
85 __pTableView->AddGroupedTableViewItemEventListener(*this);
86 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(this->GetLayoutN());
87 if (pRelativeLayout != null)
89 pRelativeLayout->SetHorizontalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
90 pRelativeLayout->SetVerticalFitPolicy(*__pTableView, FIT_POLICY_PARENT);
91 delete pRelativeLayout;
96 CertificateForm::OnTerminating(void)
100 SetFormBackEventListener(null);
105 CertificateForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
111 CertificateForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
116 CertificateForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
118 SceneManager* pSceneManager = SceneManager::GetInstance();
119 AppAssert(pSceneManager);
121 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
125 CertificateForm::GetGroupCount(void)
127 AppLogDebug("ENTER");
128 return ID_GROUP_COUNT;
132 CertificateForm::GetItemCount(int groupIndex)
134 int itemCount = ID_GROUP_MAX_ITEM_COUNT;
139 CertificateForm::CreateGroupItem(int groupIndex, int itemWidth)
141 AppLogDebug("ENTER");
143 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
144 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
145 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
146 Rectangle itemMainRectangle;
148 Label* pLabel = null;
150 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
152 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
153 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
155 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
156 itemMainRectangle.y = yItemOffset;
157 itemMainRectangle.width = itemWidth;
158 itemMainRectangle.height = itemHeight;
160 RelativeLayout relativeLayout;
161 relativeLayout.Construct();
163 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
164 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
166 pLabel = new (std::nothrow) Label();
167 pLabel->Construct(itemMainRectangle, groupText);
168 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
169 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
170 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
171 pLabel->SetTextColor(COLOR_GROUP_TITLE_TEXT);
173 pItem->AddControl(pLabel);
174 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
175 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
176 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
177 pItem->SetEnabled(false);
183 CertificateForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
185 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
187 Rectangle itemMainRectangle;
188 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
190 Label* pLabel = null;
191 int fontSize = GetFontSize();
195 case ID_ITEM_TRUSTED_ROOT_CERTIFICATES:
197 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_TRUSTED_ROOT_CERTIFICATES");
201 case ID_ITEM_USER_CERTIFICATES:
203 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_USER_CERTIFICATES");
210 TableViewItem* pItem = new (std::nothrow) TableViewItem();
212 ItemTypeOneLine(itemMainRectangle);
214 RelativeLayout relativeLayout;
215 relativeLayout.Construct();
217 pItem->Construct(relativeLayout, Dimension(itemWidth, H_GROUP_ITEM_DEFAULT), style);
218 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
220 pLabel = new (std::nothrow) Label();
221 pLabel->Construct(itemMainRectangle, itemMainText);
222 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
223 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
224 pLabel->SetTextColor(COLOR_MAIN_TEXT);
226 pItem->AddControl(pLabel);
227 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
228 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
229 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
235 CertificateForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
237 AppLogDebug("ENTER");
246 CertificateForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
248 AppLogDebug("ENTER");
257 CertificateForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
259 SceneManager* pSceneManager = SceneManager::GetInstance();
260 AppAssert(pSceneManager);
264 case ID_ITEM_USER_CERTIFICATES:
266 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_USER, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
272 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE_LIST, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
276 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
280 CertificateForm::GetDefaultGroupItemHeight(void)
282 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
286 CertificateForm::GetDefaultItemHeight(void)
288 return H_GROUP_ITEM_DEFAULT;
292 CertificateForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
297 CertificateForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
302 CertificateForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
307 CertificateForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)