Merge "[Password]: New design based changes, a new style removed password mode contro...
[framework/uifw/elementary.git] / src / lib / elm_clock.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 /**
5  * @defgroup Clock Clock
6  * @ingroup Elementary
7  *
8  * It's a widget to show clock with animation. The update of time is
9  * shown in an animation like the flip of a sheet.
10  *
11  * Signals that you can add callbacks for are:
12  *
13  * "changed" - the user changed the time
14  */
15
16 typedef struct _Widget_Data Widget_Data;
17
18 struct _Widget_Data
19 {
20    Evas_Object *clk;
21    double interval, first_interval;
22    Eina_Bool seconds : 1;
23    Eina_Bool am_pm : 1;
24    Eina_Bool edit : 1;
25    Elm_Clock_Digedit digedit;
26    int hrs, min, sec, timediff;
27    Evas_Object *digit[6];
28    Evas_Object *ampm;
29    Evas_Object *sel_obj;
30    Ecore_Timer *ticker, *spin;
31    struct
32    {
33       int hrs, min, sec;
34       char ampm;
35       Eina_Bool seconds : 1;
36       Eina_Bool am_pm : 1;
37       Eina_Bool edit : 1;
38       Elm_Clock_Digedit digedit;
39    } cur;
40 };
41
42 static const char *widtype = NULL;
43 static void _del_hook(Evas_Object *obj);
44 static void _theme_hook(Evas_Object *obj);
45 static void _on_focus_hook(void *data, Evas_Object *obj);
46 static Eina_Bool _ticker(void *data);
47 static Eina_Bool _signal_clock_val_up(void *data);
48 static Eina_Bool _signal_clock_val_down(void *data);
49 static void _time_update(Evas_Object *obj);
50
51 static void
52 _del_hook(Evas_Object *obj)
53 {
54    Widget_Data *wd = elm_widget_data_get(obj);
55    if (!wd) return;
56    int i;
57    for (i = 0; i < 6; i++)
58      {
59         if (wd->digit[i]) evas_object_del(wd->digit[i]);
60      }
61    if (wd->ampm) evas_object_del(wd->ampm);
62    if (wd->ticker) ecore_timer_del(wd->ticker);
63    if (wd->spin) ecore_timer_del(wd->spin);
64    free(wd);
65 }
66
67 static void
68 _theme_hook(Evas_Object *obj)
69 {
70    Widget_Data *wd = elm_widget_data_get(obj);
71    if (!wd) return;
72    if (elm_widget_focus_get(obj))
73      edje_object_signal_emit(wd->clk, "elm,action,focus", "elm");
74    else
75      edje_object_signal_emit(wd->clk, "elm,action,unfocus", "elm");
76    wd->cur.am_pm = !wd->cur.am_pm; /* hack - force update */
77    _time_update(obj);
78 }
79
80 static void
81 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
82 {
83    Widget_Data *wd = elm_widget_data_get(obj);
84    if (!wd) return;
85    if (elm_widget_focus_get(obj))
86      {
87         edje_object_signal_emit(wd->clk, "elm,action,focus", "elm");
88         evas_object_focus_set(wd->clk, EINA_TRUE);
89      }
90    else
91      {
92         edje_object_signal_emit(wd->clk, "elm,action,unfocus", "elm");
93         evas_object_focus_set(wd->clk, EINA_FALSE);
94      }
95 }
96
97 static void
98 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
99 {
100    Widget_Data *wd = elm_widget_data_get(obj);
101    int i;
102    if (!wd) return;
103    edje_object_signal_emit(wd->clk, emission, source);
104    for (i = 0; i < 6; i++)
105      {
106         if (wd->digit[i])
107           edje_object_signal_emit(wd->digit[i], emission, source);
108      }
109 }
110
111 static void
112 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
113 {
114    Widget_Data *wd = elm_widget_data_get(obj);
115    int i;
116    if (!wd) return;
117    edje_object_signal_callback_add(wd->clk, emission, source, func_cb, data);
118    for (i = 0; i < 6; i++)
119      {
120         if (wd->digit[i])
121           edje_object_signal_callback_add(wd->digit[i], emission, source,
122                                           func_cb, data);
123      }
124 }
125
126 static void
127 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
128 {
129    Widget_Data *wd = elm_widget_data_get(obj);
130    int i;
131    for (i = 0; i < 6; i++)
132      {
133         edje_object_signal_callback_del_full(wd->digit[i], emission, source,
134                                              func_cb, data);
135      }
136    edje_object_signal_callback_del_full(wd->clk, emission, source, func_cb,
137                                         data);
138 }
139
140 static void
141 _timediff_set(Widget_Data *wd)
142 {
143    struct timeval timev;
144    struct tm *tm;
145    time_t tt;
146    gettimeofday(&timev, NULL);
147    tt = (time_t)(timev.tv_sec);
148    tzset();
149    tm = localtime(&tt);
150    wd->timediff = (((wd->hrs - tm->tm_hour) * 60 +
151                     wd->min - tm->tm_min) * 60) + wd->sec - tm->tm_sec;
152 }
153
154 static Eina_Bool
155 _ticker(void *data)
156 {
157    Widget_Data *wd = elm_widget_data_get(data);
158    double t;
159    struct timeval timev;
160    struct tm *tm;
161    time_t tt;
162    if (!wd) return ECORE_CALLBACK_CANCEL;
163    gettimeofday(&timev, NULL);
164    t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
165    wd->ticker = ecore_timer_add(t, _ticker, data);
166    if (!wd->edit)
167      {
168         tt = (time_t)(timev.tv_sec) + wd->timediff;
169         tzset();
170         tm = localtime(&tt);
171         if (tm)
172           {
173              wd->hrs = tm->tm_hour;
174              wd->min = tm->tm_min;
175              wd->sec = tm->tm_sec;
176              _time_update(data);
177           }
178      }
179    return ECORE_CALLBACK_CANCEL;
180 }
181
182 static Eina_Bool
183 _signal_clock_val_up(void *data)
184 {
185    Widget_Data *wd = elm_widget_data_get(data);
186    if (!wd) goto clock_val_up_exit_on_error;
187    if (!wd->edit) goto clock_val_up_cancel;
188    if (!wd->sel_obj) goto clock_val_up_cancel;
189    if (wd->sel_obj == wd->digit[0])
190      {
191         wd->hrs = wd->hrs + 10;
192         if (wd->hrs >= 24) wd->hrs -= 24;
193      }
194    if (wd->sel_obj == wd->digit[1])
195      {
196         wd->hrs = wd->hrs + 1;
197         if (wd->hrs >= 24) wd->hrs -= 24;
198      }
199    if (wd->sel_obj == wd->digit[2])
200      {
201         wd->min = wd->min + 10;
202         if (wd->min >= 60) wd->min -= 60;
203      }
204    if (wd->sel_obj == wd->digit[3])
205      {
206         wd->min = wd->min + 1;
207         if (wd->min >= 60) wd->min -= 60;
208      }
209    if (wd->sel_obj == wd->digit[4])
210      {
211         wd->sec = wd->sec + 10;
212         if (wd->sec >= 60) wd->sec -= 60;
213      }
214    if (wd->sel_obj == wd->digit[5])
215      {
216         wd->sec = wd->sec + 1;
217         if (wd->sec >= 60) wd->sec -= 60;
218      }
219    if (wd->sel_obj == wd->ampm)
220      {
221         wd->hrs = wd->hrs + 12;
222         if (wd->hrs > 23) wd->hrs -= 24;
223      }
224    wd->interval = wd->interval / 1.05;
225    ecore_timer_interval_set(wd->spin, wd->interval);
226    _time_update(data);
227    evas_object_smart_callback_call(data, "changed", NULL);
228    return ECORE_CALLBACK_RENEW;
229 clock_val_up_cancel:
230    wd->spin = NULL;
231 clock_val_up_exit_on_error:
232    return ECORE_CALLBACK_CANCEL;
233 }
234
235 static Eina_Bool
236 _signal_clock_val_down(void *data)
237 {
238    Widget_Data *wd = elm_widget_data_get(data);
239    if (!wd) goto clock_val_down_exit_on_error;
240    if (!wd->edit) goto clock_val_down_cancel;
241    if (!wd->sel_obj) goto clock_val_down_cancel;
242    if (wd->sel_obj == wd->digit[0])
243      {
244         wd->hrs = wd->hrs - 10;
245         if (wd->hrs < 0) wd->hrs += 24;
246      }
247    if (wd->sel_obj == wd->digit[1])
248      {
249         wd->hrs = wd->hrs - 1;
250         if (wd->hrs < 0) wd->hrs += 24;
251      }
252    if (wd->sel_obj == wd->digit[2])
253      {
254         wd->min = wd->min - 10;
255         if (wd->min < 0) wd->min += 60;
256      }
257    if (wd->sel_obj == wd->digit[3])
258      {
259         wd->min = wd->min - 1;
260         if (wd->min < 0) wd->min += 60;
261      }
262    if (wd->sel_obj == wd->digit[4])
263      {
264         wd->sec = wd->sec - 10;
265         if (wd->sec < 0) wd->sec += 60;
266      }
267    if (wd->sel_obj == wd->digit[5])
268      {
269         wd->sec = wd->sec - 1;
270         if (wd->sec < 0) wd->sec += 60;
271      }
272    if (wd->sel_obj == wd->ampm)
273      {
274         wd->hrs = wd->hrs - 12;
275         if (wd->hrs < 0) wd->hrs += 24;
276      }
277    wd->interval = wd->interval / 1.05;
278    ecore_timer_interval_set(wd->spin, wd->interval);
279    _time_update(data);
280    evas_object_smart_callback_call(data, "changed", NULL);
281    return ECORE_CALLBACK_RENEW;
282 clock_val_down_cancel:
283    wd->spin = NULL;
284 clock_val_down_exit_on_error:
285    return ECORE_CALLBACK_CANCEL;
286 }
287
288 static void
289 _signal_clock_val_up_start(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
290 {
291    Widget_Data *wd = elm_widget_data_get(data);
292    if (!wd) return;
293    wd->interval = wd->first_interval;
294    wd->sel_obj = obj;
295    if (wd->spin) ecore_timer_del(wd->spin);
296    wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_up, data);
297    _signal_clock_val_up(data);
298 }
299
300 static void
301 _signal_clock_val_down_start(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
302 {
303    Widget_Data *wd = elm_widget_data_get(data);
304    if (!wd) return;
305    wd->interval = wd->first_interval;
306    wd->sel_obj = obj;
307    if (wd->spin) ecore_timer_del(wd->spin);
308    wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_down, data);
309    _signal_clock_val_down(data);
310 }
311
312 static void
313 _signal_clock_val_change_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
314 {
315    Widget_Data *wd = elm_widget_data_get(data);
316    if (!wd) return;
317    if (wd->spin) ecore_timer_del(wd->spin);
318    wd->spin = NULL;
319    wd->sel_obj = NULL;
320 }
321
322 static void
323 _time_update(Evas_Object *obj)
324 {
325    Widget_Data *wd = elm_widget_data_get(obj);
326    Edje_Message_Int msg;
327    int ampm = 0;
328    const char *style = elm_widget_style_get(obj);
329    if (!wd) return;
330    if ((wd->cur.seconds != wd->seconds) || (wd->cur.am_pm != wd->am_pm) ||
331        (wd->cur.edit != wd->edit) || (wd->cur.digedit != wd->digedit))
332      {
333         int i;
334         Evas_Coord mw, mh;
335
336         for (i = 0; i < 6; i++)
337           {
338              if (wd->digit[i])
339                {
340                   evas_object_del(wd->digit[i]);
341                   wd->digit[i] = NULL;
342                }
343           }
344         if (wd->ampm)
345           {
346              evas_object_del(wd->ampm);
347              wd->ampm = NULL;
348           }
349
350         if ((wd->seconds) && (wd->am_pm))
351           _elm_theme_object_set(obj, wd->clk, "clock", "base-all", style);
352         else if (wd->seconds)
353           _elm_theme_object_set(obj, wd->clk, "clock", "base-seconds", style);
354         else if (wd->am_pm)
355           _elm_theme_object_set(obj, wd->clk, "clock", "base-am_pm", style);
356         else
357           _elm_theme_object_set(obj, wd->clk, "clock", "base", style);
358         edje_object_scale_set(wd->clk, elm_widget_scale_get(obj) *
359                               _elm_config->scale);
360
361         for (i = 0; i < 6; i++)
362           {
363              char buf[16];
364
365              if ((!wd->seconds) && (i >= 4)) break;
366              wd->digit[i] = edje_object_add(evas_object_evas_get(wd->clk));
367              _elm_theme_object_set(obj, wd->digit[i], "clock", "flipdigit", style);
368              edje_object_scale_set(wd->digit[i], elm_widget_scale_get(obj) *
369                                    _elm_config->scale);
370              if ((wd->edit) && (wd->digedit & (1 << i)))
371                edje_object_signal_emit(wd->digit[i], "elm,state,edit,on", "elm");
372              edje_object_signal_callback_add(wd->digit[i], "elm,action,up,start",
373                                              "", _signal_clock_val_up_start, obj);
374              edje_object_signal_callback_add(wd->digit[i], "elm,action,up,stop",
375                                              "", _signal_clock_val_change_stop, obj);
376              edje_object_signal_callback_add(wd->digit[i], "elm,action,down,start",
377                                              "", _signal_clock_val_down_start, obj);
378              edje_object_signal_callback_add(wd->digit[i], "elm,action,down,stop",
379                                              "", _signal_clock_val_change_stop, obj);
380              mw = mh = -1;
381              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
382              edje_object_size_min_restricted_calc(wd->digit[i], &mw, &mh, mw, mh);
383              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
384              edje_extern_object_min_size_set(wd->digit[i], mw, mh);
385              snprintf(buf, sizeof(buf), "d%i", i);
386              edje_object_part_swallow(wd->clk , buf, wd->digit[i]);
387              evas_object_show(wd->digit[i]);
388           }
389         if (wd->am_pm)
390           {
391              wd->ampm = edje_object_add(evas_object_evas_get(wd->clk));
392              _elm_theme_object_set(obj, wd->ampm, "clock", "flipampm", style);
393              edje_object_scale_set(wd->ampm, elm_widget_scale_get(obj) *
394                                    _elm_config->scale);
395              if (wd->edit)
396                edje_object_signal_emit(wd->ampm, "elm,state,edit,on", "elm");
397              edje_object_signal_callback_add(wd->ampm, "elm,action,up,start",
398                                              "", _signal_clock_val_up_start, obj);
399              edje_object_signal_callback_add(wd->ampm, "elm,action,up,stop",
400                                              "", _signal_clock_val_change_stop, obj);
401              edje_object_signal_callback_add(wd->ampm, "elm,action,down,start",
402                                              "", _signal_clock_val_down_start, obj);
403              edje_object_signal_callback_add(wd->ampm, "elm,action,down,stop",
404                                              "", _signal_clock_val_change_stop, obj);
405              mw = mh = -1;
406              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
407              edje_object_size_min_restricted_calc(wd->ampm, &mw, &mh, mw, mh);
408              elm_coords_finger_size_adjust(1, &mw, 2, &mh);
409              edje_extern_object_min_size_set(wd->ampm, mw, mh);
410              edje_object_part_swallow(wd->clk , "ampm", wd->ampm);
411              evas_object_show(wd->ampm);
412           }
413
414         edje_object_size_min_calc(wd->clk, &mw, &mh);
415         evas_object_size_hint_min_set(obj, mw, mh);
416
417         wd->cur.hrs = 0;
418         wd->cur.min = 0;
419         wd->cur.sec = 0;
420         wd->cur.ampm = -1;
421         wd->cur.seconds = wd->seconds;
422         wd->cur.am_pm = wd->am_pm;
423         wd->cur.edit = wd->edit;
424         wd->cur.digedit = wd->digedit;
425      }
426    if (wd->hrs != wd->cur.hrs)
427      {
428         int hrs;
429         int d1, d2, dc1, dc2;
430
431         hrs = wd->hrs;
432         if (wd->am_pm)
433           {
434              if (hrs >= 12)
435                {
436                   if (hrs > 12) hrs -= 12;
437                   ampm = 1;
438                }
439              else if (!hrs) hrs = 12;
440           }
441         d1 = hrs / 10;
442         d2 = hrs % 10;
443         dc1 = wd->cur.hrs / 10;
444         dc2 = wd->cur.hrs % 10;
445         if (d1 != dc1)
446           {
447              msg.val = d1;
448              edje_object_message_send(wd->digit[0], EDJE_MESSAGE_INT, 1, &msg);
449           }
450         if (d2 != dc2)
451           {
452              msg.val = d2;
453              edje_object_message_send(wd->digit[1], EDJE_MESSAGE_INT, 1, &msg);
454           }
455         wd->cur.hrs = hrs;
456      }
457    if (wd->min != wd->cur.min)
458      {
459         int d1, d2, dc1, dc2;
460
461         d1 = wd->min / 10;
462         d2 = wd->min % 10;
463         dc1 = wd->cur.min / 10;
464         dc2 = wd->cur.min % 10;
465         if (d1 != dc1)
466           {
467              msg.val = d1;
468              edje_object_message_send(wd->digit[2], EDJE_MESSAGE_INT, 1, &msg);
469           }
470         if (d2 != dc2)
471           {
472              msg.val = d2;
473              edje_object_message_send(wd->digit[3], EDJE_MESSAGE_INT, 1, &msg);
474           }
475         wd->cur.min = wd->min;
476      }
477    if (wd->seconds)
478      {
479         if (wd->sec != wd->cur.sec)
480           {
481              int d1, d2, dc1, dc2;
482
483              d1 = wd->sec / 10;
484              d2 = wd->sec % 10;
485              dc1 = wd->cur.sec / 10;
486              dc2 = wd->cur.sec % 10;
487              if (d1 != dc1)
488                {
489                   msg.val = d1;
490                   edje_object_message_send(wd->digit[4], EDJE_MESSAGE_INT, 1, &msg);
491                }
492              if (d2 != dc2)
493                {
494                   msg.val = d2;
495                   edje_object_message_send(wd->digit[5], EDJE_MESSAGE_INT, 1, &msg);
496                }
497              wd->cur.sec = wd->sec;
498           }
499      }
500    else
501      wd->cur.sec = -1;
502
503    if (wd->am_pm)
504      {
505         if (wd->hrs >= 12) ampm = 1;
506         if (ampm != wd->cur.ampm)
507           {
508              if (wd->cur.ampm != ampm)
509                {
510                   msg.val = ampm;
511                   edje_object_message_send(wd->ampm, EDJE_MESSAGE_INT, 1, &msg);
512                }
513              wd->cur.ampm = ampm;
514           }
515      }
516    else
517      wd->cur.ampm = -1;
518 }
519
520 /**
521  * Add a new clock to the parent
522  *
523  * @param parent The parent object
524  *
525  * This function inserts a clock widget on a given canvas to show a
526  * animated clock.
527  *
528  * @ingroup Clock
529  */
530 EAPI Evas_Object *
531 elm_clock_add(Evas_Object *parent)
532 {
533    Evas_Object *obj;
534    Evas *e;
535    Widget_Data *wd;
536
537    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
538
539    ELM_SET_WIDTYPE(widtype, "clock");
540    elm_widget_type_set(obj, "clock");
541    elm_widget_sub_object_add(parent, obj);
542    elm_widget_data_set(obj, wd);
543    elm_widget_del_hook_set(obj, _del_hook);
544    elm_widget_theme_hook_set(obj, _theme_hook);
545    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
546    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
547    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
548    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
549    elm_widget_can_focus_set(obj, EINA_TRUE);
550
551    wd->clk = edje_object_add(e);
552    elm_widget_resize_object_set(obj, wd->clk);
553
554    wd->cur.ampm = -1;
555    wd->cur.seconds = EINA_TRUE;
556    wd->cur.am_pm = EINA_TRUE;
557    wd->cur.edit = EINA_TRUE;
558    wd->cur.digedit = ELM_CLOCK_NONE;
559    wd->first_interval = 0.85;
560    wd->timediff = 0;
561
562    _time_update(obj);
563    _ticker(obj);
564
565    return obj;
566 }
567
568 /**
569  * Set the clock time
570  *
571  * @param obj The clock object
572  * @param hrs The hours to set
573  * @param min The minutes to set
574  * @param sec The secondes to set
575  *
576  * This function updates the time that is showed by the clock widget
577  *
578  * @ingroup Clock
579  */
580 EAPI void
581 elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec)
582 {
583    ELM_CHECK_WIDTYPE(obj, widtype);
584    Widget_Data *wd = elm_widget_data_get(obj);
585    if (!wd) return;
586    wd->hrs = hrs;
587    wd->min = min;
588    wd->sec = sec;
589    _timediff_set(wd);
590    _time_update(obj);
591 }
592
593 /**
594  * Get clock time
595  *
596  * @param obj The clock object
597  * @param hrs Pointer to the variable to get the hour of this clock
598  * object
599  * @param min Pointer to the variable to get the minute of this clock
600  * object
601  * @param sec Pointer to the variable to get the second of this clock
602  * object
603  *
604  * This function gets the time set of the clock widget and returns it
605  * on the variables passed as the arguments to function
606  *
607  * @ingroup Clock
608  */
609 EAPI void
610 elm_clock_time_get(const Evas_Object *obj, int *hrs, int *min, int *sec)
611 {
612    ELM_CHECK_WIDTYPE(obj, widtype);
613    Widget_Data *wd = elm_widget_data_get(obj);
614    if (!wd) return;
615    if (hrs) *hrs = wd->hrs;
616    if (min) *min = wd->min;
617    if (sec) *sec = wd->sec;
618 }
619
620 /**
621  * Set if the clock settings can be edited
622  *
623  * @param obj The clock object
624  * @param edit Bool option for edited (1 = yes, 0 = no)
625  *
626  * This function sets if the clock settings can be edited or not.
627  * By default or if digit_edit option was previously set to ELM_CLOCK_NONE,
628  * all digits are editable. To choose what digits to make editable
629  * use elm_clock_digit_edit_set().
630  *
631  * @ingroup Clock
632  */
633 EAPI void
634 elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit)
635 {
636    ELM_CHECK_WIDTYPE(obj, widtype);
637    Widget_Data *wd = elm_widget_data_get(obj);
638    if (!wd) return;
639    wd->edit = edit;
640    if (!edit)
641      _timediff_set(wd);
642    if ((edit) && (wd->digedit == ELM_CLOCK_NONE))
643      elm_clock_digit_edit_set(obj, ELM_CLOCK_ALL);
644    else
645      _time_update(obj);
646 }
647
648 /**
649  * Get if the clock settings can be edited
650  *
651  * @param obj The clock object
652  * @return Bool option for edited (1 = yes, 0 = no)
653  *
654  * This function gets if the clock settings can be edited or not.
655  *
656  * @ingroup Clock
657  */
658 EAPI Eina_Bool
659 elm_clock_edit_get(const Evas_Object *obj)
660 {
661    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
662    Widget_Data *wd = elm_widget_data_get(obj);
663    if (!wd) return EINA_FALSE;
664    return wd->edit;
665 }
666
667 /**
668  * Set what digits of the clock are editable
669  *
670  * @param obj The clock object
671  * @param digedit Bit mask indicating the digits to edit
672  *
673  * If the digedit param is ELM_CLOCK_NONE, editing will be disabled.
674  *
675  * @ingroup Clock
676  */
677 EAPI void
678 elm_clock_digit_edit_set(Evas_Object *obj, Elm_Clock_Digedit digedit)
679 {
680    ELM_CHECK_WIDTYPE(obj, widtype);
681    Widget_Data *wd = elm_widget_data_get(obj);
682    if (!wd) return;
683    wd->digedit = digedit;
684    if (digedit == ELM_CLOCK_NONE)
685      elm_clock_edit_set(obj, EINA_FALSE);
686    else
687      _time_update(obj);
688 }
689
690 /**
691  * Get what digits of the clock are editable
692  *
693  * @param obj The clock object
694  * @return Bit mask indicating the digits.
695  *
696  * @ingroup Clock
697  */
698 EAPI Elm_Clock_Digedit
699 elm_clock_digit_edit_get(const Evas_Object *obj)
700 {
701    ELM_CHECK_WIDTYPE(obj, widtype) 0;
702    Widget_Data *wd = elm_widget_data_get(obj);
703    if (!wd) return 0;
704    return wd->digedit;
705 }
706
707 /**
708  * Set if the clock shows hours in military or am/pm mode
709  *
710  * @param obj The clock object
711  * @param am_pm Bool option for the hours mode
712  * (1 = am/pm, 0 = military)
713  *
714  * This function sets the clock to show hours in military or am/pm
715  * mode. Some countries like Brazil the military mode (00-24h-format)
716  * is used in opposition to the USA where the am/pm mode is more
717  * common used.
718  *
719  * @ingroup Clock
720  */
721 EAPI void
722 elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm)
723 {
724    ELM_CHECK_WIDTYPE(obj, widtype);
725    Widget_Data *wd = elm_widget_data_get(obj);
726    if (!wd) return;
727    wd->am_pm = am_pm;
728    _time_update(obj);
729 }
730
731 /**
732  * Get if the clock shows hours in military or am/pm mode
733  *
734  * @param obj The clock object
735  * @return Bool option for the hours mode
736  * (1 = am/pm, 0 = military)
737  *
738  * This function gets if the clock show hours in military or am/pm
739  * mode. Some countries like Brazil the military mode (00-24h-format)
740  * is used in opposition to the USA where the am/pm mode is more
741  * common used.
742  *
743  * @ingroup Clock
744  */
745 EAPI Eina_Bool
746 elm_clock_show_am_pm_get(const Evas_Object *obj)
747 {
748    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
749    Widget_Data *wd = elm_widget_data_get(obj);
750    if (!wd) return EINA_FALSE;
751    return wd->am_pm;
752 }
753
754 /**
755  * Set if the clock shows hour with the seconds
756  *
757  * @param obj The clock object
758  * @param seconds Bool option for the show seconds
759  * (1 = show seconds, 0 = not show seconds)
760  *
761  * This function sets the clock to show or not to show the elapsed
762  * seconds.
763  *
764  * @ingroup Clock
765  */
766 EAPI void
767 elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds)
768 {
769    ELM_CHECK_WIDTYPE(obj, widtype);
770    Widget_Data *wd = elm_widget_data_get(obj);
771    if (!wd) return;
772    wd->seconds = seconds;
773    _time_update(obj);
774 }
775
776 /**
777  * Get if the clock shows hour with the seconds
778  *
779  * @param obj The clock object
780  * @return Bool option for the show seconds
781  * (1 = show seconds, 0 = not show seconds)
782  *
783  * This function gets if the clock show or not show the elapsed
784  * seconds.
785  *
786  * @ingroup Clock
787  */
788 EAPI Eina_Bool
789 elm_clock_show_seconds_get(const Evas_Object *obj)
790 {
791    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
792    Widget_Data *wd = elm_widget_data_get(obj);
793    if (!wd) return EINA_FALSE;
794    return wd->seconds;
795 }
796
797 /**
798  * Set the interval for the clock
799  *
800  * @param obj The clock object
801  * @param interval The interval value in seconds
802  *
803  * The interval value is decreased while the user increments or decrements
804  * the clock value. The next interval value is the previous interval / 1.05,
805  * so it speed up a bit. Default value is 0.85 seconds.
806  *
807  * @ingroup Clock
808  */
809 EAPI void
810 elm_clock_interval_set(Evas_Object *obj, double interval)
811 {
812    ELM_CHECK_WIDTYPE(obj, widtype);
813    Widget_Data *wd = elm_widget_data_get(obj);
814    if (!wd) return;
815    wd->first_interval = interval;
816 }
817
818 /**
819  * Get the interval of the clock
820  *
821  * @param obj The clock object
822  * @return The value of the first interval in seconds
823  *
824  * The interval value is decreased while the user increments or decrements
825  * the clock value. The next interval value is the previous interval / 1.05,
826  * so it speed up a bit. Default value is 0.85 seconds.
827  *
828  * @ingroup Clock
829  */
830 EAPI double
831 elm_clock_interval_get(const Evas_Object *obj)
832 {
833    ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
834    Widget_Data *wd = elm_widget_data_get(obj);
835    if (!wd) return 0.0;
836    return wd->first_interval;
837 }