Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_DateTimeChangeEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19  * @file                FUiCtrl_DateTimeChangeEvent.cpp
20  * @brief               This is the implementation file for the _DateTimeChangeEvent and _DateTimeChangeEventArg classes.
21  */
22
23 #include <FBaseErrors.h>
24 #include <FSysSystemTime.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_DateTimeChangeEvent.h"
27 #include "FUiCtrl_IDateTimeChangeEventListener.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
31 using namespace Tizen::System;
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 _DateTimeChangeEventArg::_DateTimeChangeEventArg(_DateTimeChangeStatus status)
37         : __status(status)
38         , __year(1)
39         , __month(1)
40         , __day(1)
41         , __hour(0)
42         , __minute(0)
43 {
44         SystemTime::GetCurrentTime(WALL_TIME, __dateTime);
45 }
46
47 _DateTimeChangeEventArg::~_DateTimeChangeEventArg(void)
48 {
49         // Nothing.
50 }
51
52 void
53 _DateTimeChangeEventArg::SetDateTime(const DateTime& dateTime)
54 {
55         __dateTime = dateTime;
56
57         return;
58 }
59
60 int
61 _DateTimeChangeEventArg::GetYear(void) const
62 {
63         return __year;
64 }
65
66 int
67 _DateTimeChangeEventArg::GetMonth(void) const
68 {
69         return __month;
70 }
71
72 int
73 _DateTimeChangeEventArg::GetDay(void) const
74 {
75         return __day;
76 }
77
78 int
79 _DateTimeChangeEventArg::GetHour(void) const
80 {
81         return __hour;
82 }
83
84 int
85 _DateTimeChangeEventArg::GetMinute(void) const
86 {
87         return __minute;
88 }
89
90 DateTime
91 _DateTimeChangeEventArg::GetDateTime(void) const
92 {
93         return __dateTime;
94 }
95
96 _DateTimeChangeStatus
97 _DateTimeChangeEventArg::GetStatus(void) const
98 {
99         return __status;
100 }
101
102 void
103 _DateTimeChangeEventArg::SetTime(int hour, int minute)
104 {
105         __hour = hour;
106         __minute = minute;
107
108         return;
109 }
110
111 void
112 _DateTimeChangeEventArg::SetDate(int year, int month, int day)
113 {
114         __year = year;
115         __month = month;
116         __day = day;
117
118         return;
119 }
120
121 _DateTimeChangeEvent::_DateTimeChangeEvent(const Tizen::Ui::_Control& source)
122         : __pSource(null)
123 {
124         result r = _Event::Initialize();
125         if (r == E_SUCCESS)
126         {
127                 __pSource = const_cast<_Control*>(&source);
128         }
129 }
130
131 _DateTimeChangeEvent::~_DateTimeChangeEvent(void)
132 {
133         // Nothing.
134 }
135
136 void
137 _DateTimeChangeEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
138 {
139         // DateTimePicker
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.");
143
144         // cast Argument
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.");
148
149         switch (pArg->GetStatus())
150         {
151         case DATE_INTERNAL_CHANGE_SAVED:
152         // fall through
153         case DATETIME_INTERNAL_CHANGE_SAVED:
154         // fall through
155         case TIME_INTERNAL_CHANGE_SAVED:
156                 pDateTimeChangeEventListener->OnDateTimeChanged(*__pSource, pArg->GetYear(), pArg->GetMonth(),
157                                                                                                                 pArg->GetDay(), pArg->GetHour(), pArg->GetMinute());
158                 break;
159
160         case DATE_INTERNAL_CHANGE_CANCELED:
161         // fall through
162         case DATETIME_INTERNAL_CHANGE_CANCELED:
163         // fall through
164         case TIME_INTERNAL_CHANGE_CANCELED:
165                 pDateTimeChangeEventListener->OnDateTimeChangeCanceled(*__pSource);
166                 break;
167
168         default:
169                 break;
170         }
171
172         SetLastResult(E_SUCCESS);
173         return;
174 }
175
176 }}} // Tizen::Ui::Controls