3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file: ClkSortByPopUp.cpp
20 * @brief This CPP file contains the declarations of the SortByPopUp
23 #include <FAppUiApp.h>
24 #include <FUiScenes.h>
26 #include "ClkCommonLib.h"
27 #include "ClkSortByPopUp.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Ui;
34 using namespace Tizen::Ui::Controls;
35 using namespace Tizen::Ui::Scenes;
37 static const int ID_FORMAT_RECENT = 501;
38 static const int ID_FORMAT_TIME = 502 ;
39 static const int ID_CANCEL_BUTTON = 504;
42 ISortByEventListener::ISortByEventListener(void)
47 ISortByEventListener::~ISortByEventListener(void)
52 SortByPopUp::SortByPopUp(void)
59 SortByPopUp::~SortByPopUp(void)
61 AppLog("SortByPopUp::~SortByPopUp");
65 SortByPopUp::Initialize(void)
67 Button* pCancelButton = null;
68 Popup::Construct(L"IDL_SORT_BY");
70 __pList = static_cast<ListView*>(GetControl(L"IDC_LISTVIEW1"));
77 __pList->SetItemProvider(*this);
78 __pList->AddListViewItemEventListener(*this);
79 __pList->SetItemChecked(0, true);
81 pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON1", true));
82 if (pCancelButton != null)
84 pCancelButton->AddActionEventListener(*this);
85 pCancelButton->SetActionId(ID_CANCEL_BUTTON);
88 SetPropagatedKeyEventListener(this);
93 SortByPopUp::OnTerminating(void)
100 SortByPopUp::OnActionPerformed(const Control& source, int actionId)
104 case ID_CANCEL_BUTTON:
106 Popup::SetShowState(false);
117 SortByPopUp::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
123 if (__pList != NULL )
125 __pList->SetItemChecked(0,true);
126 __pList->SetItemChecked(1,false);
129 if(__pListener != NULL)
131 __pListener->OnSortByPopUpItemSelected(SORTBY_RECENT);
137 if (__pList != NULL )
139 __pList->SetItemChecked(0,false);
140 __pList->SetItemChecked(1,true);
143 if( __pListener != NULL)
145 __pListener->OnSortByPopUpItemSelected(SORTBY_TIME);
155 if (__pList != NULL )
157 __pList->Invalidate(true);
162 SortByPopUp::CreateItem(int index, int itemWidth)
164 result r = E_FAILURE;
165 ListAnnexStyle style = LIST_ANNEX_STYLE_RADIO;
166 int listItemWidth = 112;
168 CustomItem* pItem = new (std::nothrow) CustomItem();
169 r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemWidth), style);
170 //pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
172 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color(255, 255, 255));
173 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, Color(86, 135, 193));
174 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_HIGHLIGHTED, Color(86, 135, 193));
178 AppLogDebug("Create Item Failed with error %s", GetErrorMessage(r));
188 pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_RECENT,CommonUtil::GetString(L"IDS_COM_BUTTON_RECENT"), true);
194 pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_TIME,CommonUtil::GetString(L"IDS_WCL_TAB_TIME"), true);
205 SortByPopUp::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
211 SortByPopUp::GetItemCount(void)
216 ISortByEventListener*
217 SortByPopUp::GetEventListner(void)
223 SortByPopUp::SetEventListner(ISortByEventListener* listner)
225 __pListener = listner;
229 SortByPopUp::SetDstIndex(int index)
231 __pList->SetItemChecked(index,true);
235 __pList->SetItemChecked(1,false);
239 __pList->SetItemChecked(0,false);
241 __pList->Invalidate(true);
245 SortByPopUp::OnKeyReleased (Control &source, const KeyEventInfo &keyEventInfo)
247 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
249 Popup::SetShowState(false);