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 FUiCtrlDateTimePicker.cpp
20 * @brief This is the implementation file for the DateTimePicker class.
23 #include <FUiCtrlForm.h>
24 #include <FSysSystemTime.h>
25 #include <FUiCtrlDateTimePicker.h>
26 #include <FBaseSysLog.h>
27 #include "FUiCtrl_DateTimePickerImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::System;
33 namespace Tizen { namespace Ui { namespace Controls
36 DateTimePicker::DateTimePicker(void)
40 DateTimePicker::~DateTimePicker(void)
45 DateTimePicker::Construct(const Tizen::Base::String& title)
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.");
51 pImpl = _DateTimePickerImpl::CreateDateTimePickerImplN(this, title);
52 result r = GetLastResult();
53 SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
55 _pControlImpl = pImpl;
57 pImpl->GetCore().SetResizable(false);
58 pImpl->GetCore().SetMovable(false);
64 DateTimePicker::AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener)
66 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
67 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
69 result r = pImpl->AddDateTimeChangeEventListener(listener);
70 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
74 DateTimePicker::RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener)
76 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
77 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
79 result r = pImpl->RemoveDateTimeChangeEventListener(listener);
80 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
84 DateTimePicker::SetDateTime(const Tizen::Base::DateTime& dateTime)
86 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
87 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
89 pImpl->SetDateTime(dateTime);
90 result r = GetLastResult();
91 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
95 DateTimePicker::SetCurrentDateTime(void)
97 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
98 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
100 pImpl->SetCurrentDateTime();
101 result r = GetLastResult();
102 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
106 DateTimePicker::SetYear(int year)
108 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
109 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
111 result r = pImpl->SetYear(year);
112 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
118 DateTimePicker::SetMonth(int month)
120 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
121 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
123 result r = pImpl->SetMonth(month);
124 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
130 DateTimePicker::SetDay(int day)
132 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
133 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
135 result r = pImpl->SetDay(day);
136 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
142 DateTimePicker::SetHour(int hour)
144 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
145 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
147 result r = pImpl->SetHour(hour);
148 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
154 DateTimePicker::SetMinute(int minute)
156 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
157 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
159 result r = pImpl->SetMinute(minute);
160 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
165 Tizen::Base::DateTime
166 DateTimePicker::GetDateTime(void) const
168 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
169 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
171 DateTime dateTime = pImpl->GetDateTime();
172 result r = GetLastResult();
173 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r));
179 DateTimePicker::GetYear(void) const
181 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
182 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
184 int year = pImpl->GetYear();
185 result r = GetLastResult();
186 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, year, r, "[%s] Propagating.", GetErrorMessage(r));
192 DateTimePicker::GetMonth(void) const
194 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
195 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
197 int month = pImpl->GetMonth();
198 result r = GetLastResult();
199 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, month, r, "[%s] Propagating.", GetErrorMessage(r));
205 DateTimePicker::GetDay(void) const
207 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
208 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
210 int day = pImpl->GetDay();
211 result r = GetLastResult();
212 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, day, r, "[%s] Propagating.", GetErrorMessage(r));
218 DateTimePicker::GetHour(void) const
220 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
221 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
223 int hour = pImpl->GetHour();
224 result r = GetLastResult();
225 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, hour, r, "[%s] Propagating.", GetErrorMessage(r));
231 DateTimePicker::GetMinute(void) const
233 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
234 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
236 int minute = pImpl->GetMinute();
237 result r = GetLastResult();
238 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, minute, r, "[%s] Propagating.", GetErrorMessage(r));
244 DateTimePicker::Set24HourNotationEnabled(bool enable)
246 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
247 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
249 pImpl->Set24HourNotationEnabled(enable);
250 result r = GetLastResult();
251 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
255 DateTimePicker::Is24HourNotationEnabled(void) const
257 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
258 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
260 bool enabled = pImpl->Is24HourNotationEnabled();
261 result r = GetLastResult();
262 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, enabled, r, "[%s] Propagating.", GetErrorMessage(r));
268 DateTimePicker::SetYearRange(int minYear, int maxYear)
270 _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
271 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
273 result r = pImpl->SetYearRange(minYear, maxYear);
274 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
280 DateTimePicker::GetYearRange(int& minYear, int& maxYear) const
282 const _DateTimePickerImpl* pImpl = _DateTimePickerImpl::GetInstance(*this);
283 SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
285 return pImpl->GetYearRange(minYear, maxYear);
288 }}} // Tizen::Ui::Controls