1a2a35bf52105eea2b2685a7a9eecf73b5cf0146
[framework/uifw/elementary.git] / src / lib / elc_scrolled_entry.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 /**
5  * @defgroup Scrolled_Entry Scrolled_Entry
6  *
7  * A scrolled entry is a convenience widget which shows
8  * a box that the user can enter text into.  Unlike an
9  * @ref Entry widget, scrolled entries scroll with user
10  * input so that the window will not expand if the length
11  * of text inside the entry exceeds the initial size of the
12  * widget.
13  *
14  * Signals that you can add callbacks for are:
15  *
16  * "changed" - The text within the entry was changed
17  * "activated" - The entry has received focus and the cursor
18  * "press" - The entry has been clicked
19  * "longpressed" - The entry has been clicked for a couple seconds
20  * "clicked" - The entry has been clicked
21  * "clicked,double" - The entry has been double clicked
22  * "focused" - The entry has received focus
23  * "unfocused" - The entry has lost focus
24  * "selection,paste" - A paste action has occurred
25  * "selection,copy" - A copy action has occurred
26  * "selection,cut" - A cut action has occurred
27  * "selection,start" - A selection has begun
28  * "selection,changed" - The selection has changed
29  * "selection,cleared" - The selection has been cleared
30  * "cursor,changed" - The cursor has changed
31  * "anchor,clicked" - The anchor has been clicked
32  */
33
34 typedef struct _Widget_Data Widget_Data;
35 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
36 typedef struct _Elm_Entry_Item_Provider Elm_Entry_Item_Provider;
37 typedef struct _Elm_Entry_Text_Filter Elm_Entry_Text_Filter;
38
39 struct _Widget_Data
40 {
41    Evas_Object *scroller;
42    Evas_Object *entry;
43    Evas_Object *icon;
44    Evas_Object *end;
45    Elm_Scroller_Policy policy_h, policy_v;
46    Eina_List *items;
47    Eina_List *item_providers;
48    Eina_List *text_filters;
49    Eina_Bool single_line : 1;
50 };
51
52 struct _Elm_Entry_Context_Menu_Item
53 {
54    Evas_Object *obj;
55    Evas_Smart_Cb func;
56    void *data;
57 };
58
59 struct _Elm_Entry_Item_Provider
60 {
61    Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item);
62    void *data;
63 };
64
65 struct _Elm_Entry_Text_Filter
66 {
67    void (*func) (void *data, Evas_Object *entry, char **text);
68    void *data;
69 };
70
71 static const char *widtype = NULL;
72
73 static const char SIG_CHANGED[] = "changed";
74 static const char SIG_ACTIVATED[] = "activated";
75 static const char SIG_PRESS[] = "press";
76 static const char SIG_LONGPRESSED[] = "longpressed";
77 static const char SIG_CLICKED[] = "clicked";
78 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
79 static const char SIG_FOCUSED[] = "focused";
80 static const char SIG_UNFOCUSED[] = "unfocused";
81 static const char SIG_SELECTION_PASTE[] = "selection,paste";
82 static const char SIG_SELECTION_COPY[] = "selection,copy";
83 static const char SIG_SELECTION_CUT[] = "selection,cut";
84 static const char SIG_SELECTION_START[] = "selection,start";
85 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
86 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
87 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
88 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
89 static const Evas_Smart_Cb_Description _signals[] = {
90        {SIG_CHANGED, ""},
91        {SIG_ACTIVATED, ""},
92        {SIG_PRESS, ""},
93        {SIG_LONGPRESSED, ""},
94        {SIG_CLICKED, ""},
95        {SIG_CLICKED_DOUBLE, ""},
96        {SIG_FOCUSED, ""},
97        {SIG_UNFOCUSED, ""},
98        {SIG_SELECTION_PASTE, ""},
99        {SIG_SELECTION_COPY, ""},
100        {SIG_SELECTION_CUT, ""},
101        {SIG_SELECTION_START, ""},
102        {SIG_SELECTION_CHANGED, ""},
103        {SIG_SELECTION_CLEARED, ""},
104        {SIG_CURSOR_CHANGED, ""},
105        {SIG_ANCHOR_CLICKED, ""},
106        {NULL, NULL}
107 };
108
109 static void
110 _del_hook(Evas_Object *obj)
111 {
112    Elm_Entry_Context_Menu_Item *ci;
113    Elm_Entry_Item_Provider *ip;
114    Elm_Entry_Text_Filter *tf;
115
116    Widget_Data *wd = elm_widget_data_get(obj);
117
118    EINA_LIST_FREE(wd->items, ci)
119       free(ci);
120    EINA_LIST_FREE(wd->item_providers, ip)
121       free(ip);
122    EINA_LIST_FREE(wd->text_filters, tf)
123       free(tf);
124
125    if (!wd) return;
126    free(wd);
127 }
128
129 static void
130 _sizing_eval(Evas_Object *obj)
131 {
132    Widget_Data *wd;
133    Evas_Coord minw, minh, minw_scr, minh_scr;
134    wd = elm_widget_data_get(obj);
135    if (!wd) return;
136
137    evas_object_size_hint_min_get(obj, &minw, &minh);
138    evas_object_size_hint_min_get(wd->scroller, &minw_scr, &minh_scr);
139    if (minw < minw_scr) minw = minw_scr;
140    if (minh < minh_scr) minh = minh_scr;
141
142    evas_object_size_hint_min_set(obj, minw, minh);
143    if (wd->single_line)
144      evas_object_size_hint_max_set(obj, -1, minh);
145    else
146      evas_object_size_hint_max_set(obj, -1, -1);
147 }
148
149 static void
150 _theme_hook(Evas_Object *obj)
151 {
152    Widget_Data *wd = elm_widget_data_get(obj);
153    if (!wd) return;
154    elm_object_style_set(wd->entry, elm_widget_style_get(obj));
155    elm_object_style_set(wd->scroller, elm_widget_style_get(obj));
156    elm_object_disabled_set(wd->entry, elm_widget_disabled_get(obj));
157    elm_object_disabled_set(wd->scroller, elm_widget_disabled_get(obj));
158    _sizing_eval(obj);
159 }
160
161 static void
162 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
163 {
164    Widget_Data *wd = elm_widget_data_get(obj);
165    if (!wd) return;
166    if (elm_widget_focus_get(obj))
167      elm_widget_focus_steal(wd->entry);
168 }
169
170 static void
171 _disable_hook(Evas_Object *obj)
172 {
173    Widget_Data *wd = elm_widget_data_get(obj);
174    if (!wd) return;
175    elm_object_disabled_set(wd->entry, elm_widget_disabled_get(obj));
176 }
177
178 static void
179 _signal_emit_hook(Evas_Object *obj, const char *emission, const char *source)
180 {
181    Widget_Data *wd = elm_widget_data_get(obj);
182    if (!wd) return;
183    elm_object_signal_emit(wd->entry, emission, source);
184    elm_object_signal_emit(wd->scroller, emission, source);
185 }
186
187 static void
188 _signal_callback_add_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data)
189 {
190    Widget_Data *wd = elm_widget_data_get(obj);
191    if (!wd) return;
192    elm_object_signal_callback_add(wd->entry, emission, source, func_cb, data);
193    elm_object_signal_callback_add(wd->scroller, emission, source, func_cb,
194                                   data);
195 }
196
197 static void
198 _signal_callback_del_hook(Evas_Object *obj, const char *emission, const char *source, Edje_Signal_Cb func_cb, void *data __UNUSED__)
199 {
200    Widget_Data *wd = elm_widget_data_get(obj);
201    elm_object_signal_callback_del(wd->entry, emission, source, func_cb);
202    elm_object_signal_callback_del(wd->scroller, emission, source, func_cb);
203 }
204
205 static void
206 _on_focus_region_hook(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h)
207 {
208    Widget_Data *wd = elm_widget_data_get(obj);
209    elm_widget_focus_region_get(wd->entry, x, y, w, h);
210 }
211
212 static void
213 _changed_size_hints(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
214 {
215    _sizing_eval(obj);
216 }
217
218 static void
219 _entry_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
220 {
221    _sizing_eval(data);
222    evas_object_smart_callback_call(data, SIG_CHANGED, event_info);
223 }
224
225 static void
226 _entry_activated(void *data, Evas_Object *obj __UNUSED__, void *event_info)
227 {
228    evas_object_smart_callback_call(data, SIG_ACTIVATED, event_info);
229 }
230
231 static void
232 _entry_press(void *data, Evas_Object *obj __UNUSED__, void *event_info)
233 {
234    evas_object_smart_callback_call(data, SIG_PRESS, event_info);
235 }
236
237 static void
238 _entry_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info)
239 {
240    evas_object_smart_callback_call(data, SIG_CLICKED, event_info);
241 }
242
243 static void
244 _entry_clicked_double(void *data, Evas_Object *obj __UNUSED__, void *event_info)
245 {
246    evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, event_info);
247 }
248
249 static void
250 _entry_cursor_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
251 {
252    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, event_info);
253 }
254
255 static void
256 _entry_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info)
257 {
258    evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, event_info);
259 }
260
261 static void
262 _entry_selection_start(void *data, Evas_Object *obj __UNUSED__, void *event_info)
263 {
264    evas_object_smart_callback_call(data, SIG_SELECTION_START, event_info);
265 }
266
267 static void
268 _entry_selection_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
269 {
270    evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, event_info);
271 }
272
273 static void
274 _entry_selection_cleared(void *data, Evas_Object *obj __UNUSED__, void *event_info)
275 {
276    evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, event_info);
277 }
278
279 static void
280 _entry_selection_paste(void *data, Evas_Object *obj __UNUSED__, void *event_info)
281 {
282    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, event_info);
283 }
284
285 static void
286 _entry_selection_copy(void *data, Evas_Object *obj __UNUSED__, void *event_info)
287 {
288    evas_object_smart_callback_call(data, SIG_SELECTION_COPY, event_info);
289 }
290
291 static void
292 _entry_selection_cut(void *data, Evas_Object *obj __UNUSED__, void *event_info)
293 {
294    evas_object_smart_callback_call(data, SIG_SELECTION_CUT, event_info);
295 }
296
297 static void
298 _entry_longpressed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
299 {
300    evas_object_smart_callback_call(data, SIG_LONGPRESSED, event_info);
301 }
302
303 static void
304 _entry_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info)
305 {
306    evas_object_smart_callback_call(data, SIG_FOCUSED, event_info);
307 }
308
309 static void
310 _entry_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info)
311 {
312    evas_object_smart_callback_call(data, SIG_UNFOCUSED, event_info);
313 }
314
315 static void
316 _context_item_wrap_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info)
317 {
318    Elm_Entry_Context_Menu_Item *ci = data;
319    ci->func(ci->data, ci->obj, event_info);
320 }
321
322 static Evas_Object *
323 _item_provider_wrap_cb(void *data, Evas_Object *obj __UNUSED__, const char *item)
324 {
325    Widget_Data *wd = elm_widget_data_get(data);
326    Eina_List *l;
327    Elm_Entry_Item_Provider *ip;
328
329    EINA_LIST_FOREACH(wd->item_providers, l, ip)
330      {
331         Evas_Object *o;
332         o = ip->func(ip->data, data, item);
333         if (o) return o;
334      }
335    return NULL;
336 }
337
338 static void
339 _text_filter_wrap_cb(void *data, Evas_Object *obj __UNUSED__, char **text)
340 {
341    Widget_Data *wd = elm_widget_data_get(data);
342    Eina_List *l;
343    Elm_Entry_Text_Filter *tf;
344
345    EINA_LIST_FOREACH(wd->text_filters, l, tf)
346      {
347         tf->func(tf->data, data, text);
348         if (!*text) break;
349      }
350 }
351
352 /**
353  * This adds a scrolled entry to @p parent object.
354  *
355  * @param parent The parent object
356  * @return The new object or NULL if it cannot be created
357  *
358  * @ingroup Scrolled_Entry
359  */
360 EAPI Evas_Object *
361 elm_scrolled_entry_add(Evas_Object *parent)
362 {
363    Evas_Object *obj;
364    Evas *e;
365    Widget_Data *wd;
366
367    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
368
369    ELM_SET_WIDTYPE(widtype, "scrolled_entry");
370    elm_widget_type_set(obj, "scrolled_entry");
371    elm_widget_sub_object_add(parent, obj);
372    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
373    elm_widget_data_set(obj, wd);
374    elm_widget_del_hook_set(obj, _del_hook);
375    elm_widget_disable_hook_set(obj, _disable_hook);
376    elm_widget_can_focus_set(obj, EINA_TRUE);
377    elm_widget_theme_hook_set(obj, _theme_hook);
378    elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
379    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
380    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
381    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
382
383    wd->scroller = elm_scroller_add(obj);
384    elm_scroller_custom_widget_base_theme_set(wd->scroller, "scroller", "entry");
385    elm_widget_resize_object_set(obj, wd->scroller);
386    evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
387    evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
388    elm_scroller_bounce_set(wd->scroller, EINA_FALSE, EINA_FALSE);
389    elm_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
390    evas_object_show(wd->scroller);
391
392    wd->entry = elm_entry_add(obj);
393    evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
394    evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
395    elm_scroller_content_set(wd->scroller, wd->entry);
396    evas_object_show(wd->entry);
397
398    elm_entry_text_filter_prepend(wd->entry, _text_filter_wrap_cb, obj);
399    elm_entry_item_provider_prepend(wd->entry, _item_provider_wrap_cb, obj);
400
401    evas_object_smart_callback_add(wd->entry, "changed", _entry_changed, obj);
402    evas_object_smart_callback_add(wd->entry, "activated", _entry_activated, obj);
403    evas_object_smart_callback_add(wd->entry, "press", _entry_press, obj);
404    evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked, obj);
405    evas_object_smart_callback_add(wd->entry, "clicked,double", _entry_clicked_double, obj);
406    evas_object_smart_callback_add(wd->entry, "cursor,changed", _entry_cursor_changed, obj);
407    evas_object_smart_callback_add(wd->entry, "anchor,clicked", _entry_anchor_clicked, obj);
408    evas_object_smart_callback_add(wd->entry, "selection,start", _entry_selection_start, obj);
409    evas_object_smart_callback_add(wd->entry, "selection,changed", _entry_selection_changed, obj);
410    evas_object_smart_callback_add(wd->entry, "selection,cleared", _entry_selection_cleared, obj);
411    evas_object_smart_callback_add(wd->entry, "selection,paste", _entry_selection_paste, obj);
412    evas_object_smart_callback_add(wd->entry, "selection,copy", _entry_selection_copy, obj);
413    evas_object_smart_callback_add(wd->entry, "selection,cut", _entry_selection_cut, obj);
414    evas_object_smart_callback_add(wd->entry, "longpressed", _entry_longpressed, obj);
415    evas_object_smart_callback_add(wd->entry, "focused", _entry_focused, obj);
416    evas_object_smart_callback_add(wd->entry, "unfocused", _entry_unfocused, obj);
417
418    evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
419                                   _changed_size_hints, NULL);
420
421    _sizing_eval(obj);
422
423    // TODO: convert Elementary to subclassing of Evas_Smart_Class
424    // TODO: and save some bytes, making descriptions per-class and not instance!
425    evas_object_smart_callbacks_descriptions_set(obj, _signals);
426    return obj;
427 }
428
429 /**
430  * This sets a widget to be displayed to the left of a scrolled entry.
431  *
432  * @param obj The scrolled entry object
433  * @param icon The widget to display on the left side of the scrolled
434  * entry.
435  *
436  * @note A previously set widget will be destroyed.
437  * @note If the object being set does not have minimum size hints set,
438  * it won't get properly displayed.
439  *
440  * @ingroup Scrolled_Entry
441  * @see elm_scrolled_entry_end_set
442  */
443 EAPI void
444 elm_scrolled_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
445 {
446    ELM_CHECK_WIDTYPE(obj, widtype);
447    Widget_Data *wd = elm_widget_data_get(obj);
448    Evas_Object *edje;
449    if (!wd) return;
450    EINA_SAFETY_ON_NULL_RETURN(icon);
451    if (wd->icon == icon) return;
452    if (wd->icon) evas_object_del(wd->icon);
453    wd->icon = icon;
454    edje = _elm_scroller_edje_object_get(wd->scroller);
455    if (!edje) return;
456    edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
457    edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
458    _sizing_eval(obj);
459 }
460
461 /**
462  * Gets the leftmost widget of the scrolled entry. This object is
463  * owned by the scrolled entry and should not be modified.
464  *
465  * @param obj The scrolled entry object
466  * @return the left widget inside the scroller
467  *
468  * @ingroup Scrolled_Entry
469  */
470 EAPI Evas_Object *
471 elm_scrolled_entry_icon_get(const Evas_Object *obj)
472 {
473    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
474    Widget_Data *wd = elm_widget_data_get(obj);
475    if (!wd) return NULL;
476    return wd->icon;
477 }
478
479 /**
480  * Unset the leftmost widget of the scrolled entry, unparenting and
481  * returning it.
482  *
483  * @param obj The scrolled entry object
484  * @return the previously set icon sub-object of this entry, on
485  * success.
486  *
487  * @see elm_scrolled_entry_icon_set()
488  *
489  * @ingroup Scrolled_Entry
490  */
491 EAPI Evas_Object *
492 elm_scrolled_entry_icon_unset(Evas_Object *obj)
493 {
494    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
495    Widget_Data *wd = elm_widget_data_get(obj);
496    Evas_Object *ret = NULL;
497    if (!wd) return NULL;
498    if (wd->icon)
499      {
500         Evas_Object *edje = _elm_scroller_edje_object_get(wd->scroller);
501         if (!edje) return NULL;
502         ret = wd->icon;
503         edje_object_part_unswallow(edje, wd->icon);
504         edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
505         wd->icon = NULL;
506         _sizing_eval(obj);
507      }
508    return ret;
509 }
510
511 /**
512  * Sets the visibility of the left-side widget of the scrolled entry,
513  * set by @elm_scrolled_entry_icon_set().
514  *
515  * @param obj The scrolled entry object
516  * @param setting EINA_TRUE if the object should be displayed,
517  * EINA_FALSE if not.
518  *
519  * @ingroup Scrolled_Entry
520  */
521 EAPI void
522 elm_scrolled_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
523 {
524    ELM_CHECK_WIDTYPE(obj, widtype);
525    Widget_Data *wd = elm_widget_data_get(obj);
526    if ((!wd) || (!wd->icon)) return;
527    if (setting)
528      evas_object_hide(wd->icon);
529    else
530      evas_object_show(wd->icon);
531    _sizing_eval(obj);
532 }
533
534 /**
535  * This sets a widget to be displayed to the end of a scrolled entry.
536  *
537  * @param obj The scrolled entry object
538  * @param end The widget to display on the right side of the scrolled
539  * entry.
540  *
541  * @note A previously set widget will be destroyed.
542  * @note If the object being set does not have minimum size hints set,
543  * it won't get properly displayed.
544  *
545  * @ingroup Scrolled_Entry
546  * @see elm_scrolled_entry_icon_set
547  */
548 EAPI void
549 elm_scrolled_entry_end_set(Evas_Object *obj, Evas_Object *end)
550 {
551    ELM_CHECK_WIDTYPE(obj, widtype);
552    Widget_Data *wd = elm_widget_data_get(obj);
553    Evas_Object *edje;
554    if (!wd) return;
555    EINA_SAFETY_ON_NULL_RETURN(end);
556    if (wd->end == end) return;
557    if (wd->end) evas_object_del(wd->end);
558    wd->end = end;
559    edje = _elm_scroller_edje_object_get(wd->scroller);
560    if (!edje) return;
561    edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
562    edje_object_signal_emit(edje, "elm,action,show,end", "elm");
563    _sizing_eval(obj);
564 }
565
566 /**
567  * Gets the endmost widget of the scrolled entry. This object is owned
568  * by the scrolled entry and should not be modified.
569  *
570  * @param obj The scrolled entry object
571  * @return the right widget inside the scroller
572  *
573  * @ingroup Scrolled_Entry
574  */
575 EAPI Evas_Object *
576 elm_scrolled_entry_end_get(const Evas_Object *obj)
577 {
578    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
579    Widget_Data *wd = elm_widget_data_get(obj);
580    if (!wd) return NULL;
581    return wd->end;
582 }
583
584 /**
585  * Unset the endmost widget of the scrolled entry, unparenting and
586  * returning it.
587  *
588  * @param obj The scrolled entry object
589  * @return the previously set icon sub-object of this entry, on
590  * success.
591  *
592  * @see elm_scrolled_entry_icon_set()
593  *
594  * @ingroup Scrolled_Entry
595  */
596 EAPI Evas_Object *
597 elm_scrolled_entry_end_unset(Evas_Object *obj)
598 {
599    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
600    Widget_Data *wd = elm_widget_data_get(obj);
601    Evas_Object *ret = NULL;
602    if (!wd) return NULL;
603    if (wd->end)
604      {
605         Evas_Object *edje = _elm_scroller_edje_object_get(wd->scroller);
606         if (!edje) return NULL;
607         ret = wd->end;
608         edje_object_part_unswallow(edje, wd->end);
609         edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
610         wd->end = NULL;
611         _sizing_eval(obj);
612      }
613    return ret;
614 }
615
616 /**
617  * Sets the visibility of the end widget of the scrolled entry, set by
618  * @elm_scrolled_entry_end_set().
619  *
620  * @param obj The scrolled entry object
621  * @param setting EINA_TRUE if the object should be displayed,
622  * EINA_FALSE if not.
623  *
624  * @ingroup Scrolled_Entry
625  */
626 EAPI void
627 elm_scrolled_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
628 {
629    ELM_CHECK_WIDTYPE(obj, widtype);
630    Widget_Data *wd = elm_widget_data_get(obj);
631    if ((!wd) || (!wd->end)) return;
632    if (setting)
633      evas_object_hide(wd->end);
634    else
635      evas_object_show(wd->end);
636    _sizing_eval(obj);
637 }
638
639 /**
640  * This sets the scrolled entry object not to line wrap.  All input will
641  * be on a single line, and the entry box will scroll with user input.
642  *
643  * @param obj The scrolled entry object
644  * @param single_line If true, the text in the scrolled entry
645  * will be on a single line.
646  *
647  * @ingroup Scrolled_Entry
648  */
649 EAPI void
650 elm_scrolled_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
651 {
652    ELM_CHECK_WIDTYPE(obj, widtype);
653    Widget_Data *wd = elm_widget_data_get(obj);
654    if (!wd) return;
655    if (wd->single_line == single_line) return;
656    elm_entry_single_line_set(wd->entry, single_line);
657    wd->single_line = single_line;
658    if (single_line)
659      {
660         elm_scroller_policy_set(wd->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
661         elm_scroller_content_min_limit(wd->scroller, 0, 1);
662      }
663    else
664      {
665         elm_scroller_policy_set(wd->scroller, wd->policy_h, wd->policy_v);
666         elm_scroller_content_min_limit(wd->scroller, 0, 0);
667      }
668    _sizing_eval(obj);
669 }
670
671 /**
672  * This returns true if the scrolled entry has been set to single line mode.
673  * See also elm_scrolled_entry_single_line_set().
674  *
675  * @param obj The scrolled entry object
676  * @return single_line If true, the text in the scrolled entry is set to display
677  * on a single line.
678  *
679  * @ingroup Scrolled_Entry
680  */
681 EAPI Eina_Bool
682 elm_scrolled_entry_single_line_get(const Evas_Object *obj)
683 {
684    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
685    Widget_Data *wd = elm_widget_data_get(obj);
686    if (!wd) return EINA_FALSE;
687    return elm_entry_single_line_get(wd->entry);
688 }
689
690
691 /**
692  * This sets the scrolled entry object to password mode.  All text entered
693  * and/or displayed within the widget will be replaced with asterisks (*).
694  *
695  * @param obj The scrolled entry object
696  * @param password If true, password mode is enabled.
697  *
698  * @ingroup Scrolled_Entry
699  */
700 EAPI void
701 elm_scrolled_entry_password_set(Evas_Object *obj, Eina_Bool password)
702 {
703    ELM_CHECK_WIDTYPE(obj, widtype);
704    Widget_Data *wd = elm_widget_data_get(obj);
705    if (!wd) return;
706    elm_entry_password_set(wd->entry, password);
707 }
708
709 /**
710  * This returns whether password mode is enabled.
711  * See also elm_scrolled_entry_password_set().
712  *
713  * @param obj The scrolled entry object
714  * @return If true, the scrolled entry is set to display all characters
715  * as asterisks (*).
716  *
717  * @ingroup Scrolled_Entry
718  */
719 EAPI Eina_Bool
720 elm_scrolled_entry_password_get(const Evas_Object *obj)
721 {
722    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
723    Widget_Data *wd = elm_widget_data_get(obj);
724    if (!wd) return EINA_FALSE;
725    return elm_entry_password_get(wd->entry);
726 }
727
728
729 /**
730  * This sets the text displayed within the scrolled entry to @p entry.
731  *
732  * @param obj The scrolled entry object
733  * @param entry The text to be displayed
734  *
735  * @ingroup Scrolled_Entry
736  */
737 EAPI void
738 elm_scrolled_entry_entry_set(Evas_Object *obj, const char *entry)
739 {
740    ELM_CHECK_WIDTYPE(obj, widtype);
741    Widget_Data *wd = elm_widget_data_get(obj);
742    if (!wd) return;
743    elm_entry_entry_set(wd->entry, entry);
744 }
745
746 /**
747  * This appends @p entry to the scrolled entry
748  *
749  * @param obj The scrolled entry object
750  * @param entry The text to be displayed
751  *
752  * @ingroup Scrolled_Entry
753  */
754 EAPI void
755 elm_scrolled_entry_entry_append(Evas_Object *obj, const char *entry)
756 {
757    ELM_CHECK_WIDTYPE(obj, widtype);
758    Widget_Data *wd = elm_widget_data_get(obj);
759    if (!wd) return;
760    elm_entry_entry_append(wd->entry, entry);
761 }
762
763 /**
764  * This returns the text currently shown in object @p entry.
765  * See also elm_scrolled_entry_entry_set().
766  *
767  * @param obj The scrolled entry object
768  * @return The currently displayed text or NULL on failure
769  *
770  * @ingroup Scrolled_Entry
771  */
772 EAPI const char *
773 elm_scrolled_entry_entry_get(const Evas_Object *obj)
774 {
775    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
776    Widget_Data *wd = elm_widget_data_get(obj);
777    if (!wd) return NULL;
778    return elm_entry_entry_get(wd->entry);
779 }
780
781 /**
782  * This returns EINA_TRUE if the entry is empty/there was an error
783  * and EINA_FALSE if it is not empty.
784  *
785  * @param obj The entry object
786  * @return If the entry is empty or not.
787  *
788  * @ingroup Scrolled_Entry
789  */
790 EAPI Eina_Bool
791 elm_scrolled_entry_is_empty(const Evas_Object *obj)
792 {
793    ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
794    Widget_Data *wd = elm_widget_data_get(obj);
795    if (!wd) return EINA_TRUE;
796    return elm_entry_is_empty(wd->entry);
797 }
798
799 /**
800  * This returns all selected text within the scrolled entry.
801  *
802  * @param obj The scrolled entry object
803  * @return The selected text within the scrolled entry or NULL on failure
804  *
805  * @ingroup Scrolled_Entry
806  */
807 EAPI const char *
808 elm_scrolled_entry_selection_get(const Evas_Object *obj)
809 {
810    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
811    Widget_Data *wd = elm_widget_data_get(obj);
812    if (!wd) return NULL;
813    return elm_entry_selection_get(wd->entry);
814 }
815
816 /**
817  * This inserts text in @p entry at the beginning of the scrolled entry
818  * object.
819  *
820  * @param obj The scrolled entry object
821  * @param entry The text to insert
822  *
823  * @ingroup Scrolled_Entry
824  */
825 EAPI void
826 elm_scrolled_entry_entry_insert(Evas_Object *obj, const char *entry)
827 {
828    ELM_CHECK_WIDTYPE(obj, widtype);
829    Widget_Data *wd = elm_widget_data_get(obj);
830    if (!wd) return;
831    elm_entry_entry_insert(wd->entry, entry);
832 }
833
834 /**
835  * This enables word line wrapping in the scrolled entry object.  It is the opposite
836  * of elm_scrolled_entry_single_line_set().  Additionally, setting this disables
837  * character line wrapping.
838  * See also elm_scrolled_entry_line_char_wrap_set().
839  *
840  * @param obj The scrolled entry object
841  * @param wrap wrap according to Elm_Wrap_Type
842  * of the object. Wrapping will occur at the end of the word before the end of the
843  * object.
844  *
845  * @ingroup Scrolled_Entry
846  */
847 EAPI void
848 elm_scrolled_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
849 {
850    ELM_CHECK_WIDTYPE(obj, widtype);
851    Widget_Data *wd = elm_widget_data_get(obj);
852    if (!wd) return;
853    elm_entry_line_wrap_set(wd->entry, wrap);
854 }
855
856 /**
857  * This sets the editable attribute of the scrolled entry.
858  *
859  * @param obj The scrolled entry object
860  * @param editable If true, the scrolled entry will be editable by the user.
861  * If false, it will be set to the disabled state.
862  *
863  * @ingroup Scrolled_Entry
864  */
865 EAPI void
866 elm_scrolled_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
867 {
868    ELM_CHECK_WIDTYPE(obj, widtype);
869    Widget_Data *wd = elm_widget_data_get(obj);
870    if (!wd) return;
871    elm_entry_editable_set(wd->entry, editable);
872 }
873
874 /**
875  * This gets the editable attribute of the scrolled entry.
876  * See also elm_scrolled_entry_editable_set().
877  *
878  * @param obj The scrolled entry object
879  * @return If true, the scrolled entry is editable by the user.
880  * If false, it is not editable by the user
881  *
882  * @ingroup Scrolled_Entry
883  */
884 EAPI Eina_Bool
885 elm_scrolled_entry_editable_get(const Evas_Object *obj)
886 {
887    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
888    Widget_Data *wd = elm_widget_data_get(obj);
889    if (!wd) return EINA_FALSE;
890    return elm_entry_editable_get(wd->entry);
891 }
892
893
894 /**
895  * This drops any existing text selection within the scrolled entry.
896  *
897  * @param obj The scrolled entry object
898  *
899  * @ingroup Scrolled_Entry
900  */
901 EAPI void
902 elm_scrolled_entry_select_none(Evas_Object *obj)
903 {
904    ELM_CHECK_WIDTYPE(obj, widtype);
905    Widget_Data *wd = elm_widget_data_get(obj);
906    if (!wd) return;
907    elm_entry_select_none(wd->entry);
908 }
909
910 /**
911  * This selects all text within the scrolled entry.
912  *
913  * @param obj The scrolled entry object
914  *
915  * @ingroup Scrolled_Entry
916  */
917 EAPI void
918 elm_scrolled_entry_select_all(Evas_Object *obj)
919 {
920    ELM_CHECK_WIDTYPE(obj, widtype);
921    Widget_Data *wd = elm_widget_data_get(obj);
922    if (!wd) return;
923    elm_entry_select_all(wd->entry);
924 }
925
926 /**
927  * This moves the cursor one place to the right within the entry.
928  *
929  * @param obj The scrolled entry object
930  * @return EINA_TRUE upon success, EINA_FALSE upon failure
931  *
932  * @ingroup Scrolled_Entry
933  */
934 EAPI Eina_Bool
935 elm_scrolled_entry_cursor_next(Evas_Object *obj)
936 {
937    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
938    Widget_Data *wd = elm_widget_data_get(obj);
939    if (!wd) return EINA_FALSE;
940    return elm_entry_cursor_next(wd->entry);
941 }
942
943 /**
944  * This moves the cursor one place to the left within the entry.
945  *
946  * @param obj The scrolled entry object
947  * @return EINA_TRUE upon success, EINA_FALSE upon failure
948  *
949  * @ingroup Scrolled_Entry
950  */
951 EAPI Eina_Bool
952 elm_scrolled_entry_cursor_prev(Evas_Object *obj)
953 {
954    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
955    Widget_Data *wd = elm_widget_data_get(obj);
956    if (!wd) return EINA_FALSE;
957    return elm_entry_cursor_prev(wd->entry);
958 }
959
960 /**
961  * This moves the cursor one line up within the entry.
962  *
963  * @param obj The scrolled entry object
964  * @return EINA_TRUE upon success, EINA_FALSE upon failure
965  *
966  * @ingroup Scrolled_Entry
967  */
968 EAPI Eina_Bool
969 elm_scrolled_entry_cursor_up(Evas_Object *obj)
970 {
971    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
972    Widget_Data *wd = elm_widget_data_get(obj);
973    if (!wd) return EINA_FALSE;
974    return elm_entry_cursor_up(wd->entry);
975 }
976
977 /**
978  * This moves the cursor one line down within the entry.
979  *
980  * @param obj The scrolled entry object
981  * @return EINA_TRUE upon success, EINA_FALSE upon failure
982  *
983  * @ingroup Scrolled_Entry
984  */
985 EAPI Eina_Bool
986 elm_scrolled_entry_cursor_down(Evas_Object *obj)
987 {
988    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
989    Widget_Data *wd = elm_widget_data_get(obj);
990    if (!wd) return EINA_FALSE;
991    return elm_entry_cursor_down(wd->entry);
992 }
993
994 /**
995  * This moves the cursor to the beginning of the entry.
996  *
997  * @param obj The scrolled entry object
998  *
999  * @ingroup Scrolled_Entry
1000  */
1001 EAPI void
1002 elm_scrolled_entry_cursor_begin_set(Evas_Object *obj)
1003 {
1004    ELM_CHECK_WIDTYPE(obj, widtype);
1005    Widget_Data *wd = elm_widget_data_get(obj);
1006    if (!wd) return;
1007    elm_entry_cursor_begin_set(wd->entry);
1008 }
1009
1010 /**
1011  * This moves the cursor to the end of the entry.
1012  *
1013  * @param obj The scrolled entry object
1014  *
1015  * @ingroup Scrolled_Entry
1016  */
1017 EAPI void
1018 elm_scrolled_entry_cursor_end_set(Evas_Object *obj)
1019 {
1020    ELM_CHECK_WIDTYPE(obj, widtype);
1021    Widget_Data *wd = elm_widget_data_get(obj);
1022    if (!wd) return;
1023    int x, y, w, h;
1024    elm_entry_cursor_end_set(wd->entry);
1025    elm_widget_show_region_get(wd->entry, &x, &y, &w, &h);
1026    elm_scroller_region_show(wd->scroller, x, y, w, h);
1027 }
1028
1029 /**
1030  * This moves the cursor to the beginning of the current line.
1031  *
1032  * @param obj The scrolled entry object
1033  *
1034  * @ingroup Scrolled_Entry
1035  */
1036 EAPI void
1037 elm_scrolled_entry_cursor_line_begin_set(Evas_Object *obj)
1038 {
1039    ELM_CHECK_WIDTYPE(obj, widtype);
1040    Widget_Data *wd = elm_widget_data_get(obj);
1041    if (!wd) return;
1042    elm_entry_cursor_line_begin_set(wd->entry);
1043 }
1044
1045 /**
1046  * This moves the cursor to the end of the current line.
1047  *
1048  * @param obj The scrolled entry object
1049  *
1050  * @ingroup Scrolled_Entry
1051  */
1052 EAPI void
1053 elm_scrolled_entry_cursor_line_end_set(Evas_Object *obj)
1054 {
1055    ELM_CHECK_WIDTYPE(obj, widtype);
1056    Widget_Data *wd = elm_widget_data_get(obj);
1057    if (!wd) return;
1058    elm_entry_cursor_line_end_set(wd->entry);
1059 }
1060
1061 /**
1062  * This begins a selection within the scrolled entry as though
1063  * the user were holding down the mouse button to make a selection.
1064  *
1065  * @param obj The scrolled entry object
1066  *
1067  * @ingroup Scrolled_Entry
1068  */
1069 EAPI void
1070 elm_scrolled_entry_cursor_selection_begin(Evas_Object *obj)
1071 {
1072    ELM_CHECK_WIDTYPE(obj, widtype);
1073    Widget_Data *wd = elm_widget_data_get(obj);
1074    if (!wd) return;
1075    elm_entry_cursor_selection_begin(wd->entry);
1076 }
1077
1078 /**
1079  * This ends a selection within the scrolled entry as though
1080  * the user had just released the mouse button while making a selection.
1081  *
1082  * @param obj The scrolled entry object
1083  *
1084  * @ingroup Scrolled_Entry
1085  */
1086 EAPI void
1087 elm_scrolled_entry_cursor_selection_end(Evas_Object *obj)
1088 {
1089    ELM_CHECK_WIDTYPE(obj, widtype);
1090    Widget_Data *wd = elm_widget_data_get(obj);
1091    if (!wd) return;
1092    elm_entry_cursor_selection_end(wd->entry);
1093 }
1094
1095 /**
1096  * TODO: fill this in
1097  *
1098  * @param obj The scrolled entry object
1099  * @return TODO: fill this in
1100  *
1101  * @ingroup Scrolled_Entry
1102  */
1103 EAPI Eina_Bool
1104 elm_scrolled_entry_cursor_is_format_get(const Evas_Object *obj)
1105 {
1106    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1107    Widget_Data *wd = elm_widget_data_get(obj);
1108    if (!wd) return EINA_FALSE;
1109    return elm_entry_cursor_is_format_get(wd->entry);
1110 }
1111
1112 /**
1113  * This returns whether the cursor is visible.
1114  *
1115  * @param obj The scrolled entry object
1116  * @return If true, the cursor is visible.
1117  *
1118  * @ingroup Scrolled_Entry
1119  */
1120 EAPI Eina_Bool
1121 elm_scrolled_entry_cursor_is_visible_format_get(const Evas_Object *obj)
1122 {
1123    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1124    Widget_Data *wd = elm_widget_data_get(obj);
1125    if (!wd) return EINA_FALSE;
1126    return elm_entry_cursor_is_visible_format_get(wd->entry);
1127 }
1128
1129 /**
1130  * TODO: fill this in
1131  *
1132  * @param obj The scrolled entry object
1133  * @return TODO: fill this in
1134  *
1135  * @ingroup Scrolled_Entry
1136  */
1137 EAPI const char *
1138 elm_scrolled_entry_cursor_content_get(const Evas_Object *obj)
1139 {
1140    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1141    Widget_Data *wd = elm_widget_data_get(obj);
1142    if (!wd) return NULL;
1143    return elm_entry_cursor_content_get(wd->entry);
1144 }
1145
1146 /**
1147  * Sets the cursor position in the scrolled entry to the given value
1148  *
1149  * @param obj The scrolled entry object
1150  * @param pos the position of the cursor
1151  *
1152  * @ingroup Scrolled_Entry
1153  */
1154 EAPI void
1155 elm_scrolled_entry_cursor_pos_set(Evas_Object *obj, int pos)
1156 {
1157    ELM_CHECK_WIDTYPE(obj, widtype);
1158    Widget_Data *wd = elm_widget_data_get(obj);
1159    if (!wd) return;
1160    elm_entry_cursor_pos_set(wd->entry, pos);
1161 }
1162
1163 /**
1164  * Retrieves the current position of the cursor in the scrolled entry
1165  *
1166  * @param obj The entry object
1167  * @return the cursor position
1168  *
1169  * @ingroup Scrolled_Entry
1170  */
1171 EAPI int
1172 elm_scrolled_entry_cursor_pos_get(const Evas_Object *obj)
1173 {
1174    ELM_CHECK_WIDTYPE(obj, widtype) 0;
1175    Widget_Data *wd = elm_widget_data_get(obj);
1176    if (!wd) return 0;
1177    return elm_entry_cursor_pos_get(wd->entry);
1178 }
1179
1180 /**
1181  * This executes a "cut" action on the selected text in the scrolled entry.
1182  *
1183  * @param obj The scrolled entry object
1184  *
1185  * @ingroup Scrolled_Entry
1186  */
1187 EAPI void
1188 elm_scrolled_entry_selection_cut(Evas_Object *obj)
1189 {
1190    ELM_CHECK_WIDTYPE(obj, widtype);
1191    Widget_Data *wd = elm_widget_data_get(obj);
1192    if (!wd) return;
1193    elm_entry_selection_cut(wd->entry);
1194 }
1195
1196 /**
1197  * This executes a "copy" action on the selected text in the scrolled entry.
1198  *
1199  * @param obj The scrolled entry object
1200  *
1201  * @ingroup Scrolled_Entry
1202  */
1203 EAPI void
1204 elm_scrolled_entry_selection_copy(Evas_Object *obj)
1205 {
1206    ELM_CHECK_WIDTYPE(obj, widtype);
1207    Widget_Data *wd = elm_widget_data_get(obj);
1208    if (!wd) return;
1209    elm_entry_selection_copy(wd->entry);
1210 }
1211
1212 /**
1213  * This executes a "paste" action in the scrolled entry.
1214  *
1215  * @param obj The scrolled entry object
1216  *
1217  * @ingroup Scrolled_Entry
1218  */
1219 EAPI void
1220 elm_scrolled_entry_selection_paste(Evas_Object *obj)
1221 {
1222    ELM_CHECK_WIDTYPE(obj, widtype);
1223    Widget_Data *wd = elm_widget_data_get(obj);
1224    if (!wd) return;
1225    elm_entry_selection_paste(wd->entry);
1226 }
1227
1228 /**
1229  * This clears and frees the items in a scrolled entry's contextual (right click) menu.
1230  *
1231  * @param obj The scrolled entry object
1232  *
1233  * @ingroup Scrolled_Entry
1234  */
1235 EAPI void
1236 elm_scrolled_entry_context_menu_clear(Evas_Object *obj)
1237 {
1238    ELM_CHECK_WIDTYPE(obj, widtype);
1239    Widget_Data *wd = elm_widget_data_get(obj);
1240    if (!wd) return;
1241    elm_entry_context_menu_clear(wd->entry);
1242 }
1243
1244 /**
1245  * This adds an item to the scrolled entry's contextual menu.
1246  *
1247  * @param obj The scrolled entry object
1248  * @param label The item's text label
1249  * @param icon_file The item's icon file
1250  * @param icon_type The item's icon type
1251  * @param func The callback to execute when the item is clicked
1252  * @param data The data to associate with the item for related functions
1253  *
1254  * @ingroup Scrolled_Entry
1255  */
1256 EAPI void
1257 elm_scrolled_entry_context_menu_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, Evas_Smart_Cb func, const void *data)
1258 {
1259    Elm_Entry_Context_Menu_Item *ci;
1260    ELM_CHECK_WIDTYPE(obj, widtype);
1261    Widget_Data *wd = elm_widget_data_get(obj);
1262    if (!wd) return;
1263
1264    ci = malloc(sizeof(Elm_Entry_Context_Menu_Item));
1265    if (!ci) return;
1266    ci->func = func;
1267    ci->data = (void *)data;
1268    ci->obj = obj;
1269    wd->items = eina_list_append(wd->items, ci);
1270    elm_entry_context_menu_item_add(wd->entry, label, icon_file, icon_type, _context_item_wrap_cb, ci);
1271 }
1272
1273 /**
1274  * This disables the scrolled entry's contextual (right click) menu.
1275  *
1276  * @param obj The scrolled entry object
1277  * @param disabled If true, the menu is disabled
1278  *
1279  * @ingroup Scrolled_Entry
1280  */
1281 EAPI void
1282 elm_scrolled_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1283 {
1284    ELM_CHECK_WIDTYPE(obj, widtype);
1285    Widget_Data *wd = elm_widget_data_get(obj);
1286    if (!wd) return;
1287    elm_entry_context_menu_disabled_set(wd->entry, disabled);
1288 }
1289
1290 /**
1291  * This returns whether the scrolled entry's contextual (right click) menu is disabled.
1292  *
1293  * @param obj The scrolled entry object
1294  * @return If true, the menu is disabled
1295  *
1296  * @ingroup Scrolled_Entry
1297  */
1298 EAPI Eina_Bool
1299 elm_scrolled_entry_context_menu_disabled_get(const Evas_Object *obj)
1300 {
1301    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1302    Widget_Data *wd = elm_widget_data_get(obj);
1303    if (!wd) return EINA_FALSE;
1304    return elm_entry_context_menu_disabled_get(wd->entry);
1305 }
1306
1307 /**
1308  * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
1309  *
1310  * @param obj The scrolled entry object
1311  * @param h The horizontal scrollbar policy to apply
1312  * @param v The vertical scrollbar policy to apply
1313  *
1314  * @ingroup Scrolled_Entry
1315  */
1316 EAPI void
1317 elm_scrolled_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
1318 {
1319    ELM_CHECK_WIDTYPE(obj, widtype);
1320    Widget_Data *wd = elm_widget_data_get(obj);
1321    if (!wd) return;
1322    wd->policy_h = h;
1323    wd->policy_v = v;
1324    elm_scroller_policy_set(wd->scroller, h, v);
1325 }
1326
1327 /**
1328  * This enables/disables bouncing within the entry.
1329  *
1330  * @param obj The scrolled entry object
1331  * @param h The horizontal bounce state
1332  * @param v The vertical bounce state
1333  *
1334  * @ingroup Scrolled_Entry
1335  */
1336 EAPI void
1337 elm_scrolled_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1338 {
1339    ELM_CHECK_WIDTYPE(obj, widtype);
1340    Widget_Data *wd = elm_widget_data_get(obj);
1341    if (!wd) return;
1342    elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce);
1343 }
1344
1345 /**
1346  * Get the bounce mode
1347  *
1348  * @param obj The Scrolled_Entry object
1349  * @param h_bounce Allow bounce horizontally
1350  * @param v_bounce Allow bounce vertically
1351  *
1352  * @ingroup Scrolled_Entry
1353  */
1354 EAPI void
1355 elm_scrolled_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1356 {
1357    ELM_CHECK_WIDTYPE(obj, widtype);
1358    Widget_Data *wd = elm_widget_data_get(obj);
1359    if (!wd) return;
1360    elm_scroller_bounce_get(wd->scroller, h_bounce, v_bounce);
1361 }
1362
1363 /**
1364  * This appends a custom item provider to the list for that entry
1365  *
1366  * This appends the given callback. The list is walked from beginning to end
1367  * with each function called given the item href string in the text. If the
1368  * function returns an object handle other than NULL (it should create an
1369  * and object to do this), then this object is used to replace that item. If
1370  * not the next provider is called until one provides an item object, or the
1371  * default provider in entry does.
1372  *
1373  * @param obj The entry object
1374  * @param func The function called to provide the item object
1375  * @param data The data passed to @p func
1376  *
1377  * @ingroup Scrolled_Entry
1378  */
1379 EAPI void
1380 elm_scrolled_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1381 {
1382    ELM_CHECK_WIDTYPE(obj, widtype);
1383    Widget_Data *wd = elm_widget_data_get(obj);
1384    if (!wd) return;
1385    EINA_SAFETY_ON_NULL_RETURN(func);
1386    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
1387    if (!ip) return;
1388    ip->func = func;
1389    ip->data = data;
1390    wd->item_providers = eina_list_append(wd->item_providers, ip);
1391 }
1392
1393 /**
1394  * This prepends a custom item provider to the list for that entry
1395  *
1396  * This prepends the given callback. See elm_scrolled_entry_item_provider_append() for
1397  * more information
1398  *
1399  * @param obj The entry object
1400  * @param func The function called to provide the item object
1401  * @param data The data passed to @p func
1402  *
1403  * @ingroup Scrolled_Entry
1404  */
1405 EAPI void
1406 elm_scrolled_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1407 {
1408    ELM_CHECK_WIDTYPE(obj, widtype);
1409    Widget_Data *wd = elm_widget_data_get(obj);
1410    if (!wd) return;
1411    EINA_SAFETY_ON_NULL_RETURN(func);
1412    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
1413    if (!ip) return;
1414    ip->func = func;
1415    ip->data = data;
1416    wd->item_providers = eina_list_prepend(wd->item_providers, ip);
1417 }
1418
1419 /**
1420  * This removes a custom item provider to the list for that entry
1421  *
1422  * This removes the given callback. See elm_scrolled_entry_item_provider_append() for
1423  * more information
1424  *
1425  * @param obj The entry object
1426  * @param func The function called to provide the item object
1427  * @param data The data passed to @p func
1428  *
1429  * @ingroup Scrolled_Entry
1430  */
1431 EAPI void
1432 elm_scrolled_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1433 {
1434    ELM_CHECK_WIDTYPE(obj, widtype);
1435    Widget_Data *wd = elm_widget_data_get(obj);
1436    Eina_List *l;
1437    Elm_Entry_Item_Provider *ip;
1438    if (!wd) return;
1439    EINA_SAFETY_ON_NULL_RETURN(func);
1440    EINA_LIST_FOREACH(wd->item_providers, l, ip)
1441      {
1442         if ((ip->func == func) && (ip->data == data))
1443           {
1444              wd->item_providers = eina_list_remove_list(wd->item_providers, l);
1445              free(ip);
1446              return;
1447           }
1448      }
1449 }
1450
1451 /**
1452  * Append a filter function for text inserted in the entry
1453  *
1454  * Append the given callback to the list. This functions will be called
1455  * whenever any text is inserted into the entry, with the text to be inserted
1456  * as a parameter. The callback function is free to alter the text in any way
1457  * it wants, but it must remember to free the given pointer and update it.
1458  * If the new text is to be discarded, the function can free it and set it text
1459  * parameter to NULL. This will also prevent any following filters from being
1460  * called.
1461  *
1462  * @param obj The entry object
1463  * @param func The function to use as text filter
1464  * @param data User data to pass to @p func
1465  *
1466  * @ingroup Scrolled_Entry
1467  */
1468 EAPI void
1469 elm_scrolled_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1470 {
1471    Widget_Data *wd;
1472    Elm_Entry_Text_Filter *tf;
1473    ELM_CHECK_WIDTYPE(obj, widtype);
1474
1475    wd = elm_widget_data_get(obj);
1476
1477    EINA_SAFETY_ON_NULL_RETURN(func);
1478
1479    tf = ELM_NEW(Elm_Entry_Text_Filter);
1480    if (!tf) return;
1481    tf->func = func;
1482    tf->data = data;
1483    wd->text_filters = eina_list_append(wd->text_filters, tf);
1484 }
1485
1486 /**
1487  * Prepend a filter function for text insdrted in the entry
1488  *
1489  * Prepend the given callback to the list. See elm_scrolled_entry_text_filter_append()
1490  * for more information
1491  *
1492  * @param obj The entry object
1493  * @param func The function to use as text filter
1494  * @param data User data to pass to @p func
1495  *
1496  * @ingroup Scrolled_Entry
1497  */
1498 EAPI void
1499 elm_scrolled_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1500 {
1501    Widget_Data *wd;
1502    Elm_Entry_Text_Filter *tf;
1503    ELM_CHECK_WIDTYPE(obj, widtype);
1504
1505    wd = elm_widget_data_get(obj);
1506
1507    EINA_SAFETY_ON_NULL_RETURN(func);
1508
1509    tf = ELM_NEW(Elm_Entry_Text_Filter);
1510    if (!tf) return;
1511    tf->func = func;
1512    tf->data = data;
1513    wd->text_filters = eina_list_prepend(wd->text_filters, tf);
1514 }
1515
1516 /**
1517  * Remove a filter from the list
1518  *
1519  * Removes the given callback from the filter list. See elm_scrolled_entry_text_filter_append()
1520  * for more information.
1521  *
1522  * @param obj The entry object
1523  * @param func The filter function to remove
1524  * @param data The user data passed when adding the function
1525  *
1526  * @ingroup Scrolled_Entry
1527  */
1528 EAPI void
1529 elm_scrolled_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1530 {
1531    Widget_Data *wd;
1532    Eina_List *l;
1533    Elm_Entry_Text_Filter *tf;
1534    ELM_CHECK_WIDTYPE(obj, widtype);
1535
1536    wd = elm_widget_data_get(obj);
1537
1538    EINA_SAFETY_ON_NULL_RETURN(func);
1539
1540    EINA_LIST_FOREACH(wd->text_filters, l, tf)
1541      {
1542         if ((tf->func == func) && (tf->data == data))
1543           {
1544              wd->text_filters = eina_list_remove_list(wd->text_filters, l);
1545              free(tf);
1546              return;
1547           }
1548      }
1549 }
1550
1551 /**
1552  * This sets the file (and implicitly loads it) for the text to display and
1553  * then edit. All changes are written back to the file after a short delay if
1554  * the entry object is set to autosave.
1555  *
1556  * @param obj The scrolled entry object
1557  * @param file The path to the file to load and save
1558  * @param format The file format
1559  *
1560  * @ingroup Scrolled_Entry
1561  */
1562 EAPI void
1563 elm_scrolled_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
1564 {
1565    ELM_CHECK_WIDTYPE(obj, widtype);
1566    Widget_Data *wd = elm_widget_data_get(obj);
1567    if (!wd) return;
1568    elm_entry_file_set(wd->entry, file, format);
1569 }
1570
1571 /**
1572  * Gets the file to load and save and the file format
1573  *
1574  * @param obj The scrolled entry object
1575  * @param file The path to the file to load and save
1576  * @param format The file format
1577  *
1578  * @ingroup Scrolled_Entry
1579  */
1580 EAPI void
1581 elm_scrolled_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
1582 {
1583    ELM_CHECK_WIDTYPE(obj, widtype);
1584    Widget_Data *wd = elm_widget_data_get(obj);
1585    if (!wd) return;
1586    elm_entry_file_get(wd->entry, file, format);
1587 }
1588
1589 /**
1590  * This function writes any changes made to the file set with
1591  * elm_scrolled_entry_file_set()
1592  *
1593  * @param obj The scrolled entry object
1594  *
1595  * @ingroup Scrolled_Entry
1596  */
1597 EAPI void
1598 elm_scrolled_entry_file_save(Evas_Object *obj)
1599 {
1600    ELM_CHECK_WIDTYPE(obj, widtype);
1601    Widget_Data *wd = elm_widget_data_get(obj);
1602    if (!wd) return;
1603    elm_entry_file_save(wd->entry);
1604 }
1605
1606 /**
1607  * This sets the entry object to 'autosave' the loaded text file or not.
1608  *
1609  * @param obj The scrolled entry object
1610  * @param autosave Autosave the loaded file or not
1611  *
1612  * @ingroup Scrolled_Entry
1613  */
1614 EAPI void
1615 elm_scrolled_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
1616 {
1617    ELM_CHECK_WIDTYPE(obj, widtype);
1618    Widget_Data *wd = elm_widget_data_get(obj);
1619    if (!wd) return;
1620    elm_entry_autosave_set(wd->entry, autosave);
1621 }
1622
1623 /**
1624  * This gets the entry object's 'autosave' status.
1625  *
1626  * @param obj The scrolled entry object
1627  * @return Autosave the loaded file or not
1628  *
1629  * @ingroup Scrolled_Entry
1630  */
1631 EAPI Eina_Bool
1632 elm_scrolled_entry_autosave_get(const Evas_Object *obj)
1633 {
1634    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1635    Widget_Data *wd = elm_widget_data_get(obj);
1636    if (!wd) return EINA_FALSE;
1637    return elm_entry_autosave_get(wd->entry);
1638 }
1639
1640 /**
1641  * Control pasting of text and images for the widget.
1642  *
1643  * Normally the scrolled entry allows both text and images to be pasted.
1644  * By setting textonly to be true, this prevents images from being pasted.
1645  *
1646  * Note this only changes the behaviour of text.
1647  *
1648  * @param obj The scrolled entry object
1649  * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
1650  *
1651  * @see elm_entry_cnp_textonly_set
1652  * @ingroup Scrolled_Entry
1653  */
1654 EAPI void
1655 elm_scrolled_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
1656 {
1657    ELM_CHECK_WIDTYPE(obj, widtype);
1658    Widget_Data *wd = elm_widget_data_get(obj);
1659    if (!wd) return;
1660    elm_entry_cnp_textonly_set(wd->entry, textonly);
1661 }
1662
1663 /**
1664  * Getting elm_scrolled_entry text paste/drop mode.
1665  *
1666  * In textonly mode, only text may be pasted or dropped into the widget.
1667  *
1668  * @param obj The scrolled entry object
1669  * @return If the widget only accepts text from pastes.
1670  *
1671  * @see elm_entry_cnp_textonly_get
1672  * @ingroup Scrolled_Entry
1673  */
1674 EAPI Eina_Bool
1675 elm_scrolled_entry_cnp_textonly_get(Evas_Object *obj)
1676 {
1677    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1678    Widget_Data *wd = elm_widget_data_get(obj);
1679    if (!wd) return EINA_FALSE;
1680    return elm_entry_cnp_textonly_get(wd->entry);
1681 }