Fix to adjust the position of the partial Frame
[platform/framework/native/uifw.git] / inc / FUiCtrlTimePicker.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19 * @file                 FUiCtrlTimePicker.h
20 * @brief        This is the header file for the %TimePicker class.
21 *
22 * This header file contains the declarations of the %TimePicker class.
23 */
24 #ifndef _FUI_CTRL_TIME_PICKER_H_
25 #define _FUI_CTRL_TIME_PICKER_H_
26
27 #include <FUiWindow.h>
28 #include <FUiITimeChangeEventListener.h>
29
30 namespace Tizen { namespace Ui { namespace Controls
31 {
32
33 /**
34 * @class        TimePicker
35 * @brief        This class displays a %TimePicker control on top of the screen.
36 *
37 * @since        2.0
38 *
39 * The %TimePicker class displays a full screen window-based selector that allows the user to select a certain time.
40 *
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>.
42 *
43 * The following example demonstrates how to use the %TimePicker class.
44 *
45 * @code
46 // Sample Code for TimePickerSample.h
47 #include <FUi.h>
48
49 class TimePickerSample
50         : public Tizen::Ui::Controls::Form
51         , public Tizen::Ui::ITimeChangeEventListener
52         , public Tizen::Ui::IActionEventListener
53 {
54 public:
55         TimePickerSample(void)
56         : __pTimePicker(null){}
57
58         bool Initialize(void);
59         void ShowTimePicker(bool show);
60         virtual result OnInitializing(void);
61         virtual result OnTerminating(void);
62
63         // IActionEventListener
64         virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
65
66         // ITimeChangeEventListener
67         virtual void OnTimeChanged(const Tizen::Ui::Control& source, int hour, int minute);
68         virtual void OnTimeChangeCanceled(const Tizen::Ui::Control& source);
69
70 private:
71         static const int ID_BUTTON  = 101;
72
73         Tizen::Ui::Controls::TimePicker* __pTimePicker;
74 };
75  *      @endcode
76  *
77  *      @code
78 // Sample Code for TimePickerSample.cpp
79 #include <FGraphics.h>
80
81 #include "TimePickerSample.h"
82
83 using namespace Tizen::Graphics;
84 using namespace Tizen::Ui::Controls;
85
86 bool
87 TimePickerSample::Initialize(void)
88 {
89         Construct(FORM_STYLE_NORMAL);
90         return true;
91 }
92
93 result
94 TimePickerSample::OnInitializing(void)
95 {
96         result r = E_SUCCESS;
97
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);
103
104         // Adds a Button to the Form
105         AddControl(*pButton);
106
107         // Creates an instance of TimePicker
108         __pTimePicker = new TimePicker();
109         __pTimePicker->Construct();
110
111         // Adds an instance of ITimeChangeEventListener
112         __pTimePicker->AddTimeChangeEventListener(*this);
113
114         // Show TimePicker after it's owner Form is shown.
115
116         return r;
117 }
118
119 void
120 TimePickerSample::ShowTimePicker(bool show)
121 {
122         // Change to desired show state
123         __pTimePicker->SetShowState(show);
124
125         //Call Show() of the control
126         if (show)
127         {
128                 __pTimePicker->Show();
129         }
130         // Call Invalidate() of the container
131         else
132         {
133                 Invalidate(true);
134         }
135 }
136
137 result
138 TimePickerSample::OnTerminating(void)
139 {
140         result r = E_SUCCESS;
141
142         // Deallocates the time picker
143         __pTimePicker->Destroy();
144
145         return r;
146 }
147
148 // IActionEventListener implementation
149 void
150 TimePickerSample::OnActionPerformed(const Control& source, int actionId)
151 {
152         switch (actionId)
153         {
154         case ID_BUTTON:
155                 ShowTimePicker(true);
156                 break;
157
158         default:
159                 break;
160         }
161 }
162
163
164 // ITimeChangeEventListener implementation
165 void
166 TimePickerSample::OnTimeChanged(const Control& source, int hour, int minute)
167 {
168         // Todo:
169 }
170
171 void
172 TimePickerSample::OnTimeChangeCanceled(const Control& source)
173 {
174         // Todo:
175 }
176 * @endcode
177 **/
178 class _OSP_EXPORT_ TimePicker
179         : public Tizen::Ui::Window
180 {
181 public:
182         /**
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.
184          *
185          * @since       2.0
186          */
187         TimePicker(void);
188
189         /**
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.
191          *
192          * @since       2.0
193          */
194         virtual ~TimePicker(void);
195
196         /**
197          * Adds a time changed event listener instance.
198          *
199          * @since               2.0
200          *
201          * @param[in]   listener        The listener to add
202          * @see                 ITimeChangeEventListener::OnTimeChanged()
203          * @see                 ITimeChangeEventListener::OnTimeChangeCanceled()
204          * @see                 RemoveTimeChangeEventListener()
205          */
206         void AddTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
207
208         /**
209          * Removes a listener instance. @n
210          * The removed listener cannot listen to events when they are fired.
211          *
212          * @since               2.0
213          *
214          * @param[in]   listener    The listener to remove
215          * @see                 AddTimeChangeEventListener()
216          */
217         void RemoveTimeChangeEventListener(Tizen::Ui::ITimeChangeEventListener& listener);
218
219         /**
220          * Initializes this instance of %TimePicker to the current date and time in wall time mode.
221          *
222          * @since               2.0
223          *
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.
228          */
229         result Construct(const Tizen::Base::String& title = L"");
230
231         /**
232          * Gets the current hour value of the %TimePicker control. @n
233          * The hour value is between @c 0 to @c 23.
234          *
235          * @since               2.0
236          *
237          * @return              The current hour value, @n
238          *                              else @c -1 if an error occurs
239          */
240         int GetHour(void) const;
241
242         /**
243          * Gets the current minute value of the %TimePicker control. @n
244          * The minute value is between @c 0 to @c 59.
245          *
246          * @since               2.0
247          *
248          * @return              The current minute value, @n
249          *                              else @c -1 if an error occurs
250          */
251         int GetMinute(void) const;
252
253         /**
254          * Gets the current time value of the %TimePicker control.
255          *
256          * @since               2.0
257          *
258          * @return              The time value
259          */
260         Tizen::Base::DateTime GetTime(void) const;
261
262         /**
263          * Sets the 12H or 24H hour display type of the %TimePicker control.
264          *
265          * @since               2.0
266          *
267          * @param[in]   enable          Set to @c true to enable the 24 hour notation, @n
268          *                                                      else @c false
269          */
270         void Set24HourNotationEnabled(bool enable);
271
272         /**
273          * Sets the hour value. @n
274          * The hour value should be between @c 0 and @c  23.
275          *
276          * @since               2.0
277          *
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.
282          */
283         result SetHour(int hour);
284
285         /**
286          * Sets the minute value. @n
287          * The minute value should be between @c 0 and @c 59.
288          *
289          * @since               2.0
290          *
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.
295          */
296         result SetMinute(int minute);
297
298         /**
299          * Sets the current time value of the %TimePicker control.
300          *
301          * @since               2.0
302          *
303          * @param[in]   time    The time to set
304          */
305         void SetTime(const Tizen::Base::DateTime& time);
306
307         /**
308          * Sets the time value of the %TimePicker control with the current system time in the Coordinated Universal Time (UTC) mode.
309          *
310          * @since               2.0
311          */
312         void SetCurrentTime(void);
313
314 protected:
315         friend class _TimePickerImpl;
316
317 private:
318         //
319         // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
320         //
321         TimePicker(const TimePicker& rhs);
322
323         //
324         // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
325         //
326         TimePicker& operator =(const TimePicker& rhs);
327
328 }; // TimePicker
329
330 }}} // Tizen::Ui::Controls
331
332 #endif // _FUI_CTRL_TIME_PICKER_H_