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 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
42 * <a href="../org.tizen.native.appprogramming/html/guide/ui/implementing_datepicker.htm">DatePicker, TimePicker, and DateTimeimePicker</a>.
44 * The following example demonstrates how to use the %TimePicker class.
47 // Sample Code for TimePickerSample.h
50 class TimePickerSample
51 : public Tizen::Ui::Controls::Form
52 , public Tizen::Ui::ITimeChangeEventListener
53 , public Tizen::Ui::IActionEventListener
56 TimePickerSample(void)
57 : __pTimePicker(null){}
59 bool Initialize(void);
60 void ShowTimePicker(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 // ITimeChangeEventListener
68 virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute);
69 virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source);
72 static const int ID_BUTTON = 101;
74 Tizen::Ui::Controls::TimePicker* __pTimePicker;
79 // Sample Code for TimePickerSample.cpp
80 #include <FGraphics.h>
82 #include "TimePickerSample.h"
84 using namespace Tizen::Graphics;
85 using namespace Tizen::Ui::Controls;
88 TimePickerSample::Initialize(void)
90 Construct(FORM_STYLE_NORMAL);
95 TimePickerSample::OnInitializing(void)
99 // Creates an instance of Button
100 Button* pButton = new Button();
101 pButton->Construct(Rectangle(50, 50, 300, 200), L"Show TimePicker");
102 pButton->SetActionId(ID_BUTTON);
103 pButton->AddActionEventListener(*this);
105 // Adds a Button to the Form
108 // Creates an instance of TimePicker
109 __pTimePicker = new TimePicker();
110 __pTimePicker->Construct();
112 // Adds an instance of ITimeChangeEventListener
113 __pTimePicker->AddTimeChangeEventListener(*this);
115 // Show TimePicker after it's owner Form is shown.
121 TimePickerSample::ShowTimePicker(bool show)
123 // Change to desired show state
124 __pTimePicker->SetShowState(show);
126 //Call Show() of the control
129 __pTimePicker->Show();
131 // Call Invalidate() of the container
139 TimePickerSample::OnTerminating(void)
141 result r = E_SUCCESS;
143 // Deallocates the time picker
144 __pTimePicker->Destroy();
149 // IActionEventListener implementation
151 TimePickerSample::OnActionPerformed(const Control& source, int actionId)
156 ShowTimePicker(true);
165 // ITimeChangeEventListener implementation
167 TimePickerSample::OnTimeChanged(const Control& source, int hour, int minute)
173 TimePickerSample::OnTimeChangeCanceled(const Control& source)
179 class _OSP_EXPORT_ TimePicker
180 : public Tizen::Ui::Window
184 * The object is not fully constructed after this constructor is called. @n
185 * For full construction, the TimePicker::Construct() method must be called right after calling this constructor.
192 * This polymorphic destructor should be overridden if required.@n
193 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
197 virtual ~TimePicker(void);
200 * Adds a time changed event listener instance.
204 * @param[in] listener The listener to add
205 * @see ITimeChangeEventListener::OnTimeChanged()
206 * @see ITimeChangeEventListener::OnTimeChangeCanceled()
207 * @see RemoveTimeChangeEventListener()
209 void AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
212 * Removes a 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 AddTimeChangeEventListener()
220 void RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
223 * Initializes this instance of %TimePicker to the current date and time in wall time mode.
227 * @return An error code
228 * @param[in] title The title
229 * @exception E_SUCCESS The method is successful.
230 * @exception E_SYSTEM A system error has occurred.
231 * @remarks The default owner will be the current Form (or Frame). It is possible that this control may not be visible
232 * due to this ownership relationship. @n In this case, use the SetOwner() method to change the ownership to the top-most window. @n
233 * The optimal size of the control is defined in
234 * <a href="../org.tizen.native.appprogramming/html/guide/ui/control_optimalsize.htm">Optimal Size of UI Controls</a>.
236 result Construct(const Tizen::Base::String& title = L"");
239 * Gets the current hour value of the %TimePicker control. @n
240 * The hour value is between @c 0 to @c 23.
244 * @return The current hour value, @n
245 * else @c -1 if an error occurs
247 int GetHour(void) const;
250 * Gets the current minute value of the %TimePicker control. @n
251 * The minute value is between @c 0 to @c 59.
255 * @return The current minute value, @n
256 * else @c -1 if an error occurs
258 int GetMinute(void) const;
261 * Gets the current time value of the %TimePicker control.
265 * @return The time value
267 Tizen::Base::DateTime GetTime(void) const;
270 * Sets the 12H or 24H hour display type of the %TimePicker control.
274 * @param[in] enable Set to @c true to enable the 24 hour notation, @n
277 void Set24HourNotationEnabled(bool enable);
280 * Sets the hour value. @n
281 * The hour value should be between @c 0 and @c 23.
285 * @param[in] hour The hour value
286 * @exception E_SUCCESS The method is successful.
287 * @exception E_INVALID_ARG The specified @c hour value is invalid.
288 * @exception E_SYSTEM A system error has occurred.
290 result SetHour(int hour);
293 * Sets the minute value. @n
294 * The minute value should be between @c 0 and @c 59.
298 * @param[in] minute The minute value
299 * @exception E_SUCCESS The method is successful.
300 * @exception E_INVALID_ARG The specified @c minute value is invalid.
301 * @exception E_SYSTEM A system error has occurred.
303 result SetMinute(int minute);
306 * Sets the current time value of the %TimePicker control.
310 * @param[in] time The time to set
312 void SetTime(const Tizen::Base::DateTime& time);
315 * Sets the time value of the %TimePicker control with the current system time in the wall time mode.
319 void SetCurrentTime(void);
322 friend class _TimePickerImpl;
326 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
328 TimePicker(const TimePicker& rhs);
331 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
333 TimePicker& operator =(const TimePicker& rhs);
337 }}} // Tizen::Ui::Controls
339 #endif // _FUI_CTRL_TIME_PICKER_H_