fixed plugin image size problem
[framework/uifw/elementary.git] / src / bin / test_datetime.c
1 #ifdef HAVE_CONFIG_H
2 #include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 /* A simple test, just displaying datetime in its default format */
8
9 static void
10 _changed_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
11 {
12    printf("Datetime value is changed\n");
13 }
14
15 void
16 test_datetime(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
17 {
18    Evas_Object *win, *bx, *datetime;
19    time_t t;
20    struct tm time1;
21
22    win = elm_win_util_standard_add("datetime", "DateTime");
23    elm_win_autodel_set(win, 1);
24
25    bx = elm_box_add(win);
26    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
27    elm_win_resize_object_add(win, bx);
28    elm_box_horizontal_set(bx, EINA_FALSE);
29    evas_object_show(bx);
30    evas_object_size_hint_min_set(bx, 360, 240);
31
32    datetime = elm_datetime_add(bx);
33    evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
34    evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
35    elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_FALSE);
36    elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_FALSE);
37    elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
38    elm_box_pack_end(bx, datetime);
39    evas_object_show(datetime);
40
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_YEAR, EINA_FALSE);
45    elm_datetime_field_visible_set(datetime, ELM_DATETIME_MONTH, EINA_FALSE);
46    elm_datetime_field_visible_set(datetime, ELM_DATETIME_DATE, EINA_FALSE);
47    elm_box_pack_end(bx, datetime);
48    evas_object_show(datetime);
49
50    datetime = elm_datetime_add(bx);
51    evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
52    evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
53
54    // get the current local time
55    t = time(NULL);
56    localtime_r(&t, &time1);
57    // set the max year as 2030 and the remaining fields are equal to current time values
58    time1.tm_year = 130;
59    elm_datetime_value_max_set(datetime, &time1);
60    // set the min time limit as "1980 January 10th 02:30 PM"
61    time1.tm_year = 80;
62    time1.tm_mon = 4;
63    time1.tm_mday = 10;
64    time1.tm_hour = 14;
65    time1.tm_min = 30;
66    elm_datetime_value_min_set(datetime, &time1);
67    // minutes can be input only in between 15 and 45
68    elm_datetime_field_limit_set(datetime, ELM_DATETIME_MINUTE, 15, 45);
69    evas_object_smart_callback_add(datetime, "changed", _changed_cb, datetime);
70    elm_box_pack_end(bx, datetime);
71    evas_object_show(datetime);
72
73    evas_object_show(win);
74 }
75 #endif