1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5
6 static void
_print_clicked(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)7 _print_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
8 {
9 printf("bubble clicked\n");
10 }
11
12 static void
my_entry_anchor_bt(void * data,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)13 my_entry_anchor_bt(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
14 {
15 Evas_Object *av = data;
16 elm_entry_anchor_hover_end(av);
17 }
18
19 static void
my_entry_anchor(void * data,Evas_Object * obj,void * event_info)20 my_entry_anchor(void *data, Evas_Object *obj, void *event_info)
21 {
22 Evas_Object *av = data;
23 Elm_Entry_Anchor_Hover_Info *ei = event_info;
24 Evas_Object *bt, *bx;
25
26 bt = elm_button_add(obj);
27 elm_object_text_set(bt, ei->anchor_info->name);
28 elm_object_part_content_set(ei->hover, "middle", bt);
29 evas_object_show(bt);
30
31 // hints as to where we probably should put hover contents (buttons etc.).
32 if (ei->hover_top)
33 {
34 bx = elm_box_add(obj);
35 bt = elm_button_add(obj);
36 elm_object_text_set(bt, "Top 1");
37 elm_box_pack_end(bx, bt);
38 evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av);
39 evas_object_show(bt);
40 bt = elm_button_add(obj);
41 elm_object_text_set(bt, "Top 2");
42 elm_box_pack_end(bx, bt);
43 evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av);
44 evas_object_show(bt);
45 bt = elm_button_add(obj);
46 elm_object_text_set(bt, "Top 3");
47 elm_box_pack_end(bx, bt);
48 evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av);
49 evas_object_show(bt);
50 elm_object_part_content_set(ei->hover, "top", bx);
51 evas_object_show(bx);
52 }
53 if (ei->hover_bottom)
54 {
55 bt = elm_button_add(obj);
56 elm_object_text_set(bt, "Bot");
57 elm_object_part_content_set(ei->hover, "bottom", bt);
58 evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av);
59 evas_object_show(bt);
60 }
61 if (ei->hover_left)
62 {
63 bt = elm_button_add(obj);
64 elm_object_text_set(bt, "Left");
65 elm_object_part_content_set(ei->hover, "left", bt);
66 evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av);
67 evas_object_show(bt);
68 }
69 if (ei->hover_right)
70 {
71 bt = elm_button_add(obj);
72 elm_object_text_set(bt, "Right");
73 elm_object_part_content_set(ei->hover, "right", bt);
74 evas_object_smart_callback_add(bt, "clicked", my_entry_anchor_bt, av);
75 evas_object_show(bt);
76 }
77 }
78
79 static void
my_entry_anchor_edge_left(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)80 my_entry_anchor_edge_left(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
81 {
82 printf("left\n");
83 }
84
85 static void
my_entry_anchor_edge_right(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)86 my_entry_anchor_edge_right(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
87 {
88 printf("right\n");
89 }
90
91 static void
my_entry_anchor_edge_top(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)92 my_entry_anchor_edge_top(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
93 {
94 printf("top\n");
95 }
96
97 static void
my_entry_anchor_edge_bottom(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)98 my_entry_anchor_edge_bottom(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
99 {
100 printf("bottom\n");
101 }
102
103 static void
my_entry_anchor_scroll(void * data EINA_UNUSED,Evas_Object * obj,void * event_info EINA_UNUSED)104 my_entry_anchor_scroll(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
105 {
106 Evas_Coord x, y, w, h, vw, vh;
107
108 elm_scroller_region_get(obj, &x, &y, &w, &h);
109 elm_scroller_child_size_get(obj, &vw, &vh);
110 printf("scroll %ix%i +%i+%i in %ix%i\n", w, h, x, y, vw, vh);
111 }
112
113 void
test_entry_anchor(void * data EINA_UNUSED,Evas_Object * obj EINA_UNUSED,void * event_info EINA_UNUSED)114 test_entry_anchor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
115 {
116 Evas_Object *win, *en, *sc, *bx, *bb, *ic;
117 char buf[PATH_MAX];
118
119 win = elm_win_util_standard_add("entry_anchor", "Entry Anchor");
120 elm_win_autodel_set(win, EINA_TRUE);
121
122 sc = elm_scroller_add(win);
123 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
124 elm_win_resize_object_add(win, sc);
125
126 evas_object_smart_callback_add(sc, "edge,left", my_entry_anchor_edge_left, NULL);
127 evas_object_smart_callback_add(sc, "edge,right", my_entry_anchor_edge_right, NULL);
128 evas_object_smart_callback_add(sc, "edge,top", my_entry_anchor_edge_top, NULL);
129 evas_object_smart_callback_add(sc, "edge,bottom", my_entry_anchor_edge_bottom, NULL);
130 evas_object_smart_callback_add(sc, "scroll", my_entry_anchor_scroll, NULL);
131
132 bx = elm_box_add(win);
133 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
134 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
135
136 ic = elm_icon_add(win);
137 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
138 elm_image_file_set(ic, buf, NULL);
139 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
140 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
141
142 bb = elm_bubble_add(win);
143 elm_object_text_set(bb, "Message 3");
144 elm_object_part_text_set(bb, "info", "10:32 4/11/2008");
145 elm_object_part_content_set(bb, "icon", ic);
146 evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
147 evas_object_show(ic);
148 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
149 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
150
151 en = elm_entry_add(win);
152 elm_entry_anchor_hover_style_set(en, "popout");
153 elm_entry_anchor_hover_parent_set(en, win);
154 elm_object_text_set(en,
155 "Hi there. This is the most recent message in the "
156 "list of messages. It has one <a href=tel:+614321234>+61 432 1234</a> "
157 "(phone number) to click on.");
158 evas_object_smart_callback_add(en, "anchor,hover,opened",
159 my_entry_anchor, en);
160 elm_object_content_set(bb, en);
161 evas_object_show(en);
162 elm_box_pack_end(bx, bb);
163 evas_object_show(bb);
164
165 ic = elm_icon_add(win);
166 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
167 elm_image_file_set(ic, buf, NULL);
168 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
169
170 bb = elm_bubble_add(win);
171 elm_object_text_set(bb, "Message 2");
172 elm_object_part_text_set(bb, "info", "7:16 27/10/2008");
173 elm_object_part_content_set(bb, "icon", ic);
174 evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
175 evas_object_show(ic);
176 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
177 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
178
179 en = elm_entry_add(win);
180 elm_entry_anchor_hover_style_set(en, "popout");
181 elm_entry_anchor_hover_parent_set(en, win);
182 elm_object_text_set(en,
183 "Hey what are you doing? This is the second last message "
184 "Hi there. This is the most recent message in the "
185 "list. It's a longer one so it can wrap more and "
186 "contains a <a href=contact:john>John</a> contact "
187 "link in it to test popups on links. The idea is that "
188 "all SMS's are scanned for things that look like phone "
189 "numbers or names that are in your contacts list, and "
190 "if they are, they become clickable links that pop up "
191 "a menus of obvious actions to perform on this piece "
192 "of information. This of course can be later explicitly "
193 "done by links maybe running local apps or even being "
194 "web URL's too that launch the web browser and point it "
195 "to that URL. <item relsize=16x16 vsize=full href=emoticon/omg></item>");
196 evas_object_smart_callback_add(en, "anchor,hover,opened", my_entry_anchor, en);
197 elm_object_content_set(bb, en);
198 evas_object_show(en);
199 elm_box_pack_end(bx, bb);
200 evas_object_show(bb);
201
202 ic = elm_icon_add(win);
203 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
204 elm_image_file_set(ic, buf, NULL);
205 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
206 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
207
208 bb = elm_bubble_add(win);
209 elm_object_text_set(bb, "Message 1");
210 elm_object_part_text_set(bb, "info", "20:47 18/6/2008");
211 elm_object_part_content_set(bb, "icon", ic);
212 evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
213 evas_object_show(ic);
214 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
215 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
216
217 en = elm_entry_add(win);
218 elm_entry_anchor_hover_style_set(en, "popout");
219 elm_entry_anchor_hover_parent_set(en, win);
220 elm_object_text_set(en, "This is a short message. <item relsize=16x16 vsize=full href=emoticon/haha></item>");
221 evas_object_smart_callback_add(en, "anchor,hover,opened",
222 my_entry_anchor, en);
223 elm_object_content_set(bb, en);
224 evas_object_show(en);
225 elm_box_pack_end(bx, bb);
226 evas_object_show(bb);
227
228 elm_object_content_set(sc, bx);
229 evas_object_show(bx);
230
231 evas_object_show(sc);
232
233 elm_object_focus_set(win, EINA_TRUE);
234 evas_object_resize(win, 320, 300);
235 evas_object_show(win);
236 }
237