Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlDateTimePicker.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                FUiCtrlDateTimePicker.cpp
20  * @brief               This is the implementation file for the DateTimePicker class.
21  */
22
23 #include <FUiCtrlForm.h>
24 #include <FSysSystemTime.h>
25 #include <FUiCtrlDateTimePicker.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_DateTimePickerImpl.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::System;
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 DateTimePicker::DateTimePicker(void)
37 {
38 }
39
40 DateTimePicker::~DateTimePicker(void)
41 {
42 }
43
44 result
45 DateTimePicker::Construct(const Tizen::Base::String& title)
46 {
47         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
48         SysAssertf((pImpl == null),
49                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
50
51         pImpl = _DateTimePickerImpl::CreateDateTimePickerImplN(this, title);
52         result r = GetLastResult();
53         SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
54
55         _pControlImpl = pImpl;
56
57         pImpl->GetCore().SetResizable(false);
58         pImpl->GetCore().SetMovable(false);
59
60         return r;
61 }
62
63 void
64 DateTimePicker::AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener)
65 {
66         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
67         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
68
69         result r = pImpl->AddDateTimeChangeEventListener(listener);
70         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
71 }
72
73 void
74 DateTimePicker::RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener)
75 {
76         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
77         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
78
79         result r = pImpl->RemoveDateTimeChangeEventListener(listener);
80         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
81 }
82
83 void
84 DateTimePicker::SetDateTime(const Tizen::Base::DateTime& dateTime)
85 {
86         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
87         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
88
89         pImpl->SetDateTime(dateTime);
90         result r = GetLastResult();
91         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
92 }
93
94 void
95 DateTimePicker::SetCurrentDateTime(void)
96 {
97         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
98         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
99
100         pImpl->SetCurrentDateTime();
101         result r = GetLastResult();
102         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
103 }
104
105 result
106 DateTimePicker::SetYear(int year)
107 {
108         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
109         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
110
111         result r = pImpl->SetYear(year);
112         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
113
114         return r;
115 }
116
117 result
118 DateTimePicker::SetMonth(int month)
119 {
120         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
121         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
122
123         result r = pImpl->SetMonth(month);
124         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
125
126         return r;
127 }
128
129 result
130 DateTimePicker::SetDay(int day)
131 {
132         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
133         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
134
135         result r = pImpl->SetDay(day);
136         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
137
138         return r;
139 }
140
141 result
142 DateTimePicker::SetHour(int hour)
143 {
144         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
145         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
146
147         result r = pImpl->SetHour(hour);
148         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
149
150         return r;
151 }
152
153 result
154 DateTimePicker::SetMinute(int minute)
155 {
156         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
157         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
158
159         result r = pImpl->SetMinute(minute);
160         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
161
162         return r;
163 }
164
165 Tizen::Base::DateTime
166 DateTimePicker::GetDateTime(void) const
167 {
168         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
169         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
170
171         DateTime dateTime = pImpl->GetDateTime();
172         result r = GetLastResult();
173         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r));
174
175         return dateTime;
176 }
177
178 int
179 DateTimePicker::GetYear(void) const
180 {
181         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
182         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
183
184         int year = pImpl->GetYear();
185         result r = GetLastResult();
186         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, year, r, "[%s] Propagating.", GetErrorMessage(r));
187
188         return year;
189 }
190
191 int
192 DateTimePicker::GetMonth(void) const
193 {
194         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
195         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
196
197         int month = pImpl->GetMonth();
198         result r = GetLastResult();
199         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, month, r, "[%s] Propagating.", GetErrorMessage(r));
200
201         return month;
202 }
203
204 int
205 DateTimePicker::GetDay(void) const
206 {
207         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
208         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
209
210         int day = pImpl->GetDay();
211         result r = GetLastResult();
212         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, day, r, "[%s] Propagating.", GetErrorMessage(r));
213
214         return day;
215 }
216
217 int
218 DateTimePicker::GetHour(void) const
219 {
220         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
221         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
222
223         int hour = pImpl->GetHour();
224         result r = GetLastResult();
225         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, hour, r, "[%s] Propagating.", GetErrorMessage(r));
226
227         return hour;
228 }
229
230 int
231 DateTimePicker::GetMinute(void) const
232 {
233         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
234         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
235
236         int minute = pImpl->GetMinute();
237         result r = GetLastResult();
238         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, minute, r, "[%s] Propagating.", GetErrorMessage(r));
239
240         return minute;
241 }
242
243 void
244 DateTimePicker::Set24HourNotationEnabled(bool enable)
245 {
246         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
247         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
248
249         pImpl->Set24HourNotationEnabled(enable);
250         result r = GetLastResult();
251         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
252 }
253
254 bool
255 DateTimePicker::Is24HourNotationEnabled(void) const
256 {
257         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
258         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
259
260         bool enabled = pImpl->Is24HourNotationEnabled();
261         result r = GetLastResult();
262         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, enabled, r, "[%s] Propagating.", GetErrorMessage(r));
263
264         return enabled;
265 }
266
267 result
268 DateTimePicker::SetYearRange(int minYear, int maxYear)
269 {
270         _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
271         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
272
273         result r = pImpl->SetYearRange(minYear, maxYear);
274         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
275
276         return r;
277 }
278
279 result
280 DateTimePicker::GetYearRange(int& minYear, int& maxYear) const
281 {
282         const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
283         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
284
285         return pImpl->GetYearRange(minYear, maxYear);
286 }
287
288 }}} // Tizen::Ui::Controls