diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/edje/src/examples/edje-table.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/examples/edje-table.c | 210 |
1 files changed, 0 insertions, 210 deletions
diff --git a/libraries/edje/src/examples/edje-table.c b/libraries/edje/src/examples/edje-table.c deleted file mode 100644 index 7780221..0000000 --- a/libraries/edje/src/examples/edje-table.c +++ /dev/null | |||
@@ -1,210 +0,0 @@ | |||
1 | /** | ||
2 | * Simple Edje example illustrating table 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 table.edc && gcc -o edje-table edje-table.c `pkg-config --libs --cflags evas ecore ecore-evas edje` | ||
9 | * @endverbatim | ||
10 | */ | ||
11 | |||
12 | #ifdef HAVE_CONFIG_H | ||
13 | # include "config.h" | ||
14 | #else | ||
15 | # define __UNUSED__ | ||
16 | #endif | ||
17 | |||
18 | #include <Ecore.h> | ||
19 | #include <Ecore_Evas.h> | ||
20 | #include <Edje.h> | ||
21 | |||
22 | #define WIDTH (400) | ||
23 | #define HEIGHT (400) | ||
24 | |||
25 | static void | ||
26 | _on_delete(Ecore_Evas *ee __UNUSED__) | ||
27 | { | ||
28 | ecore_main_loop_quit(); | ||
29 | } | ||
30 | |||
31 | /* Try to get the number of columns and rows of the table | ||
32 | * and print them. */ | ||
33 | static void | ||
34 | _columns_rows_print(Evas_Object *edje_obj) | ||
35 | { | ||
36 | int cols, rows; | ||
37 | |||
38 | if (edje_object_part_table_col_row_size_get(edje_obj, "table_part", &cols, | ||
39 | &rows)) | ||
40 | fprintf(stdout, "Number of columns: %d\nNumber of rows: %d\n", cols, rows); | ||
41 | else | ||
42 | fprintf(stderr, "Cannot get the number of columns and rows\n"); | ||
43 | } | ||
44 | |||
45 | /* here just to keep our example's window size and table items | ||
46 | * size in synchrony. */ | ||
47 | static void | ||
48 | _on_canvas_resize(Ecore_Evas *ee) | ||
49 | { | ||
50 | Evas_Object *bg; | ||
51 | Evas_Object *edje_obj; | ||
52 | Evas_Object **rects; | ||
53 | int i; | ||
54 | int w; | ||
55 | int h; | ||
56 | |||
57 | bg = ecore_evas_data_get(ee, "background"); | ||
58 | edje_obj = ecore_evas_data_get(ee, "edje_obj"); | ||
59 | rects = ecore_evas_data_get(ee, "rects"); | ||
60 | ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); | ||
61 | |||
62 | evas_object_resize(bg, w, h); | ||
63 | evas_object_resize(edje_obj, w, h); | ||
64 | |||
65 | for (i = 0; i < 4; i++) | ||
66 | evas_object_size_hint_min_set(rects[i], w/2, h/2); | ||
67 | } | ||
68 | |||
69 | /* Mouse button 1 = remove the clicked item | ||
70 | * any other button = remove all items. */ | ||
71 | static void | ||
72 | _on_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) | ||
73 | { | ||
74 | Evas_Event_Mouse_Down *ev; | ||
75 | Evas_Object *edje_obj; | ||
76 | |||
77 | ev = (Evas_Event_Mouse_Down *)event_info; | ||
78 | edje_obj = (Evas_Object *)data; | ||
79 | |||
80 | if (ev->button != 1) | ||
81 | edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE); | ||
82 | else if (!edje_object_part_table_unpack(edje_obj, "table_part", obj)) | ||
83 | fprintf(stderr, "Cannot remove the selected rectangle\n"); | ||
84 | |||
85 | evas_object_del(obj); | ||
86 | _columns_rows_print(edje_obj); | ||
87 | } | ||
88 | |||
89 | static void | ||
90 | _rects_create(Evas *evas, Evas_Object **rects, Evas_Object *edje_obj) | ||
91 | { | ||
92 | int i; | ||
93 | |||
94 | for (i = 0; i < 4; i++) | ||
95 | { | ||
96 | rects[i] = evas_object_rectangle_add(evas); | ||
97 | evas_object_size_hint_min_set(rects[i], 200, 200); | ||
98 | evas_object_size_hint_weight_set(rects[i], 1.0, 1.0); | ||
99 | evas_object_show(rects[i]); | ||
100 | evas_object_event_callback_add(rects[i], EVAS_CALLBACK_MOUSE_DOWN, | ||
101 | _on_mouse_down, edje_obj); | ||
102 | } | ||
103 | } | ||
104 | |||
105 | int | ||
106 | main(int argc __UNUSED__, char *argv[]) | ||
107 | { | ||
108 | char edje_file_path[PATH_MAX]; | ||
109 | const char *edje_file = "table.edj"; | ||
110 | Ecore_Evas *ee; | ||
111 | Evas *evas; | ||
112 | Evas_Object *bg; | ||
113 | Evas_Object *edje_obj; | ||
114 | Evas_Object *rects[4]; | ||
115 | Eina_Prefix *pfx; | ||
116 | |||
117 | if (!ecore_evas_init()) | ||
118 | return EXIT_FAILURE; | ||
119 | |||
120 | if (!edje_init()) | ||
121 | goto shutdown_ecore_evas; | ||
122 | |||
123 | pfx = eina_prefix_new(argv[0], main, | ||
124 | "EDJE_EXAMPLES", | ||
125 | "edje/examples", | ||
126 | edje_file, | ||
127 | PACKAGE_BIN_DIR, | ||
128 | PACKAGE_LIB_DIR, | ||
129 | PACKAGE_DATA_DIR, | ||
130 | PACKAGE_DATA_DIR); | ||
131 | if (!pfx) | ||
132 | goto shutdown_edje; | ||
133 | |||
134 | /* this will give you a window with an Evas canvas under the first | ||
135 | * engine available */ | ||
136 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | ||
137 | if (!ee) | ||
138 | goto free_prefix; | ||
139 | |||
140 | ecore_evas_callback_delete_request_set(ee, _on_delete); | ||
141 | ecore_evas_callback_resize_set(ee, _on_canvas_resize); | ||
142 | ecore_evas_title_set(ee, "Edje Table Example"); | ||
143 | |||
144 | evas = ecore_evas_get(ee); | ||
145 | |||
146 | bg = evas_object_rectangle_add(evas); | ||
147 | evas_object_color_set(bg, 255, 255, 255, 255); /* white bg */ | ||
148 | evas_object_move(bg, 0, 0); /* at canvas' origin */ | ||
149 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ | ||
150 | evas_object_show(bg); | ||
151 | ecore_evas_data_set(ee, "background", bg); | ||
152 | |||
153 | edje_obj = edje_object_add(evas); | ||
154 | |||
155 | snprintf(edje_file_path, sizeof(edje_file_path), | ||
156 | "%s/examples/%s", eina_prefix_data_get(pfx), edje_file); | ||
157 | edje_object_file_set(edje_obj, edje_file_path, "example_table"); | ||
158 | evas_object_move(edje_obj, 0, 0); /* at canvas' origin */ | ||
159 | evas_object_resize(edje_obj, WIDTH, HEIGHT); | ||
160 | evas_object_show(edje_obj); | ||
161 | ecore_evas_data_set(ee, "edje_obj", edje_obj); | ||
162 | |||
163 | _rects_create(evas, rects, edje_obj); | ||
164 | ecore_evas_data_set(ee, "rects", rects); | ||
165 | |||
166 | /* Colouring the rectangles */ | ||
167 | evas_object_color_set(rects[0], 255, 0, 0, 255); | ||
168 | evas_object_color_set(rects[1], 0, 255, 0, 255); | ||
169 | evas_object_color_set(rects[2], 0, 0, 255, 255); | ||
170 | evas_object_color_set(rects[3], 128, 128, 128, 255); | ||
171 | |||
172 | /* Packing the rectangles into the table */ | ||
173 | if (!edje_object_part_table_pack(edje_obj, "table_part", rects[0], | ||
174 | 0, 0, 1, 2)) | ||
175 | fprintf(stderr, "Cannot add the rectangle 1 to table\n"); | ||
176 | |||
177 | if (!edje_object_part_table_pack(edje_obj, "table_part", rects[1], | ||
178 | 0, 1, 1, 1)) | ||
179 | fprintf(stderr, "Cannot add the rectangle 2 to table\n"); | ||
180 | |||
181 | if (!edje_object_part_table_pack(edje_obj, "table_part", rects[2], | ||
182 | 1, 0, 1, 1)) | ||
183 | fprintf(stderr, "Cannot add the rectangle 3 to table\n"); | ||
184 | |||
185 | if (!edje_object_part_table_pack(edje_obj, "table_part", rects[3], | ||
186 | 1, 1, 1, 1)) | ||
187 | fprintf(stderr, "Cannot add the rectangle 4 to table\n"); | ||
188 | |||
189 | _columns_rows_print(edje_obj); | ||
190 | |||
191 | ecore_evas_show(ee); | ||
192 | |||
193 | ecore_main_loop_begin(); | ||
194 | |||
195 | eina_prefix_free(pfx); | ||
196 | ecore_evas_free(ee); | ||
197 | ecore_evas_shutdown(); | ||
198 | edje_shutdown(); | ||
199 | |||
200 | return EXIT_SUCCESS; | ||
201 | |||
202 | free_prefix: | ||
203 | eina_prefix_free(pfx); | ||
204 | shutdown_edje: | ||
205 | edje_shutdown(); | ||
206 | shutdown_ecore_evas: | ||
207 | ecore_evas_shutdown(); | ||
208 | |||
209 | return EXIT_FAILURE; | ||
210 | } | ||