oops forgot to add.
[framework/uifw/elementary.git] / src / examples / datetime_example.c
1 //Compile with:
2 //gcc -g `pkg-config --cflags --libs elementary` datetime_example.c -o datetime_example
3
4 #include <Elementary.h>
5 #ifdef HAVE_CONFIG_H
6 # include "elementary_config.h"
7 #else
8 # define __UNUSED__
9 #endif
10
11 static void
12 _on_done(void *data __UNUSED__,
13         Evas_Object *obj __UNUSED__,
14         void *event_info __UNUSED__)
15 {
16    elm_exit();
17 }
18
19 int
20 elm_main(int argc __UNUSED__, char *argv[] __UNUSED__)
21 {
22    Evas_Object *win, *bg, *bx, *datetime;
23
24    win = elm_win_add(NULL, "Datetime", ELM_WIN_BASIC);
25    elm_win_title_set(win, "Datetime");
26    evas_object_smart_callback_add(win, "delete,request", _on_done, NULL);
27
28    bg = elm_bg_add(win);
29    elm_win_resize_object_add(win, bg);
30    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
31    evas_object_show(bg);
32
33    bx = elm_box_add(win);
34    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
35    elm_win_resize_object_add(win, bx);
36    elm_box_horizontal_set(bx, EINA_FALSE);
37    evas_object_show(bx);
38    evas_object_size_hint_min_set(bx, 360, 200);
39
40    //datetime showing only DATE
41    datetime = elm_datetime_add(bx);
42    evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43    evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
44    elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_FALSE);
45    elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_FALSE);
46    elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
47    elm_box_pack_end(bx, datetime);
48    evas_object_show(datetime);
49
50    //datetime showing only TIME
51    datetime = elm_datetime_add(bx);
52    evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
53    evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
54    elm_datetime_field_visible_set(datetime, ELM_DATETIME_YEAR, EINA_FALSE);
55    elm_datetime_field_visible_set(datetime, ELM_DATETIME_MONTH, EINA_FALSE);
56    elm_datetime_field_visible_set(datetime, ELM_DATETIME_DATE, EINA_FALSE);
57    elm_box_pack_end(bx, datetime);
58    evas_object_show(datetime);
59
60    //datetime showing both DATE and TIME
61    datetime = elm_datetime_add(bx);
62    evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
63    evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
64    elm_box_pack_end(bx, datetime);
65    evas_object_show(datetime);
66
67    evas_object_show(win);
68
69    elm_run();
70
71    return 0;
72 }
73 ELM_MAIN();