1 #include <Elementary.h>
2 #include "elm_module_priv.h"
5 Elm_Entry_Extension_data *ext_mod;
6 static int _mod_hook_count = 0;
8 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
9 struct _Elm_Entry_Context_Menu_Item
13 const char *icon_file;
14 const char *icon_group;
15 Elm_Icon_Type icon_type;
21 _ctxpopup_position(Evas_Object *obj)
23 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
24 evas_object_geometry_get(ext_mod->ent, &x, &y, NULL, NULL);
25 edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text",
27 evas_object_size_hint_min_get(ext_mod->popup, &mw, &mh);
38 evas_object_move(ext_mod->popup, x + cx, y + cy);
39 evas_object_resize(ext_mod->popup, cw, ch);
43 _select_all(void *data, Evas_Object *obj, void *event_info)
45 ext_mod->selectall(data,obj,event_info);
46 evas_object_hide(obj);
50 _select(void *data, Evas_Object *obj, void *event_info)
52 ext_mod->select(data,obj,event_info);
53 evas_object_hide(obj);
57 _paste(void *data, Evas_Object *obj, void *event_info)
59 ext_mod->paste(data,obj,event_info);
60 evas_object_hide(obj);
64 _cut(void *data, Evas_Object *obj, void *event_info)
66 ext_mod->cut(data,obj,event_info);
67 evas_object_hide(obj);
68 elm_object_scroll_freeze_pop(ext_mod->popup);
72 _copy(void *data, Evas_Object *obj, void *event_info)
74 ext_mod->copy(data,obj,event_info);
75 evas_object_hide(obj);
76 elm_object_scroll_freeze_pop(ext_mod->popup);
80 _cancel(void *data, Evas_Object *obj, void *event_info)
82 ext_mod->cancel(data,obj,event_info);
83 evas_object_hide(obj);
84 elm_object_scroll_freeze_pop(ext_mod->popup);
88 _clipboard_menu(void *data, Evas_Object *obj, void *event_info)
91 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
92 ext_mod->cnpinit(data,obj,event_info);
93 elm_cbhm_helper_init(obj);
94 if (ext_mod->textonly)
95 elm_cbhm_send_raw_data("show0");
97 elm_cbhm_send_raw_data("show1");
98 evas_object_hide(obj);
103 _item_clicked(void *data, Evas_Object *obj, void *event_info)
105 Elm_Entry_Context_Menu_Item *it = data;
106 Evas_Object *obj2 = it->obj;
108 if (it->func) it->func(it->data, obj2, NULL);
109 evas_object_hide(obj);
112 // module api funcs needed
114 elm_modapi_init(void *m)
116 return 1; // succeed always
120 elm_modapi_shutdown(void *m)
122 return 1; // succeed always
125 // module fucns for the specific module type
127 obj_hook(Evas_Object *obj)
133 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
134 elm_entry_extension_module_data_get(obj,ext_mod);
139 obj_unhook(Evas_Object *obj)
143 if(_mod_hook_count > 0) return;
153 obj_longpress(Evas_Object *obj)
158 const Elm_Entry_Context_Menu_Item *it;
159 const char *context_menu_orientation;
164 elm_entry_extension_module_data_get(obj,ext_mod);
165 if (ext_mod->context_menu)
167 if (ext_mod->popup) evas_object_del(ext_mod->popup);
168 //else elm_widget_scroll_freeze_push(obj);
169 top = elm_widget_top_get(obj);
171 ext_mod->popup = elm_ctxpopup_add(top);
172 /*currently below theme not used,when guideline comes a new theme can be created if required*/
173 elm_object_style_set(ext_mod->popup,"extended/entry");
174 context_menu_orientation = edje_object_data_get
175 (ext_mod->ent, "context_menu_orientation");
176 if ((context_menu_orientation) &&
177 (!strcmp(context_menu_orientation, "horizontal")))
178 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_TRUE);
180 elm_widget_sub_object_add(obj, ext_mod->popup);
181 if (!ext_mod->selmode)
183 if (!ext_mod->password)
185 if (!elm_entry_is_empty(obj))
187 elm_ctxpopup_item_append(ext_mod->popup, "Select", NULL, _select, obj );
188 elm_ctxpopup_item_append(ext_mod->popup, "Select All", NULL, _select_all, obj );
191 if (1) // need way to detect if someone has a selection
193 if (ext_mod->editable)
194 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
196 //elm_ctxpopup_item_append(wd->ctxpopup, NULL, "Selectall",_select_all, obj );
198 if ((!ext_mod->password) && (ext_mod->editable))
200 icon = elm_icon_add(ext_mod->popup);
201 snprintf(buf, sizeof(buf), "%s/images/copypaste_icon_clipboard.png", PACKAGE_DATA_DIR);
202 elm_icon_file_set(icon, buf, NULL);
203 elm_ctxpopup_item_append(ext_mod->popup, NULL, icon, _clipboard_menu, obj);
204 //elm_ctxpopup_item_append(ext_mod->popup, "More", NULL, _clipboard_menu, obj );
210 if (!ext_mod->password)
212 if (ext_mod->have_selection)
214 elm_ctxpopup_item_append(ext_mod->popup, "Copy", NULL, _copy, obj );
215 if (ext_mod->editable)
216 elm_ctxpopup_item_append(ext_mod->popup, "Cut", NULL, _cut, obj );
217 if (ext_mod->editable)
218 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
222 _cancel(obj,ext_mod->popup,NULL);
223 if (!elm_entry_is_empty(obj))
225 elm_ctxpopup_item_append(ext_mod->popup, "Select", NULL, _select, obj );
226 elm_ctxpopup_item_append(ext_mod->popup, "Select All", NULL, _select_all, obj );
228 if (1) // need way to detect if someone has a selection
230 if (ext_mod->editable)
231 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
235 if (ext_mod->editable)
237 icon = elm_icon_add(ext_mod->popup);
238 snprintf(buf, sizeof(buf), "%s/images/copypaste_icon_clipboard.png", PACKAGE_DATA_DIR);
239 elm_icon_file_set(icon, buf, NULL);
240 elm_ctxpopup_item_append(ext_mod->popup, NULL, icon, _clipboard_menu, obj);
241 //elm_ctxpopup_item_append(ext_mod->popup, "More", NULL, _clipboard_menu, obj );
246 EINA_LIST_FOREACH(ext_mod->items, l, it)
248 elm_ctxpopup_item_append(ext_mod->popup, it->label, NULL, _item_clicked, it );
252 elm_object_scroll_freeze_push(ext_mod->popup);
253 _ctxpopup_position(obj);
254 evas_object_show(ext_mod->popup);
257 ext_mod->longpress_timer = NULL;
261 obj_mouseup(Evas_Object *obj)
263 if (!obj || !ext_mod) {
268 elm_entry_extension_module_data_get(obj,ext_mod);
269 if (ext_mod->longpress_timer)
271 if (ext_mod->have_selection )
273 _cancel(obj,ext_mod->popup,NULL);
280 obj_hidemenu(Evas_Object *obj)
282 if (!obj || !ext_mod) {
286 evas_object_hide(ext_mod->popup);
287 // if (ext_mod->popup) evas_object_del(ext_mod->popup);