2 * Simple Edje example illustrating text functions.
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
8 * edje_cc text.edc && gcc -o edje-text edje-text.c `pkg-config --libs --cflags ecore-evas edje`
19 #include <Ecore_Evas.h>
26 _on_delete(Ecore_Evas *ee __UNUSED__)
28 ecore_main_loop_quit();
32 _on_text_change(void *data __UNUSED__, Evas_Object *obj, const char *part)
34 printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part));
38 main(int argc __UNUSED__, char *argv[])
40 char edje_file_path[PATH_MAX];
41 const char *edje_file = "text.edj";
45 Evas_Object *edje_obj;
48 if (!ecore_evas_init())
52 goto shutdown_ecore_evas;
54 pfx = eina_prefix_new(argv[0], main,
65 /* this will give you a window with an Evas canvas under the first
67 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
71 ecore_evas_callback_delete_request_set(ee, _on_delete);
72 ecore_evas_title_set(ee, "Edje text Example");
74 evas = ecore_evas_get(ee);
76 bg = evas_object_rectangle_add(evas);
77 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
78 evas_object_move(bg, 0, 0); /* at canvas' origin */
79 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
81 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
83 edje_obj = edje_object_add(evas);
85 snprintf(edje_file_path, sizeof(edje_file_path),
86 "%s/examples/%s", eina_prefix_data_get(pfx), edje_file);
87 edje_object_file_set(edje_obj, edje_file_path, "example_group");
88 evas_object_move(edje_obj, 20, 20);
89 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
90 evas_object_show(edje_obj);
92 edje_object_text_change_cb_set(edje_obj, _on_text_change, NULL);
93 edje_object_part_text_set(edje_obj, "part_one", "one");
94 edje_object_part_text_set(edje_obj, "part_two", "<b>two");
96 edje_object_part_text_select_allow_set(edje_obj, "part_two", EINA_TRUE);
97 edje_object_part_text_select_all(edje_obj, "part_two");
98 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
99 edje_object_part_text_select_none(edje_obj, "part_two");
100 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
104 ecore_main_loop_begin();
106 eina_prefix_free(pfx);
108 ecore_evas_shutdown();
114 eina_prefix_free(pfx);
118 ecore_evas_shutdown();