Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlDatePicker.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                FUiCtrlDatePicker.cpp
20  * @brief               This is the implementation file for the DatePicker class.
21  */
22
23 #include <FSysSystemTime.h>
24 #include <FUiCtrlDatePicker.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_DatePickerImpl.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::System;
31
32 namespace Tizen { namespace Ui { namespace Controls
33 {
34
35 DatePicker::DatePicker(void)
36 {
37 }
38
39 DatePicker::~DatePicker(void)
40 {
41 }
42
43 result
44 DatePicker::Construct(const Tizen::Base::String& title)
45 {
46         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
47         SysAssertf((pImpl == null),
48                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
49
50         pImpl = _DatePickerImpl::CreateDatePickerImplN(this, title);
51         result r = GetLastResult();
52         SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
53
54         _pControlImpl = pImpl;
55
56         pImpl->GetCore().SetResizable(false);
57         pImpl->GetCore().SetMovable(false);
58
59         return r;
60 }
61
62 void
63 DatePicker::AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener)
64 {
65         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
66         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
67
68         result r = pImpl->AddDateChangeEventListener(listener);
69         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
70 }
71
72 void
73 DatePicker::RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener)
74 {
75         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
76         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
77
78         result r = pImpl->RemoveDateChangeEventListener(listener);
79         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
80 }
81
82 Tizen::Base::DateTime
83 DatePicker::GetDate(void) const
84 {
85         result r = E_SUCCESS;
86         Tizen::Base::DateTime dateTime;
87         const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
88         if (pImpl == null)
89         {
90                 r = SystemTime::GetCurrentTime(WALL_TIME, dateTime);
91                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r));
92                 return dateTime;
93         }
94
95         dateTime = pImpl->GetDate();
96         r = GetLastResult();
97         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, dateTime, r, "[%s] Propagating.", GetErrorMessage(r));
98
99         return dateTime;
100 }
101
102 int
103 DatePicker::GetDay(void) const
104 {
105         const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
106         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
107
108         int day = pImpl->GetDay();
109         result r = GetLastResult();
110         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, day, r, "[%s] Propagating.", GetErrorMessage(r));
111
112         return day;
113 }
114
115 int
116 DatePicker::GetMonth(void) const
117 {
118         const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
119         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
120
121         int month = pImpl->GetMonth();
122         result r = GetLastResult();
123         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, month, r, "[%s] Propagating.", GetErrorMessage(r));
124
125         return month;
126 }
127
128 int
129 DatePicker::GetYear(void) const
130 {
131         const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
132         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
133
134         int year = pImpl->GetYear();
135         result r = GetLastResult();
136         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, year, r, "[%s] Propagating.", GetErrorMessage(r));
137
138         return year;
139 }
140
141 void
142 DatePicker::SetDate(const Tizen::Base::DateTime& date)
143 {
144         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
145         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
146
147         pImpl->SetDate(date);
148         result r = GetLastResult();
149         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
150 }
151
152 void
153 DatePicker::SetCurrentDate(void)
154 {
155         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
156         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
157
158         pImpl->SetCurrentDate();
159         result r = GetLastResult();
160         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
161 }
162
163 result
164 DatePicker::SetYear(int year)
165 {
166         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
167         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
168
169         result r = pImpl->SetYear(year);
170         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
171
172         return r;
173 }
174
175 result
176 DatePicker::SetMonth(int month)
177 {
178         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
179         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
180
181         result r = pImpl->SetMonth(month);
182         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
183
184         return r;
185 }
186
187 result
188 DatePicker::SetDay(int day)
189 {
190         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
191         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
192
193         result r = pImpl->SetDay(day);
194         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
195
196         return r;
197 }
198
199 result
200 DatePicker::SetYearRange(int minYear, int maxYear)
201 {
202         _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
203         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
204
205         result r = pImpl->SetYearRange(minYear, maxYear);
206         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
207
208         return r;
209 }
210
211 result
212 DatePicker::GetYearRange(int& minYear, int& maxYear) const
213 {
214         const _DatePickerImpl* pImpl = _DatePickerImpl::GetInstance(*this);
215         SysAssertf((pImpl != null), "Not yet constructed. Construct() should be called before use.");
216
217         return pImpl->GetYearRange(minYear, maxYear);
218 }
219
220 }}} //Tizen::Ui::Controls