elementary/datetime - elm_datetime - Open source patch : Separator parsing logic...
[framework/uifw/elementary.git] / src / lib / elm_clock.h
1 /**
2  * @defgroup Clock Clock
3  *
4  * @image html img/widget/clock/preview-00.png
5  * @image latex img/widget/clock/preview-00.eps
6  *
7  * This is a @b digital clock widget. In its default theme, it has a
8  * vintage "flipping numbers clock" appearance, which will animate
9  * sheets of individual algarisms individually as time goes by.
10  *
11  * A newly created clock will fetch system's time (already
12  * considering local time adjustments) to start with, and will tick
13  * accordingly. It may or may not show seconds.
14  *
15  * Clocks have an @b edition  mode. When in it, the sheets will
16  * display extra arrow indications on the top and bottom and the
17  * user may click on them to raise or lower the time values. After
18  * it's told to exit edition mode, it will keep ticking with that
19  * new time set (it keeps the difference from local time).
20  *
21  * Also, when under edition mode, user clicks on the cited arrows
22  * which are @b held for some time will make the clock to flip the
23  * sheet, thus editing the time, continuously and automatically for
24  * the user. The interval between sheet flips will keep growing in
25  * time, so that it helps the user to reach a time which is distant
26  * from the one set.
27  *
28  * The time display is, by default, in military mode (24h), but an
29  * am/pm indicator may be optionally shown, too, when it will
30  * switch to 12h.
31  *
32  * Smart callbacks one can register to:
33  * - "changed" - the clock's user changed the time
34  *
35  * Supported elm_object common APIs.
36  * @li elm_object_signal_emit
37  * @li elm_object_signal_callback_add
38  * @li elm_object_signal_callback_del
39  *
40  * Here is an example on its usage:
41  * @li @ref clock_example
42  */
43
44 /**
45  * @addtogroup Clock
46  * @{
47  */
48
49 /**
50  * Identifiers for which clock digits should be editable, when a
51  * clock widget is in edition mode. Values may be OR-ed together to
52  * make a mask, naturally.
53  *
54  * @see elm_clock_edit_set()
55  * @see elm_clock_edit_mode_set()
56  */
57 typedef enum
58 {
59    ELM_CLOCK_EDIT_DEFAULT = 0, /**< Default value. Means that all digits are editable, when in edition mode. */
60    ELM_CLOCK_EDIT_HOUR_DECIMAL = 1 << 0, /**< Decimal algarism of hours value should be editable */
61    ELM_CLOCK_EDIT_HOUR_UNIT = 1 << 1, /**< Unit algarism of hours value should be editable */
62    ELM_CLOCK_EDIT_MIN_DECIMAL = 1 << 2, /**< Decimal algarism of minutes value should be editable */
63    ELM_CLOCK_EDIT_MIN_UNIT = 1 << 3, /**< Unit algarism of minutes value should be editable */
64    ELM_CLOCK_EDIT_SEC_DECIMAL = 1 << 4, /**< Decimal algarism of seconds value should be editable */
65    ELM_CLOCK_EDIT_SEC_UNIT = 1 << 5, /**< Unit algarism of seconds value should be editable */
66    ELM_CLOCK_EDIT_ALL = (1 << 6) - 1 /**< All digits should be editable */
67 } Elm_Clock_Edit_Mode;
68
69 /**
70  * Add a new clock widget to the given parent Elementary
71  * (container) object
72  *
73  * @param parent The parent object
74  * @return a new clock widget handle or @c NULL, on errors
75  *
76  * This function inserts a new clock widget on the canvas.
77  *
78  * @ingroup Clock
79  */
80 EAPI Evas_Object      *elm_clock_add(Evas_Object *parent);
81
82 /**
83  * Set a clock widget's time, programmatically
84  *
85  * @param obj The clock widget object
86  * @param hrs The hours to set
87  * @param min The minutes to set
88  * @param sec The seconds to set
89  *
90  * This function updates the time that is showed by the clock
91  * widget.
92  *
93  *  Values @b must be set within the following ranges:
94  * - 0 - 23, for hours
95  * - 0 - 59, for minutes
96  * - 0 - 59, for seconds,
97  *
98  * even if the clock is not in "military" mode.
99  *
100  * @warning The behavior for values set out of those ranges is @b
101  * undefined.
102  *
103  * @ingroup Clock
104  */
105 EAPI void              elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec);
106
107 /**
108  * Get a clock widget's time values
109  *
110  * @param obj The clock object
111  * @param[out] hrs Pointer to the variable to get the hours value
112  * @param[out] min Pointer to the variable to get the minutes value
113  * @param[out] sec Pointer to the variable to get the seconds value
114  *
115  * This function gets the time set for @p obj, returning
116  * it on the variables passed as the arguments to function
117  *
118  * @note Use @c NULL pointers on the time values you're not
119  * interested in: they'll be ignored by the function.
120  *
121  * @ingroup Clock
122  */
123 EAPI void              elm_clock_time_get(const Evas_Object *obj, int *hrs, int *min, int *sec);
124
125 /**
126  * Set whether a given clock widget is under <b>edition mode</b> or
127  * under (default) displaying-only mode.
128  *
129  * @param obj The clock object
130  * @param edit @c EINA_TRUE to put it in edition, @c EINA_FALSE to
131  * put it back to "displaying only" mode
132  *
133  * This function makes a clock's time to be editable or not <b>by
134  * user interaction</b>. When in edition mode, clocks @b stop
135  * ticking, until one brings them back to canonical mode. The
136  * elm_clock_edit_mode_set() function will influence which digits
137  * of the clock will be editable. By default, all of them will be
138  * (#ELM_CLOCK_NONE).
139  *
140  * @note am/pm sheets, if being shown, will @b always be editable
141  * under edition mode.
142  *
143  * @see elm_clock_edit_get()
144  *
145  * @ingroup Clock
146  */
147 EAPI void              elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit);
148
149 /**
150  * Retrieve whether a given clock widget is under editing mode
151  * or under (default) displaying-only mode.
152  *
153  * @param obj The clock object
154  * @return @c EINA_TRUE, if it's in edition mode, @c EINA_FALSE otherwise
155  *
156  * This function retrieves whether the clock's time can be edited
157  * or not by user interaction.
158  *
159  * @see elm_clock_edit_set() for more details
160  *
161  * @ingroup Clock
162  */
163 EAPI Eina_Bool         elm_clock_edit_get(const Evas_Object *obj);
164
165 /**
166  * Set what digits of the given clock widget should be editable
167  * when in edition mode.
168  *
169  * @param obj The clock object
170  * @param digedit Bit mask indicating the digits to be editable
171  * (values in #Elm_Clock_Edit_Mode).
172  *
173  * If the @p digedit param is #ELM_CLOCK_NONE, editing will be
174  * disabled on @p obj (same effect as elm_clock_edit_set(), with @c
175  * EINA_FALSE).
176  *
177  * @see elm_clock_edit_mode_get()
178  *
179  * @ingroup Clock
180  */
181 EAPI void              elm_clock_edit_mode_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit);
182
183 /**
184  * Retrieve what digits of the given clock widget should be
185  * editable when in edition mode.
186  *
187  * @param obj The clock object
188  * @return Bit mask indicating the digits to be editable
189  * (values in #Elm_Clock_Edit_Mode).
190  *
191  * @see elm_clock_edit_mode_set() for more details
192  *
193  * @ingroup Clock
194  */
195 EAPI Elm_Clock_Edit_Mode elm_clock_edit_mode_get(const Evas_Object *obj);
196
197 /**
198  * Set if the given clock widget must show hours in military or
199  * am/pm mode
200  *
201  * @param obj The clock object
202  * @param am_pm @c EINA_TRUE to put it in am/pm mode, @c EINA_FALSE
203  * to military mode
204  *
205  * This function sets if the clock must show hours in military or
206  * am/pm mode. In some countries like Brazil the military mode
207  * (00-24h-format) is used, in opposition to the USA, where the
208  * am/pm mode is more commonly used.
209  *
210  * @see elm_clock_show_am_pm_get()
211  *
212  * @ingroup Clock
213  */
214 EAPI void              elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm);
215
216 /**
217  * Get if the given clock widget shows hours in military or am/pm
218  * mode
219  *
220  * @param obj The clock object
221  * @return @c EINA_TRUE, if in am/pm mode, @c EINA_FALSE if in
222  * military
223  *
224  * This function gets if the clock shows hours in military or am/pm
225  * mode.
226  *
227  * @see elm_clock_show_am_pm_set() for more details
228  *
229  * @ingroup Clock
230  */
231 EAPI Eina_Bool         elm_clock_show_am_pm_get(const Evas_Object *obj);
232
233 /**
234  * Set if the given clock widget must show time with seconds or not
235  *
236  * @param obj The clock object
237  * @param seconds @c EINA_TRUE to show seconds, @c EINA_FALSE otherwise
238  *
239  * This function sets if the given clock must show or not elapsed
240  * seconds. By default, they are @b not shown.
241  *
242  * @see elm_clock_show_seconds_get()
243  *
244  * @ingroup Clock
245  */
246 EAPI void              elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds);
247
248 /**
249  * Get whether the given clock widget is showing time with seconds
250  * or not
251  *
252  * @param obj The clock object
253  * @return @c EINA_TRUE if it's showing seconds, @c EINA_FALSE otherwise
254  *
255  * This function gets whether @p obj is showing or not the elapsed
256  * seconds.
257  *
258  * @see elm_clock_show_seconds_set()
259  *
260  * @ingroup Clock
261  */
262 EAPI Eina_Bool         elm_clock_show_seconds_get(const Evas_Object *obj);
263
264 /**
265  * Set the first interval on time updates for a user mouse button hold
266  * on clock widgets' time edition.
267  *
268  * @param obj The clock object
269  * @param interval The first interval value in seconds
270  *
271  * This interval value is @b decreased while the user holds the
272  * mouse pointer either incrementing or decrementing a given the
273  * clock digit's value.
274  *
275  * This helps the user to get to a given time distant from the
276  * current one easier/faster, as it will start to flip quicker and
277  * quicker on mouse button holds.
278  *
279  * The calculation for the next flip interval value, starting from
280  * the one set with this call, is the previous interval divided by
281  * 1.05, so it decreases a little bit.
282  *
283  * The default starting interval value for automatic flips is
284  * @b 0.85 seconds.
285  *
286  * @see elm_clock_first_interval_get()
287  *
288  * @ingroup Clock
289  */
290 EAPI void              elm_clock_first_interval_set(Evas_Object *obj, double interval);
291
292 /**
293  * Get the first interval on time updates for a user mouse button hold
294  * on clock widgets' time edition.
295  *
296  * @param obj The clock object
297  * @return The first interval value, in seconds, set on it
298  *
299  * @see elm_clock_first_interval_set() for more details
300  *
301  * @ingroup Clock
302  */
303 EAPI double            elm_clock_first_interval_get(const Evas_Object *obj);
304
305 /**
306  * @}
307  */