diff options
Diffstat (limited to 'libraries/elementary/src/bin/test_win_inline.c')
-rw-r--r-- | libraries/elementary/src/bin/test_win_inline.c | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_win_inline.c b/libraries/elementary/src/bin/test_win_inline.c new file mode 100644 index 0000000..a8aed99 --- /dev/null +++ b/libraries/elementary/src/bin/test_win_inline.c | |||
@@ -0,0 +1,246 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "elementary_config.h" | ||
3 | #endif | ||
4 | #include <Elementary.h> | ||
5 | #ifndef ELM_LIB_QUICKLAUNCH | ||
6 | |||
7 | static void | ||
8 | fill(Evas_Object *win, Eina_Bool do_bg) | ||
9 | { | ||
10 | Evas_Object *bg, *sc, *bx, *ic, *bb, *av, *en; | ||
11 | char buf[PATH_MAX]; | ||
12 | |||
13 | if (do_bg) | ||
14 | { | ||
15 | bg = elm_bg_add(win); | ||
16 | elm_win_resize_object_add(win, bg); | ||
17 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
18 | evas_object_show(bg); | ||
19 | } | ||
20 | |||
21 | sc = elm_scroller_add(win); | ||
22 | evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
23 | elm_win_resize_object_add(win, sc); | ||
24 | |||
25 | bx = elm_box_add(win); | ||
26 | evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0); | ||
27 | evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
28 | |||
29 | en = elm_entry_add(win); | ||
30 | elm_entry_scrollable_set(en, EINA_TRUE); | ||
31 | evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); | ||
32 | evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); | ||
33 | elm_object_text_set(en, "This is a single line"); | ||
34 | elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); | ||
35 | elm_entry_single_line_set(en, EINA_TRUE); | ||
36 | evas_object_show(en); | ||
37 | elm_box_pack_end(bx, en); | ||
38 | |||
39 | en = elm_entry_add(win); | ||
40 | elm_entry_scrollable_set(en, EINA_TRUE); | ||
41 | evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0); | ||
42 | evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5); | ||
43 | elm_object_text_set(en, "Entry 2"); | ||
44 | elm_entry_scrollbar_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); | ||
45 | elm_entry_single_line_set(en, EINA_TRUE); | ||
46 | evas_object_show(en); | ||
47 | elm_box_pack_end(bx, en); | ||
48 | |||
49 | ic = elm_icon_add(win); | ||
50 | snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); | ||
51 | elm_icon_file_set(ic, buf, NULL); | ||
52 | elm_icon_resizable_set(ic, 0, 0); | ||
53 | evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1); | ||
54 | |||
55 | bb = elm_bubble_add(win); | ||
56 | elm_object_text_set(bb, "Message 3"); | ||
57 | elm_object_part_text_set(bb, "info", "10:32 4/11/2008"); | ||
58 | elm_object_part_content_set(bb, "icon", ic); | ||
59 | evas_object_show(ic); | ||
60 | evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); | ||
61 | evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
62 | av = elm_entry_add(win); | ||
63 | elm_entry_anchor_hover_style_set(av, "popout"); | ||
64 | elm_entry_anchor_hover_parent_set(av, win); | ||
65 | elm_object_text_set(av, | ||
66 | "Hi there. This is the most recent message in the " | ||
67 | "list of messages. It has one <a href=tel:+614321234>+61 432 1234</a> " | ||
68 | "(phone number) to click on."); | ||
69 | elm_object_content_set(bb, av); | ||
70 | evas_object_show(av); | ||
71 | elm_box_pack_end(bx, bb); | ||
72 | evas_object_show(bb); | ||
73 | |||
74 | ic = elm_icon_add(win); | ||
75 | snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); | ||
76 | elm_icon_file_set(ic, buf, NULL); | ||
77 | evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); | ||
78 | |||
79 | bb = elm_bubble_add(win); | ||
80 | elm_object_text_set(bb, "Message 2"); | ||
81 | elm_object_part_text_set(bb, "info", "7:16 27/10/2008"); | ||
82 | elm_object_part_content_set(bb, "icon", ic); | ||
83 | evas_object_show(ic); | ||
84 | evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); | ||
85 | evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
86 | av = elm_entry_add(win); | ||
87 | elm_entry_anchor_hover_style_set(av, "popout"); | ||
88 | elm_entry_anchor_hover_parent_set(av, win); | ||
89 | elm_object_text_set(av, | ||
90 | "Hey what are you doing? This is the second last message " | ||
91 | "Hi there. This is the most recent message in the " | ||
92 | "list. It's a longer one so it can wrap more and " | ||
93 | "contains a <a href=contact:john>John</a> contact " | ||
94 | "link in it to test popups on links. The idea is that " | ||
95 | "all SMS's are scanned for things that look like phone " | ||
96 | "numbers or names that are in your contacts list, and " | ||
97 | "if they are, they become clickable links that pop up " | ||
98 | "a menus of obvious actions to perform on this piece " | ||
99 | "of information. This of course can be later explicitly " | ||
100 | "done by links maybe running local apps or even being " | ||
101 | "web URL's too that launch the web browser and point it " | ||
102 | "to that URL. <item relsize=16x16 vsize=full href=emoticon/omg></item>"); | ||
103 | elm_object_content_set(bb, av); | ||
104 | evas_object_show(av); | ||
105 | elm_box_pack_end(bx, bb); | ||
106 | evas_object_show(bb); | ||
107 | |||
108 | ic = elm_icon_add(win); | ||
109 | snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get()); | ||
110 | elm_icon_file_set(ic, buf, NULL); | ||
111 | elm_icon_resizable_set(ic, 0, 0); | ||
112 | evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1); | ||
113 | |||
114 | bb = elm_bubble_add(win); | ||
115 | elm_object_text_set(bb, "Message 1"); | ||
116 | elm_object_part_text_set(bb, "info", "20:47 18/6/2008"); | ||
117 | elm_object_part_content_set(bb, "icon", ic); | ||
118 | evas_object_show(ic); | ||
119 | evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0); | ||
120 | evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
121 | |||
122 | av = elm_entry_add(win); | ||
123 | elm_entry_anchor_hover_style_set(av, "popout"); | ||
124 | elm_entry_anchor_hover_parent_set(av, win); | ||
125 | elm_object_text_set(av, "This is a short message. <item relsize=16x16 vsize=full href=emoticon/haha></item>"); | ||
126 | elm_object_content_set(bb, av); | ||
127 | evas_object_show(av); | ||
128 | elm_box_pack_end(bx, bb); | ||
129 | evas_object_show(bb); | ||
130 | |||
131 | elm_object_content_set(sc, bx); | ||
132 | evas_object_show(bx); | ||
133 | |||
134 | evas_object_show(sc); | ||
135 | } | ||
136 | |||
137 | static void | ||
138 | cb_mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj, void *event_info) | ||
139 | { | ||
140 | Evas_Event_Mouse_Move *ev = event_info; | ||
141 | Evas_Object *orig = data; | ||
142 | Evas_Coord x, y; | ||
143 | Evas_Map *p; | ||
144 | int i, w, h; | ||
145 | |||
146 | if (!ev->buttons) return; | ||
147 | evas_object_geometry_get(obj, &x, &y, NULL, NULL); | ||
148 | evas_object_move(obj, | ||
149 | x + (ev->cur.canvas.x - ev->prev.output.x), | ||
150 | y + (ev->cur.canvas.y - ev->prev.output.y)); | ||
151 | evas_object_image_size_get(orig, &w, &h); | ||
152 | p = evas_map_new(4); | ||
153 | evas_object_map_enable_set(orig, EINA_TRUE); | ||
154 | evas_object_raise(orig); | ||
155 | for (i = 0; i < 4; i++) | ||
156 | { | ||
157 | Evas_Object *hand; | ||
158 | char key[32]; | ||
159 | |||
160 | snprintf(key, sizeof(key), "h-%i\n", i); | ||
161 | hand = evas_object_data_get(orig, key); | ||
162 | evas_object_raise(hand); | ||
163 | evas_object_geometry_get(hand, &x, &y, NULL, NULL); | ||
164 | x += 15; | ||
165 | y += 15; | ||
166 | evas_map_point_coord_set(p, i, x, y, 0); | ||
167 | if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0); | ||
168 | else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0); | ||
169 | else if (i == 2) evas_map_point_image_uv_set(p, i, w, h); | ||
170 | else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h); | ||
171 | } | ||
172 | evas_object_map_set(orig, p); | ||
173 | evas_map_free(p); | ||
174 | } | ||
175 | |||
176 | static void | ||
177 | create_handles(Evas_Object *obj) | ||
178 | { | ||
179 | int i; | ||
180 | Evas_Coord x, y, w, h; | ||
181 | |||
182 | evas_object_geometry_get(obj, &x, &y, &w, &h); | ||
183 | for (i = 0; i < 4; i++) | ||
184 | { | ||
185 | Evas_Object *hand; | ||
186 | char buf[PATH_MAX]; | ||
187 | char key[32]; | ||
188 | |||
189 | hand = evas_object_image_filled_add(evas_object_evas_get(obj)); | ||
190 | evas_object_resize(hand, 31, 31); | ||
191 | snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get()); | ||
192 | evas_object_image_file_set(hand, buf, NULL); | ||
193 | if (i == 0) evas_object_move(hand, x - 15, y - 15); | ||
194 | else if (i == 1) evas_object_move(hand, x + w - 15, y - 15); | ||
195 | else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15); | ||
196 | else if (i == 3) evas_object_move(hand, x - 15, y + h - 15); | ||
197 | evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); | ||
198 | evas_object_show(hand); | ||
199 | snprintf(key, sizeof(key), "h-%i\n", i); | ||
200 | evas_object_data_set(obj, key, hand); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | void | ||
205 | test_win_inline(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
206 | { | ||
207 | Evas_Object *win, *bg, *win2, *win3; | ||
208 | char buf[PATH_MAX]; | ||
209 | |||
210 | win = elm_win_add(NULL, "window-inline", ELM_WIN_BASIC); | ||
211 | elm_win_title_set(win, "Window Inline"); | ||
212 | elm_win_autodel_set(win, EINA_TRUE); | ||
213 | |||
214 | bg = elm_bg_add(win); | ||
215 | snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); | ||
216 | elm_bg_file_set(bg, buf, NULL); | ||
217 | elm_win_resize_object_add(win, bg); | ||
218 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
219 | evas_object_show(bg); | ||
220 | |||
221 | win2 = elm_win_add(win, "inlined", ELM_WIN_INLINED_IMAGE); | ||
222 | fill(win2, EINA_TRUE); | ||
223 | |||
224 | evas_object_move(win2, 20, 60); | ||
225 | evas_object_resize(win2, 300, 200); | ||
226 | // image object for win2 is unlinked to its pos/size - so manual control | ||
227 | // this allows also for using map and other things with it. | ||
228 | evas_object_move(elm_win_inlined_image_object_get(win2), 20, 40); | ||
229 | evas_object_resize(elm_win_inlined_image_object_get(win2), 200, 320); | ||
230 | evas_object_show(win2); | ||
231 | |||
232 | win3 = elm_win_add(win, "inlined", ELM_WIN_INLINED_IMAGE); | ||
233 | elm_win_alpha_set(win3, EINA_TRUE); | ||
234 | fill(win3, EINA_FALSE); | ||
235 | |||
236 | evas_object_resize(win3, 300, 200); | ||
237 | evas_object_move(elm_win_inlined_image_object_get(win3), 80, 180); | ||
238 | evas_object_resize(elm_win_inlined_image_object_get(win3), 300, 200); | ||
239 | evas_object_show(win3); | ||
240 | |||
241 | create_handles(elm_win_inlined_image_object_get(win3)); | ||
242 | |||
243 | evas_object_resize(win, 400, 600); | ||
244 | evas_object_show(win); | ||
245 | } | ||
246 | #endif | ||