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