1 #include <Elementary.h>
2 #include "elm_module_priv.h"
5 Elm_Entry_Extension_data *ext_mod;
8 _ctxpopup_position(Evas_Object *obj)
10 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
11 evas_object_geometry_get(ext_mod->ent, &x, &y, NULL, NULL);
12 edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text",
14 evas_object_size_hint_min_get(ext_mod->popup, &mw, &mh);
25 evas_object_move(ext_mod->popup, x + cx, y + cy);
26 evas_object_resize(ext_mod->popup, cw, ch);
30 _select_all(void *data, Evas_Object *obj, void *event_info)
32 ext_mod->selectall(data,obj,event_info);
33 evas_object_hide(obj);
37 _select(void *data, Evas_Object *obj, void *event_info)
39 ext_mod->select(data,obj,event_info);
40 evas_object_hide(obj);
44 _paste(void *data, Evas_Object *obj, void *event_info)
46 ext_mod->paste(data,obj,event_info);
47 evas_object_hide(obj);
51 _cut(void *data, Evas_Object *obj, void *event_info)
53 ext_mod->cut(data,obj,event_info);
54 evas_object_hide(obj);
55 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
59 _copy(void *data, Evas_Object *obj, void *event_info)
61 ext_mod->copy(data,obj,event_info);
62 evas_object_hide(obj);
63 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
67 _cancel(void *data, Evas_Object *obj, void *event_info)
69 ext_mod->cancel(data,obj,event_info);
70 evas_object_hide(obj);
71 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
75 _clipboard_menu(void *data, Evas_Object *obj, void *event_info)
78 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
79 ext_mod->cnpinit(data,obj,event_info);
80 elm_cbhm_helper_init(obj);
81 elm_cbhm_send_raw_data("show");
82 evas_object_hide(obj);
87 _item_clicked(void *data, Evas_Object *obj, void *event_info)
89 Elm_Entry_Context_Menu_Item *it = data;
90 Evas_Object *obj2 = it->obj;
92 if (it->func) it->func(it->data, obj2, NULL);
93 evas_object_hide(obj);
96 // module api funcs needed
98 elm_modapi_init(void *m)
100 return 1; // succeed always
104 elm_modapi_shutdown(void *m)
106 return 1; // succeed always
109 // module fucns for the specific module type
111 obj_hook(Evas_Object *obj)
115 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
116 elm_entry_extension_module_data_get(obj,ext_mod);
121 obj_unhook(Evas_Object *obj)
131 obj_longpress(Evas_Object *obj)
136 const Elm_Entry_Context_Menu_Item *it;
137 const char *context_menu_orientation;
140 elm_entry_extension_module_data_get(obj,ext_mod);
141 if (ext_mod->context_menu)
143 if (ext_mod->popup) evas_object_del(ext_mod->popup);
144 else elm_widget_scroll_freeze_push(obj);
145 top = elm_widget_top_get(obj);
147 ext_mod->popup = elm_ctxpopup_add(top);
148 /*currently below theme not used,when guideline comes a new theme can be created if required*/
149 elm_object_style_set(ext_mod->popup,"extended/entry");
150 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_TRUE);
151 context_menu_orientation = edje_object_data_get
152 (ext_mod->ent, "context_menu_orientation");
153 if ((context_menu_orientation) &&
154 (!strcmp(context_menu_orientation, "horizontal")))
155 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_TRUE);
157 elm_widget_sub_object_add(obj, ext_mod->popup);
158 if (!ext_mod->selmode)
160 if (!ext_mod->password)
162 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Select",_select, obj );
163 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Select All",_select_all, obj );
165 if (1) // need way to detect if someone has a selection
167 if (ext_mod->editable)
168 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Paste",_paste, obj );
170 // elm_ctxpopup_item_add(wd->ctxpopup, NULL, "Selectall",_select_all, obj );
172 if (!ext_mod->password)
173 elm_ctxpopup_item_add(ext_mod->popup, NULL, "More", _clipboard_menu, obj );
178 if (!ext_mod->password)
180 if (ext_mod->have_selection)
182 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Copy",_copy, obj );
183 if (ext_mod->editable)
184 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Cut",_cut, obj );
185 if (ext_mod->editable)
186 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Paste",_paste, obj );
190 _cancel(obj,ext_mod->popup,NULL);
191 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Select",_select, obj );
192 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Select All",_select_all, obj );
193 if (1) // need way to detect if someone has a selection
195 if (ext_mod->editable)
196 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Paste", _paste, obj );
200 elm_ctxpopup_item_add(ext_mod->popup, NULL, "More",_clipboard_menu, obj );
204 EINA_LIST_FOREACH(ext_mod->items, l, it)
206 elm_ctxpopup_item_add(ext_mod->popup, NULL, it->label,_item_clicked, it );
210 _ctxpopup_position(obj);
211 evas_object_show(ext_mod->popup);
214 ext_mod->longpress_timer = NULL;
218 obj_mouseup(Evas_Object *obj)
220 if (!obj || !ext_mod) {
225 elm_entry_extension_module_data_get(obj,ext_mod);
226 if (ext_mod->longpress_timer)
228 if (ext_mod->have_selection )
230 _cancel(obj,ext_mod->popup,NULL);