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.
18 * @file FUiCtrlTimePicker.h
19 * @brief This is the header file for the %TimePicker class.
21 * This header file contains the declarations of the %TimePicker class.
23 #ifndef _FUI_CTRL_TIME_PICKER_H_
24 #define _FUI_CTRL_TIME_PICKER_H_
26 #include <FUiWindow.h>
27 #include <FUiITimeChangeEventListener.h>
29 namespace Tizen { namespace Ui { namespace Controls
34 * @brief This class displays a %TimePicker control on top of the screen.
38 * The %TimePicker class displays a full screen window-based selector that allows the user to select a certain time.
40 * 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>.
42 * The following example demonstrates how to use the %TimePicker class.
45 // Sample Code for TimePickerSample.h
48 class TimePickerSample
49 : public Tizen::Ui::Controls::Form
50 , public Tizen::Ui::ITimeChangeEventListener
51 , public Tizen::Ui::IActionEventListener
54 TimePickerSample(void)
55 : __pTimePicker(null){}
57 bool Initialize(void);
58 void ShowTimePicker(bool show);
59 virtual result OnInitializing(void);
60 virtual result OnTerminating(void);
62 // IActionEventListener
63 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
65 // ITimeChangeEventListener
66 virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute);
67 virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source);
70 static const int ID_BUTTON = 101;
72 Tizen::Ui::Controls::TimePicker* __pTimePicker;
77 // Sample Code for TimePickerSample.cpp
78 #include <FGraphics.h>
80 #include "TimePickerSample.h"
82 using namespace Tizen::Graphics;
83 using namespace Tizen::Ui::Controls;
86 TimePickerSample::Initialize(void)
88 Construct(FORM_STYLE_NORMAL);
93 TimePickerSample::OnInitializing(void)
97 // Createa an instance of Button
98 Button* pButton = new Button();
99 pButton->Construct(Rectangle(50, 50, 300, 200), L"Show TimePicker");
100 pButton->SetActionId(ID_BUTTON);
101 pButton->AddActionEventListener(*this);
103 // Adda a Button to the Form
104 AddControl(*pButton);
106 // Creates an instanceo of TimePicker
107 __pTimePicker = new TimePicker();
108 __pTimePicker->Construct();
110 // Adds an instanceo of ITimeChangeEventListener
111 __pTimePicker->AddTimeChangeEventListener(*this);
113 // Show TimePicker after it's owner Form is shown.
119 TimePickerSample::ShowTimePicker(bool show)
121 // Change to desired show state
122 __pTimePicker->SetShowState(show);
124 //Call Show() of the control
127 __pTimePicker->Show();
129 // Call Invalidate() of the container
137 TimePickerSample::OnTerminating(void)
139 result r = E_SUCCESS;
141 // Deallocates the time picker
142 delete __pTimePicker;
147 // IActionEventListener implementation
149 TimePickerSample::OnActionPerformed(const Control& source, int actionId)
154 ShowTimePicker(true);
163 // ITimeChangeEventListener implementation
165 TimePickerSample::OnTimeChanged(const Control& source, int hour, int minute)
171 TimePickerSample::OnTimeChangeCanceled(const Control& source)
177 class _OSP_EXPORT_ TimePicker
178 : public Tizen::Ui::Window
182 * 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 * 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.
193 virtual ~TimePicker(void);
196 * Adds a time changed event listener instance.
200 * @param[in] listener The listener to be added
201 * @see ITimeChangeEventListener::OnTimeChanged()
202 * @see ITimeChangeEventListener::OnTimeChangeCanceled()
203 * @see RemoveTimeChangeEventListener()
205 void AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
208 * Removes a listener instance. @n
209 * The removed listener cannot listen to events when they are fired.
213 * @param[in] listener The listener to be removed
214 * @see AddTimeChangeEventListener()
216 void RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
219 * Initializes this instance of %TimePicker to the current date and time in wall time mode.
223 * @return An error code
224 * @param[in] title The title
225 * @exception E_SUCCESS The method is successful.
226 * @exception E_SYSTEM A system error has occurred.
228 result Construct(const Tizen::Base::String& title = L"");
231 * Gets the current hour value of the %TimePicker control. @n
232 * The hour value is between @c 0 to @c 23.
236 * @return The current hour value, @n
237 * else @c -1 if an error occurs
239 int GetHour(void) const;
242 * Gets the current minute value of the %TimePicker control. @n
243 * The minute value is between @c 0 to @c 59.
247 * @return The current minute value, @n
248 * else @c -1 if an error occurs
250 int GetMinute(void) const;
253 * Gets the current time value of the %TimePicker control.
257 * @return The time value
259 Tizen::Base::DateTime GetTime(void) const;
262 * Sets the 12H or 24H hour display type of the %TimePicker control.
266 * @param[in] enable Set to @c true to enable the 24 hour notation, @n
269 void Set24HourNotationEnabled(bool enable);
272 * Sets the hour value. @n
273 * The hour value should be between @c 0 and @c 23.
277 * @param[in] hour The hour value
278 * @exception E_SUCCESS The method is successful.
279 * @exception E_INVALID_ARG The specified @c hour value is invalid.
280 * @exception E_SYSTEM A system error has occurred.
282 result SetHour(int hour);
285 * Sets the minute value. @n
286 * The minute value should be between @c 0 and @c 59.
290 * @param[in] minute The minute value
291 * @exception E_SUCCESS The method is successful.
292 * @exception E_INVALID_ARG The specified @c minute value is invalid.
293 * @exception E_SYSTEM A system error has occurred.
295 result SetMinute(int minute);
298 * Sets the current time value of the %TimePicker control.
302 * @param[in] time The time to be set
304 void SetTime(const Tizen::Base::DateTime& time);
307 * Sets the time value of the %TimePicker control with the current system time in the Coordinated Universal Time (UTC) mode.
311 void SetCurrentTime(void);
314 friend class _TimePickerImpl;
318 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
320 TimePicker(const TimePicker& rhs);
323 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
325 TimePicker& operator =(const TimePicker& rhs);
329 }}} // Tizen::Ui::Controls
331 #endif // _FUI_CTRL_TIME_PICKER_H_