Clock widget example

This code places five Elementary clock widgets on a window, each of them exemplifying a part of the widget's API.

The first of them is the pristine clock:

/* pristine (no seconds, military time) */
ck = elm_clock_add(win);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
elm_box_pack_end
void elm_box_pack_end(Elm_Box *obj, Efl_Canvas_Object *subobj)
Add an object at the end of the pack list.
Definition: elm_box_eo.legacy.c:57
elm_clock_add
Evas_Object * elm_clock_add(Evas_Object *parent)
Add a new clock widget to the given parent Elementary (container) object.
Definition: elm_clock.c:797
evas_object_show
EVAS_API void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition: evas_object_main.c:1814

As you see, the defaults for a clock are:

- military time
- no seconds shown

For am/pm time, see the second clock:

/* am/pm */
ck = elm_clock_add(win);
elm_clock_show_am_pm_set(ck, EINA_TRUE);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539

The third one will show the seconds digits, which will flip in synchrony with system time. Note, besides, that the time itself is different from the system's – it was customly set with elm_clock_time_set():

/* with seconds and custom time */
ck = elm_clock_add(win);
elm_clock_show_seconds_set(ck, EINA_TRUE);
elm_clock_time_set(ck, 10, 11, 12);
elm_box_pack_end(bx, ck);
evas_object_show(ck);

In both fourth and fifth ones, we turn on the edition mode. See how you can change each of the sheets on it, and be sure to try holding the mouse pressed over one of the sheet arrows. The forth one also starts with a custom time set:

/* in edition mode, with seconds, custom time and am/pm set */
ck = elm_clock_add(win);
elm_clock_edit_set(ck, EINA_TRUE);
elm_clock_show_seconds_set(ck, EINA_TRUE);
elm_clock_show_am_pm_set(ck, EINA_TRUE);
elm_clock_time_set(ck, 10, 11, 12);
elm_box_pack_end(bx, ck);
evas_object_show(ck);

The fifth, besides editable, has only the time units editable, for hours, minutes and seconds. This exemplifies elm_clock_edit_mode_set():

/* in edition mode, with seconds, but only some digits editable */
ck = elm_clock_add(win);
elm_clock_show_seconds_set(ck, EINA_TRUE);
elm_clock_edit_set(ck, EINA_TRUE);
digedit = ELM_CLOCK_EDIT_HOUR_UNIT | ELM_CLOCK_EDIT_MIN_UNIT | ELM_CLOCK_EDIT_SEC_UNIT;
elm_clock_edit_mode_set(ck, digedit);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ELM_CLOCK_EDIT_HOUR_UNIT
@ ELM_CLOCK_EDIT_HOUR_UNIT
Unit digit of hours value should be editable.
Definition: elm_clock_eo.h:29
ELM_CLOCK_EDIT_SEC_UNIT
@ ELM_CLOCK_EDIT_SEC_UNIT
Unit digit of seconds value should be editable.
Definition: elm_clock_eo.h:37
ELM_CLOCK_EDIT_MIN_UNIT
@ ELM_CLOCK_EDIT_MIN_UNIT
Unit digit of minutes value should be editable.
Definition: elm_clock_eo.h:33

See the full example, whose window should look like this picture:

See the full source code for this example.