3 // Open Service Platform
4 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // All rights reserved.
7 // This software contains confidential and proprietary information
8 // of Samsung Electronics Co., Ltd.
9 // The user of this software agrees not to disclose, disseminate or copy such
10 // Confidential Information and shall use the software only in accordance with
11 // the terms of the license agreement the user entered into with Samsung.
14 #include "FeatureManagerForm.h"
17 using namespace Tizen::App;
18 using namespace Tizen::Ui;
19 using namespace Tizen::Ui::Controls;
20 using namespace Tizen::Ui::Scenes;
21 using namespace Tizen::Base;
22 using namespace Tizen::Graphics;
24 FeatureManagerForm::FeatureManagerForm(void)
25 : __pIconListView(null)
30 FeatureManagerForm::~FeatureManagerForm(void)
35 FeatureManagerForm::Initialize(void)
37 Construct(FORM_STYLE_NORMAL| FORM_STYLE_HEADER| FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
39 SetFormBackEventListener(this);
45 FeatureManagerForm::OnInitializing(void)
47 Header* pHeader = GetHeader();
48 pHeader->SetTitleText(L"Delete Features");
49 if (!CreateMainList())
54 Footer* pFooter = GetFooter();
55 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
56 pFooter->SetBackButton();
58 FooterItem pFooterItemDelete;
59 pFooterItemDelete.Construct(ID_FOOTER_ITEM_DELETE);
60 pFooterItemDelete.SetText(L"Delete");
61 pFooter->AddItem(pFooterItemDelete);
62 pFooter->SetItemEnabled(0, false);
63 pFooter->AddActionEventListener(*this);
69 FeatureManagerForm::OnTerminating(void)
76 FeatureManagerForm::CreateMainList(void)
78 __pIconListView = new IconListView();
79 __pIconListView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height),
80 Dimension(GetClientAreaBounds().width - 100, 250), ICON_LIST_VIEW_STYLE_MARK, ICON_LIST_VIEW_SCROLL_DIRECTION_VERTICAL);
81 __pIconListView->SetItemProvider(*this);
82 __pIconListView->AddIconListViewItemEventListener(*this);
83 AddControl(*__pIconListView);
90 FeatureManagerForm::OnActionPerformed (const Tizen::Ui::Control &source, int actionId)
92 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
93 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
95 SceneManager* pSceneManager = SceneManager::GetInstance();
96 AppAssert(pSceneManager);
100 case ID_FOOTER_ITEM_DELETE:
102 int items = this->GetItemCount() - 1;
104 for (int i = items; i >= 0; i--)
106 if (__pIconListView->IsItemChecked(i))
108 pForm->GetFeatureManager()->DeleteFeature(i);
112 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_OUT));
121 FeatureManagerForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
123 SceneManager* pSceneManager = SceneManager::GetInstance();
124 AppAssert(pSceneManager);
125 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_ZOOM_OUT));
130 FeatureManagerForm::GetItemCount(void)
132 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
133 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
137 if (pForm->GetFeatureManager())
139 return pForm->GetFeatureManager()->GetTotalNumberOfFeatures();
147 FeatureManagerForm::DeleteItem(int index, Tizen::Ui::Controls::IconListViewItem* pItem)
154 Tizen::Ui::Controls::IconListViewItem*
155 FeatureManagerForm::CreateItem(int index)
157 IconListViewItem* pIconListViewItem = new IconListViewItem();
158 Tizen::Ui::Controls::Frame *pFrame = Tizen::App::Application::GetInstance()->GetAppFrame()->GetFrame();
159 MainForm* pForm = static_cast<MainForm*>(pFrame->GetControl(L"IDF_FORM", true));
160 if (pForm->GetFeatureManager())
162 const Tizen::Uix::Vision::ImageFeatureInfo* pFeature = pForm->GetFeatureManager()->GetImageFeatureInfo(index);
163 if (pFeature == null)
165 return pIconListViewItem;
168 ByteBuffer* pByteBuffer = null;
169 pByteBuffer = pFeature->GetThumbnailN();
170 if (pByteBuffer == null)
174 int __thumbnailWidth = pFeature->GetThumbnailWidth();
175 int __thumbnailHeight = pFeature->GetThumbnailHeight();
176 unsigned char* ptr = const_cast<unsigned char*>(pByteBuffer->GetPointer());
177 unsigned char* end = ptr + __thumbnailWidth * __thumbnailHeight;
179 ByteBuffer imageBuffer;
180 imageBuffer.Construct(__thumbnailWidth * __thumbnailHeight * 4);
181 unsigned char* iptr = const_cast<unsigned char*>(imageBuffer.GetPointer());
183 for (;ptr < end; ++ptr)
191 Bitmap* pBitmap = new Bitmap();
192 pBitmap->Construct(imageBuffer, Dimension(__thumbnailWidth, __thumbnailHeight), BITMAP_PIXEL_FORMAT_R8G8B8A8);
194 //before this we should get name of the item
195 Tizen::Base::String name;
196 name.Format(80, L"%i: %ls", index, pFeature->GetDescription().GetPointer());
198 pIconListViewItem->Construct(*pBitmap, &name);
206 return pIconListViewItem;
210 FeatureManagerForm::OnIconListViewItemStateChanged(Tizen::Ui::Controls::IconListView &view, int index, Tizen::Ui::Controls::IconListViewItemStatus status)
212 Footer* pFooter = GetFooter();
215 case ICON_LIST_VIEW_ITEM_CHECKED:
217 pFooter->SetItemEnabled(0, true);
221 case ICON_LIST_VIEW_ITEM_UNCHECKED:
223 pFooter->SetItemEnabled(0, false);
224 int items = this->GetItemCount() - 1;
226 for (int i = items; i >= 0 && i != index; i--)
228 if (__pIconListView->IsItemChecked(i))
230 pFooter->SetItemEnabled(0, true);
244 FeatureManagerForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
245 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
247 __pIconListView->ScrollToItem(0);
248 __pIconListView->UpdateList();
258 FeatureManagerForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
259 const Tizen::Ui::Scenes::SceneId& nextSceneId)