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