summaryrefslogtreecommitdiff
path: root/src/examples/calendar_example_02.c
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2011-07-14 15:45:44 +0000
committerBruno Dilly <bdilly@profusion.mobi>2011-07-14 15:45:44 +0000
commitb660cc5182f0e917ca3c178d655bea2caa0285a6 (patch)
tree2253be8e954451e620752725e4ad4a76de4590c3 /src/examples/calendar_example_02.c
parentdc0e22df5703c2926dd14c279134ad602b6ec4d2 (diff)
Elementary: Calendar Documentation
SVN revision: 61383
Diffstat (limited to 'src/examples/calendar_example_02.c')
-rw-r--r--src/examples/calendar_example_02.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/examples/calendar_example_02.c b/src/examples/calendar_example_02.c
new file mode 100644
index 0000000..d32dec8
--- /dev/null
+++ b/src/examples/calendar_example_02.c
@@ -0,0 +1,61 @@
1/**
2 * Elementary's <b>calendar widget</b> example, demonstrates how to modify
3 * layout strings, using functions to set weekdays names and to format
4 * month and year label.
5 *
6 * See stdout/stderr for output. Compile with:
7 *
8 * @verbatim
9 * gcc -g `pkg-config --cflags --libs elementary` calendar_example_02.c -o calendar_example_02
10 * @endverbatim
11 */
12
13#include <Elementary.h>
14#ifdef HAVE_CONFIG_H
15# include "elementary_config.h"
16#else
17# define __UNUSED__
18#endif
19
20static char *
21_format_month_year(struct tm *stime)
22{
23 char buf[32];
24 /* abbreviates month and year */
25 if (!strftime(buf, sizeof(buf), "%b %y", stime)) return NULL;
26 return strdup(buf);
27}
28
29EAPI int
30elm_main(int argc __UNUSED__, char **argv __UNUSED__)
31{
32 Evas_Object *win, *bg, *cal;
33 const char *weekdays[] =
34 {
35 "S", "M", "T", "W", "T", "F", "S"
36 };
37
38 win = elm_win_add(NULL, "calendar", ELM_WIN_BASIC);
39 elm_win_title_set(win, "Calendar Layout Formatting Example");
40 elm_win_autodel_set(win, EINA_TRUE);
41
42 bg = elm_bg_add(win);
43 elm_win_resize_object_add(win, bg);
44 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
45 evas_object_show(bg);
46
47 cal = elm_calendar_add(win);
48 elm_win_resize_object_add(win, cal);
49 evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
50
51 elm_calendar_format_function_set(cal, _format_month_year);
52 elm_calendar_weekdays_names_set(cal, weekdays);
53
54 evas_object_show(cal);
55
56 evas_object_show(win);
57
58 elm_run();
59 return 0;
60}
61ELM_MAIN()