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 FUiCtrlTimePicker.h
20 * @brief This is the header file for the %TimePicker class.
22 * This header file contains the declarations of the %TimePicker class.
24 #ifndef _FUI_CTRL_TIME_PICKER_H_
25 #define _FUI_CTRL_TIME_PICKER_H_
27 #include <FUiWindow.h>
28 #include <FUiITimeChangeEventListener.h>
30 namespace Tizen { namespace Ui { namespace Controls
35 * @brief This class displays a %TimePicker control on top of the screen.
39 * The %TimePicker class displays a full screen window-based selector that allows the user to select a certain 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 DateTimeimePicker</a>.
43 * The following example demonstrates how to use the %TimePicker class.
46 // Sample Code for TimePickerSample.h
49 class TimePickerSample
50 : public Tizen::Ui::Controls::Form
51 , public Tizen::Ui::ITimeChangeEventListener
52 , public Tizen::Ui::IActionEventListener
55 TimePickerSample(void)
56 : __pTimePicker(null){}
58 bool Initialize(void);
59 void ShowTimePicker(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 // ITimeChangeEventListener
67 virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute);
68 virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source);
71 static const int ID_BUTTON = 101;
73 Tizen::Ui::Controls::TimePicker* __pTimePicker;
78 // Sample Code for TimePickerSample.cpp
79 #include <FGraphics.h>
81 #include "TimePickerSample.h"
83 using namespace Tizen::Graphics;
84 using namespace Tizen::Ui::Controls;
87 TimePickerSample::Initialize(void)
89 Construct(FORM_STYLE_NORMAL);
94 TimePickerSample::OnInitializing(void)
98 // Creates an instance of Button
99 Button* pButton = new Button();
100 pButton->Construct(Rectangle(50, 50, 300, 200), L"Show TimePicker");
101 pButton->SetActionId(ID_BUTTON);
102 pButton->AddActionEventListener(*this);
104 // Adds a Button to the Form
105 AddControl(*pButton);
107 // Creates an instance of TimePicker
108 __pTimePicker = new TimePicker();
109 __pTimePicker->Construct();
111 // Adds an instance of ITimeChangeEventListener
112 __pTimePicker->AddTimeChangeEventListener(*this);
114 // Show TimePicker after it's owner Form is shown.
120 TimePickerSample::ShowTimePicker(bool show)
122 // Change to desired show state
123 __pTimePicker->SetShowState(show);
125 //Call Show() of the control
128 __pTimePicker->Show();
130 // Call Invalidate() of the container
138 TimePickerSample::OnTerminating(void)
140 result r = E_SUCCESS;
142 // Deallocates the time picker
143 __pTimePicker->Destroy();
148 // IActionEventListener implementation
150 TimePickerSample::OnActionPerformed(const Control& source, int actionId)
155 ShowTimePicker(true);
164 // ITimeChangeEventListener implementation
166 TimePickerSample::OnTimeChanged(const Control& source, int hour, int minute)
172 TimePickerSample::OnTimeChangeCanceled(const Control& source)
178 class _OSP_EXPORT_ TimePicker
179 : public Tizen::Ui::Window
183 * 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.
190 * 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.
194 virtual ~TimePicker(void);
197 * Adds a time changed event listener instance.
201 * @param[in] listener The listener to add
202 * @see ITimeChangeEventListener::OnTimeChanged()
203 * @see ITimeChangeEventListener::OnTimeChangeCanceled()
204 * @see RemoveTimeChangeEventListener()
206 void AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
209 * Removes a listener instance. @n
210 * The removed listener cannot listen to events when they are fired.
214 * @param[in] listener The listener to remove
215 * @see AddTimeChangeEventListener()
217 void RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
220 * Initializes this instance of %TimePicker to the current date and time in wall time mode.
224 * @return An error code
225 * @param[in] title The title
226 * @exception E_SUCCESS The method is successful.
227 * @exception E_SYSTEM A system error has occurred.
229 result Construct(const Tizen::Base::String& title = L"");
232 * Gets the current hour value of the %TimePicker control. @n
233 * The hour value is between @c 0 to @c 23.
237 * @return The current hour value, @n
238 * else @c -1 if an error occurs
240 int GetHour(void) const;
243 * Gets the current minute value of the %TimePicker control. @n
244 * The minute value is between @c 0 to @c 59.
248 * @return The current minute value, @n
249 * else @c -1 if an error occurs
251 int GetMinute(void) const;
254 * Gets the current time value of the %TimePicker control.
258 * @return The time value
260 Tizen::Base::DateTime GetTime(void) const;
263 * Sets the 12H or 24H hour display type of the %TimePicker control.
267 * @param[in] enable Set to @c true to enable the 24 hour notation, @n
270 void Set24HourNotationEnabled(bool enable);
273 * Sets the hour value. @n
274 * The hour value should be between @c 0 and @c 23.
278 * @param[in] hour The hour value
279 * @exception E_SUCCESS The method is successful.
280 * @exception E_INVALID_ARG The specified @c hour value is invalid.
281 * @exception E_SYSTEM A system error has occurred.
283 result SetHour(int hour);
286 * Sets the minute value. @n
287 * The minute value should be between @c 0 and @c 59.
291 * @param[in] minute The minute value
292 * @exception E_SUCCESS The method is successful.
293 * @exception E_INVALID_ARG The specified @c minute value is invalid.
294 * @exception E_SYSTEM A system error has occurred.
296 result SetMinute(int minute);
299 * Sets the current time value of the %TimePicker control.
303 * @param[in] time The time to set
305 void SetTime(const Tizen::Base::DateTime& time);
308 * Sets the time value of the %TimePicker control with the current system time in the Coordinated Universal Time (UTC) mode.
312 void SetCurrentTime(void);
315 friend class _TimePickerImpl;
319 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
321 TimePicker(const TimePicker& rhs);
324 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
326 TimePicker& operator =(const TimePicker& rhs);
330 }}} // Tizen::Ui::Controls
332 #endif // _FUI_CTRL_TIME_PICKER_H_