Elementary: Use an enum for selecting line-wrap method.
[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 returns the text currently shown in object @p entry.
748  * See also elm_scrolled_entry_entry_set().
749  *
750  * @param obj The scrolled entry object
751  * @return The currently displayed text or NULL on failure
752  *
753  * @ingroup Scrolled_Entry
754  */
755 EAPI const char *
756 elm_scrolled_entry_entry_get(const Evas_Object *obj)
757 {
758    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
759    Widget_Data *wd = elm_widget_data_get(obj);
760    if (!wd) return NULL;
761    return elm_entry_entry_get(wd->entry);
762 }
763
764 /**
765  * This returns EINA_TRUE if the entry is empty/there was an error
766  * and EINA_FALSE if it is not empty.
767  *
768  * @param obj The entry object
769  * @return If the entry is empty or not.
770  *
771  * @ingroup Entry
772  */
773 EAPI Eina_Bool
774 elm_scrolled_entry_is_empty(const Evas_Object *obj)
775 {
776    ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
777    Widget_Data *wd = elm_widget_data_get(obj);
778    if (!wd) return EINA_TRUE;
779    return elm_entry_is_empty(wd->entry);
780 }
781
782 /**
783  * This returns all selected text within the scrolled entry.
784  *
785  * @param obj The scrolled entry object
786  * @return The selected text within the scrolled entry or NULL on failure
787  *
788  * @ingroup Scrolled_Entry
789  */
790 EAPI const char *
791 elm_scrolled_entry_selection_get(const Evas_Object *obj)
792 {
793    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
794    Widget_Data *wd = elm_widget_data_get(obj);
795    if (!wd) return NULL;
796    return elm_entry_selection_get(wd->entry);
797 }
798
799 /**
800  * This inserts text in @p entry at the beginning of the scrolled entry
801  * object.
802  *
803  * @param obj The scrolled entry object
804  * @param entry The text to insert
805  *
806  * @ingroup Scrolled_Entry
807  */
808 EAPI void
809 elm_scrolled_entry_entry_insert(Evas_Object *obj, const char *entry)
810 {
811    ELM_CHECK_WIDTYPE(obj, widtype);
812    Widget_Data *wd = elm_widget_data_get(obj);
813    if (!wd) return;
814    elm_entry_entry_insert(wd->entry, entry);
815 }
816
817 /**
818  * This enables word line wrapping in the scrolled entry object.  It is the opposite
819  * of elm_scrolled_entry_single_line_set().  Additionally, setting this disables
820  * character line wrapping.
821  * See also elm_scrolled_entry_line_char_wrap_set().
822  *
823  * @param obj The scrolled entry object
824  * @param wrap wrap according to Elm_Wrap_Type
825  * of the object. Wrapping will occur at the end of the word before the end of the
826  * object.
827  *
828  * @ingroup Scrolled_Entry
829  */
830 EAPI void
831 elm_scrolled_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap)
832 {
833    ELM_CHECK_WIDTYPE(obj, widtype);
834    Widget_Data *wd = elm_widget_data_get(obj);
835    if (!wd) return;
836    elm_entry_line_wrap_set(wd->entry, wrap);
837 }
838
839 /**
840  * This sets the editable attribute of the scrolled entry.
841  *
842  * @param obj The scrolled entry object
843  * @param editable If true, the scrolled entry will be editable by the user.
844  * If false, it will be set to the disabled state.
845  *
846  * @ingroup Scrolled_Entry
847  */
848 EAPI void
849 elm_scrolled_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
850 {
851    ELM_CHECK_WIDTYPE(obj, widtype);
852    Widget_Data *wd = elm_widget_data_get(obj);
853    if (!wd) return;
854    elm_entry_editable_set(wd->entry, editable);
855 }
856
857 /**
858  * This gets the editable attribute of the scrolled entry.
859  * See also elm_scrolled_entry_editable_set().
860  *
861  * @param obj The scrolled entry object
862  * @return If true, the scrolled entry is editable by the user.
863  * If false, it is not editable by the user
864  *
865  * @ingroup Scrolled_Entry
866  */
867 EAPI Eina_Bool
868 elm_scrolled_entry_editable_get(const Evas_Object *obj)
869 {
870    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
871    Widget_Data *wd = elm_widget_data_get(obj);
872    if (!wd) return EINA_FALSE;
873    return elm_entry_editable_get(wd->entry);
874 }
875
876
877 /**
878  * This drops any existing text selection within the scrolled entry.
879  *
880  * @param obj The scrolled entry object
881  *
882  * @ingroup Scrolled_Entry
883  */
884 EAPI void
885 elm_scrolled_entry_select_none(Evas_Object *obj)
886 {
887    ELM_CHECK_WIDTYPE(obj, widtype);
888    Widget_Data *wd = elm_widget_data_get(obj);
889    if (!wd) return;
890    elm_entry_select_none(wd->entry);
891 }
892
893 /**
894  * This selects all text within the scrolled entry.
895  *
896  * @param obj The scrolled entry object
897  *
898  * @ingroup Scrolled_Entry
899  */
900 EAPI void
901 elm_scrolled_entry_select_all(Evas_Object *obj)
902 {
903    ELM_CHECK_WIDTYPE(obj, widtype);
904    Widget_Data *wd = elm_widget_data_get(obj);
905    if (!wd) return;
906    elm_entry_select_all(wd->entry);
907 }
908
909 /**
910  * This moves the cursor one place to the right within the entry.
911  *
912  * @param obj The scrolled entry object
913  * @return EINA_TRUE upon success, EINA_FALSE upon failure
914  *
915  * @ingroup Scrolled_Entry
916  */
917 EAPI Eina_Bool
918 elm_scrolled_entry_cursor_next(Evas_Object *obj)
919 {
920    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
921    Widget_Data *wd = elm_widget_data_get(obj);
922    if (!wd) return EINA_FALSE;
923    return elm_entry_cursor_next(wd->entry);
924 }
925
926 /**
927  * This moves the cursor one place to the left 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_prev(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_prev(wd->entry);
941 }
942
943 /**
944  * This moves the cursor one line up 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_up(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_up(wd->entry);
958 }
959
960 /**
961  * This moves the cursor one line down 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_down(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_down(wd->entry);
975 }
976
977 /**
978  * This moves the cursor to the beginning of the entry.
979  *
980  * @param obj The scrolled entry object
981  *
982  * @ingroup Scrolled_Entry
983  */
984 EAPI void
985 elm_scrolled_entry_cursor_begin_set(Evas_Object *obj)
986 {
987    ELM_CHECK_WIDTYPE(obj, widtype);
988    Widget_Data *wd = elm_widget_data_get(obj);
989    if (!wd) return;
990    elm_entry_cursor_begin_set(wd->entry);
991 }
992
993 /**
994  * This moves the cursor to the end of the entry.
995  *
996  * @param obj The scrolled entry object
997  *
998  * @ingroup Scrolled_Entry
999  */
1000 EAPI void
1001 elm_scrolled_entry_cursor_end_set(Evas_Object *obj)
1002 {
1003    ELM_CHECK_WIDTYPE(obj, widtype);
1004    Widget_Data *wd = elm_widget_data_get(obj);
1005    if (!wd) return;
1006    int x, y, w, h;
1007    elm_entry_cursor_end_set(wd->entry);
1008    elm_widget_show_region_get(wd->entry, &x, &y, &w, &h);
1009    elm_scroller_region_show(wd->scroller, x, y, w, h);
1010 }
1011
1012 /**
1013  * This moves the cursor to the beginning of the current line.
1014  *
1015  * @param obj The scrolled entry object
1016  *
1017  * @ingroup Scrolled_Entry
1018  */
1019 EAPI void
1020 elm_scrolled_entry_cursor_line_begin_set(Evas_Object *obj)
1021 {
1022    ELM_CHECK_WIDTYPE(obj, widtype);
1023    Widget_Data *wd = elm_widget_data_get(obj);
1024    if (!wd) return;
1025    elm_entry_cursor_line_begin_set(wd->entry);
1026 }
1027
1028 /**
1029  * This moves the cursor to the end of the current line.
1030  *
1031  * @param obj The scrolled entry object
1032  *
1033  * @ingroup Scrolled_Entry
1034  */
1035 EAPI void
1036 elm_scrolled_entry_cursor_line_end_set(Evas_Object *obj)
1037 {
1038    ELM_CHECK_WIDTYPE(obj, widtype);
1039    Widget_Data *wd = elm_widget_data_get(obj);
1040    if (!wd) return;
1041    elm_entry_cursor_line_end_set(wd->entry);
1042 }
1043
1044 /**
1045  * This begins a selection within the scrolled entry as though
1046  * the user were holding down the mouse button to make a selection.
1047  *
1048  * @param obj The scrolled entry object
1049  *
1050  * @ingroup Scrolled_Entry
1051  */
1052 EAPI void
1053 elm_scrolled_entry_cursor_selection_begin(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_selection_begin(wd->entry);
1059 }
1060
1061 /**
1062  * This ends a selection within the scrolled entry as though
1063  * the user had just released the mouse button while making 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_end(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_end(wd->entry);
1076 }
1077
1078 /**
1079  * TODO: fill this in
1080  *
1081  * @param obj The scrolled entry object
1082  * @return TODO: fill this in
1083  *
1084  * @ingroup Scrolled_Entry
1085  */
1086 EAPI Eina_Bool
1087 elm_scrolled_entry_cursor_is_format_get(const Evas_Object *obj)
1088 {
1089    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1090    Widget_Data *wd = elm_widget_data_get(obj);
1091    if (!wd) return EINA_FALSE;
1092    return elm_entry_cursor_is_format_get(wd->entry);
1093 }
1094
1095 /**
1096  * This returns whether the cursor is visible.
1097  *
1098  * @param obj The scrolled entry object
1099  * @return If true, the cursor is visible.
1100  *
1101  * @ingroup Scrolled_Entry
1102  */
1103 EAPI Eina_Bool
1104 elm_scrolled_entry_cursor_is_visible_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_visible_format_get(wd->entry);
1110 }
1111
1112 /**
1113  * TODO: fill this in
1114  *
1115  * @param obj The scrolled entry object
1116  * @return TODO: fill this in
1117  *
1118  * @ingroup Scrolled_Entry
1119  */
1120 EAPI const char *
1121 elm_scrolled_entry_cursor_content_get(const Evas_Object *obj)
1122 {
1123    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1124    Widget_Data *wd = elm_widget_data_get(obj);
1125    if (!wd) return NULL;
1126    return elm_entry_cursor_content_get(wd->entry);
1127 }
1128
1129 /**
1130  * Sets the cursor position in the scrolled entry to the given value
1131  *
1132  * @param obj The scrolled entry object
1133  * @param pos the position of the cursor
1134  *
1135  * @ingroup Scrolled_Entry
1136  */
1137 EAPI void
1138 elm_scrolled_entry_cursor_pos_set(Evas_Object *obj, int pos)
1139 {
1140    ELM_CHECK_WIDTYPE(obj, widtype);
1141    Widget_Data *wd = elm_widget_data_get(obj);
1142    if (!wd) return;
1143    elm_entry_cursor_pos_set(wd->entry, pos);
1144 }
1145
1146 /**
1147  * Retrieves the current position of the cursor in the scrolled entry
1148  *
1149  * @param obj The entry object
1150  * @return the cursor position
1151  *
1152  * @ingroup Scrolled_Entry
1153  */
1154 EAPI int
1155 elm_scrolled_entry_cursor_pos_get(const Evas_Object *obj)
1156 {
1157    ELM_CHECK_WIDTYPE(obj, widtype) 0;
1158    Widget_Data *wd = elm_widget_data_get(obj);
1159    if (!wd) return 0;
1160    return elm_entry_cursor_pos_get(wd->entry);
1161 }
1162
1163 /**
1164  * This executes a "cut" action on the selected text in the scrolled entry.
1165  *
1166  * @param obj The scrolled entry object
1167  *
1168  * @ingroup Scrolled_Entry
1169  */
1170 EAPI void
1171 elm_scrolled_entry_selection_cut(Evas_Object *obj)
1172 {
1173    ELM_CHECK_WIDTYPE(obj, widtype);
1174    Widget_Data *wd = elm_widget_data_get(obj);
1175    if (!wd) return;
1176    elm_entry_selection_cut(wd->entry);
1177 }
1178
1179 /**
1180  * This executes a "copy" action on the selected text in the scrolled entry.
1181  *
1182  * @param obj The scrolled entry object
1183  *
1184  * @ingroup Scrolled_Entry
1185  */
1186 EAPI void
1187 elm_scrolled_entry_selection_copy(Evas_Object *obj)
1188 {
1189    ELM_CHECK_WIDTYPE(obj, widtype);
1190    Widget_Data *wd = elm_widget_data_get(obj);
1191    if (!wd) return;
1192    elm_entry_selection_copy(wd->entry);
1193 }
1194
1195 /**
1196  * This executes a "paste" action in the scrolled entry.
1197  *
1198  * @param obj The scrolled entry object
1199  *
1200  * @ingroup Scrolled_Entry
1201  */
1202 EAPI void
1203 elm_scrolled_entry_selection_paste(Evas_Object *obj)
1204 {
1205    ELM_CHECK_WIDTYPE(obj, widtype);
1206    Widget_Data *wd = elm_widget_data_get(obj);
1207    if (!wd) return;
1208    elm_entry_selection_paste(wd->entry);
1209 }
1210
1211 /**
1212  * This clears and frees the items in a scrolled entry's contextual (right click) menu.
1213  *
1214  * @param obj The scrolled entry object
1215  *
1216  * @ingroup Scrolled_Entry
1217  */
1218 EAPI void
1219 elm_scrolled_entry_context_menu_clear(Evas_Object *obj)
1220 {
1221    ELM_CHECK_WIDTYPE(obj, widtype);
1222    Widget_Data *wd = elm_widget_data_get(obj);
1223    if (!wd) return;
1224    elm_entry_context_menu_clear(wd->entry);
1225 }
1226
1227 /**
1228  * This adds an item to the scrolled entry's contextual menu.
1229  *
1230  * @param obj The scrolled entry object
1231  * @param label The item's text label
1232  * @param icon_file The item's icon file
1233  * @param icon_type The item's icon type
1234  * @param func The callback to execute when the item is clicked
1235  * @param data The data to associate with the item for related functions
1236  *
1237  * @ingroup Scrolled_Entry
1238  */
1239 EAPI void
1240 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)
1241 {
1242    Elm_Entry_Context_Menu_Item *ci;
1243    ELM_CHECK_WIDTYPE(obj, widtype);
1244    Widget_Data *wd = elm_widget_data_get(obj);
1245    if (!wd) return;
1246
1247    ci = malloc(sizeof(Elm_Entry_Context_Menu_Item));
1248    if (!ci) return;
1249    ci->func = func;
1250    ci->data = (void *)data;
1251    ci->obj = obj;
1252    wd->items = eina_list_append(wd->items, ci);
1253    elm_entry_context_menu_item_add(wd->entry, label, icon_file, icon_type, _context_item_wrap_cb, ci);
1254 }
1255
1256 /**
1257  * This disables the scrolled entry's contextual (right click) menu.
1258  *
1259  * @param obj The scrolled entry object
1260  * @param disabled If true, the menu is disabled
1261  *
1262  * @ingroup Scrolled_Entry
1263  */
1264 EAPI void
1265 elm_scrolled_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1266 {
1267    ELM_CHECK_WIDTYPE(obj, widtype);
1268    Widget_Data *wd = elm_widget_data_get(obj);
1269    if (!wd) return;
1270    elm_entry_context_menu_disabled_set(wd->entry, disabled);
1271 }
1272
1273 /**
1274  * This returns whether the scrolled entry's contextual (right click) menu is disabled.
1275  *
1276  * @param obj The scrolled entry object
1277  * @return If true, the menu is disabled
1278  *
1279  * @ingroup Scrolled_Entry
1280  */
1281 EAPI Eina_Bool
1282 elm_scrolled_entry_context_menu_disabled_get(const Evas_Object *obj)
1283 {
1284    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1285    Widget_Data *wd = elm_widget_data_get(obj);
1286    if (!wd) return EINA_FALSE;
1287    return elm_entry_context_menu_disabled_get(wd->entry);
1288 }
1289
1290 /**
1291  * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
1292  *
1293  * @param obj The scrolled entry object
1294  * @param h The horizontal scrollbar policy to apply
1295  * @param v The vertical scrollbar policy to apply
1296  *
1297  * @ingroup Scrolled_Entry
1298  */
1299 EAPI void
1300 elm_scrolled_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
1301 {
1302    ELM_CHECK_WIDTYPE(obj, widtype);
1303    Widget_Data *wd = elm_widget_data_get(obj);
1304    if (!wd) return;
1305    wd->policy_h = h;
1306    wd->policy_v = v;
1307    elm_scroller_policy_set(wd->scroller, h, v);
1308 }
1309
1310 /**
1311  * This enables/disables bouncing within the entry.
1312  *
1313  * @param obj The scrolled entry object
1314  * @param h The horizontal bounce state
1315  * @param v The vertical bounce state
1316  *
1317  * @ingroup Scrolled_Entry
1318  */
1319 EAPI void
1320 elm_scrolled_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1321 {
1322    ELM_CHECK_WIDTYPE(obj, widtype);
1323    Widget_Data *wd = elm_widget_data_get(obj);
1324    if (!wd) return;
1325    elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce);
1326 }
1327
1328 /**
1329  * Get the bounce mode
1330  *
1331  * @param obj The Scrolled_Entry object
1332  * @param h_bounce Allow bounce horizontally
1333  * @param v_bounce Allow bounce vertically
1334  *
1335  * @ingroup Scrolled_Entry
1336  */
1337 EAPI void
1338 elm_scrolled_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1339 {
1340    ELM_CHECK_WIDTYPE(obj, widtype);
1341    Widget_Data *wd = elm_widget_data_get(obj);
1342    if (!wd) return;
1343    elm_scroller_bounce_get(wd->scroller, h_bounce, v_bounce);
1344 }
1345
1346 /**
1347  * This appends a custom item provider to the list for that entry
1348  *
1349  * This appends the given callback. The list is walked from beginning to end
1350  * with each function called given the item href string in the text. If the
1351  * function returns an object handle other than NULL (it should create an
1352  * and object to do this), then this object is used to replace that item. If
1353  * not the next provider is called until one provides an item object, or the
1354  * default provider in entry does.
1355  *
1356  * @param obj The entry object
1357  * @param func The function called to provide the item object
1358  * @param data The data passed to @p func
1359  *
1360  * @ingroup Scrolled_Entry
1361  */
1362 EAPI void
1363 elm_scrolled_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1364 {
1365    ELM_CHECK_WIDTYPE(obj, widtype);
1366    Widget_Data *wd = elm_widget_data_get(obj);
1367    if (!wd) return;
1368    EINA_SAFETY_ON_NULL_RETURN(func);
1369    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
1370    if (!ip) return;
1371    ip->func = func;
1372    ip->data = data;
1373    wd->item_providers = eina_list_append(wd->item_providers, ip);
1374 }
1375
1376 /**
1377  * This prepends a custom item provider to the list for that entry
1378  *
1379  * This prepends the given callback. See elm_scrolled_entry_item_provider_append() for
1380  * more information
1381  *
1382  * @param obj The entry object
1383  * @param func The function called to provide the item object
1384  * @param data The data passed to @p func
1385  *
1386  * @ingroup Scrolled_Entry
1387  */
1388 EAPI void
1389 elm_scrolled_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1390 {
1391    ELM_CHECK_WIDTYPE(obj, widtype);
1392    Widget_Data *wd = elm_widget_data_get(obj);
1393    if (!wd) return;
1394    EINA_SAFETY_ON_NULL_RETURN(func);
1395    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
1396    if (!ip) return;
1397    ip->func = func;
1398    ip->data = data;
1399    wd->item_providers = eina_list_prepend(wd->item_providers, ip);
1400 }
1401
1402 /**
1403  * This removes a custom item provider to the list for that entry
1404  *
1405  * This removes the given callback. See elm_scrolled_entry_item_provider_append() for
1406  * more information
1407  *
1408  * @param obj The entry object
1409  * @param func The function called to provide the item object
1410  * @param data The data passed to @p func
1411  *
1412  * @ingroup Scrolled_Entry
1413  */
1414 EAPI void
1415 elm_scrolled_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1416 {
1417    ELM_CHECK_WIDTYPE(obj, widtype);
1418    Widget_Data *wd = elm_widget_data_get(obj);
1419    Eina_List *l;
1420    Elm_Entry_Item_Provider *ip;
1421    if (!wd) return;
1422    EINA_SAFETY_ON_NULL_RETURN(func);
1423    EINA_LIST_FOREACH(wd->item_providers, l, ip)
1424      {
1425         if ((ip->func == func) && (ip->data == data))
1426           {
1427              wd->item_providers = eina_list_remove_list(wd->item_providers, l);
1428              free(ip);
1429              return;
1430           }
1431      }
1432 }
1433
1434 /**
1435  * Append a filter function for text inserted in the entry
1436  *
1437  * Append the given callback to the list. This functions will be called
1438  * whenever any text is inserted into the entry, with the text to be inserted
1439  * as a parameter. The callback function is free to alter the text in any way
1440  * it wants, but it must remember to free the given pointer and update it.
1441  * If the new text is to be discarded, the function can free it and set it text
1442  * parameter to NULL. This will also prevent any following filters from being
1443  * called.
1444  *
1445  * @param obj The entry object
1446  * @param func The function to use as text filter
1447  * @param data User data to pass to @p func
1448  *
1449  * @ingroup Scrolled_Entry
1450  */
1451 EAPI void
1452 elm_scrolled_entry_text_filter_append(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1453 {
1454    Widget_Data *wd;
1455    Elm_Entry_Text_Filter *tf;
1456    ELM_CHECK_WIDTYPE(obj, widtype);
1457
1458    wd = elm_widget_data_get(obj);
1459
1460    EINA_SAFETY_ON_NULL_RETURN(func);
1461
1462    tf = ELM_NEW(Elm_Entry_Text_Filter);
1463    if (!tf) return;
1464    tf->func = func;
1465    tf->data = data;
1466    wd->text_filters = eina_list_append(wd->text_filters, tf);
1467 }
1468
1469 /**
1470  * Prepend a filter function for text insdrted in the entry
1471  *
1472  * Prepend the given callback to the list. See elm_scrolled_entry_text_filter_append()
1473  * for more information
1474  *
1475  * @param obj The entry object
1476  * @param func The function to use as text filter
1477  * @param data User data to pass to @p func
1478  *
1479  * @ingroup Scrolled_Entry
1480  */
1481 EAPI void
1482 elm_scrolled_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1483 {
1484    Widget_Data *wd;
1485    Elm_Entry_Text_Filter *tf;
1486    ELM_CHECK_WIDTYPE(obj, widtype);
1487
1488    wd = elm_widget_data_get(obj);
1489
1490    EINA_SAFETY_ON_NULL_RETURN(func);
1491
1492    tf = ELM_NEW(Elm_Entry_Text_Filter);
1493    if (!tf) return;
1494    tf->func = func;
1495    tf->data = data;
1496    wd->text_filters = eina_list_prepend(wd->text_filters, tf);
1497 }
1498
1499 /**
1500  * Remove a filter from the list
1501  *
1502  * Removes the given callback from the filter list. See elm_scrolled_entry_text_filter_append()
1503  * for more information.
1504  *
1505  * @param obj The entry object
1506  * @param func The filter function to remove
1507  * @param data The user data passed when adding the function
1508  *
1509  * @ingroup Scrolled_Entry
1510  */
1511 EAPI void
1512 elm_scrolled_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1513 {
1514    Widget_Data *wd;
1515    Eina_List *l;
1516    Elm_Entry_Text_Filter *tf;
1517    ELM_CHECK_WIDTYPE(obj, widtype);
1518
1519    wd = elm_widget_data_get(obj);
1520
1521    EINA_SAFETY_ON_NULL_RETURN(func);
1522
1523    EINA_LIST_FOREACH(wd->text_filters, l, tf)
1524      {
1525         if ((tf->func == func) && (tf->data == data))
1526           {
1527              wd->text_filters = eina_list_remove_list(wd->text_filters, l);
1528              free(tf);
1529              return;
1530           }
1531      }
1532 }
1533
1534 /**
1535  * This sets the file (and implicitly loads it) for the text to display and
1536  * then edit. All changes are written back to the file after a short delay if
1537  * the entry object is set to autosave.
1538  *
1539  * @param obj The scrolled entry object
1540  * @param file The path to the file to load and save
1541  * @param format The file format
1542  *
1543  * @ingroup Scrolled_Entry
1544  */
1545 EAPI void
1546 elm_scrolled_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
1547 {
1548    ELM_CHECK_WIDTYPE(obj, widtype);
1549    Widget_Data *wd = elm_widget_data_get(obj);
1550    if (!wd) return;
1551    elm_entry_file_set(wd->entry, file, format);
1552 }
1553
1554 /**
1555  * Gets the file to load and save and the file format
1556  *
1557  * @param obj The scrolled entry object
1558  * @param file The path to the file to load and save
1559  * @param format The file format
1560  *
1561  * @ingroup Scrolled_Entry
1562  */
1563 EAPI void
1564 elm_scrolled_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
1565 {
1566    ELM_CHECK_WIDTYPE(obj, widtype);
1567    Widget_Data *wd = elm_widget_data_get(obj);
1568    if (!wd) return;
1569    elm_entry_file_get(wd->entry, file, format);
1570 }
1571
1572 /**
1573  * This function writes any changes made to the file set with
1574  * elm_scrolled_entry_file_set()
1575  *
1576  * @param obj The scrolled entry object
1577  *
1578  * @ingroup Scrolled_Entry
1579  */
1580 EAPI void
1581 elm_scrolled_entry_file_save(Evas_Object *obj)
1582 {
1583    ELM_CHECK_WIDTYPE(obj, widtype);
1584    Widget_Data *wd = elm_widget_data_get(obj);
1585    if (!wd) return;
1586    elm_entry_file_save(wd->entry);
1587 }
1588
1589 /**
1590  * This sets the entry object to 'autosave' the loaded text file or not.
1591  *
1592  * @param obj The scrolled entry object
1593  * @param autosave Autosave the loaded file or not
1594  *
1595  * @ingroup Scrolled_Entry
1596  */
1597 EAPI void
1598 elm_scrolled_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
1599 {
1600    ELM_CHECK_WIDTYPE(obj, widtype);
1601    Widget_Data *wd = elm_widget_data_get(obj);
1602    if (!wd) return;
1603    elm_entry_autosave_set(wd->entry, autosave);
1604 }
1605
1606 /**
1607  * This gets the entry object's 'autosave' status.
1608  *
1609  * @param obj The scrolled entry object
1610  * @return Autosave the loaded file or not
1611  *
1612  * @ingroup Scrolled_Entry
1613  */
1614 EAPI Eina_Bool
1615 elm_scrolled_entry_autosave_get(const Evas_Object *obj)
1616 {
1617    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1618    Widget_Data *wd = elm_widget_data_get(obj);
1619    if (!wd) return EINA_FALSE;
1620    return elm_entry_autosave_get(wd->entry);
1621 }
1622
1623 /**
1624  * Control pasting of text and images for the widget.
1625  *
1626  * Normally the scrolled entry allows both text and images to be pasted.
1627  * By setting textonly to be true, this prevents images from being pasted.
1628  *
1629  * Note this only changes the behaviour of text.
1630  *
1631  * @param obj The scrolled entry object
1632  * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
1633  *
1634  * @see elm_entry_cnp_textonly_set
1635  * @ingroup Scrolled_Entry
1636  */
1637 EAPI void
1638 elm_scrolled_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
1639 {
1640    ELM_CHECK_WIDTYPE(obj, widtype);
1641    Widget_Data *wd = elm_widget_data_get(obj);
1642    if (!wd) return;
1643    elm_entry_cnp_textonly_set(wd->entry, textonly);
1644 }
1645
1646 /**
1647  * Getting elm_scrolled_entry text paste/drop mode.
1648  *
1649  * In textonly mode, only text may be pasted or dropped into the widget.
1650  *
1651  * @param obj The scrolled entry object
1652  * @return If the widget only accepts text from pastes.
1653  *
1654  * @see elm_entry_cnp_textonly_get
1655  * @ingroup Scrolled_Entry
1656  */
1657 EAPI Eina_Bool
1658 elm_scrolled_entry_cnp_textonly_get(Evas_Object *obj)
1659 {
1660    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1661    Widget_Data *wd = elm_widget_data_get(obj);
1662    if (!wd) return EINA_FALSE;
1663    return elm_entry_cnp_textonly_get(wd->entry);
1664 }