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 FUiCtrlDateTimePicker.h
20 * @brief This is the header file for the %DateTimePicker class.
22 * This header file contains the declarations of the %DateTimePicker class.
24 #ifndef _FUI_CTRL_DATE_TIME_PICKER_H_
25 #define _FUI_CTRL_DATE_TIME_PICKER_H_
27 #include <FUiWindow.h>
28 #include <FUiIDateTimeChangeEventListener.h>
30 namespace Tizen { namespace Ui { namespace Controls
34 * @class DateTimePicker
35 * @brief This class displays a full screen %DateTimePicker on top of the screen.
39 * The %DateTimePicker class displays a full screen window-based selector that allows the user to select a certain date and time.
41 * 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>.
43 * The following example demonstrates how to use the %DateTimePicker class.
46 // Sample code for DateTimePickerSample.h
49 class DateTimePickerSample
50 : public Tizen::Ui::Controls::Form
51 , public Tizen::Ui::IDateTimeChangeEventListener
52 , public Tizen::Ui::IActionEventListener
55 DateTimePickerSample(void)
56 :__pDateTimePicker(null){}
58 bool Initialize(void);
59 void ShowDateTimePicker(bool show);
60 virtual result OnInitializing(void);
61 virtual result OnTerminating(void);
63 // IActionEventListener
64 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
66 // IDateTimeChangeEventListener
67 virtual void OnDateTimeChanged(const Tizen::Ui::Control& source, int year, int month, int day, int hour, int minute);
68 virtual void OnDateTimeChangeCanceled(const Tizen::Ui::Control& source);
71 static const int ID_BUTTON = 101;
73 Tizen::Ui::Controls::DateTimePicker* __pDateTimePicker;
79 // Sample code for DateTimePickerSample.cpp
80 #include <FGraphics.h>
82 #include "DateTimePickerSample.h"
84 using namespace Tizen::Graphics;
85 using namespace Tizen::Ui::Controls;
88 DateTimePickerSample::Initialize(void)
90 Construct(FORM_STYLE_NORMAL);
95 DateTimePickerSample::OnInitializing(void)
99 // Creates an instance of Button
100 Button* pButton = new Button();
101 pButton->Construct(Rectangle(50, 50, 300, 200), L"Show DateTimePicker");
102 pButton->SetActionId(ID_BUTTON);
103 pButton->AddActionEventListener(*this);
105 // Adds the button to the form
106 AddControl(*pButton);
108 // Creates an instance of DateTimePicker
109 __pDateTimePicker = new DateTimePicker();
110 __pDateTimePicker->Construct();
112 // Adds an instace of IDateTimeChangeEventListener
113 __pDateTimePicker->AddDateTimeChangeEventListener(*this);
115 // Shows the date time picker after it's owner form is shown.
121 DateTimePickerSample::ShowDateTimePicker(bool show)
123 // Changes to desired show state
124 __pDateTimePicker->SetShowState(show);
126 // Calls Show() of the control
129 __pDateTimePicker->Show();
131 // Calls Show() of the container
139 DateTimePickerSample::OnTerminating(void)
141 result r = E_SUCCESS;
143 // Deallocates the date time picker
144 __pDateTimePicker->Destroy();
149 // IActionEventListener implementation
151 DateTimePickerSample::OnActionPerformed(const Control& source, int actionId)
157 ShowDateTimePicker(true);
165 // IDateTimeChangeEventListener implementation
167 DateTimePickerSample::OnDateTimeChanged(const Control& source, int year, int month, int day, int hour, int minute)
173 DateTimePickerSample::OnDateTimeChangeCanceled(const Control& source)
180 class _OSP_EXPORT_ DateTimePicker
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.
189 DateTimePicker(void);
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 ~DateTimePicker(void);
199 * Adds the IDateTimeChangeEventListener instance. @n
200 * The added listener gets notified when date or time of the %DateTimePicker instance is changed either by user manipulation or by calling one of its
205 * @param[in] listener The listener to be added
206 * @see IDateTimeChangeEventListener::OnDateTimeChanged()
207 * @see IDateTimeChangeEventListener::OnDateTimeChangeCanceled()
208 * @see RemoveDateTimeChangeEventListener()
210 void AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener);
213 * Removes the IDateTimeChangeEventListener instance. @n
214 * The removed listener is not called even when the date and time change events are fired.
218 * @param[in] listener The listener to be removed
219 * @see IDateTimeChangeEventListener::OnDateTimeChanged()
220 * @see IDateTimeChangeEventListener::OnDateTimeChangeCanceled()
221 * @see AddDateTimeChangeEventListener()
223 void RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener);
226 * Initializes this instance of %DateTimePicker to the current date and time in the wall time mode.
230 * @return An error code
231 * @param[in] title The title
232 * @exception E_SUCCESS The method is successful.
233 * @exception E_SYSTEM A system error has occurred.
235 result Construct(const Tizen::Base::String& title = L"");
238 * Sets the date and time value of the %DateTimePicker control.
242 * @param[in] dateTime The date and time to be set
244 void SetDateTime(const Tizen::Base::DateTime& dateTime);
247 * Sets the date and time value of the %DateTimePicker control with the current date and time in the Coordinated Universal Time (UTC) mode.
251 void SetCurrentDateTime(void);
254 * Sets the year value of the %DateTimePicker control.
258 * @return An error code
259 * @param[in] year The year value
260 * @exception E_SUCCESS The method is successful.
261 * @exception E_INVALID_ARG The specified @c year value is invalid.
262 * @exception E_SYSTEM A system error has occurred.
263 * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by SetYearRange().
264 * @remarks The specified @c year should be in the range set by SetYearRange(). The default year range is from @c 1 to @c 9999.
265 * @see SetYearRange()
267 result SetYear(int year);
270 * Sets the month value. @n
271 * The month value should be between @c 1 and @c 12.
275 * @return An error code
276 * @param[in] month The month value
277 * @exception E_SUCCESS The method is successful.
278 * @exception E_INVALID_ARG The specified @c month value is invalid.
279 * @exception E_SYSTEM A system error has occurred.
281 result SetMonth(int month);
284 * Sets the day value.
285 * The day value should be between @c 1 and @c 31.
289 * @return An error code
290 * @param[in] day The day value
291 * @exception E_SUCCESS The method is successful.
292 * @exception E_INVALID_ARG The specified @c day value is invalid.
293 * @exception E_SYSTEM A system error has occurred.
295 result SetDay(int day);
298 * Sets the hour value of the %DateTimePicker control.
299 * The hour value should be between @c 0 and @c 23.
303 * @return An error code
304 * @param[in] hour The hour value to be set
305 * @exception E_SUCCESS The method is successful.
306 * @exception E_INVALID_ARG The specified @c hour value is invalid.
307 * @exception E_SYSTEM A system error has occurred.
309 result SetHour(int hour);
312 * Sets the minute value of the %DateTimePicker control.
313 * The minute value should be between @c 0 and @c 59.
317 * @return An error code
318 * @param[in] minute The minute value to be set
319 * @exception E_SUCCESS The method is successful.
320 * @exception E_INVALID_ARG The specified @c minute value is invalid.
321 * @exception E_SYSTEM A system error has occurred.
323 result SetMinute(int minute);
326 * Gets the current date and time value of the %DateTimePicker control.
330 * @return The current date and time
331 * @remarks This method does not work when %DateTimePicker style is DATETIME_PICKER_STYLE_FROMTO.
333 Tizen::Base::DateTime GetDateTime(void) const;
336 * Gets the current year value of %DateTimePicker. @n
337 * The year value should be between @c 1 to @c 9999.
341 * @return The current year value, @n
342 * else @c -1 if an error occurs
344 int GetYear(void) const;
347 * Gets the current month value of %DateTimePicker. @n
348 * The month value should be between @c 1 to @c 12.
352 * @return The current month value, @n
353 * else @c -1 if an error occurs
355 int GetMonth(void) const;
358 * Gets the current day value of %DateTimePicker. @n
359 * The day value should be between @c 1 to @c 31.
363 * @return The current day value , @n
364 * else @c -1 if an error occurs
366 int GetDay(void) const;
369 * Gets the current hour value of the %DateTimePicker control. @n
370 * The hour value should be between @c 0 to @c 23.
374 * @return The current hour value, @n
375 * else @c -1 if an error occurs
376 * @remarks Whether the time display mode is 12-hour or 24-hour, this method always returns the hour value ranging from @c 0 to @c 23.
378 int GetHour(void) const;
381 * Gets the current minute value of the %DateTimePicker control.
385 * @return The current minute value, @n
386 * else @c -1 if an error occurs
388 int GetMinute(void) const;
391 * Sets the 12-hour or 24-hour display mode of the %DateTimePicker control.
395 void Set24HourNotationEnabled(bool enable);
398 * Checks whether the 24-hour notation is enabled for the %DateTimePicker control. @n
399 * This can be 12-hour or 24-hour mode.
403 * @return @c true if the 24-hour notation is enabled, @n
404 * else @c false if the 12-hour notation is enabled
406 bool Is24HourNotationEnabled(void) const;
409 * Sets the valid year range. @n
410 * The range should be set between @c 1 and @c 9999.
414 * @return An error code
415 * @param[in] minYear The minimum year for the valid range
416 * @param[in] maxYear The maximum year for the valid range
417 * @exception E_SUCCESS The method is successful.
418 * @exception E_INVALID_ARG The specified year range is invalid.
419 * @exception E_SYSTEM A system error has occurred.
421 result SetYearRange(int minYear, int maxYear);
424 * Gets the valid year range.
428 * @return An error code
429 * @param[out] minYear The minimum year for the valid range
430 * @param[out] maxYear The maximum year for the valid range
431 * @exception E_SUCCESS The method is successful.
432 * @exception E_SYSTEM A system error has occurred.
434 result GetYearRange(int& minYear, int& maxYear) const;
437 friend class _DateTimePickerImpl;
441 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
443 DateTimePicker(const DateTimePicker& rhs);
446 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
448 DateTimePicker& operator =(const DateTimePicker& rhs);
452 }}} // Tizen::Ui::Controls
454 #endif // _FUI_CTRL_DATE_TIME_PICKER_H_