2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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 FUiCtrl_DateTimeChangeEvent.cpp
20 * @brief This is the implementation file for the _DateTimeChangeEvent and _DateTimeChangeEventArg classes.
23 #include <FBaseErrors.h>
24 #include <FSysSystemTime.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_DateTimeChangeEvent.h"
27 #include "FUiCtrl_IDateTimeChangeEventListener.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
31 using namespace Tizen::System;
33 namespace Tizen { namespace Ui { namespace Controls
36 _DateTimeChangeEventArg::_DateTimeChangeEventArg(_DateTimeChangeStatus status)
44 SystemTime::GetCurrentTime(WALL_TIME, __dateTime);
47 _DateTimeChangeEventArg::~_DateTimeChangeEventArg(void)
53 _DateTimeChangeEventArg::SetDateTime(const DateTime& dateTime)
55 __dateTime = dateTime;
61 _DateTimeChangeEventArg::GetYear(void) const
67 _DateTimeChangeEventArg::GetMonth(void) const
73 _DateTimeChangeEventArg::GetDay(void) const
79 _DateTimeChangeEventArg::GetHour(void) const
85 _DateTimeChangeEventArg::GetMinute(void) const
91 _DateTimeChangeEventArg::GetDateTime(void) const
97 _DateTimeChangeEventArg::GetStatus(void) const
103 _DateTimeChangeEventArg::SetTime(int hour, int minute)
112 _DateTimeChangeEventArg::SetDate(int year, int month, int day)
121 _DateTimeChangeEvent::_DateTimeChangeEvent(const Tizen::Ui::_Control& source)
124 result r = _Event::Initialize();
127 __pSource = const_cast<_Control*>(&source);
131 _DateTimeChangeEvent::~_DateTimeChangeEvent(void)
137 _DateTimeChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
140 _IDateTimeChangeEventListener* pDateTimeChangeEventListener = dynamic_cast <_IDateTimeChangeEventListener*>(&listener);
141 SysTryReturnVoidResult(NID_UI_CTRL, (pDateTimeChangeEventListener != null), E_INVALID_ARG,
142 "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _IDateTimeChangeEventListener is null.");
145 const _DateTimeChangeEventArg* pArg = dynamic_cast <const _DateTimeChangeEventArg*>(&arg);
146 SysTryReturnVoidResult(NID_UI_CTRL, (pArg != null), E_INVALID_ARG,
147 "[E_INVALID_ARG] Invalid argument(s) is used. The instance of _DateTimeChangeEventArg is null.");
149 switch (pArg->GetStatus())
151 case DATE_INTERNAL_CHANGE_SAVED:
153 case DATETIME_INTERNAL_CHANGE_SAVED:
155 case TIME_INTERNAL_CHANGE_SAVED:
156 pDateTimeChangeEventListener->OnDateTimeChanged(*__pSource, pArg->GetYear(), pArg->GetMonth(),
157 pArg->GetDay(), pArg->GetHour(), pArg->GetMinute());
160 case DATE_INTERNAL_CHANGE_CANCELED:
162 case DATETIME_INTERNAL_CHANGE_CANCELED:
164 case TIME_INTERNAL_CHANGE_CANCELED:
165 pDateTimeChangeEventListener->OnDateTimeChangeCanceled(*__pSource);
172 SetLastResult(E_SUCCESS);
176 }}} // Tizen::Ui::Controls