aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/examples/edje-text.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libraries/edje/src/examples/edje-text.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/libraries/edje/src/examples/edje-text.c b/libraries/edje/src/examples/edje-text.c
new file mode 100644
index 0000000..0916509
--- /dev/null
+++ b/libraries/edje/src/examples/edje-text.c
@@ -0,0 +1,92 @@
1/**
2 * Simple Edje example illustrating text functions.
3 *
4 * You'll need at least one Evas engine built for it (excluding the
5 * buffer one). See stdout/stderr for output.
6 *
7 * @verbatim
8 * edje_cc text.edc && gcc -o edje-text edje-text.c `pkg-config --libs --cflags ecore-evas edje`
9 * @endverbatim
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#else
15#define PACKAGE_EXAMPLES_DIR "."
16#define __UNUSED__
17#endif
18
19#include <Ecore.h>
20#include <Ecore_Evas.h>
21#include <Edje.h>
22
23#define WIDTH (300)
24#define HEIGHT (300)
25
26static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/text.edj";
27
28static Ecore_Evas *ee;
29static Evas_Object *bg;
30
31static void
32_on_delete(Ecore_Evas *ee __UNUSED__)
33{
34 ecore_main_loop_quit();
35}
36
37static void
38_cb(void *data, Evas_Object *obj, const char *part)
39{
40 printf("text: %s\n", edje_object_part_text_unescaped_get(obj, part));
41}
42
43int
44main(void)
45{
46 Evas_Object *edje_obj, *rect, *obj;
47 Evas *evas;
48
49 ecore_evas_init();
50 edje_init();
51
52 /* this will give you a window with an Evas canvas under the first
53 * engine available */
54 ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
55
56 ecore_evas_callback_delete_request_set(ee, _on_delete);
57 ecore_evas_title_set(ee, "Edje text Example");
58 ecore_evas_show(ee);
59
60 evas = ecore_evas_get(ee);
61
62 bg = evas_object_rectangle_add(evas);
63 evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */
64 evas_object_move(bg, 0, 0); /* at canvas' origin */
65 evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */
66 evas_object_show(bg);
67 ecore_evas_object_associate(ee, bg, ECORE_EVAS_OBJECT_ASSOCIATE_BASE);
68
69 edje_obj = edje_object_add(evas);
70
71 edje_object_file_set(edje_obj, edje_file_path, "example_group");
72 evas_object_move(edje_obj, 20, 20);
73 evas_object_resize(edje_obj, WIDTH - 40, HEIGHT - 40);
74 evas_object_show(edje_obj);
75
76 edje_object_text_change_cb_set(edje_obj, _cb, NULL);
77 edje_object_part_text_set(edje_obj, "part_one", "one");
78 edje_object_part_text_set(edje_obj, "part_two", "<b>two");
79
80 edje_object_part_text_select_allow_set(edje_obj, "part_two", EINA_TRUE);
81 edje_object_part_text_select_all(edje_obj, "part_two");
82 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
83 edje_object_part_text_select_none(edje_obj, "part_two");
84 printf("selection: %s\n", edje_object_part_text_selection_get(edje_obj, "part_two"));
85
86 ecore_main_loop_begin();
87
88 ecore_evas_free(ee);
89 ecore_evas_shutdown();
90 edje_shutdown();
91 return 0;
92}