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.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,
42 * see <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_datepicker.htm">DatePicker, TimePicker, and DateTimePicker</a>.
44 * The following example demonstrates how to use the %DateTimePicker class.
47 // Sample code for DateTimePickerSample.h
50 class DateTimePickerSample
51 : public Tizen::Ui::Controls::Form
52 , public Tizen::Ui::IDateTimeChangeEventListener
53 , public Tizen::Ui::IActionEventListener
56 DateTimePickerSample(void)
57 :__pDateTimePicker(null){}
59 bool Initialize(void);
60 void ShowDateTimePicker(bool show);
61 virtual result OnInitializing(void);
62 virtual result OnTerminating(void);
64 // IActionEventListener
65 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
67 // IDateTimeChangeEventListener
68 virtual void OnDateTimeChanged(const Tizen::Ui::Control& source, int year, int month, int day, int hour, int minute);
69 virtual void OnDateTimeChangeCanceled(const Tizen::Ui::Control& source);
72 static const int ID_BUTTON = 101;
74 Tizen::Ui::Controls::DateTimePicker* __pDateTimePicker;
80 // Sample code for DateTimePickerSample.cpp
81 #include <FGraphics.h>
83 #include "DateTimePickerSample.h"
85 using namespace Tizen::Graphics;
86 using namespace Tizen::Ui::Controls;
89 DateTimePickerSample::Initialize(void)
91 Construct(FORM_STYLE_NORMAL);
96 DateTimePickerSample::OnInitializing(void)
100 // Creates an instance of Button
101 Button* pButton = new Button();
102 pButton->Construct(Rectangle(50, 50, 300, 200), L"Show DateTimePicker");
103 pButton->SetActionId(ID_BUTTON);
104 pButton->AddActionEventListener(*this);
106 // Adds the button to the form
109 // Creates an instance of DateTimePicker
110 __pDateTimePicker = new DateTimePicker();
111 __pDateTimePicker->Construct();
113 // Adds an instance of IDateTimeChangeEventListener
114 __pDateTimePicker->AddDateTimeChangeEventListener(*this);
116 // Shows the date time picker after it's owner form is shown.
122 DateTimePickerSample::ShowDateTimePicker(bool show)
124 // Changes to desired show state
125 __pDateTimePicker->SetShowState(show);
127 // Calls Show() of the control
130 __pDateTimePicker->Show();
132 // Calls Show() of the container
140 DateTimePickerSample::OnTerminating(void)
142 result r = E_SUCCESS;
144 // Deallocates the date time picker
145 __pDateTimePicker->Destroy();
150 // IActionEventListener implementation
152 DateTimePickerSample::OnActionPerformed(const Control& source, int actionId)
158 ShowDateTimePicker(true);
166 // IDateTimeChangeEventListener implementation
168 DateTimePickerSample::OnDateTimeChanged(const Control& source, int year, int month, int day, int hour, int minute)
174 DateTimePickerSample::OnDateTimeChangeCanceled(const Control& source)
181 class _OSP_EXPORT_ DateTimePicker
182 : public Tizen::Ui::Window
186 * The object is not fully constructed after this constructor is called. @n
187 * For full construction, the DateTimePicker::Construct() method must be called right after calling this constructor.
191 DateTimePicker(void);
194 * This polymorphic destructor should be overridden if required. @n
195 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
199 virtual ~DateTimePicker(void);
202 * Adds the IDateTimeChangeEventListener instance. @n
203 * 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
208 * @param[in] listener The listener to add
209 * @see IDateTimeChangeEventListener::OnDateTimeChanged()
210 * @see IDateTimeChangeEventListener::OnDateTimeChangeCanceled()
211 * @see RemoveDateTimeChangeEventListener()
213 void AddDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener);
216 * Removes the IDateTimeChangeEventListener instance. @n
217 * The removed listener is not called even when the date and time change events are fired.
221 * @param[in] listener The listener to remove
222 * @see IDateTimeChangeEventListener::OnDateTimeChanged()
223 * @see IDateTimeChangeEventListener::OnDateTimeChangeCanceled()
224 * @see AddDateTimeChangeEventListener()
226 void RemoveDateTimeChangeEventListener(Tizen::Ui::IDateTimeChangeEventListener& listener);
229 * Initializes this instance of %DateTimePicker to the current date and time in the wall time mode.
233 * @return An error code
234 * @param[in] title The title
235 * @exception E_SUCCESS The method is successful.
236 * @exception E_SYSTEM A system error has occurred.
237 * @remarks The optimal size of the control is defined in
238 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
240 result Construct(const Tizen::Base::String& title = L"");
243 * Sets the date and time value of the %DateTimePicker control.
247 * @param[in] dateTime The date and time to set
249 void SetDateTime(const Tizen::Base::DateTime& dateTime);
252 * Sets the date and time value of the %DateTimePicker control with the current date and time in the wall time mode.
256 void SetCurrentDateTime(void);
259 * Sets the year value of the %DateTimePicker control.
263 * @return An error code
264 * @param[in] year The year value @n
265 * It should be in the range set by SetYearRange(). The default year range is from @c 1 to @c 9999.
266 * @exception E_SUCCESS The method is successful.
267 * @exception E_INVALID_ARG The specified @c year value is invalid.
268 * @exception E_SYSTEM A system error has occurred.
269 * @exception E_OUT_OF_RANGE The value of the argument is outside the valid range defined by SetYearRange().
270 * @see SetYearRange()
272 result SetYear(int year);
275 * Sets the month value.
279 * @return An error code
280 * @param[in] month The month value between @c 1 and @c 12.
281 * @exception E_SUCCESS The method is successful.
282 * @exception E_INVALID_ARG The specified @c month value is invalid.
283 * @exception E_SYSTEM A system error has occurred.
285 result SetMonth(int month);
288 * Sets the day value.
292 * @return An error code
293 * @param[in] day The day value between @c 1 and @c 31.
294 * @exception E_SUCCESS The method is successful.
295 * @exception E_INVALID_ARG The specified @c day value is invalid.
296 * @exception E_SYSTEM A system error has occurred.
298 result SetDay(int day);
301 * Sets the hour value of the %DateTimePicker control.
305 * @return An error code
306 * @param[in] hour The hour value between @c 0 and @c 23.
307 * @exception E_SUCCESS The method is successful.
308 * @exception E_INVALID_ARG The specified @c hour value is invalid.
309 * @exception E_SYSTEM A system error has occurred.
311 result SetHour(int hour);
314 * Sets the minute value of the %DateTimePicker control.
318 * @return An error code
319 * @param[in] minute The minute value between @c 0 and @c 59.
320 * @exception E_SUCCESS The method is successful.
321 * @exception E_INVALID_ARG The specified @c minute value is invalid.
322 * @exception E_SYSTEM A system error has occurred.
324 result SetMinute(int minute);
327 * Gets the current date and time value of the %DateTimePicker control.
331 * @return The current date and time
333 Tizen::Base::DateTime GetDateTime(void) const;
336 * Gets the current year value of %DateTimePicker. @n
340 * @return The current year value between @c 1 to @c 9999, @n
341 * else @c -1 if an error occurs
343 int GetYear(void) const;
346 * Gets the current month value of %DateTimePicker. @n
350 * @return The current month value between @c 1 to @c 12, @n
351 * else @c -1 if an error occurs
353 int GetMonth(void) const;
356 * Gets the current day value of %DateTimePicker. @n
360 * @return The current day value between @c 1 to @c 31, @n
361 * else @c -1 if an error occurs
363 int GetDay(void) const;
366 * Gets the current hour value of the %DateTimePicker control. @n
370 * @return The current hour value between @c 0 to @c 23 regardless of whether the time display mode is 12-hour or 24-hour, @n
371 * else @c -1 if an error occurs
373 int GetHour(void) const;
376 * Gets the current minute value of the %DateTimePicker control.
380 * @return The current minute value, @n
381 * else @c -1 if an error occurs
383 int GetMinute(void) const;
386 * Sets the 12-hour or 24-hour display mode of the %DateTimePicker control.
390 void Set24HourNotationEnabled(bool enable);
393 * Checks whether the 24-hour notation is enabled for the %DateTimePicker control. @n
394 * This can be 12-hour or 24-hour mode.
398 * @return @c true if the 24-hour notation is enabled, @n
399 * else @c false if the 12-hour notation is enabled
401 bool Is24HourNotationEnabled(void) const;
404 * Sets the valid year range. @n
408 * @return An error code
409 * @param[in] minYear The minimum year for the valid range between @c 1 and @c 9999
410 * @param[in] maxYear The maximum year for the valid range
411 * @exception E_SUCCESS The method is successful.
412 * @exception E_INVALID_ARG The specified year range is invalid.
413 * @exception E_SYSTEM A system error has occurred.
415 result SetYearRange(int minYear, int maxYear);
418 * Gets the valid year range.
422 * @return An error code
423 * @param[out] minYear The minimum year for the valid range
424 * @param[out] maxYear The maximum year for the valid range
425 * @exception E_SUCCESS The method is successful.
426 * @exception E_SYSTEM A system error has occurred.
428 result GetYearRange(int& minYear, int& maxYear) const;
431 friend class _DateTimePickerImpl;
435 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
437 DateTimePicker(const DateTimePicker& rhs);
440 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
442 DateTimePicker& operator =(const DateTimePicker& rhs);
446 }}} // Tizen::Ui::Controls
448 #endif // _FUI_CTRL_DATE_TIME_PICKER_H_