aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/elementary/src/lib/elm_clock.c
blob: 3bd0b2d2cbef207954317130365526748aed50fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
#include <Elementary.h>
#include "elm_priv.h"

#define DEFAULT_FIRST_INTERVAL 0.85
typedef struct _Widget_Data Widget_Data;

struct _Widget_Data
{
   Evas_Object *clk;
   double interval, first_interval;
   Eina_Bool seconds : 1;
   Eina_Bool am_pm : 1;
   Eina_Bool edit : 1;
   Elm_Clock_Edit_Mode digedit;
   int hrs, min, sec, timediff;
   Evas_Object *digit[6];
   Evas_Object *ampm;
   Evas_Object *sel_obj;
   Ecore_Timer *ticker, *spin;
   struct
   {
      int hrs, min, sec;
      char ampm;
      Eina_Bool seconds : 1;
      Eina_Bool am_pm : 1;
      Eina_Bool edit : 1;
      Elm_Clock_Edit_Mode digedit;
   } cur;
};

static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _on_focus_hook(void *data, Evas_Object *obj);
static Eina_Bool _ticker(void *data);
static Eina_Bool _signal_clock_val_up(void *data);
static Eina_Bool _signal_clock_val_down(void *data);
static void _time_update(Evas_Object *obj);

static const char SIG_CHANGED[] = "changed";

static const Evas_Smart_Cb_Description _signals[] = {
   {SIG_CHANGED, ""},
   {NULL, NULL}
};


static void
_del_hook(Evas_Object *obj)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   int i;
   for (i = 0; i < 6; i++)
     {
        if (wd->digit[i]) evas_object_del(wd->digit[i]);
     }
   if (wd->ampm) evas_object_del(wd->ampm);
   if (wd->ticker) ecore_timer_del(wd->ticker);
   if (wd->spin) ecore_timer_del(wd->spin);
   free(wd);
}

static void
_theme_hook(Evas_Object *obj)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   if (elm_widget_focus_get(obj))
     edje_object_signal_emit(wd->clk, "elm,action,focus", "elm");
   else
     edje_object_signal_emit(wd->clk, "elm,action,unfocus", "elm");
   wd->cur.am_pm = !wd->cur.am_pm; /* hack - force update */
   _time_update(obj);
}

static void
_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   if (elm_widget_focus_get(obj))
     {
        edje_object_signal_emit(wd->clk, "elm,action,focus", "elm");
        evas_object_focus_set(wd->clk, EINA_TRUE);
     }
   else
     {
        edje_object_signal_emit(wd->clk, "elm,action,unfocus", "elm");
        evas_object_focus_set(wd->clk, EINA_FALSE);
     }
}

static void
_signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   int i;
   if (!wd) return;
   edje_object_signal_emit(wd->clk, emission, source);
   for (i = 0; i < 6; i++)
     {
        if (wd->digit[i])
          edje_object_signal_emit(wd->digit[i], emission, source);
     }
}

static void
_signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   int i;
   if (!wd) return;
   edje_object_signal_callback_add(wd->clk, emission, source, func_cb, data);
   for (i = 0; i < 6; i++)
     {
        if (wd->digit[i])
          edje_object_signal_callback_add(wd->digit[i], emission, source,
                                          func_cb, data);
     }
}

static void
_signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   int i;
   for (i = 0; i < 6; i++)
     {
        edje_object_signal_callback_del_full(wd->digit[i], emission, source,
                                             func_cb, data);
     }
   edje_object_signal_callback_del_full(wd->clk, emission, source, func_cb,
                                        data);
}

static void
_timediff_set(Widget_Data *wd)
{
   struct timeval timev;
   struct tm *tm;
   time_t tt;
   gettimeofday(&timev, NULL);
   tt = (time_t)(timev.tv_sec);
   tzset();
   tm = localtime(&tt);
   wd->timediff = (((wd->hrs - tm->tm_hour) * 60 +
                    wd->min - tm->tm_min) * 60) + wd->sec - tm->tm_sec;
}

static Eina_Bool
_ticker(void *data)
{
   Widget_Data *wd = elm_widget_data_get(data);
   double t;
   struct timeval timev;
   struct tm *tm;
   time_t tt;
   if (!wd) return ECORE_CALLBACK_CANCEL;
   gettimeofday(&timev, NULL);
   t = ((double)(1000000 - timev.tv_usec)) / 1000000.0;
   wd->ticker = ecore_timer_add(t, _ticker, data);
   if (!wd->edit)
     {
        tt = (time_t)(timev.tv_sec) + wd->timediff;
        tzset();
        tm = localtime(&tt);
        if (tm)
          {
             wd->hrs = tm->tm_hour;
             wd->min = tm->tm_min;
             wd->sec = tm->tm_sec;
             _time_update(data);
          }
     }
   return ECORE_CALLBACK_CANCEL;
}

static Eina_Bool
_signal_clock_val_up(void *data)
{
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) goto clock_val_up_exit_on_error;
   if (!wd->edit) goto clock_val_up_cancel;
   if (!wd->sel_obj) goto clock_val_up_cancel;
   if (wd->sel_obj == wd->digit[0])
     {
        wd->hrs = wd->hrs + 10;
        if (wd->hrs >= 24) wd->hrs -= 24;
     }
   if (wd->sel_obj == wd->digit[1])
     {
        wd->hrs = wd->hrs + 1;
        if (wd->hrs >= 24) wd->hrs -= 24;
     }
   if (wd->sel_obj == wd->digit[2])
     {
        wd->min = wd->min + 10;
        if (wd->min >= 60) wd->min -= 60;
     }
   if (wd->sel_obj == wd->digit[3])
     {
        wd->min = wd->min + 1;
        if (wd->min >= 60) wd->min -= 60;
     }
   if (wd->sel_obj == wd->digit[4])
     {
        wd->sec = wd->sec + 10;
        if (wd->sec >= 60) wd->sec -= 60;
     }
   if (wd->sel_obj == wd->digit[5])
     {
        wd->sec = wd->sec + 1;
        if (wd->sec >= 60) wd->sec -= 60;
     }
   if (wd->sel_obj == wd->ampm)
     {
        wd->hrs = wd->hrs + 12;
        if (wd->hrs > 23) wd->hrs -= 24;
     }
   wd->interval = wd->interval / 1.05;
   ecore_timer_interval_set(wd->spin, wd->interval);
   _time_update(data);
   evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
   return ECORE_CALLBACK_RENEW;
clock_val_up_cancel:
   wd->spin = NULL;
clock_val_up_exit_on_error:
   return ECORE_CALLBACK_CANCEL;
}

static Eina_Bool
_signal_clock_val_down(void *data)
{
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) goto clock_val_down_exit_on_error;
   if (!wd->edit) goto clock_val_down_cancel;
   if (!wd->sel_obj) goto clock_val_down_cancel;
   if (wd->sel_obj == wd->digit[0])
     {
        wd->hrs = wd->hrs - 10;
        if (wd->hrs < 0) wd->hrs += 24;
     }
   if (wd->sel_obj == wd->digit[1])
     {
        wd->hrs = wd->hrs - 1;
        if (wd->hrs < 0) wd->hrs += 24;
     }
   if (wd->sel_obj == wd->digit[2])
     {
        wd->min = wd->min - 10;
        if (wd->min < 0) wd->min += 60;
     }
   if (wd->sel_obj == wd->digit[3])
     {
        wd->min = wd->min - 1;
        if (wd->min < 0) wd->min += 60;
     }
   if (wd->sel_obj == wd->digit[4])
     {
        wd->sec = wd->sec - 10;
        if (wd->sec < 0) wd->sec += 60;
     }
   if (wd->sel_obj == wd->digit[5])
     {
        wd->sec = wd->sec - 1;
        if (wd->sec < 0) wd->sec += 60;
     }
   if (wd->sel_obj == wd->ampm)
     {
        wd->hrs = wd->hrs - 12;
        if (wd->hrs < 0) wd->hrs += 24;
     }
   wd->interval = wd->interval / 1.05;
   ecore_timer_interval_set(wd->spin, wd->interval);
   _time_update(data);
   evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
   return ECORE_CALLBACK_RENEW;
clock_val_down_cancel:
   wd->spin = NULL;
clock_val_down_exit_on_error:
   return ECORE_CALLBACK_CANCEL;
}

static void
_signal_clock_val_up_start(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) return;
   wd->interval = wd->first_interval;
   wd->sel_obj = obj;
   if (wd->spin) ecore_timer_del(wd->spin);
   wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_up, data);
   _signal_clock_val_up(data);
}

static void
_signal_clock_val_down_start(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) return;
   wd->interval = wd->first_interval;
   wd->sel_obj = obj;
   if (wd->spin) ecore_timer_del(wd->spin);
   wd->spin = ecore_timer_add(wd->interval, _signal_clock_val_down, data);
   _signal_clock_val_down(data);
}

static void
_signal_clock_val_change_stop(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
{
   Widget_Data *wd = elm_widget_data_get(data);
   if (!wd) return;
   if (wd->spin) ecore_timer_del(wd->spin);
   wd->spin = NULL;
   wd->sel_obj = NULL;
}

static void
_time_update(Evas_Object *obj)
{
   Widget_Data *wd = elm_widget_data_get(obj);
   Edje_Message_Int msg;
   int ampm = 0;
   const char *style = elm_widget_style_get(obj);
   if (!wd) return;
   if ((wd->cur.seconds != wd->seconds) || (wd->cur.am_pm != wd->am_pm) ||
       (wd->cur.edit != wd->edit) || (wd->cur.digedit != wd->digedit))
     {
        int i;
        Evas_Coord mw, mh;

        for (i = 0; i < 6; i++)
          {
             if (wd->digit[i])
               {
                  evas_object_del(wd->digit[i]);
                  wd->digit[i] = NULL;
               }
          }
        if (wd->ampm)
          {
             evas_object_del(wd->ampm);
             wd->ampm = NULL;
          }

        if ((wd->seconds) && (wd->am_pm))
          _elm_theme_object_set(obj, wd->clk, "clock", "base-all", style);
        else if (wd->seconds)
          _elm_theme_object_set(obj, wd->clk, "clock", "base-seconds", style);
        else if (wd->am_pm)
          _elm_theme_object_set(obj, wd->clk, "clock", "base-am_pm", style);
        else
          _elm_theme_object_set(obj, wd->clk, "clock", "base", style);
        edje_object_scale_set(wd->clk, elm_widget_scale_get(obj) *
                              _elm_config->scale);

        for (i = 0; i < 6; i++)
          {
             char buf[16];

             if ((!wd->seconds) && (i >= 4)) break;
             wd->digit[i] = edje_object_add(evas_object_evas_get(wd->clk));
             _elm_theme_object_set(obj, wd->digit[i], "clock", "flipdigit", style);
             edje_object_scale_set(wd->digit[i], elm_widget_scale_get(obj) *
                                   _elm_config->scale);
             if ((wd->edit) && (wd->digedit & (1 << i)))
               edje_object_signal_emit(wd->digit[i], "elm,state,edit,on", "elm");
             edje_object_signal_callback_add(wd->digit[i], "elm,action,up,start",
                                             "", _signal_clock_val_up_start, obj);
             edje_object_signal_callback_add(wd->digit[i], "elm,action,up,stop",
                                             "", _signal_clock_val_change_stop, obj);
             edje_object_signal_callback_add(wd->digit[i], "elm,action,down,start",
                                             "", _signal_clock_val_down_start, obj);
             edje_object_signal_callback_add(wd->digit[i], "elm,action,down,stop",
                                             "", _signal_clock_val_change_stop, obj);
             mw = mh = -1;
             elm_coords_finger_size_adjust(1, &mw, 2, &mh);
             edje_object_size_min_restricted_calc(wd->digit[i], &mw, &mh, mw, mh);
             elm_coords_finger_size_adjust(1, &mw, 2, &mh);
             edje_extern_object_min_size_set(wd->digit[i], mw, mh);
             snprintf(buf, sizeof(buf), "d%i", i);
             edje_object_part_swallow(wd->clk , buf, wd->digit[i]);
             evas_object_show(wd->digit[i]);
          }
        if (wd->am_pm)
          {
             wd->ampm = edje_object_add(evas_object_evas_get(wd->clk));
             _elm_theme_object_set(obj, wd->ampm, "clock", "flipampm", style);
             edje_object_scale_set(wd->ampm, elm_widget_scale_get(obj) *
                                   _elm_config->scale);
             if (wd->edit)
               edje_object_signal_emit(wd->ampm, "elm,state,edit,on", "elm");
             edje_object_signal_callback_add(wd->ampm, "elm,action,up,start",
                                             "", _signal_clock_val_up_start, obj);
             edje_object_signal_callback_add(wd->ampm, "elm,action,up,stop",
                                             "", _signal_clock_val_change_stop, obj);
             edje_object_signal_callback_add(wd->ampm, "elm,action,down,start",
                                             "", _signal_clock_val_down_start, obj);
             edje_object_signal_callback_add(wd->ampm, "elm,action,down,stop",
                                             "", _signal_clock_val_change_stop, obj);
             mw = mh = -1;
             elm_coords_finger_size_adjust(1, &mw, 2, &mh);
             edje_object_size_min_restricted_calc(wd->ampm, &mw, &mh, mw, mh);
             elm_coords_finger_size_adjust(1, &mw, 2, &mh);
             edje_extern_object_min_size_set(wd->ampm, mw, mh);
             edje_object_part_swallow(wd->clk , "ampm", wd->ampm);
             evas_object_show(wd->ampm);
          }

        edje_object_size_min_calc(wd->clk, &mw, &mh);
        evas_object_size_hint_min_set(obj, mw, mh);

        wd->cur.hrs = 0;
        wd->cur.min = 0;
        wd->cur.sec = 0;
        wd->cur.ampm = -1;
        wd->cur.seconds = wd->seconds;
        wd->cur.am_pm = wd->am_pm;
        wd->cur.edit = wd->edit;
        wd->cur.digedit = wd->digedit;
     }
   if (wd->hrs != wd->cur.hrs)
     {
        int hrs;
        int d1, d2, dc1, dc2;

        hrs = wd->hrs;
        if (wd->am_pm)
          {
             if (hrs >= 12)
               {
                  if (hrs > 12) hrs -= 12;
                  ampm = 1;
               }
             else if (!hrs) hrs = 12;
          }
        d1 = hrs / 10;
        d2 = hrs % 10;
        dc1 = wd->cur.hrs / 10;
        dc2 = wd->cur.hrs % 10;
        if (d1 != dc1)
          {
             msg.val = d1;
             edje_object_message_send(wd->digit[0], EDJE_MESSAGE_INT, 1, &msg);
          }
        if (d2 != dc2)
          {
             msg.val = d2;
             edje_object_message_send(wd->digit[1], EDJE_MESSAGE_INT, 1, &msg);
          }
        wd->cur.hrs = hrs;
     }
   if (wd->min != wd->cur.min)
     {
        int d1, d2, dc1, dc2;

        d1 = wd->min / 10;
        d2 = wd->min % 10;
        dc1 = wd->cur.min / 10;
        dc2 = wd->cur.min % 10;
        if (d1 != dc1)
          {
             msg.val = d1;
             edje_object_message_send(wd->digit[2], EDJE_MESSAGE_INT, 1, &msg);
          }
        if (d2 != dc2)
          {
             msg.val = d2;
             edje_object_message_send(wd->digit[3], EDJE_MESSAGE_INT, 1, &msg);
          }
        wd->cur.min = wd->min;
     }
   if (wd->seconds)
     {
        if (wd->sec != wd->cur.sec)
          {
             int d1, d2, dc1, dc2;

             d1 = wd->sec / 10;
             d2 = wd->sec % 10;
             dc1 = wd->cur.sec / 10;
             dc2 = wd->cur.sec % 10;
             if (d1 != dc1)
               {
                  msg.val = d1;
                  edje_object_message_send(wd->digit[4], EDJE_MESSAGE_INT, 1, &msg);
               }
             if (d2 != dc2)
               {
                  msg.val = d2;
                  edje_object_message_send(wd->digit[5], EDJE_MESSAGE_INT, 1, &msg);
               }
             wd->cur.sec = wd->sec;
          }
     }
   else
     wd->cur.sec = -1;

   if (wd->am_pm)
     {
        if (wd->hrs >= 12) ampm = 1;
        if (ampm != wd->cur.ampm)
          {
             if (wd->cur.ampm != ampm)
               {
                  msg.val = ampm;
                  edje_object_message_send(wd->ampm, EDJE_MESSAGE_INT, 1, &msg);
               }
             wd->cur.ampm = ampm;
          }
     }
   else
     wd->cur.ampm = -1;
}

EAPI Evas_Object *
elm_clock_add(Evas_Object *parent)
{
   Evas_Object *obj;
   Evas *e;
   Widget_Data *wd;

   ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);

   ELM_SET_WIDTYPE(widtype, "clock");
   elm_widget_type_set(obj, "clock");
   elm_widget_sub_object_add(parent, obj);
   elm_widget_data_set(obj, wd);
   elm_widget_del_hook_set(obj, _del_hook);
   elm_widget_theme_hook_set(obj, _theme_hook);
   elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
   elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
   elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
   elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
   elm_widget_can_focus_set(obj, EINA_TRUE);

   wd->clk = edje_object_add(e);
   elm_widget_resize_object_set(obj, wd->clk);

   wd->cur.ampm = -1;
   wd->cur.seconds = EINA_TRUE;
   wd->cur.am_pm = EINA_TRUE;
   wd->cur.edit = EINA_TRUE;
   wd->cur.digedit = ELM_CLOCK_EDIT_DEFAULT;
   wd->first_interval = DEFAULT_FIRST_INTERVAL;
   wd->timediff = 0;

   _time_update(obj);
   _ticker(obj);

   evas_object_smart_callbacks_descriptions_set(obj, _signals);

   return obj;
}

EAPI void
elm_clock_time_set(Evas_Object *obj, int hrs, int min, int sec)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->hrs = hrs;
   wd->min = min;
   wd->sec = sec;
   _timediff_set(wd);
   _time_update(obj);
}

EAPI void
elm_clock_time_get(const Evas_Object *obj, int *hrs, int *min, int *sec)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   if (hrs) *hrs = wd->hrs;
   if (min) *min = wd->min;
   if (sec) *sec = wd->sec;
}

EAPI void
elm_clock_edit_set(Evas_Object *obj, Eina_Bool edit)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->edit = edit;
   if (!edit)
     _timediff_set(wd);
   if ((edit) && (wd->digedit == ELM_CLOCK_EDIT_DEFAULT))
     elm_clock_edit_mode_set(obj, ELM_CLOCK_EDIT_ALL);
   else
     _time_update(obj);
}

EAPI Eina_Bool
elm_clock_edit_get(const Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return EINA_FALSE;
   return wd->edit;
}

EAPI void
elm_clock_edit_mode_set(Evas_Object *obj, Elm_Clock_Edit_Mode digedit)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->digedit = digedit;
   if (digedit == ELM_CLOCK_EDIT_DEFAULT)
     elm_clock_edit_set(obj, EINA_FALSE);
   else
     _time_update(obj);
}

EAPI Elm_Clock_Edit_Mode
elm_clock_edit_mode_get(const Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) 0;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return 0;
   return wd->digedit;
}

EAPI void
elm_clock_show_am_pm_set(Evas_Object *obj, Eina_Bool am_pm)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->am_pm = !!am_pm;
   _time_update(obj);
}

EAPI Eina_Bool
elm_clock_show_am_pm_get(const Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return EINA_FALSE;
   return wd->am_pm;
}

EAPI void
elm_clock_show_seconds_set(Evas_Object *obj, Eina_Bool seconds)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->seconds = !!seconds;
   _time_update(obj);
}

EAPI Eina_Bool
elm_clock_show_seconds_get(const Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return EINA_FALSE;
   return wd->seconds;
}

EAPI void
elm_clock_first_interval_set(Evas_Object *obj, double interval)
{
   ELM_CHECK_WIDTYPE(obj, widtype);
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return;
   wd->first_interval = !!interval;
}

EAPI double
elm_clock_first_interval_get(const Evas_Object *obj)
{
   ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
   Widget_Data *wd = elm_widget_data_get(obj);
   if (!wd) return 0.0;
   return wd->first_interval;
}