diff options
author | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-04-22 09:19:23 +1000 |
commit | c963d75dfdeec11f82e79e727062fbf89afa2c04 (patch) | |
tree | 895633dbf641110be46f117c29890c49b3ffc0bd /libraries/edje/src/examples/edje-table.c | |
parent | Adding the new extantz viewer and grid manager. (diff) | |
download | SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2 SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz |
Update EFL to latest beta.
Diffstat (limited to '')
-rw-r--r-- | libraries/edje/src/examples/edje-table.c | 101 |
1 files changed, 73 insertions, 28 deletions
diff --git a/libraries/edje/src/examples/edje-table.c b/libraries/edje/src/examples/edje-table.c index 3866d22..7780221 100644 --- a/libraries/edje/src/examples/edje-table.c +++ b/libraries/edje/src/examples/edje-table.c | |||
@@ -10,10 +10,9 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #ifdef HAVE_CONFIG_H | 12 | #ifdef HAVE_CONFIG_H |
13 | #include "config.h" | 13 | # include "config.h" |
14 | #else | 14 | #else |
15 | #define PACKAGE_EXAMPLES_DIR "." | 15 | # define __UNUSED__ |
16 | #define __UNUSED__ | ||
17 | #endif | 16 | #endif |
18 | 17 | ||
19 | #include <Ecore.h> | 18 | #include <Ecore.h> |
@@ -23,12 +22,6 @@ | |||
23 | #define WIDTH (400) | 22 | #define WIDTH (400) |
24 | #define HEIGHT (400) | 23 | #define HEIGHT (400) |
25 | 24 | ||
26 | static const char *edje_file_path = PACKAGE_EXAMPLES_DIR "/table.edj"; | ||
27 | |||
28 | static Ecore_Evas *ee; | ||
29 | static Evas *evas; | ||
30 | static Evas_Object *bg, *edje_obj, *rects[4]; | ||
31 | |||
32 | static void | 25 | static void |
33 | _on_delete(Ecore_Evas *ee __UNUSED__) | 26 | _on_delete(Ecore_Evas *ee __UNUSED__) |
34 | { | 27 | { |
@@ -38,7 +31,7 @@ _on_delete(Ecore_Evas *ee __UNUSED__) | |||
38 | /* Try to get the number of columns and rows of the table | 31 | /* Try to get the number of columns and rows of the table |
39 | * and print them. */ | 32 | * and print them. */ |
40 | static void | 33 | static void |
41 | _columns_rows_print(void) | 34 | _columns_rows_print(Evas_Object *edje_obj) |
42 | { | 35 | { |
43 | int cols, rows; | 36 | int cols, rows; |
44 | 37 | ||
@@ -52,10 +45,18 @@ _columns_rows_print(void) | |||
52 | /* here just to keep our example's window size and table items | 45 | /* here just to keep our example's window size and table items |
53 | * size in synchrony. */ | 46 | * size in synchrony. */ |
54 | static void | 47 | static void |
55 | _canvas_resize_cb(Ecore_Evas *ee) | 48 | _on_canvas_resize(Ecore_Evas *ee) |
56 | { | 49 | { |
57 | int i, w, h; | 50 | Evas_Object *bg; |
58 | 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"); | ||
59 | ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); | 60 | ecore_evas_geometry_get(ee, NULL, NULL, &w, &h); |
60 | 61 | ||
61 | evas_object_resize(bg, w, h); | 62 | evas_object_resize(bg, w, h); |
@@ -68,9 +69,13 @@ _canvas_resize_cb(Ecore_Evas *ee) | |||
68 | /* Mouse button 1 = remove the clicked item | 69 | /* Mouse button 1 = remove the clicked item |
69 | * any other button = remove all items. */ | 70 | * any other button = remove all items. */ |
70 | static void | 71 | static void |
71 | _on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) | 72 | _on_mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) |
72 | { | 73 | { |
73 | Evas_Event_Mouse_Down *ev = event_info; | 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; | ||
74 | 79 | ||
75 | if (ev->button != 1) | 80 | if (ev->button != 1) |
76 | edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE); | 81 | edje_object_part_table_clear(edje_obj, "table_part", EINA_TRUE); |
@@ -78,11 +83,11 @@ _on_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) | |||
78 | fprintf(stderr, "Cannot remove the selected rectangle\n"); | 83 | fprintf(stderr, "Cannot remove the selected rectangle\n"); |
79 | 84 | ||
80 | evas_object_del(obj); | 85 | evas_object_del(obj); |
81 | _columns_rows_print(); | 86 | _columns_rows_print(edje_obj); |
82 | } | 87 | } |
83 | 88 | ||
84 | static void | 89 | static void |
85 | _rects_create(void) | 90 | _rects_create(Evas *evas, Evas_Object **rects, Evas_Object *edje_obj) |
86 | { | 91 | { |
87 | int i; | 92 | int i; |
88 | 93 | ||
@@ -93,26 +98,48 @@ _rects_create(void) | |||
93 | evas_object_size_hint_weight_set(rects[i], 1.0, 1.0); | 98 | evas_object_size_hint_weight_set(rects[i], 1.0, 1.0); |
94 | evas_object_show(rects[i]); | 99 | evas_object_show(rects[i]); |
95 | evas_object_event_callback_add(rects[i], EVAS_CALLBACK_MOUSE_DOWN, | 100 | evas_object_event_callback_add(rects[i], EVAS_CALLBACK_MOUSE_DOWN, |
96 | _on_mouse_down, NULL); | 101 | _on_mouse_down, edje_obj); |
97 | } | 102 | } |
98 | } | 103 | } |
99 | 104 | ||
100 | int | 105 | int |
101 | main(void) | 106 | main(int argc __UNUSED__, char *argv[]) |
102 | { | 107 | { |
103 | int i; | 108 | char edje_file_path[PATH_MAX]; |
104 | 109 | const char *edje_file = "table.edj"; | |
105 | ecore_evas_init(); | 110 | Ecore_Evas *ee; |
106 | edje_init(); | 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; | ||
107 | 133 | ||
108 | /* this will give you a window with an Evas canvas under the first | 134 | /* this will give you a window with an Evas canvas under the first |
109 | * engine available */ | 135 | * engine available */ |
110 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); | 136 | ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); |
137 | if (!ee) | ||
138 | goto free_prefix; | ||
111 | 139 | ||
112 | ecore_evas_callback_delete_request_set(ee, _on_delete); | 140 | ecore_evas_callback_delete_request_set(ee, _on_delete); |
113 | ecore_evas_callback_resize_set(ee, _canvas_resize_cb); | 141 | ecore_evas_callback_resize_set(ee, _on_canvas_resize); |
114 | ecore_evas_title_set(ee, "Edje Table Example"); | 142 | ecore_evas_title_set(ee, "Edje Table Example"); |
115 | ecore_evas_show(ee); | ||
116 | 143 | ||
117 | evas = ecore_evas_get(ee); | 144 | evas = ecore_evas_get(ee); |
118 | 145 | ||
@@ -121,15 +148,20 @@ main(void) | |||
121 | evas_object_move(bg, 0, 0); /* at canvas' origin */ | 148 | evas_object_move(bg, 0, 0); /* at canvas' origin */ |
122 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ | 149 | evas_object_resize(bg, WIDTH, HEIGHT); /* covers full canvas */ |
123 | evas_object_show(bg); | 150 | evas_object_show(bg); |
151 | ecore_evas_data_set(ee, "background", bg); | ||
124 | 152 | ||
125 | edje_obj = edje_object_add(evas); | 153 | edje_obj = edje_object_add(evas); |
126 | 154 | ||
155 | snprintf(edje_file_path, sizeof(edje_file_path), | ||
156 | "%s/examples/%s", eina_prefix_data_get(pfx), edje_file); | ||
127 | edje_object_file_set(edje_obj, edje_file_path, "example_table"); | 157 | edje_object_file_set(edje_obj, edje_file_path, "example_table"); |
128 | evas_object_move(edje_obj, 0, 0); /* at canvas' origin */ | 158 | evas_object_move(edje_obj, 0, 0); /* at canvas' origin */ |
129 | evas_object_resize(edje_obj, WIDTH, HEIGHT); | 159 | evas_object_resize(edje_obj, WIDTH, HEIGHT); |
130 | evas_object_show(edje_obj); | 160 | evas_object_show(edje_obj); |
161 | ecore_evas_data_set(ee, "edje_obj", edje_obj); | ||
131 | 162 | ||
132 | _rects_create(); | 163 | _rects_create(evas, rects, edje_obj); |
164 | ecore_evas_data_set(ee, "rects", rects); | ||
133 | 165 | ||
134 | /* Colouring the rectangles */ | 166 | /* Colouring the rectangles */ |
135 | evas_object_color_set(rects[0], 255, 0, 0, 255); | 167 | evas_object_color_set(rects[0], 255, 0, 0, 255); |
@@ -154,12 +186,25 @@ main(void) | |||
154 | 1, 1, 1, 1)) | 186 | 1, 1, 1, 1)) |
155 | fprintf(stderr, "Cannot add the rectangle 4 to table\n"); | 187 | fprintf(stderr, "Cannot add the rectangle 4 to table\n"); |
156 | 188 | ||
157 | _columns_rows_print(); | 189 | _columns_rows_print(edje_obj); |
190 | |||
191 | ecore_evas_show(ee); | ||
158 | 192 | ||
159 | ecore_main_loop_begin(); | 193 | ecore_main_loop_begin(); |
160 | 194 | ||
195 | eina_prefix_free(pfx); | ||
161 | ecore_evas_free(ee); | 196 | ecore_evas_free(ee); |
162 | ecore_evas_shutdown(); | 197 | ecore_evas_shutdown(); |
163 | edje_shutdown(); | 198 | edje_shutdown(); |
164 | return 0; | 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; | ||
165 | } | 210 | } |