1 #include <Elementary.h>
2 #include "elm_module_priv.h"
5 Elm_Entry_Extension_data *ext_mod;
7 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
8 struct _Elm_Entry_Context_Menu_Item
12 const char *icon_file;
13 const char *icon_group;
14 Elm_Icon_Type icon_type;
20 _ctxpopup_position(Evas_Object *obj)
22 Evas_Coord cx, cy, cw, ch, x, y, mw, mh;
23 evas_object_geometry_get(ext_mod->ent, &x, &y, NULL, NULL);
24 edje_object_part_text_cursor_geometry_get(ext_mod->ent, "elm.text",
26 evas_object_size_hint_min_get(ext_mod->popup, &mw, &mh);
37 evas_object_move(ext_mod->popup, x + cx, y + cy);
38 evas_object_resize(ext_mod->popup, cw, ch);
42 _select_all(void *data, Evas_Object *obj, void *event_info)
44 ext_mod->selectall(data,obj,event_info);
45 evas_object_hide(obj);
49 _select(void *data, Evas_Object *obj, void *event_info)
51 ext_mod->select(data,obj,event_info);
52 evas_object_hide(obj);
56 _paste(void *data, Evas_Object *obj, void *event_info)
58 ext_mod->paste(data,obj,event_info);
59 evas_object_hide(obj);
63 _cut(void *data, Evas_Object *obj, void *event_info)
65 ext_mod->cut(data,obj,event_info);
66 evas_object_hide(obj);
67 elm_object_scroll_freeze_pop(ext_mod->popup);
71 _copy(void *data, Evas_Object *obj, void *event_info)
73 ext_mod->copy(data,obj,event_info);
74 evas_object_hide(obj);
75 elm_object_scroll_freeze_pop(ext_mod->popup);
79 _cancel(void *data, Evas_Object *obj, void *event_info)
81 ext_mod->cancel(data,obj,event_info);
82 evas_object_hide(obj);
83 elm_object_scroll_freeze_pop(ext_mod->popup);
87 _clipboard_menu(void *data, Evas_Object *obj, void *event_info)
90 ecore_x_selection_secondary_set(elm_win_xwindow_get(obj), "",1);
91 ext_mod->cnpinit(data,obj,event_info);
92 elm_cbhm_helper_init(obj);
93 if (ext_mod->textonly)
94 elm_cbhm_send_raw_data("show0");
96 elm_cbhm_send_raw_data("show1");
97 evas_object_hide(obj);
102 _item_clicked(void *data, Evas_Object *obj, void *event_info)
104 Elm_Entry_Context_Menu_Item *it = data;
105 Evas_Object *obj2 = it->obj;
107 if (it->func) it->func(it->data, obj2, NULL);
108 evas_object_hide(obj);
111 // module api funcs needed
113 elm_modapi_init(void *m)
115 return 1; // succeed always
119 elm_modapi_shutdown(void *m)
121 return 1; // succeed always
124 // module fucns for the specific module type
126 obj_hook(Evas_Object *obj)
130 ext_mod = ELM_NEW(Elm_Entry_Extension_data);
131 elm_entry_extension_module_data_get(obj,ext_mod);
136 obj_unhook(Evas_Object *obj)
146 obj_longpress(Evas_Object *obj)
151 const Elm_Entry_Context_Menu_Item *it;
152 const char *context_menu_orientation;
155 elm_entry_extension_module_data_get(obj,ext_mod);
156 if (ext_mod->context_menu)
158 if (ext_mod->popup) evas_object_del(ext_mod->popup);
159 // else elm_widget_scroll_freeze_push(obj);
160 top = elm_widget_top_get(obj);
162 ext_mod->popup = elm_ctxpopup_add(top);
163 /*currently below theme not used,when guideline comes a new theme can be created if required*/
164 elm_object_style_set(ext_mod->popup,"extended/entry");
165 elm_object_scroll_freeze_push(ext_mod->popup);
166 context_menu_orientation = edje_object_data_get
167 (ext_mod->ent, "context_menu_orientation");
168 if ((context_menu_orientation) &&
169 (!strcmp(context_menu_orientation, "horizontal")))
170 elm_ctxpopup_horizontal_set(ext_mod->popup, EINA_TRUE);
172 elm_widget_sub_object_add(obj, ext_mod->popup);
173 if (!ext_mod->selmode)
175 if (!ext_mod->password)
177 elm_ctxpopup_item_append(ext_mod->popup, "Select", NULL, _select, obj );
178 elm_ctxpopup_item_append(ext_mod->popup, "Select All", NULL, _select_all, obj );
180 if (1) // need way to detect if someone has a selection
182 if (ext_mod->editable)
183 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
185 // elm_ctxpopup_item_append(wd->ctxpopup, NULL, "Selectall",_select_all, obj );
187 if (!ext_mod->password)
188 elm_ctxpopup_item_append(ext_mod->popup, "More", NULL, _clipboard_menu, obj );
193 if (!ext_mod->password)
195 if (ext_mod->have_selection)
197 elm_ctxpopup_item_append(ext_mod->popup, "Copy", NULL, _copy, obj );
198 if (ext_mod->editable)
199 elm_ctxpopup_item_append(ext_mod->popup, "Cut", NULL, _cut, obj );
200 if (ext_mod->editable)
201 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
205 _cancel(obj,ext_mod->popup,NULL);
206 elm_ctxpopup_item_append(ext_mod->popup, "Select", NULL, _select, obj );
207 elm_ctxpopup_item_append(ext_mod->popup, "Select All", NULL, _select_all, obj );
208 if (1) // need way to detect if someone has a selection
210 if (ext_mod->editable)
211 elm_ctxpopup_item_append(ext_mod->popup, "Paste", NULL, _paste, obj );
215 elm_ctxpopup_item_append(ext_mod->popup, "More", NULL, _clipboard_menu, obj );
219 EINA_LIST_FOREACH(ext_mod->items, l, it)
221 elm_ctxpopup_item_append(ext_mod->popup, it->label, NULL, _item_clicked, it );
225 _ctxpopup_position(obj);
226 evas_object_show(ext_mod->popup);
229 ext_mod->longpress_timer = NULL;
233 obj_mouseup(Evas_Object *obj)
235 if (!obj || !ext_mod) {
240 elm_entry_extension_module_data_get(obj,ext_mod);
241 if (ext_mod->longpress_timer)
243 if (ext_mod->have_selection )
245 _cancel(obj,ext_mod->popup,NULL);
252 obj_hidemenu(Evas_Object *obj)
254 if (!obj || !ext_mod) {
258 evas_object_hide(ext_mod->popup);
259 // if (ext_mod->popup) evas_object_del(ext_mod->popup);