2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (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.
18 * @file FUiCtrl_DateTimeChangeEvent.cpp
19 * @brief This is the implementation file for the _DateTimeChangeEvent and _DateTimeChangeEventArg classes.
22 #include <FBaseErrors.h>
23 #include <FSysSystemTime.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_DateTimeChangeEvent.h"
26 #include "FUiCtrl_IDateTimeChangeEventListener.h"
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Runtime;
30 using namespace Tizen::System;
32 namespace Tizen { namespace Ui { namespace Controls
35 _DateTimeChangeEventArg::_DateTimeChangeEventArg(_DateTimeChangeStatus status)
43 SystemTime::GetCurrentTime(WALL_TIME, __dateTime);
46 _DateTimeChangeEventArg::~_DateTimeChangeEventArg(void)
52 _DateTimeChangeEventArg::SetDateTime(const DateTime& dateTime)
54 __dateTime = dateTime;
60 _DateTimeChangeEventArg::GetYear(void) const
66 _DateTimeChangeEventArg::GetMonth(void) const
72 _DateTimeChangeEventArg::GetDay(void) const
78 _DateTimeChangeEventArg::GetHour(void) const
84 _DateTimeChangeEventArg::GetMinute(void) const
90 _DateTimeChangeEventArg::GetDateTime(void) const
96 _DateTimeChangeEventArg::GetStatus(void) const
102 _DateTimeChangeEventArg::SetTime(int hour, int minute)
111 _DateTimeChangeEventArg::SetDate(int year, int month, int day)
120 _DateTimeChangeEvent::_DateTimeChangeEvent(const Tizen::Ui::_Control& source)
123 result r = _Event::Initialize();
126 __pSource = const_cast<_Control*>(&source);
130 _DateTimeChangeEvent::~_DateTimeChangeEvent(void)
136 _DateTimeChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
139 _IDateTimeChangeEventListener* pDateTimeChangeEventListener = dynamic_cast <_IDateTimeChangeEventListener*>(&listener);
140 SysTryReturnVoidResult(NID_UI_CTRL, (pDateTimeChangeEventListener != null), E_INVALID_ARG,
141 "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _IDateTimeChangeEventListener is null.");
144 const _DateTimeChangeEventArg* pArg = dynamic_cast <const _DateTimeChangeEventArg*>(&arg);
145 SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG,
146 "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _DateTimeChangeEventArg is null.");
148 switch (pArg->GetStatus())
150 case DATE_INTERNAL_CHANGE_SAVED:
152 case DATETIME_INTERNAL_CHANGE_SAVED:
154 case TIME_INTERNAL_CHANGE_SAVED:
155 pDateTimeChangeEventListener->OnDateTimeChanged(*__pSource, pArg->GetYear(), pArg->GetMonth(),
156 pArg->GetDay(), pArg->GetHour(), pArg->GetMinute());
159 case DATE_INTERNAL_CHANGE_CANCELED:
161 case DATETIME_INTERNAL_CHANGE_CANCELED:
163 case TIME_INTERNAL_CHANGE_CANCELED:
164 pDateTimeChangeEventListener->OnDateTimeChangeCanceled(*__pSource);
171 SetLastResult(E_SUCCESS);
175 }}} // Tizen::Ui::Controls