2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 FUiCtrlDatePicker.h
20 * @brief This is the header file for the %DatePicker class.
22 * This header file contains the declarations of the %DatePicker class.
24 #ifndef _FUI_CTRL_DATE_PICKER_H_
25 #define _FUI_CTRL_DATE_PICKER_H_
27 #include <FUiWindow.h>
28 #include <FUiIDateChangeEventListener.h>
30 namespace Tizen { namespace Ui { namespace Controls
35 * @brief This class displays a full screen %DatePicker on top of the screen.
39 * @remarks One cannot change the size and the position of the %DatePicker.
41 * The %DatePicker class displays a full screen window-based selector that allows the user to select a certain date.
43 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_datepicker.htm">DatePicker, TimePicker, and DateTimePicker</a>.
45 * The following example demonstrates how to use the %DatePicker class.
48 // Sample code for DatePickerSample.h
51 class DatePickerSample
52 : public Tizen::Ui::Controls::Form
53 , public Tizen::Ui::IDateChangeEventListener
54 , public Tizen::Ui::IActionEventListener
57 DatePickerSample(void)
58 :__pDatePicker(null){}
60 bool Initialize(void);
61 virtual result OnInitializing(void);
62 virtual result OnTerminating(void);
63 void ShowDatePicker(bool show);
65 // IActionEventListener
66 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
68 // IDateChangeEventListener
69 virtual void OnDateChanged(const Tizen::Ui::Control& source, int year, int month, int day);
70 virtual void OnDateChangeCanceled(const Tizen::Ui::Control& source);
73 static const int ID_BUTTON = 101;
75 Tizen::Ui::Controls::DatePicker* __pDatePicker;
81 // Sample code for DatePickerSample.cpp
82 #include "DatePickerSample.h"
83 #include <FGraphics.h>
85 using namespace Tizen::Graphics;
86 using namespace Tizen::Ui::Controls;
89 DatePickerSample::Initialize(void)
91 Construct(FORM_STYLE_NORMAL);
96 DatePickerSample::OnInitializing(void)
100 // Creates an instance of Button
101 Button* pButton = new Button();
102 pButton->Construct(Rectangle(50, 50, 300, 200), L"Show DatePicker");
103 pButton->SetActionId(ID_BUTTON);
104 pButton->AddActionEventListener(*this);
106 // Adds the button to the form
107 AddControl(*pButton);
109 // Creates an instance of DatePicker
110 __pDatePicker = new DatePicker();
111 __pDatePicker->Construct();
113 // Adds an instance of IDateChangeEventListener
114 __pDatePicker->AddDateChangeEventListener(*this);
116 // Shows the date picker after it's owner form is shown.
122 DatePickerSample::ShowDatePicker(bool show)
124 // Changes to desired show state
125 __pDatePicker->SetShowState(show);
127 // Calls Show() of the control
130 __pDatePicker->Show();
132 // Calls Show() of the container
140 DatePickerSample::OnTerminating(void)
142 result r = E_SUCCESS;
144 // Deallocates the date picker
145 __pDatePicker->Destroy();
150 // IActionEventListener implementation
152 DatePickerSample::OnActionPerformed(const Control& source, int actionId)
158 ShowDatePicker(true);
166 // IDateChangeEventListener implementation
168 DatePickerSample::OnDateChanged(const Control& source, int year, int month, int day)
174 DatePickerSample::OnDateChangeCanceled(const Control& source)
180 class _OSP_EXPORT_ DatePicker
181 : public Tizen::Ui::Window
185 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
192 * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
196 virtual ~DatePicker(void);
199 * Adds a data change event listener instance. @n
200 * The added listener is called when the date of the %DatePicker is changed either through user manipulation or by calling one of its setters.
204 * @param[in] listener The listener to add
205 * @see IDateChangeEventListener::OnDateChanged()
206 * @see IDateChangeEventListener::OnDateChangeCanceled()
207 * @see RemoveDateChangeEventListener()
209 void AddDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener);
212 * Removes a date changed event listener instance. @n
213 * The removed listener cannot listen to events when they are fired.
217 * @param[in] listener The listener to remove
218 * @see IDateChangeEventListener::OnDateChanged()
219 * @see IDateChangeEventListener::OnDateChangeCanceled()
220 * @see AddDateChangeEventListener()
222 void RemoveDateChangeEventListener(Tizen::Ui::IDateChangeEventListener& listener);
225 * Initializes this instance of %DatePicker with the specified parameter.
229 * @return An error code
230 * @param[in] title The title
231 * @exception E_SUCCESS The method is successful.
232 * @exception E_SYSTEM A system error has occurred.
234 result Construct(const Tizen::Base::String& title = L"");
237 * Gets the current date value of the %DatePicker control.
241 * @return A %DateTime instance
243 Tizen::Base::DateTime GetDate(void) const;
246 * Gets the current day value of the %DatePicker control. @n
247 * The day value is between @c 1 to @c 31.
251 * @return The current day value, @n
252 * else @c -1 if an error occurs
254 int GetDay(void) const;
257 * Gets the current month value of the %DatePicker control. @n
258 * The month value is between @c 1 to @c 12.
262 * @return The current month value, @n
263 * else @c -1 if an error occurs
265 int GetMonth(void) const;
268 * Gets the current year value of the %DatePicker control.
269 * The year value is between @c 1 to @c 9999.
273 * @return The current year value, @n
274 * else @c -1 if an error occurs
277 int GetYear(void) const;
280 * Sets the date value of the %DatePicker control.
284 * @param[in] date The date to set
286 void SetDate(const Tizen::Base::DateTime& date);
289 * Sets the date value of the %DatePicker control with the current date.
293 void SetCurrentDate(void);
296 * Sets the year value. @n
297 * The year value should be between @c 1 and @c 9999.
301 * @return An error code
302 * @param[in] year The year value
303 * @exception E_SUCCESS The method is successful.
304 * @exception E_INVALID_ARG The specified year value is invalid.
306 result SetYear(int year);
309 * Sets the month value. @n
310 * The month value should be between @c 1 and @c 12.
314 * @return An error code
315 * @param[in] month The month value
316 * @exception E_SUCCESS The method is successful.
317 * @exception E_INVALID_ARG The specified month value is invalid.
319 result SetMonth(int month);
322 * Sets the day value. @n
323 * The day value should be between @c 1 and @c 31.
327 * @return An error code
328 * @param[in] day The day value
329 * @exception E_SUCCESS The method is successful.
330 * @exception E_INVALID_ARG The specified @c day is invalid.
332 result SetDay(int day);
335 * Sets the valid year range.
336 * The range should be set in between @c 1 and @c 9999.
340 * @return An error code
341 * @param[in] minYear The minimum year for the valid range
342 * @param[in] maxYear The maximum year for the valid range
343 * @exception E_SUCCESS The method is successful.
344 * @exception E_INVALID_ARG The given year range is invalid.
345 * @exception E_SYSTEM A system error has occurred.
347 result SetYearRange(int minYear, int maxYear);
350 * Gets the valid year range.
354 * @return An error code
355 * @param[out] minYear The minimum year for the valid range
356 * @param[out] maxYear The maximum year for the valid range
357 * @exception E_SUCCESS The method is successful.
358 * @exception E_SYSTEM A system error has occurred.
360 result GetYearRange(int& minYear, int& maxYear) const;
363 friend class _DatePickerImpl;
367 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
369 DatePicker(const DatePicker& rhs);
372 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
374 DatePicker& operator =(const DatePicker& rhs);
378 }}} // Tizen::Ui::Controls
380 #endif // _FUI_CTRL_DATE_PICKER_H_