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 DaylightSavingPopUp.cpp
20 * @brief This file contains the definitions of the DayLightSavingPopup class.
23 #include <FAppUiApp.h>
24 #include <FUiScenes.h>
26 #include "ClkCommonLib.h"
27 #include "ClkDaylightSavingPopUp.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;
38 static const int ID_FORMAT_OFF = 501;
39 static const int ID_FORMAT_1_HOUR = 502 ;
40 static const int ID_FORMAT_2_HOURS = 503 ;
41 static const int ID_CANCEL_BUTTON = 504;
43 const RequestId REQUEST_CANCEL_CLICKED = 10001;
45 IDstTimeEventListener::IDstTimeEventListener(void)
50 IDstTimeEventListener::~IDstTimeEventListener(void)
55 DaylightSavingPopUp::DaylightSavingPopUp(void)
61 DaylightSavingPopUp::~DaylightSavingPopUp(void)
67 DaylightSavingPopUp::Initialize(void)
69 Button* pCancelButton = null;
70 Popup::Construct(L"IDL_DST_POPUP");
72 __pList = static_cast<ListView*>(GetControl(L"IDC_POPUP_LIST"));
79 __pList->SetItemProvider(*this);
80 __pList->AddListViewItemEventListener(*this);
82 pCancelButton = static_cast< Button* >(GetControl(L"IDC_BUTTON", true));
84 if (pCancelButton != null)
86 pCancelButton->AddActionEventListener(*this);
87 pCancelButton->SetActionId(ID_CANCEL_BUTTON);
90 SetPropagatedKeyEventListener(this);
96 DaylightSavingPopUp::OnTerminating(void)
103 DaylightSavingPopUp::OnActionPerformed(const Control& source, int actionId)
107 case ID_CANCEL_BUTTON:
109 Popup::SetShowState(false);
111 Form *pWorldClockForm = dynamic_cast<Form*>(UiApp::GetInstance()->GetFrameAt(0)->GetCurrentForm());
112 if(pWorldClockForm != NULL)
114 pWorldClockForm->SendUserEvent(REQUEST_CANCEL_CLICKED, null);
125 DaylightSavingPopUp::OnListViewItemStateChanged(ListView& listView, int index, int elementId, ListItemStatus status)
131 __pList->SetItemChecked(0,true);
132 __pList->SetItemChecked(1,false);
133 __pList->SetItemChecked(2,false);
135 if (__pListener != null)
137 __pListener->OnDaylightSavingPopUpItemSelected(0);
144 __pList->SetItemChecked(0,false);
145 __pList->SetItemChecked(1,true);
146 __pList->SetItemChecked(2,false);
148 if (__pListener != null)
150 __pListener->OnDaylightSavingPopUpItemSelected(1);
158 __pList->SetItemChecked(0,false);
159 __pList->SetItemChecked(1,false);
160 __pList->SetItemChecked(2,true);
162 if (__pListener != null)
164 __pListener->OnDaylightSavingPopUpItemSelected(2);
174 __pList->Invalidate(true);
178 DaylightSavingPopUp::CreateItem(int index, int itemWidth)
180 result r = E_FAILURE;
181 ListAnnexStyle style = LIST_ANNEX_STYLE_RADIO;
182 int listItemWidth = 112;
184 CustomItem* pItem = new (std::nothrow) CustomItem();
185 r = pItem->Construct(Dimension(GetClientAreaBounds().width, listItemWidth), style);
186 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
191 AppLogDebug("Create Item Failed with error %s", GetErrorMessage(r));
200 pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_OFF, L"Off", true);
206 pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_1_HOUR, L"1 hour", true);
212 pItem->AddElement(Rectangle(0, 0, GetClientAreaBounds().width, listItemWidth), ID_FORMAT_2_HOURS, L"2 hours", true);
223 DaylightSavingPopUp::DeleteItem(int index, ListItemBase* pItem, int itemWidth)
229 DaylightSavingPopUp::GetItemCount(void)
235 DaylightSavingPopUp::SetEventListner(IDstTimeEventListener* listner)
237 __pListener = listner;
241 DaylightSavingPopUp::SetDstIndex(int index)
243 __pList->SetItemChecked(index,true);
247 __pList->SetItemChecked(1,false);
248 __pList->SetItemChecked(2,false);
252 __pList->SetItemChecked(0,false);
253 __pList->SetItemChecked(2,false);
257 __pList->SetItemChecked(0,false);
258 __pList->SetItemChecked(1,false);
261 __pList->Invalidate(true);
265 DaylightSavingPopUp::OnKeyReleased (Control &source, const KeyEventInfo &keyEventInfo)
267 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
269 Popup::SetShowState(false);
271 Form *pWorldClockForm = dynamic_cast<Form*>(UiApp::GetInstance()->GetFrameAt(0)->GetCurrentForm());
272 if(pWorldClockForm != NULL)
274 pWorldClockForm->SendUserEvent(REQUEST_CANCEL_CLICKED, null);