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 PhnSpeedDialPopup.cpp
19 * @brief Speed dial popup class
25 #include <FGraphics.h>
28 #include "PhnSpeedDialPopup.h"
29 #include "PhnSettingsConstants.h"
30 #include "PhnAppUtility.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Base::Utility;
35 using namespace Tizen::App;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Social;
38 using namespace Tizen::Ui;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Ui::Scenes;
42 const int W_POPUP = 620;
43 const int H_POPUP = 712;
44 const int W_CANCEL_BUTTON = 400;
45 const int H_CANCEL_BUTTON = 72;
46 const int CANCEL_BUTTON_PADDING = 40;
47 const int H_LIST_ITEM = 112;
48 const int W_LIST_ITEM = 112;
49 const int HORIZONTAL_PADDING = 16;
50 const int VERTICAL_PADDING = 110;
51 static const wchar_t* IDL_SPEED_DIAL_POPUP = L"IDL_SPEED_DIAL_POPUP";
53 SpeedDialPopup::SpeedDialPopup(IPopupItemSelectListener& listener)
54 : __pCancelButton(null)
55 , __popupListener(listener)
56 , __pListItemArray(null)
61 SpeedDialPopup::~SpeedDialPopup(void)
63 if (__pListItemArray != null)
65 delete __pListItemArray;
70 SpeedDialPopup::Initialize(void)
73 Construct(IDL_SPEED_DIAL_POPUP);
76 __pCancelButton = static_cast<Button*> (GetControl(L"IDC_CLOSE_BUTTON"));
77 __pCancelButton->SetActionId(IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP);
78 __pCancelButton->AddActionEventListener(*this);
80 ListView* __pList = static_cast<ListView*> (GetControl(L"IDC_LISTVIEW"));
81 __pList->AddListViewItemEventListener(*this);
82 __pList->SetItemProvider(*this);
90 SpeedDialPopup::ConstructListData(void)
92 __pListItemArray = new (std::nothrow) ArrayList();
93 __pListItemArray->Construct(2);
94 String optionStr = AppUtility::GetResourceString(L"IDS_CHANGE_CONTACT");
95 String* listItem1 = new (std::nothrow) String(optionStr);
96 __pListItemArray->Add(*listItem1);
98 optionStr = AppUtility::GetResourceString(L"IDS_REMOVE_CONTACT");
99 String* listItem2 = new (std::nothrow) String(optionStr);
100 __pListItemArray->Add(*listItem2);
104 SpeedDialPopup::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId,
105 Tizen::Ui::Controls::ListItemStatus status)
107 Popup::SetShowState(false);
108 __popupListener.OnItemSelected(elementId);
113 SpeedDialPopup::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index,
114 Tizen::Ui::Controls::SweepDirection direction)
120 SpeedDialPopup::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId,
121 Tizen::Ui::Controls::ListContextItemStatus state)
128 SpeedDialPopup::OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId,
129 bool& invokeListViewItemCallback)
135 SpeedDialPopup::GetItemCount(void)
137 if (__pListItemArray != null)
139 return __pListItemArray->GetCount();
144 Tizen::Ui::Controls::ListItemBase*
145 SpeedDialPopup::CreateItem(int index, int itemWidth)
148 String* strText = static_cast<String*>(__pListItemArray->GetAt(index));
149 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
150 CustomItem* pItem = new (std::nothrow) CustomItem();
151 pItem->Construct(Dimension(itemWidth, W_LIST_ITEM), style);
154 elementId = IDA_UPDATE_SPEED_DIAL;
158 elementId = IDA_REMOVE_SPEED_DIAL;
160 pItem->AddElement(Rectangle(HORIZONTAL_PADDING, 0, W_POPUP - HORIZONTAL_PADDING, H_LIST_ITEM), elementId, *strText);
165 SpeedDialPopup::DeleteItem(int index, Tizen::Ui::Controls::ListItemBase* pItem, int itemWidth)
174 SpeedDialPopup::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
178 case IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP:
180 Popup::SetShowState(false);
181 __popupListener.OnItemSelected(IDA_BUTTON_CLOSE_SPEED_DIAL_POPUP);