Elementary: Use pre-defined type Edje_Signal_Cb instead of describing all of its...
[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, Edje_Signal_Cb func_cb, 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, Edje_Signal_Cb func_cb, 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    ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
367
368    ELM_SET_WIDTYPE(widtype, "scrolled_entry");
369    elm_widget_type_set(obj, "scrolled_entry");
370    elm_widget_sub_object_add(parent, obj);
371    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
372    elm_widget_data_set(obj, wd);
373    elm_widget_del_hook_set(obj, _del_hook);
374    elm_widget_disable_hook_set(obj, _disable_hook);
375    elm_widget_can_focus_set(obj, EINA_TRUE);
376    elm_widget_theme_hook_set(obj, _theme_hook);
377    elm_widget_on_focus_region_hook_set(obj, _on_focus_region_hook);
378    elm_widget_signal_emit_hook_set(obj, _signal_emit_hook);
379    elm_widget_signal_callback_add_hook_set(obj, _signal_callback_add_hook);
380    elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
381
382    wd->scroller = elm_scroller_add(obj);
383    elm_scroller_custom_widget_base_theme_set(wd->scroller, "scroller", "entry");
384    elm_widget_resize_object_set(obj, wd->scroller);
385    evas_object_size_hint_weight_set(wd->scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
386    evas_object_size_hint_align_set(wd->scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
387    elm_scroller_bounce_set(wd->scroller, EINA_FALSE, EINA_FALSE);
388    elm_scroller_propagate_events_set(wd->scroller, EINA_TRUE);
389    evas_object_show(wd->scroller);
390
391    wd->entry = elm_entry_add(obj);
392    evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
393    evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
394    elm_scroller_content_set(wd->scroller, wd->entry);
395    evas_object_show(wd->entry);
396
397    elm_entry_text_filter_prepend(wd->entry, _text_filter_wrap_cb, obj);
398    elm_entry_item_provider_prepend(wd->entry, _item_provider_wrap_cb, obj);
399
400    evas_object_smart_callback_add(wd->entry, "changed", _entry_changed, obj);
401    evas_object_smart_callback_add(wd->entry, "activated", _entry_activated, obj);
402    evas_object_smart_callback_add(wd->entry, "press", _entry_press, obj);
403    evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked, obj);
404    evas_object_smart_callback_add(wd->entry, "clicked,double", _entry_clicked_double, obj);
405    evas_object_smart_callback_add(wd->entry, "cursor,changed", _entry_cursor_changed, obj);
406    evas_object_smart_callback_add(wd->entry, "anchor,clicked", _entry_anchor_clicked, obj);
407    evas_object_smart_callback_add(wd->entry, "selection,start", _entry_selection_start, obj);
408    evas_object_smart_callback_add(wd->entry, "selection,changed", _entry_selection_changed, obj);
409    evas_object_smart_callback_add(wd->entry, "selection,cleared", _entry_selection_cleared, obj);
410    evas_object_smart_callback_add(wd->entry, "selection,paste", _entry_selection_paste, obj);
411    evas_object_smart_callback_add(wd->entry, "selection,copy", _entry_selection_copy, obj);
412    evas_object_smart_callback_add(wd->entry, "selection,cut", _entry_selection_cut, obj);
413    evas_object_smart_callback_add(wd->entry, "longpressed", _entry_longpressed, obj);
414    evas_object_smart_callback_add(wd->entry, "focused", _entry_focused, obj);
415    evas_object_smart_callback_add(wd->entry, "unfocused", _entry_unfocused, obj);
416
417    evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
418                                   _changed_size_hints, NULL);
419
420    _sizing_eval(obj);
421
422    // TODO: convert Elementary to subclassing of Evas_Smart_Class
423    // TODO: and save some bytes, making descriptions per-class and not instance!
424    evas_object_smart_callbacks_descriptions_set(obj, _signals);
425    return obj;
426 }
427
428 /**
429  * This sets a widget to be displayed to the left of a scrolled entry.
430  *
431  * @param obj The scrolled entry object
432  * @param icon The widget to display on the left side of the scrolled
433  * entry.
434  *
435  * @note A previously set widget will be destroyed.
436  * @note If the object being set does not have minimum size hints set,
437  * it won't get properly displayed.
438  *
439  * @ingroup Scrolled_Entry
440  * @see elm_scrolled_entry_end_set
441  */
442 EAPI void
443 elm_scrolled_entry_icon_set(Evas_Object *obj, Evas_Object *icon)
444 {
445    ELM_CHECK_WIDTYPE(obj, widtype);
446    Widget_Data *wd = elm_widget_data_get(obj);
447    Evas_Object *edje;
448    if (!wd) return;
449    EINA_SAFETY_ON_NULL_RETURN(icon);
450    if (wd->icon == icon) return;
451    if (wd->icon) evas_object_del(wd->icon);
452    wd->icon = icon;
453    edje = _elm_scroller_edje_object_get(wd->scroller);
454    if (!edje) return;
455    edje_object_part_swallow(edje, "elm.swallow.icon", wd->icon);
456    edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
457    _sizing_eval(obj);
458 }
459
460 /**
461  * Gets the leftmost widget of the scrolled entry. This object is
462  * owned by the scrolled entry and should not be modified.
463  *
464  * @param obj The scrolled entry object
465  * @return the left widget inside the scroller
466  *
467  * @ingroup Scrolled_Entry
468  */
469 EAPI Evas_Object *
470 elm_scrolled_entry_icon_get(const Evas_Object *obj)
471 {
472    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
473    Widget_Data *wd = elm_widget_data_get(obj);
474    if (!wd) return NULL;
475    return wd->icon;
476 }
477
478 /**
479  * Unset the leftmost widget of the scrolled entry, unparenting and
480  * returning it.
481  *
482  * @param obj The scrolled entry object
483  * @return the previously set icon sub-object of this entry, on
484  * success.
485  *
486  * @see elm_scrolled_entry_icon_set()
487  *
488  * @ingroup Scrolled_Entry
489  */
490 EAPI Evas_Object *
491 elm_scrolled_entry_icon_unset(Evas_Object *obj)
492 {
493    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
494    Widget_Data *wd = elm_widget_data_get(obj);
495    Evas_Object *ret = NULL;
496    if (!wd) return NULL;
497    if (wd->icon)
498      {
499         Evas_Object *edje = _elm_scroller_edje_object_get(wd->scroller);
500         if (!edje) return NULL;
501         ret = wd->icon;
502         edje_object_part_unswallow(edje, wd->icon);
503         edje_object_signal_emit(edje, "elm,action,hide,icon", "elm");
504         wd->icon = NULL;
505         _sizing_eval(obj);
506      }
507    return ret;
508 }
509
510 /**
511  * Sets the visibility of the left-side widget of the scrolled entry,
512  * set by @elm_scrolled_entry_icon_set().
513  *
514  * @param obj The scrolled entry object
515  * @param setting EINA_TRUE if the object should be displayed,
516  * EINA_FALSE if not.
517  *
518  * @ingroup Scrolled_Entry
519  */
520 EAPI void
521 elm_scrolled_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting)
522 {
523    ELM_CHECK_WIDTYPE(obj, widtype);
524    Widget_Data *wd = elm_widget_data_get(obj);
525    if ((!wd) || (!wd->icon)) return;
526    if (setting)
527      evas_object_hide(wd->icon);
528    else
529      evas_object_show(wd->icon);
530    _sizing_eval(obj);
531 }
532
533 /**
534  * This sets a widget to be displayed to the end of a scrolled entry.
535  *
536  * @param obj The scrolled entry object
537  * @param end The widget to display on the right side of the scrolled
538  * entry.
539  *
540  * @note A previously set widget will be destroyed.
541  * @note If the object being set does not have minimum size hints set,
542  * it won't get properly displayed.
543  *
544  * @ingroup Scrolled_Entry
545  * @see elm_scrolled_entry_icon_set
546  */
547 EAPI void
548 elm_scrolled_entry_end_set(Evas_Object *obj, Evas_Object *end)
549 {
550    ELM_CHECK_WIDTYPE(obj, widtype);
551    Widget_Data *wd = elm_widget_data_get(obj);
552    Evas_Object *edje;
553    if (!wd) return;
554    EINA_SAFETY_ON_NULL_RETURN(end);
555    if (wd->end == end) return;
556    if (wd->end) evas_object_del(wd->end);
557    wd->end = end;
558    edje = _elm_scroller_edje_object_get(wd->scroller);
559    if (!edje) return;
560    edje_object_part_swallow(edje, "elm.swallow.end", wd->end);
561    edje_object_signal_emit(edje, "elm,action,show,end", "elm");
562    _sizing_eval(obj);
563 }
564
565 /**
566  * Gets the endmost widget of the scrolled entry. This object is owned
567  * by the scrolled entry and should not be modified.
568  *
569  * @param obj The scrolled entry object
570  * @return the right widget inside the scroller
571  *
572  * @ingroup Scrolled_Entry
573  */
574 EAPI Evas_Object *
575 elm_scrolled_entry_end_get(const Evas_Object *obj)
576 {
577    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
578    Widget_Data *wd = elm_widget_data_get(obj);
579    if (!wd) return NULL;
580    return wd->end;
581 }
582
583 /**
584  * Unset the endmost widget of the scrolled entry, unparenting and
585  * returning it.
586  *
587  * @param obj The scrolled entry object
588  * @return the previously set icon sub-object of this entry, on
589  * success.
590  *
591  * @see elm_scrolled_entry_icon_set()
592  *
593  * @ingroup Scrolled_Entry
594  */
595 EAPI Evas_Object *
596 elm_scrolled_entry_end_unset(Evas_Object *obj)
597 {
598    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
599    Widget_Data *wd = elm_widget_data_get(obj);
600    Evas_Object *ret = NULL;
601    if (!wd) return NULL;
602    if (wd->end)
603      {
604         Evas_Object *edje = _elm_scroller_edje_object_get(wd->scroller);
605         if (!edje) return NULL;
606         ret = wd->end;
607         edje_object_part_unswallow(edje, wd->end);
608         edje_object_signal_emit(edje, "elm,action,hide,end", "elm");
609         wd->end = NULL;
610         _sizing_eval(obj);
611      }
612    return ret;
613 }
614
615 /**
616  * Sets the visibility of the end widget of the scrolled entry, set by
617  * @elm_scrolled_entry_end_set().
618  *
619  * @param obj The scrolled entry object
620  * @param setting EINA_TRUE if the object should be displayed,
621  * EINA_FALSE if not.
622  *
623  * @ingroup Scrolled_Entry
624  */
625 EAPI void
626 elm_scrolled_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting)
627 {
628    ELM_CHECK_WIDTYPE(obj, widtype);
629    Widget_Data *wd = elm_widget_data_get(obj);
630    if ((!wd) || (!wd->end)) return;
631    if (setting)
632      evas_object_hide(wd->end);
633    else
634      evas_object_show(wd->end);
635    _sizing_eval(obj);
636 }
637
638 /**
639  * This sets the scrolled entry object not to line wrap.  All input will
640  * be on a single line, and the entry box will scroll with user input.
641  *
642  * @param obj The scrolled entry object
643  * @param single_line If true, the text in the scrolled entry
644  * will be on a single line.
645  *
646  * @ingroup Scrolled_Entry
647  */
648 EAPI void
649 elm_scrolled_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
650 {
651    ELM_CHECK_WIDTYPE(obj, widtype);
652    Widget_Data *wd = elm_widget_data_get(obj);
653    if (!wd) return;
654    if (wd->single_line == single_line) return;
655    elm_entry_single_line_set(wd->entry, single_line);
656    wd->single_line = single_line;
657    if (single_line)
658      {
659         elm_scroller_policy_set(wd->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
660         elm_scroller_content_min_limit(wd->scroller, 0, 1);
661      }
662    else
663      {
664         elm_scroller_policy_set(wd->scroller, wd->policy_h, wd->policy_v);
665         elm_scroller_content_min_limit(wd->scroller, 0, 0);
666      }
667    _sizing_eval(obj);
668 }
669
670 /**
671  * This returns true if the scrolled entry has been set to single line mode.
672  * See also elm_scrolled_entry_single_line_set().
673  *
674  * @param obj The scrolled entry object
675  * @return single_line If true, the text in the scrolled entry is set to display
676  * on a single line.
677  *
678  * @ingroup Scrolled_Entry
679  */
680 EAPI Eina_Bool
681 elm_scrolled_entry_single_line_get(const Evas_Object *obj)
682 {
683    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
684    Widget_Data *wd = elm_widget_data_get(obj);
685    if (!wd) return EINA_FALSE;
686    return elm_entry_single_line_get(wd->entry);
687 }
688
689
690 /**
691  * This sets the scrolled entry object to password mode.  All text entered
692  * and/or displayed within the widget will be replaced with asterisks (*).
693  *
694  * @param obj The scrolled entry object
695  * @param password If true, password mode is enabled.
696  *
697  * @ingroup Scrolled_Entry
698  */
699 EAPI void
700 elm_scrolled_entry_password_set(Evas_Object *obj, Eina_Bool password)
701 {
702    ELM_CHECK_WIDTYPE(obj, widtype);
703    Widget_Data *wd = elm_widget_data_get(obj);
704    if (!wd) return;
705    elm_entry_password_set(wd->entry, password);
706 }
707
708 /**
709  * This returns whether password mode is enabled.
710  * See also elm_scrolled_entry_password_set().
711  *
712  * @param obj The scrolled entry object
713  * @return If true, the scrolled entry is set to display all characters
714  * as asterisks (*).
715  *
716  * @ingroup Scrolled_Entry
717  */
718 EAPI Eina_Bool
719 elm_scrolled_entry_password_get(const Evas_Object *obj)
720 {
721    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
722    Widget_Data *wd = elm_widget_data_get(obj);
723    if (!wd) return EINA_FALSE;
724    return elm_entry_password_get(wd->entry);
725 }
726
727
728 /**
729  * This sets the text displayed within the scrolled entry to @p entry.
730  *
731  * @param obj The scrolled entry object
732  * @param entry The text to be displayed
733  *
734  * @ingroup Scrolled_Entry
735  */
736 EAPI void
737 elm_scrolled_entry_entry_set(Evas_Object *obj, const char *entry)
738 {
739    ELM_CHECK_WIDTYPE(obj, widtype);
740    Widget_Data *wd = elm_widget_data_get(obj);
741    if (!wd) return;
742    elm_entry_entry_set(wd->entry, entry);
743 }
744
745 /**
746  * This returns the text currently shown in object @p entry.
747  * See also elm_scrolled_entry_entry_set().
748  *
749  * @param obj The scrolled entry object
750  * @return The currently displayed text or NULL on failure
751  *
752  * @ingroup Scrolled_Entry
753  */
754 EAPI const char *
755 elm_scrolled_entry_entry_get(const Evas_Object *obj)
756 {
757    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
758    Widget_Data *wd = elm_widget_data_get(obj);
759    if (!wd) return NULL;
760    return elm_entry_entry_get(wd->entry);
761 }
762
763 /**
764  * This returns EINA_TRUE if the entry is empty/there was an error
765  * and EINA_FALSE if it is not empty.
766  *
767  * @param obj The entry object
768  * @return If the entry is empty or not.
769  *
770  * @ingroup Entry
771  */
772 EAPI Eina_Bool
773 elm_scrolled_entry_is_empty(const Evas_Object *obj)
774 {
775    ELM_CHECK_WIDTYPE(obj, widtype) EINA_TRUE;
776    Widget_Data *wd = elm_widget_data_get(obj);
777    if (!wd) return EINA_TRUE;
778    return elm_entry_is_empty(wd->entry);
779 }
780
781 /**
782  * This returns all selected text within the scrolled entry.
783  *
784  * @param obj The scrolled entry object
785  * @return The selected text within the scrolled entry or NULL on failure
786  *
787  * @ingroup Scrolled_Entry
788  */
789 EAPI const char *
790 elm_scrolled_entry_selection_get(const Evas_Object *obj)
791 {
792    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
793    Widget_Data *wd = elm_widget_data_get(obj);
794    if (!wd) return NULL;
795    return elm_entry_selection_get(wd->entry);
796 }
797
798 /**
799  * This inserts text in @p entry at the beginning of the scrolled entry
800  * object.
801  *
802  * @param obj The scrolled entry object
803  * @param entry The text to insert
804  *
805  * @ingroup Scrolled_Entry
806  */
807 EAPI void
808 elm_scrolled_entry_entry_insert(Evas_Object *obj, const char *entry)
809 {
810    ELM_CHECK_WIDTYPE(obj, widtype);
811    Widget_Data *wd = elm_widget_data_get(obj);
812    if (!wd) return;
813    elm_entry_entry_insert(wd->entry, entry);
814 }
815
816 /**
817  * This enables word line wrapping in the scrolled entry object.  It is the opposite
818  * of elm_scrolled_entry_single_line_set().  Additionally, setting this disables
819  * character line wrapping.
820  * See also elm_scrolled_entry_line_char_wrap_set().
821  *
822  * @param obj The scrolled entry object
823  * @param wrap If true, the scrolled entry will be wrapped once it reaches the end
824  * of the object. Wrapping will occur at the end of the word before the end of the
825  * object.
826  *
827  * @ingroup Scrolled_Entry
828  */
829 EAPI void
830 elm_scrolled_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
831 {
832    ELM_CHECK_WIDTYPE(obj, widtype);
833    Widget_Data *wd = elm_widget_data_get(obj);
834    if (!wd) return;
835    elm_entry_line_wrap_set(wd->entry, wrap);
836 }
837
838 /**
839  * This enables character line wrapping in the scrolled entry object.  It is the opposite
840  * of elm_scrolled_entry_single_line_set().  Additionally, setting this disables
841  * word line wrapping.
842  * See also elm_scrolled_entry_line_wrap_set().
843  *
844  * @param obj The scrolled entry object
845  * @param wrap If true, the scrolled entry will be wrapped once it reaches the end
846  * of the object. Wrapping will occur immediately upon reaching the end of the object.
847  *
848  * @ingroup Scrolled_Entry
849  */
850 EAPI void
851 elm_scrolled_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
852 {
853    ELM_CHECK_WIDTYPE(obj, widtype);
854    Widget_Data *wd = elm_widget_data_get(obj);
855    if (!wd) return;
856    elm_entry_line_char_wrap_set(wd->entry, wrap);
857 }
858
859 /**
860  * This sets the editable attribute of the scrolled entry.
861  *
862  * @param obj The scrolled entry object
863  * @param editable If true, the scrolled entry will be editable by the user.
864  * If false, it will be set to the disabled state.
865  *
866  * @ingroup Scrolled_Entry
867  */
868 EAPI void
869 elm_scrolled_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
870 {
871    ELM_CHECK_WIDTYPE(obj, widtype);
872    Widget_Data *wd = elm_widget_data_get(obj);
873    if (!wd) return;
874    elm_entry_editable_set(wd->entry, editable);
875 }
876
877 /**
878  * This gets the editable attribute of the scrolled entry.
879  * See also elm_scrolled_entry_editable_set().
880  *
881  * @param obj The scrolled entry object
882  * @return If true, the scrolled entry is editable by the user.
883  * If false, it is not editable by the user
884  *
885  * @ingroup Scrolled_Entry
886  */
887 EAPI Eina_Bool
888 elm_scrolled_entry_editable_get(const Evas_Object *obj)
889 {
890    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
891    Widget_Data *wd = elm_widget_data_get(obj);
892    if (!wd) return EINA_FALSE;
893    return elm_entry_editable_get(wd->entry);
894 }
895
896
897 /**
898  * This drops any existing text selection within the scrolled entry.
899  *
900  * @param obj The scrolled entry object
901  *
902  * @ingroup Scrolled_Entry
903  */
904 EAPI void
905 elm_scrolled_entry_select_none(Evas_Object *obj)
906 {
907    ELM_CHECK_WIDTYPE(obj, widtype);
908    Widget_Data *wd = elm_widget_data_get(obj);
909    if (!wd) return;
910    elm_entry_select_none(wd->entry);
911 }
912
913 /**
914  * This selects all text within the scrolled entry.
915  *
916  * @param obj The scrolled entry object
917  *
918  * @ingroup Scrolled_Entry
919  */
920 EAPI void
921 elm_scrolled_entry_select_all(Evas_Object *obj)
922 {
923    ELM_CHECK_WIDTYPE(obj, widtype);
924    Widget_Data *wd = elm_widget_data_get(obj);
925    if (!wd) return;
926    elm_entry_select_all(wd->entry);
927 }
928
929 /**
930  * This moves the cursor one place to the right within the entry.
931  *
932  * @param obj The scrolled entry object
933  * @return EINA_TRUE upon success, EINA_FALSE upon failure
934  *
935  * @ingroup Scrolled_Entry
936  */
937 EAPI Eina_Bool
938 elm_scrolled_entry_cursor_next(Evas_Object *obj)
939 {
940    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
941    Widget_Data *wd = elm_widget_data_get(obj);
942    if (!wd) return EINA_FALSE;
943    return elm_entry_cursor_next(wd->entry);
944 }
945
946 /**
947  * This moves the cursor one place to the left within the entry.
948  *
949  * @param obj The scrolled entry object
950  * @return EINA_TRUE upon success, EINA_FALSE upon failure
951  *
952  * @ingroup Scrolled_Entry
953  */
954 EAPI Eina_Bool
955 elm_scrolled_entry_cursor_prev(Evas_Object *obj)
956 {
957    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
958    Widget_Data *wd = elm_widget_data_get(obj);
959    if (!wd) return EINA_FALSE;
960    return elm_entry_cursor_prev(wd->entry);
961 }
962
963 /**
964  * This moves the cursor one line up within the entry.
965  *
966  * @param obj The scrolled entry object
967  * @return EINA_TRUE upon success, EINA_FALSE upon failure
968  *
969  * @ingroup Scrolled_Entry
970  */
971 EAPI Eina_Bool
972 elm_scrolled_entry_cursor_up(Evas_Object *obj)
973 {
974    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
975    Widget_Data *wd = elm_widget_data_get(obj);
976    if (!wd) return EINA_FALSE;
977    return elm_entry_cursor_up(wd->entry);
978 }
979
980 /**
981  * This moves the cursor one line down within the entry.
982  *
983  * @param obj The scrolled entry object
984  * @return EINA_TRUE upon success, EINA_FALSE upon failure
985  *
986  * @ingroup Scrolled_Entry
987  */
988 EAPI Eina_Bool
989 elm_scrolled_entry_cursor_down(Evas_Object *obj)
990 {
991    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
992    Widget_Data *wd = elm_widget_data_get(obj);
993    if (!wd) return EINA_FALSE;
994    return elm_entry_cursor_down(wd->entry);
995 }
996
997 /**
998  * This moves the cursor to the beginning of the entry.
999  *
1000  * @param obj The scrolled entry object
1001  *
1002  * @ingroup Scrolled_Entry
1003  */
1004 EAPI void
1005 elm_scrolled_entry_cursor_begin_set(Evas_Object *obj)
1006 {
1007    ELM_CHECK_WIDTYPE(obj, widtype);
1008    Widget_Data *wd = elm_widget_data_get(obj);
1009    if (!wd) return;
1010    elm_entry_cursor_begin_set(wd->entry);
1011 }
1012
1013 /**
1014  * This moves the cursor to the end of the entry.
1015  *
1016  * @param obj The scrolled entry object
1017  *
1018  * @ingroup Scrolled_Entry
1019  */
1020 EAPI void
1021 elm_scrolled_entry_cursor_end_set(Evas_Object *obj)
1022 {
1023    ELM_CHECK_WIDTYPE(obj, widtype);
1024    Widget_Data *wd = elm_widget_data_get(obj);
1025    if (!wd) return;
1026    int x, y, w, h;
1027    elm_entry_cursor_end_set(wd->entry);
1028    elm_widget_show_region_get(wd->entry, &x, &y, &w, &h);
1029    elm_scroller_region_show(wd->scroller, x, y, w, h);
1030 }
1031
1032 /**
1033  * This moves the cursor to the beginning of the current line.
1034  *
1035  * @param obj The scrolled entry object
1036  *
1037  * @ingroup Scrolled_Entry
1038  */
1039 EAPI void
1040 elm_scrolled_entry_cursor_line_begin_set(Evas_Object *obj)
1041 {
1042    ELM_CHECK_WIDTYPE(obj, widtype);
1043    Widget_Data *wd = elm_widget_data_get(obj);
1044    if (!wd) return;
1045    elm_entry_cursor_line_begin_set(wd->entry);
1046 }
1047
1048 /**
1049  * This moves the cursor to the end of the current line.
1050  *
1051  * @param obj The scrolled entry object
1052  *
1053  * @ingroup Scrolled_Entry
1054  */
1055 EAPI void
1056 elm_scrolled_entry_cursor_line_end_set(Evas_Object *obj)
1057 {
1058    ELM_CHECK_WIDTYPE(obj, widtype);
1059    Widget_Data *wd = elm_widget_data_get(obj);
1060    if (!wd) return;
1061    elm_entry_cursor_line_end_set(wd->entry);
1062 }
1063
1064 /**
1065  * This begins a selection within the scrolled entry as though
1066  * the user were holding down the mouse button to make a selection.
1067  *
1068  * @param obj The scrolled entry object
1069  *
1070  * @ingroup Scrolled_Entry
1071  */
1072 EAPI void
1073 elm_scrolled_entry_cursor_selection_begin(Evas_Object *obj)
1074 {
1075    ELM_CHECK_WIDTYPE(obj, widtype);
1076    Widget_Data *wd = elm_widget_data_get(obj);
1077    if (!wd) return;
1078    elm_entry_cursor_selection_begin(wd->entry);
1079 }
1080
1081 /**
1082  * This ends a selection within the scrolled entry as though
1083  * the user had just released the mouse button while making a selection.
1084  *
1085  * @param obj The scrolled entry object
1086  *
1087  * @ingroup Scrolled_Entry
1088  */
1089 EAPI void
1090 elm_scrolled_entry_cursor_selection_end(Evas_Object *obj)
1091 {
1092    ELM_CHECK_WIDTYPE(obj, widtype);
1093    Widget_Data *wd = elm_widget_data_get(obj);
1094    if (!wd) return;
1095    elm_entry_cursor_selection_end(wd->entry);
1096 }
1097
1098 /**
1099  * TODO: fill this in
1100  *
1101  * @param obj The scrolled entry object
1102  * @return TODO: fill this in
1103  *
1104  * @ingroup Scrolled_Entry
1105  */
1106 EAPI Eina_Bool
1107 elm_scrolled_entry_cursor_is_format_get(const Evas_Object *obj)
1108 {
1109    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1110    Widget_Data *wd = elm_widget_data_get(obj);
1111    if (!wd) return EINA_FALSE;
1112    return elm_entry_cursor_is_format_get(wd->entry);
1113 }
1114
1115 /**
1116  * This returns whether the cursor is visible.
1117  *
1118  * @param obj The scrolled entry object
1119  * @return If true, the cursor is visible.
1120  *
1121  * @ingroup Scrolled_Entry
1122  */
1123 EAPI Eina_Bool
1124 elm_scrolled_entry_cursor_is_visible_format_get(const Evas_Object *obj)
1125 {
1126    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1127    Widget_Data *wd = elm_widget_data_get(obj);
1128    if (!wd) return EINA_FALSE;
1129    return elm_entry_cursor_is_visible_format_get(wd->entry);
1130 }
1131
1132 /**
1133  * TODO: fill this in
1134  *
1135  * @param obj The scrolled entry object
1136  * @return TODO: fill this in
1137  *
1138  * @ingroup Scrolled_Entry
1139  */
1140 EAPI const char *
1141 elm_scrolled_entry_cursor_content_get(const Evas_Object *obj)
1142 {
1143    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1144    Widget_Data *wd = elm_widget_data_get(obj);
1145    if (!wd) return NULL;
1146    return elm_entry_cursor_content_get(wd->entry);
1147 }
1148
1149 /**
1150  * Sets the cursor position in the scrolled entry to the given value
1151  *
1152  * @param obj The scrolled entry object
1153  * @param pos the position of the cursor
1154  *
1155  * @ingroup Scrolled_Entry
1156  */
1157 EAPI void
1158 elm_scrolled_entry_cursor_pos_set(Evas_Object *obj, int pos)
1159 {
1160    ELM_CHECK_WIDTYPE(obj, widtype);
1161    Widget_Data *wd = elm_widget_data_get(obj);
1162    if (!wd) return;
1163    elm_entry_cursor_pos_set(wd->entry, pos);
1164 }
1165
1166 /**
1167  * Retrieves the current position of the cursor in the scrolled entry
1168  *
1169  * @param obj The entry object
1170  * @return the cursor position
1171  *
1172  * @ingroup Scrolled_Entry
1173  */
1174 EAPI int
1175 elm_scrolled_entry_cursor_pos_get(const Evas_Object *obj)
1176 {
1177    ELM_CHECK_WIDTYPE(obj, widtype) 0;
1178    Widget_Data *wd = elm_widget_data_get(obj);
1179    if (!wd) return 0;
1180    return elm_entry_cursor_pos_get(wd->entry);
1181 }
1182
1183 /**
1184  * This executes a "cut" action on the selected text in the scrolled entry.
1185  *
1186  * @param obj The scrolled entry object
1187  *
1188  * @ingroup Scrolled_Entry
1189  */
1190 EAPI void
1191 elm_scrolled_entry_selection_cut(Evas_Object *obj)
1192 {
1193    ELM_CHECK_WIDTYPE(obj, widtype);
1194    Widget_Data *wd = elm_widget_data_get(obj);
1195    if (!wd) return;
1196    elm_entry_selection_cut(wd->entry);
1197 }
1198
1199 /**
1200  * This executes a "copy" action on the selected text in the scrolled entry.
1201  *
1202  * @param obj The scrolled entry object
1203  *
1204  * @ingroup Scrolled_Entry
1205  */
1206 EAPI void
1207 elm_scrolled_entry_selection_copy(Evas_Object *obj)
1208 {
1209    ELM_CHECK_WIDTYPE(obj, widtype);
1210    Widget_Data *wd = elm_widget_data_get(obj);
1211    if (!wd) return;
1212    elm_entry_selection_copy(wd->entry);
1213 }
1214
1215 /**
1216  * This executes a "paste" action in the scrolled entry.
1217  *
1218  * @param obj The scrolled entry object
1219  *
1220  * @ingroup Scrolled_Entry
1221  */
1222 EAPI void
1223 elm_scrolled_entry_selection_paste(Evas_Object *obj)
1224 {
1225    ELM_CHECK_WIDTYPE(obj, widtype);
1226    Widget_Data *wd = elm_widget_data_get(obj);
1227    if (!wd) return;
1228    elm_entry_selection_paste(wd->entry);
1229 }
1230
1231 /**
1232  * This clears and frees the items in a scrolled entry's contextual (right click) menu.
1233  *
1234  * @param obj The scrolled entry object
1235  *
1236  * @ingroup Scrolled_Entry
1237  */
1238 EAPI void
1239 elm_scrolled_entry_context_menu_clear(Evas_Object *obj)
1240 {
1241    ELM_CHECK_WIDTYPE(obj, widtype);
1242    Widget_Data *wd = elm_widget_data_get(obj);
1243    if (!wd) return;
1244    elm_entry_context_menu_clear(wd->entry);
1245 }
1246
1247 /**
1248  * This adds an item to the scrolled entry's contextual menu.
1249  *
1250  * @param obj The scrolled entry object
1251  * @param label The item's text label
1252  * @param icon_file The item's icon file
1253  * @param icon_type The item's icon type
1254  * @param func The callback to execute when the item is clicked
1255  * @param data The data to associate with the item for related functions
1256  *
1257  * @ingroup Scrolled_Entry
1258  */
1259 EAPI void
1260 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)
1261 {
1262    Elm_Entry_Context_Menu_Item *ci;
1263    ELM_CHECK_WIDTYPE(obj, widtype);
1264    Widget_Data *wd = elm_widget_data_get(obj);
1265    if (!wd) return;
1266
1267    ci = malloc(sizeof(Elm_Entry_Context_Menu_Item));
1268    if (!ci) return;
1269    ci->func = func;
1270    ci->data = (void *)data;
1271    ci->obj = obj;
1272    wd->items = eina_list_append(wd->items, ci);
1273    elm_entry_context_menu_item_add(wd->entry, label, icon_file, icon_type, _context_item_wrap_cb, ci);
1274 }
1275
1276 /**
1277  * This disables the scrolled entry's contextual (right click) menu.
1278  *
1279  * @param obj The scrolled entry object
1280  * @param disabled If true, the menu is disabled
1281  *
1282  * @ingroup Scrolled_Entry
1283  */
1284 EAPI void
1285 elm_scrolled_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1286 {
1287    ELM_CHECK_WIDTYPE(obj, widtype);
1288    Widget_Data *wd = elm_widget_data_get(obj);
1289    if (!wd) return;
1290    elm_entry_context_menu_disabled_set(wd->entry, disabled);
1291 }
1292
1293 /**
1294  * This returns whether the scrolled entry's contextual (right click) menu is disabled.
1295  *
1296  * @param obj The scrolled entry object
1297  * @return If true, the menu is disabled
1298  *
1299  * @ingroup Scrolled_Entry
1300  */
1301 EAPI Eina_Bool
1302 elm_scrolled_entry_context_menu_disabled_get(const Evas_Object *obj)
1303 {
1304    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1305    Widget_Data *wd = elm_widget_data_get(obj);
1306    if (!wd) return EINA_FALSE;
1307    return elm_entry_context_menu_disabled_get(wd->entry);
1308 }
1309
1310 /**
1311  * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
1312  *
1313  * @param obj The scrolled entry object
1314  * @param h The horizontal scrollbar policy to apply
1315  * @param v The vertical scrollbar policy to apply
1316  *
1317  * @ingroup Scrolled_Entry
1318  */
1319 EAPI void
1320 elm_scrolled_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
1321 {
1322    ELM_CHECK_WIDTYPE(obj, widtype);
1323    Widget_Data *wd = elm_widget_data_get(obj);
1324    if (!wd) return;
1325    wd->policy_h = h;
1326    wd->policy_v = v;
1327    elm_scroller_policy_set(wd->scroller, h, v);
1328 }
1329
1330 /**
1331  * This enables/disables bouncing within the entry.
1332  *
1333  * @param obj The scrolled entry object
1334  * @param h The horizontal bounce state
1335  * @param v The vertical bounce state
1336  *
1337  * @ingroup Scrolled_Entry
1338  */
1339 EAPI void
1340 elm_scrolled_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1341 {
1342    ELM_CHECK_WIDTYPE(obj, widtype);
1343    Widget_Data *wd = elm_widget_data_get(obj);
1344    if (!wd) return;
1345    elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce);
1346 }
1347
1348 /**
1349  * Get the bounce mode
1350  *
1351  * @param obj The Scrolled_Entry object
1352  * @param h_bounce Allow bounce horizontally
1353  * @param v_bounce Allow bounce vertically
1354  *
1355  * @ingroup Scrolled_Entry
1356  */
1357 EAPI void
1358 elm_scrolled_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1359 {
1360    ELM_CHECK_WIDTYPE(obj, widtype);
1361    Widget_Data *wd = elm_widget_data_get(obj);
1362    if (!wd) return;
1363    elm_scroller_bounce_get(wd->scroller, h_bounce, v_bounce);
1364 }
1365
1366 /**
1367  * This appends a custom item provider to the list for that entry
1368  *
1369  * This appends the given callback. The list is walked from beginning to end
1370  * with each function called given the item href string in the text. If the
1371  * function returns an object handle other than NULL (it should create an
1372  * and object to do this), then this object is used to replace that item. If
1373  * not the next provider is called until one provides an item object, or the
1374  * default provider in entry does.
1375  *
1376  * @param obj The entry object
1377  * @param func The function called to provide the item object
1378  * @param data The data passed to @p func
1379  *
1380  * @ingroup Scrolled_Entry
1381  */
1382 EAPI void
1383 elm_scrolled_entry_item_provider_append(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1384 {
1385    ELM_CHECK_WIDTYPE(obj, widtype);
1386    Widget_Data *wd = elm_widget_data_get(obj);
1387    if (!wd) return;
1388    EINA_SAFETY_ON_NULL_RETURN(func);
1389    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
1390    if (!ip) return;
1391    ip->func = func;
1392    ip->data = data;
1393    wd->item_providers = eina_list_append(wd->item_providers, ip);
1394 }
1395
1396 /**
1397  * This prepends a custom item provider to the list for that entry
1398  *
1399  * This prepends the given callback. See elm_scrolled_entry_item_provider_append() for
1400  * more information
1401  *
1402  * @param obj The entry object
1403  * @param func The function called to provide the item object
1404  * @param data The data passed to @p func
1405  *
1406  * @ingroup Scrolled_Entry
1407  */
1408 EAPI void
1409 elm_scrolled_entry_item_provider_prepend(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1410 {
1411    ELM_CHECK_WIDTYPE(obj, widtype);
1412    Widget_Data *wd = elm_widget_data_get(obj);
1413    if (!wd) return;
1414    EINA_SAFETY_ON_NULL_RETURN(func);
1415    Elm_Entry_Item_Provider *ip = calloc(1, sizeof(Elm_Entry_Item_Provider));
1416    if (!ip) return;
1417    ip->func = func;
1418    ip->data = data;
1419    wd->item_providers = eina_list_prepend(wd->item_providers, ip);
1420 }
1421
1422 /**
1423  * This removes a custom item provider to the list for that entry
1424  *
1425  * This removes the given callback. See elm_scrolled_entry_item_provider_append() for
1426  * more information
1427  *
1428  * @param obj The entry object
1429  * @param func The function called to provide the item object
1430  * @param data The data passed to @p func
1431  *
1432  * @ingroup Scrolled_Entry
1433  */
1434 EAPI void
1435 elm_scrolled_entry_item_provider_remove(Evas_Object *obj, Evas_Object *(*func) (void *data, Evas_Object *entry, const char *item), void *data)
1436 {
1437    ELM_CHECK_WIDTYPE(obj, widtype);
1438    Widget_Data *wd = elm_widget_data_get(obj);
1439    Eina_List *l;
1440    Elm_Entry_Item_Provider *ip;
1441    if (!wd) return;
1442    EINA_SAFETY_ON_NULL_RETURN(func);
1443    EINA_LIST_FOREACH(wd->item_providers, l, ip)
1444      {
1445         if ((ip->func == func) && (ip->data == data))
1446           {
1447              wd->item_providers = eina_list_remove_list(wd->item_providers, l);
1448              free(ip);
1449              return;
1450           }
1451      }
1452 }
1453
1454 /**
1455  * Append a filter function for text inserted in the entry
1456  *
1457  * Append the given callback to the list. This functions will be called
1458  * whenever any text is inserted into the entry, with the text to be inserted
1459  * as a parameter. The callback function is free to alter the text in any way
1460  * it wants, but it must remember to free the given pointer and update it.
1461  * If the new text is to be discarded, the function can free it and set it text
1462  * parameter to NULL. This will also prevent any following filters from being
1463  * called.
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_append(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_append(wd->text_filters, tf);
1487 }
1488
1489 /**
1490  * Prepend a filter function for text insdrted in the entry
1491  *
1492  * Prepend the given callback to the list. See elm_scrolled_entry_text_filter_append()
1493  * for more information
1494  *
1495  * @param obj The entry object
1496  * @param func The function to use as text filter
1497  * @param data User data to pass to @p func
1498  *
1499  * @ingroup Scrolled_Entry
1500  */
1501 EAPI void
1502 elm_scrolled_entry_text_filter_prepend(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1503 {
1504    Widget_Data *wd;
1505    Elm_Entry_Text_Filter *tf;
1506    ELM_CHECK_WIDTYPE(obj, widtype);
1507
1508    wd = elm_widget_data_get(obj);
1509
1510    EINA_SAFETY_ON_NULL_RETURN(func);
1511
1512    tf = ELM_NEW(Elm_Entry_Text_Filter);
1513    if (!tf) return;
1514    tf->func = func;
1515    tf->data = data;
1516    wd->text_filters = eina_list_prepend(wd->text_filters, tf);
1517 }
1518
1519 /**
1520  * Remove a filter from the list
1521  *
1522  * Removes the given callback from the filter list. See elm_scrolled_entry_text_filter_append()
1523  * for more information.
1524  *
1525  * @param obj The entry object
1526  * @param func The filter function to remove
1527  * @param data The user data passed when adding the function
1528  *
1529  * @ingroup Scrolled_Entry
1530  */
1531 EAPI void
1532 elm_scrolled_entry_text_filter_remove(Evas_Object *obj, void (*func) (void *data, Evas_Object *entry, char **text), void *data)
1533 {
1534    Widget_Data *wd;
1535    Eina_List *l;
1536    Elm_Entry_Text_Filter *tf;
1537    ELM_CHECK_WIDTYPE(obj, widtype);
1538
1539    wd = elm_widget_data_get(obj);
1540
1541    EINA_SAFETY_ON_NULL_RETURN(func);
1542
1543    EINA_LIST_FOREACH(wd->text_filters, l, tf)
1544      {
1545         if ((tf->func == func) && (tf->data == data))
1546           {
1547              wd->text_filters = eina_list_remove_list(wd->text_filters, l);
1548              free(tf);
1549              return;
1550           }
1551      }
1552 }
1553
1554 /**
1555  * This sets the file (and implicitly loads it) for the text to display and
1556  * then edit. All changes are written back to the file after a short delay if
1557  * the entry object is set to autosave.
1558  *
1559  * @param obj The scrolled entry object
1560  * @param file The path to the file to load and save
1561  * @param format The file format
1562  *
1563  * @ingroup Scrolled_Entry
1564  */
1565 EAPI void
1566 elm_scrolled_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format)
1567 {
1568    ELM_CHECK_WIDTYPE(obj, widtype);
1569    Widget_Data *wd = elm_widget_data_get(obj);
1570    if (!wd) return;
1571    elm_entry_file_set(wd->entry, file, format);
1572 }
1573
1574 /**
1575  * Gets the file to load and save and the file format
1576  *
1577  * @param obj The scrolled entry object
1578  * @param file The path to the file to load and save
1579  * @param format The file format
1580  *
1581  * @ingroup Scrolled_Entry
1582  */
1583 EAPI void
1584 elm_scrolled_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format)
1585 {
1586    ELM_CHECK_WIDTYPE(obj, widtype);
1587    Widget_Data *wd = elm_widget_data_get(obj);
1588    if (!wd) return;
1589    elm_entry_file_get(wd->entry, file, format);
1590 }
1591
1592 /**
1593  * This function writes any changes made to the file set with
1594  * elm_scrolled_entry_file_set()
1595  *
1596  * @param obj The scrolled entry object
1597  *
1598  * @ingroup Scrolled_Entry
1599  */
1600 EAPI void
1601 elm_scrolled_entry_file_save(Evas_Object *obj)
1602 {
1603    ELM_CHECK_WIDTYPE(obj, widtype);
1604    Widget_Data *wd = elm_widget_data_get(obj);
1605    if (!wd) return;
1606    elm_entry_file_save(wd->entry);
1607 }
1608
1609 /**
1610  * This sets the entry object to 'autosave' the loaded text file or not.
1611  *
1612  * @param obj The scrolled entry object
1613  * @param autosave Autosave the loaded file or not
1614  *
1615  * @ingroup Scrolled_Entry
1616  */
1617 EAPI void
1618 elm_scrolled_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave)
1619 {
1620    ELM_CHECK_WIDTYPE(obj, widtype);
1621    Widget_Data *wd = elm_widget_data_get(obj);
1622    if (!wd) return;
1623    elm_entry_autosave_set(wd->entry, autosave);
1624 }
1625
1626 /**
1627  * This gets the entry object's 'autosave' status.
1628  *
1629  * @param obj The scrolled entry object
1630  * @return Autosave the loaded file or not
1631  *
1632  * @ingroup Scrolled_Entry
1633  */
1634 EAPI Eina_Bool
1635 elm_scrolled_entry_autosave_get(const Evas_Object *obj)
1636 {
1637    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1638    Widget_Data *wd = elm_widget_data_get(obj);
1639    if (!wd) return EINA_FALSE;
1640    return elm_entry_autosave_get(wd->entry);
1641 }
1642
1643 /**
1644  * Control pasting of text and images for the widget.
1645  *
1646  * Normally the scrolled entry allows both text and images to be pasted.
1647  * By setting textonly to be true, this prevents images from being pasted.
1648  *
1649  * Note this only changes the behaviour of text.
1650  *
1651  * @param obj The scrolled entry object
1652  * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is text+image+other.
1653  *
1654  * @see elm_entry_cnp_textonly_set
1655  * @ingroup Scrolled_Entry
1656  */
1657 EAPI void
1658 elm_scrolled_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly)
1659 {
1660    ELM_CHECK_WIDTYPE(obj, widtype);
1661    Widget_Data *wd = elm_widget_data_get(obj);
1662    if (!wd) return;
1663    elm_entry_cnp_textonly_set(wd->entry, textonly);
1664 }
1665
1666 /**
1667  * Getting elm_scrolled_entry text paste/drop mode.
1668  *
1669  * In textonly mode, only text may be pasted or dropped into the widget.
1670  *
1671  * @param obj The scrolled entry object
1672  * @return If the widget only accepts text from pastes.
1673  *
1674  * @see elm_entry_cnp_textonly_get
1675  * @ingroup Scrolled_Entry
1676  */
1677 EAPI Eina_Bool
1678 elm_scrolled_entry_cnp_textonly_get(Evas_Object *obj)
1679 {
1680    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1681    Widget_Data *wd = elm_widget_data_get(obj);
1682    if (!wd) return EINA_FALSE;
1683    return elm_entry_cnp_textonly_get(wd->entry);
1684 }