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(void *data, Evas_Object *obj, void *event_info)
32 ext_mod->select(data,obj,event_info);
33 evas_object_hide(obj);
37 _paste(void *data, Evas_Object *obj, void *event_info)
39 ext_mod->paste(data,obj,event_info);
40 evas_object_hide(obj);
44 _cut(void *data, Evas_Object *obj, void *event_info)
46 ext_mod->cut(data,obj,event_info);
47 evas_object_hide(obj);
48 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
52 _copy(void *data, Evas_Object *obj, void *event_info)
54 ext_mod->copy(data,obj,event_info);
55 evas_object_hide(obj);
56 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
60 _cancel(void *data, Evas_Object *obj, void *event_info)
62 ext_mod->cancel(data,obj,event_info);
63 evas_object_hide(obj);
64 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_FALSE);
68 _item_clicked(void *data, Evas_Object *obj, void *event_info)
70 Elm_Entry_Context_Menu_Item *it = data;
71 Evas_Object *obj2 = it->obj;
73 if (it->func) it->func(it->data, obj2, NULL);
74 evas_object_hide(obj);
77 // module api funcs needed
79 elm_modapi_init(void *m)
81 return 1; // succeed always
85 elm_modapi_shutdown(void *m)
87 return 1; // succeed always
90 // module fucns for the specific module type
92 obj_hook(Evas_Object *obj)
96 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
97 elm_entry_extension_module_data_get(obj,ext_mod);
102 obj_unhook(Evas_Object *obj)
112 obj_longpress(Evas_Object *obj)
117 const Elm_Entry_Context_Menu_Item *it;
118 const char *context_menu_orientation;
121 elm_entry_extension_module_data_get(obj,ext_mod);
122 if (ext_mod->context_menu)
124 if (ext_mod->popup) evas_object_del(ext_mod->popup);
125 else elm_widget_scroll_freeze_push(obj);
126 top = elm_widget_top_get(obj);
128 ext_mod->popup = elm_ctxpopup_add(top);
129 /*currently below theme not used,when guideline comes a new theme can be created if required*/
130 //elm_object_style_set(ext_mod->popup,"entry");
131 elm_ctxpopup_scroller_disabled_set(ext_mod->popup, EINA_TRUE);
132 context_menu_orientation = edje_object_data_get
133 (ext_mod->ent, "context_menu_orientation");
134 if ((context_menu_orientation) &&
135 (!strcmp(context_menu_orientation, "horizontal")))
136 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_TRUE);
138 elm_widget_sub_object_add(obj, ext_mod->popup);
139 if (!ext_mod->selmode)
141 if (!ext_mod->password)
142 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Select",_select, obj );
143 if (1) // need way to detect if someone has a selection
145 if (ext_mod->editable)
146 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Paste", _paste, obj );
148 // elm_ctxpopup_item_add(wd->ctxpopup, NULL, "Selectall",_select_all, obj );
152 if (!ext_mod->password)
154 if (ext_mod->have_selection)
156 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Copy",_copy, obj );
157 if (ext_mod->editable)
158 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Cut",_cut, obj );
162 _cancel(obj,ext_mod->popup,NULL);
163 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Select",_select, obj );
164 if (1) // need way to detect if someone has a selection
166 if (ext_mod->editable)
167 elm_ctxpopup_item_add(ext_mod->popup, NULL, "Paste", _paste, obj );
172 EINA_LIST_FOREACH(ext_mod->items, l, it)
174 elm_ctxpopup_item_add(ext_mod->popup, NULL, it->label,_item_clicked, it );
178 _ctxpopup_position(obj);
179 evas_object_show(ext_mod->popup);
182 ext_mod->longpress_timer = NULL;
186 obj_mouseup(Evas_Object *obj)
189 if (!obj || !ext_mod) {
194 elm_entry_extension_module_data_get(obj,ext_mod);
195 if (ext_mod->longpress_timer)
197 if (ext_mod->have_selection )
199 _cancel(obj,ext_mod->popup,NULL);
204 if (ext_mod->have_selection )
206 obj_longpress( obj );