664cce7f4197af8d059e33b89e7bfd58be4d72b2
[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
35 struct _Widget_Data
36 {
37    Evas_Object *scroller;
38    Evas_Object *entry;
39    Elm_Scroller_Policy policy_h, policy_v;
40    Eina_Bool single_line : 1;
41 };
42
43 static const char *widtype = NULL;
44
45 static const char SIG_CHANGED[] = "changed";
46 static const char SIG_ACTIVATED[] = "activated";
47 static const char SIG_PRESS[] = "press";
48 static const char SIG_LONGPRESSED[] = "longpressed";
49 static const char SIG_CLICKED[] = "clicked";
50 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
51 static const char SIG_FOCUSED[] = "focused";
52 static const char SIG_UNFOCUSED[] = "unfocused";
53 static const char SIG_SELECTION_PASTE[] = "selection,paste";
54 static const char SIG_SELECTION_COPY[] = "selection,copy";
55 static const char SIG_SELECTION_CUT[] = "selection,cut";
56 static const char SIG_SELECTION_START[] = "selection,start";
57 static const char SIG_SELECTION_CHANGED[] = "selection,changed";
58 static const char SIG_SELECTION_CLEARED[] = "selection,cleared";
59 static const char SIG_CURSOR_CHANGED[] = "cursor,changed";
60 static const char SIG_ANCHOR_CLICKED[] = "anchor,clicked";
61 static const Evas_Smart_Cb_Description _signals[] = {
62   {SIG_CHANGED, ""},
63   {SIG_ACTIVATED, ""},
64   {SIG_PRESS, ""},
65   {SIG_LONGPRESSED, ""},
66   {SIG_CLICKED, ""},
67   {SIG_CLICKED_DOUBLE, ""},
68   {SIG_FOCUSED, ""},
69   {SIG_UNFOCUSED, ""},
70   {SIG_SELECTION_PASTE, ""},
71   {SIG_SELECTION_COPY, ""},
72   {SIG_SELECTION_CUT, ""},
73   {SIG_SELECTION_START, ""},
74   {SIG_SELECTION_CHANGED, ""},
75   {SIG_SELECTION_CLEARED, ""},
76   {SIG_CURSOR_CHANGED, ""},
77   {SIG_ANCHOR_CLICKED, ""},
78   {NULL, NULL}
79 };
80
81 static void
82 _del_hook(Evas_Object *obj)
83 {
84    Widget_Data *wd = elm_widget_data_get(obj);
85    if (!wd) return;
86    free(wd);
87 }
88
89 static void
90 _theme_hook(Evas_Object *obj)
91 {
92    Widget_Data *wd = elm_widget_data_get(obj);
93    if (!wd) return;
94    elm_object_style_set(wd->entry, elm_widget_style_get(obj));
95    elm_object_style_set(wd->scroller, elm_widget_style_get(obj));
96 }
97
98 static void
99 _sizing_eval(Evas_Object *obj)
100 {
101    Widget_Data *wd = elm_widget_data_get(obj);
102    Evas_Coord minw, minh;
103    if (!wd) return;
104    evas_object_size_hint_min_get(wd->scroller, &minw, &minh);
105    evas_object_size_hint_min_set(obj, minw, minh);
106    if (wd->single_line)
107      evas_object_size_hint_max_set(obj, -1, minh);
108    else
109      evas_object_size_hint_max_set(obj, -1, -1);
110 }
111
112 static void
113 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
114 {
115    Widget_Data *wd = elm_widget_data_get(obj);
116    if (!wd) return;
117    if (elm_widget_focus_get(obj))
118      elm_widget_focus_steal(wd->entry);
119 }
120
121 static void
122 _disable_hook(Evas_Object *obj)
123 {
124    Widget_Data *wd = elm_widget_data_get(obj);
125    if (!wd) return;
126    elm_object_disabled_set(wd->entry, elm_widget_disabled_get(obj));
127 }
128
129 static void
130 _entry_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
131 {
132    _sizing_eval(data);
133    evas_object_smart_callback_call(data, SIG_CHANGED, NULL);
134 }
135
136 static void
137 _entry_activated(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
138 {
139    evas_object_smart_callback_call(data, SIG_ACTIVATED, NULL);
140 }
141
142 static void
143 _entry_press(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
144 {
145    evas_object_smart_callback_call(data, SIG_PRESS, NULL);
146 }
147
148 static void
149 _entry_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
150 {
151    evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
152 }
153
154 static void
155 _entry_clicked_double(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
156 {
157    evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
158 }
159
160 static void
161 _entry_cursor_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
162 {
163    evas_object_smart_callback_call(data, SIG_CURSOR_CHANGED, NULL);
164 }
165
166 static void
167 _entry_anchor_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
168 {
169    evas_object_smart_callback_call(data, SIG_ANCHOR_CLICKED, NULL);
170 }
171
172 static void
173 _entry_selection_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
174 {
175    evas_object_smart_callback_call(data, SIG_SELECTION_START, NULL);
176 }
177
178 static void
179 _entry_selection_changed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
180 {
181    evas_object_smart_callback_call(data, SIG_SELECTION_CHANGED, NULL);
182 }
183
184 static void
185 _entry_selection_cleared(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
186 {
187    evas_object_smart_callback_call(data, SIG_SELECTION_CLEARED, NULL);
188 }
189
190 static void
191 _entry_selection_paste(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
192 {
193    evas_object_smart_callback_call(data, SIG_SELECTION_PASTE, NULL);
194 }
195
196 static void
197 _entry_selection_copy(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
198 {
199    evas_object_smart_callback_call(data, SIG_SELECTION_COPY, NULL);
200 }
201
202 static void
203 _entry_selection_cut(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
204 {
205    evas_object_smart_callback_call(data, SIG_SELECTION_CUT, NULL);
206 }
207
208 static void
209 _entry_longpressed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
210 {
211    evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
212 }
213
214 static void
215 _entry_focused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
216 {
217    evas_object_smart_callback_call(data, SIG_FOCUSED, NULL);
218 }
219
220 static void
221 _entry_unfocused(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
222 {
223    evas_object_smart_callback_call(data, SIG_UNFOCUSED, NULL);
224 }
225
226
227 /**
228  * This adds a scrolled entry to @p parent object.
229  *
230  * @param parent The parent object
231  * @return The new object or NULL if it cannot be created
232  *
233  * @ingroup Scrolled_Entry
234  */
235 EAPI Evas_Object *
236 elm_scrolled_entry_add(Evas_Object *parent)
237 {
238    Evas_Object *obj;
239    Evas *e;
240    Widget_Data *wd;
241
242    wd = ELM_NEW(Widget_Data);
243    e = evas_object_evas_get(parent);
244    obj = elm_widget_add(e);
245    ELM_SET_WIDTYPE(widtype, "scrolled_entry");
246    elm_widget_type_set(obj, "scrolled_entry");
247    elm_widget_sub_object_add(parent, obj);
248    elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
249    elm_widget_data_set(obj, wd);
250    elm_widget_del_hook_set(obj, _del_hook);
251    elm_widget_disable_hook_set(obj, _disable_hook);
252    elm_widget_can_focus_set(obj, 1);
253    elm_widget_theme_hook_set(obj, _theme_hook);
254
255    wd->scroller = elm_scroller_add(parent);
256    elm_widget_resize_object_set(obj, wd->scroller);
257    elm_scroller_bounce_set(wd->scroller, 0, 0);
258    
259    wd->entry = elm_entry_add(parent);
260    evas_object_size_hint_weight_set(wd->entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
261    evas_object_size_hint_align_set(wd->entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
262    elm_scroller_content_set(wd->scroller, wd->entry);
263    evas_object_show(wd->entry);
264
265    evas_object_smart_callback_add(wd->entry, "changed", _entry_changed, obj);
266    evas_object_smart_callback_add(wd->entry, "activated", _entry_activated, obj);
267    evas_object_smart_callback_add(wd->entry, "press", _entry_press, obj);
268    evas_object_smart_callback_add(wd->entry, "clicked", _entry_clicked, obj);
269    evas_object_smart_callback_add(wd->entry, "clicked,double", _entry_clicked_double, obj);
270    evas_object_smart_callback_add(wd->entry, "cursor,changed", _entry_cursor_changed, obj);
271    evas_object_smart_callback_add(wd->entry, "anchor,clicked", _entry_anchor_clicked, obj);
272    evas_object_smart_callback_add(wd->entry, "selection,start", _entry_selection_start, obj);
273    evas_object_smart_callback_add(wd->entry, "selection,changed", _entry_selection_changed, obj);
274    evas_object_smart_callback_add(wd->entry, "selection,cleared", _entry_selection_cleared, obj);
275    evas_object_smart_callback_add(wd->entry, "selection,paste", _entry_selection_paste, obj);
276    evas_object_smart_callback_add(wd->entry, "selection,copy", _entry_selection_copy, obj);
277    evas_object_smart_callback_add(wd->entry, "selection,cut", _entry_selection_cut, obj);
278    evas_object_smart_callback_add(wd->entry, "longpressed", _entry_longpressed, obj);
279    evas_object_smart_callback_add(wd->entry, "focused", _entry_focused, obj);
280    evas_object_smart_callback_add(wd->entry, "unfocused", _entry_unfocused, obj);
281
282    _sizing_eval(obj);
283
284    // TODO: convert Elementary to subclassing of Evas_Smart_Class
285    // TODO: and save some bytes, making descriptions per-class and not instance!
286    evas_object_smart_callbacks_descriptions_set(obj, _signals);
287    return obj;
288 }
289
290 /**
291  * This sets the scrolled entry object not to line wrap.  All input will
292  * be on a single line, and the entry box will scroll with user input.
293  *
294  * @param obj The scrolled entry object
295  * @param single_line If true, the text in the scrolled entry
296  * will be on a single line.
297  *
298  * @ingroup Scrolled_Entry
299  */
300 EAPI void
301 elm_scrolled_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line)
302 {
303    ELM_CHECK_WIDTYPE(obj, widtype);
304    Widget_Data *wd = elm_widget_data_get(obj);
305    if (!wd) return;
306    if (wd->single_line == single_line) return;
307    elm_entry_single_line_set(wd->entry, single_line);
308    wd->single_line = single_line;
309    if (single_line)
310      {
311         elm_scroller_policy_set(wd->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
312         elm_scroller_content_min_limit(wd->scroller, 0, 1);
313      }
314    else
315      {
316         elm_scroller_policy_set(wd->scroller, wd->policy_h, wd->policy_v);
317         elm_scroller_content_min_limit(wd->scroller, 0, 0);
318      }
319    _sizing_eval(obj);
320 }
321
322 /**
323  * This returns true if the scrolled entry has been set to single line mode.
324  * See also elm_scrolled_entry_single_line_set().
325  *
326  * @param obj The scrolled entry object
327  * @return single_line If true, the text in the scrolled entry is set to display
328  * on a single line.
329  *
330  * @ingroup Scrolled_Entry
331  */
332 EAPI Eina_Bool
333 elm_scrolled_entry_single_line_get(const Evas_Object *obj)
334 {
335    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
336    Widget_Data *wd = elm_widget_data_get(obj);
337    if (!wd) return EINA_FALSE;
338    return elm_entry_single_line_get(wd->entry);
339 }
340
341
342 /**
343  * This sets the scrolled entry object to password mode.  All text entered
344  * and/or displayed within the widget will be replaced with asterisks (*).
345  *
346  * @param obj The scrolled entry object
347  * @param password If true, password mode is enabled.
348  *
349  * @ingroup Scrolled_Entry
350  */
351 EAPI void
352 elm_scrolled_entry_password_set(Evas_Object *obj, Eina_Bool password)
353 {
354    ELM_CHECK_WIDTYPE(obj, widtype);
355    Widget_Data *wd = elm_widget_data_get(obj);
356    if (!wd) return;
357    elm_entry_password_set(wd->entry, password);
358 }
359
360 /**
361  * This returns whether password mode is enabled.
362  * See also elm_scrolled_entry_password_set().
363  *
364  * @param obj The scrolled entry object
365  * @return If true, the scrolled entry is set to display all characters
366  * as asterisks (*).
367  *
368  * @ingroup Scrolled_Entry
369  */
370 EAPI Eina_Bool
371 elm_scrolled_entry_password_get(const Evas_Object *obj)
372 {
373    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
374    Widget_Data *wd = elm_widget_data_get(obj);
375    if (!wd) return EINA_FALSE;
376    return elm_entry_password_get(wd->entry);
377 }
378
379
380 /**
381  * This sets the text displayed within the scrolled entry to @p entry.
382  *
383  * @param obj The scrolled entry object
384  * @param entry The text to be displayed
385  *
386  * @ingroup Scrolled_Entry
387  */
388 EAPI void
389 elm_scrolled_entry_entry_set(Evas_Object *obj, const char *entry)
390 {
391    ELM_CHECK_WIDTYPE(obj, widtype);
392    Widget_Data *wd = elm_widget_data_get(obj);
393    if (!wd) return;
394    elm_entry_entry_set(wd->entry, entry);
395 }
396
397 /**
398  * This returns the text currently shown in object @p entry.
399  * See also elm_scrolled_entry_entry_set().
400  *
401  * @param obj The scrolled entry object
402  * @return The currently displayed text or NULL on failure
403  *
404  * @ingroup Scrolled_Entry
405  */
406 EAPI const char *
407 elm_scrolled_entry_entry_get(const Evas_Object *obj)
408 {
409    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
410    Widget_Data *wd = elm_widget_data_get(obj);
411    if (!wd) return NULL;
412    return elm_entry_entry_get(wd->entry);
413 }
414
415 /**
416  * This returns all selected text within the scrolled entry.
417  *
418  * @param obj The scrolled entry object
419  * @return The selected text within the scrolled entry or NULL on failure
420  *
421  * @ingroup Scrolled_Entry
422  */
423 EAPI const char *
424 elm_scrolled_entry_selection_get(const Evas_Object *obj)
425 {
426    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
427    Widget_Data *wd = elm_widget_data_get(obj);
428    if (!wd) return NULL;
429    return elm_entry_selection_get(wd->entry);
430 }
431
432 /**
433  * This inserts text in @p entry at the beginning of the scrolled entry
434  * object.
435  *
436  * @param obj The scrolled entry object
437  * @param entry The text to insert
438  *
439  * @ingroup Scrolled_Entry
440  */
441 EAPI void
442 elm_scrolled_entry_entry_insert(Evas_Object *obj, const char *entry)
443 {
444    ELM_CHECK_WIDTYPE(obj, widtype);
445    Widget_Data *wd = elm_widget_data_get(obj);
446    if (!wd) return;
447    elm_entry_entry_insert(wd->entry, entry);
448 }
449
450 /**
451  * This enables word line wrapping in the scrolled entry object.  It is the opposite
452  * of elm_scrolled_entry_single_line_set().  Additionally, setting this disables
453  * character line wrapping.
454  * See also elm_scrolled_entry_line_char_wrap_set().
455  *
456  * @param obj The scrolled entry object
457  * @param wrap If true, the scrolled entry will be wrapped once it reaches the end
458  * of the object. Wrapping will occur at the end of the word before the end of the
459  * object.
460  *
461  * @ingroup Scrolled_Entry
462  */
463 EAPI void
464 elm_scrolled_entry_line_wrap_set(Evas_Object *obj, Eina_Bool wrap)
465 {
466    ELM_CHECK_WIDTYPE(obj, widtype);
467    Widget_Data *wd = elm_widget_data_get(obj);
468    if (!wd) return;
469    elm_entry_line_wrap_set(wd->entry, wrap);
470 }
471
472 /**
473  * This enables character line wrapping in the scrolled entry object.  It is the opposite
474  * of elm_scrolled_entry_single_line_set().  Additionally, setting this disables
475  * word line wrapping.
476  * See also elm_scrolled_entry_line_wrap_set().
477  *
478  * @param obj The scrolled entry object
479  * @param wrap If true, the scrolled entry will be wrapped once it reaches the end
480  * of the object. Wrapping will occur immediately upon reaching the end of the object.
481  *
482  * @ingroup Scrolled_Entry
483  */
484 EAPI void
485 elm_scrolled_entry_line_char_wrap_set(Evas_Object *obj, Eina_Bool wrap)
486 {
487    ELM_CHECK_WIDTYPE(obj, widtype);
488    Widget_Data *wd = elm_widget_data_get(obj);
489    if (!wd) return;
490    elm_entry_line_char_wrap_set(wd->entry, wrap);
491 }
492
493 /**
494  * This sets the editable attribute of the scrolled entry.
495  *
496  * @param obj The scrolled entry object
497  * @param editable If true, the scrolled entry will be editable by the user.
498  * If false, it will be set to the disabled state.
499  *
500  * @ingroup Scrolled_Entry
501  */
502 EAPI void
503 elm_scrolled_entry_editable_set(Evas_Object *obj, Eina_Bool editable)
504 {
505    ELM_CHECK_WIDTYPE(obj, widtype);
506    Widget_Data *wd = elm_widget_data_get(obj);
507    if (!wd) return;
508    elm_entry_editable_set(wd->entry, editable);
509 }
510
511 /**
512  * This gets the editable attribute of the scrolled entry.
513  * See also elm_scrolled_entry_editable_set().
514  *
515  * @param obj The scrolled entry object
516  * @return If true, the scrolled entry is editable by the user.
517  * If false, it is not editable by the user
518  *
519  * @ingroup Scrolled_Entry
520  */
521 EAPI Eina_Bool
522 elm_scrolled_entry_editable_get(const Evas_Object *obj)
523 {
524    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
525    Widget_Data *wd = elm_widget_data_get(obj);
526    if (!wd) return EINA_FALSE;
527    return elm_entry_editable_get(wd->entry);
528 }
529
530
531 /**
532  * This drops any existing text selection within the scrolled entry.
533  *
534  * @param obj The scrolled entry object
535  *
536  * @ingroup Scrolled_Entry
537  */
538 EAPI void
539 elm_scrolled_entry_select_none(Evas_Object *obj)
540 {
541    ELM_CHECK_WIDTYPE(obj, widtype);
542    Widget_Data *wd = elm_widget_data_get(obj);
543    if (!wd) return;
544    elm_entry_select_none(wd->entry);
545 }
546
547 /**
548  * This selects all text within the scrolled entry.
549  *
550  * @param obj The scrolled entry object
551  *
552  * @ingroup Scrolled_Entry
553  */
554 EAPI void
555 elm_scrolled_entry_select_all(Evas_Object *obj)
556 {
557    ELM_CHECK_WIDTYPE(obj, widtype);
558    Widget_Data *wd = elm_widget_data_get(obj);
559    if (!wd) return;
560    elm_entry_select_all(wd->entry);
561 }
562
563 /**
564  * This moves the cursor one place to the right within the entry.
565  *
566  * @param obj The scrolled entry object
567  * @return EINA_TRUE upon success, EINA_FALSE upon failure
568  *
569  * @ingroup Scrolled_Entry
570  */
571 EAPI Eina_Bool
572 elm_scrolled_entry_cursor_next(Evas_Object *obj)
573 {
574    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
575    Widget_Data *wd = elm_widget_data_get(obj);
576    if (!wd) return EINA_FALSE;
577    return elm_entry_cursor_next(wd->entry);
578 }
579
580 /**
581  * This moves the cursor one place to the left within the entry.
582  *
583  * @param obj The scrolled entry object
584  * @return EINA_TRUE upon success, EINA_FALSE upon failure
585  *
586  * @ingroup Scrolled_Entry
587  */
588 EAPI Eina_Bool
589 elm_scrolled_entry_cursor_prev(Evas_Object *obj)
590 {
591    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
592    Widget_Data *wd = elm_widget_data_get(obj);
593    if (!wd) return EINA_FALSE;
594    return elm_entry_cursor_prev(wd->entry);
595 }
596
597 /**
598  * This moves the cursor one line up within the entry.
599  *
600  * @param obj The scrolled entry object
601  * @return EINA_TRUE upon success, EINA_FALSE upon failure
602  *
603  * @ingroup Scrolled_Entry
604  */
605 EAPI Eina_Bool
606 elm_scrolled_entry_cursor_up(Evas_Object *obj)
607 {
608    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
609    Widget_Data *wd = elm_widget_data_get(obj);
610    if (!wd) return EINA_FALSE;
611    return elm_entry_cursor_up(wd->entry);
612 }
613
614 /**
615  * This moves the cursor one line down within the entry.
616  *
617  * @param obj The scrolled entry object
618  * @return EINA_TRUE upon success, EINA_FALSE upon failure
619  *
620  * @ingroup Scrolled_Entry
621  */
622 EAPI Eina_Bool
623 elm_scrolled_entry_cursor_down(Evas_Object *obj)
624 {
625    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
626    Widget_Data *wd = elm_widget_data_get(obj);
627    if (!wd) return EINA_FALSE;
628    return elm_entry_cursor_down(wd->entry);
629 }
630
631 /**
632  * This moves the cursor to the beginning of the entry.
633  *
634  * @param obj The scrolled entry object
635  *
636  * @ingroup Scrolled_Entry
637  */
638 EAPI void
639 elm_scrolled_entry_cursor_begin_set(Evas_Object *obj)
640 {
641    ELM_CHECK_WIDTYPE(obj, widtype);
642    Widget_Data *wd = elm_widget_data_get(obj);
643    if (!wd) return;
644    elm_entry_cursor_begin_set(wd->entry);
645 }
646
647 /**
648  * This moves the cursor to the end of the entry.
649  *
650  * @param obj The scrolled entry object
651  *
652  * @ingroup Scrolled_Entry
653  */
654 EAPI void
655 elm_scrolled_entry_cursor_end_set(Evas_Object *obj)
656 {
657    ELM_CHECK_WIDTYPE(obj, widtype);
658    Widget_Data *wd = elm_widget_data_get(obj);
659    if (!wd) return;
660    elm_entry_cursor_end_set(wd->entry);
661 }
662
663 /**
664  * This moves the cursor to the beginning of the current line.
665  *
666  * @param obj The scrolled entry object
667  *
668  * @ingroup Scrolled_Entry
669  */
670 EAPI void
671 elm_scrolled_entry_cursor_line_begin_set(Evas_Object *obj)
672 {
673    ELM_CHECK_WIDTYPE(obj, widtype);
674    Widget_Data *wd = elm_widget_data_get(obj);
675    if (!wd) return;
676    elm_entry_cursor_line_begin_set(wd->entry);
677 }
678
679 /**
680  * This moves the cursor to the end of the current line.
681  *
682  * @param obj The scrolled entry object
683  *
684  * @ingroup Scrolled_Entry
685  */
686 EAPI void
687 elm_scrolled_entry_cursor_line_end_set(Evas_Object *obj)
688 {
689    ELM_CHECK_WIDTYPE(obj, widtype);
690    Widget_Data *wd = elm_widget_data_get(obj);
691    if (!wd) return;
692    elm_entry_cursor_line_end_set(wd->entry);
693 }
694
695 /**
696  * This begins a selection within the scrolled entry as though
697  * the user were holding down the mouse button to make a selection.
698  *
699  * @param obj The scrolled entry object
700  *
701  * @ingroup Scrolled_Entry
702  */
703 EAPI void
704 elm_scrolled_entry_cursor_selection_begin(Evas_Object *obj)
705 {
706    ELM_CHECK_WIDTYPE(obj, widtype);
707    Widget_Data *wd = elm_widget_data_get(obj);
708    if (!wd) return;
709    elm_entry_cursor_selection_begin(wd->entry);
710 }
711
712 /**
713  * This ends a selection within the scrolled entry as though
714  * the user had just released the mouse button while making a selection.
715  *
716  * @param obj The scrolled entry object
717  *
718  * @ingroup Scrolled_Entry
719  */
720 EAPI void
721 elm_scrolled_entry_cursor_selection_end(Evas_Object *obj)
722 {
723    ELM_CHECK_WIDTYPE(obj, widtype);
724    Widget_Data *wd = elm_widget_data_get(obj);
725    if (!wd) return;
726    elm_entry_cursor_selection_end(wd->entry);
727 }
728
729 /**
730  * TODO: fill this in
731  *
732  * @param obj The scrolled entry object
733  * @return TODO: fill this in
734  *
735  * @ingroup Scrolled_Entry
736  */
737 EAPI Eina_Bool
738 elm_scrolled_entry_cursor_is_format_get(const Evas_Object *obj)
739 {
740    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
741    Widget_Data *wd = elm_widget_data_get(obj);
742    if (!wd) return EINA_FALSE;
743    return elm_entry_cursor_is_format_get(wd->entry);
744 }
745
746 /**
747  * This returns whether the cursor is visible.
748  *
749  * @param obj The scrolled entry object
750  * @return If true, the cursor is visible.
751  *
752  * @ingroup Scrolled_Entry
753  */
754 EAPI Eina_Bool
755 elm_scrolled_entry_cursor_is_visible_format_get(const Evas_Object *obj)
756 {
757    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
758    Widget_Data *wd = elm_widget_data_get(obj);
759    if (!wd) return EINA_FALSE;
760    return elm_entry_cursor_is_visible_format_get(wd->entry);
761 }
762
763 /**
764  * TODO: fill this in
765  *
766  * @param obj The scrolled entry object
767  * @return TODO: fill this in
768  *
769  * @ingroup Scrolled_Entry
770  */
771 EAPI const char *
772 elm_scrolled_entry_cursor_content_get(const Evas_Object *obj)
773 {
774    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
775    Widget_Data *wd = elm_widget_data_get(obj);
776    if (!wd) return NULL;
777    return elm_entry_cursor_content_get(wd->entry);
778 }
779
780 /**
781  * This executes a "cut" action on the selected text in the scrolled entry.
782  *
783  * @param obj The scrolled entry object
784  *
785  * @ingroup Scrolled_Entry
786  */
787 EAPI void
788 elm_scrolled_entry_selection_cut(Evas_Object *obj)
789 {
790    ELM_CHECK_WIDTYPE(obj, widtype);
791    Widget_Data *wd = elm_widget_data_get(obj);
792    if (!wd) return;
793    elm_entry_selection_cut(wd->entry);
794 }
795
796 /**
797  * This executes a "copy" action on the selected text in the scrolled entry.
798  *
799  * @param obj The scrolled entry object
800  *
801  * @ingroup Scrolled_Entry
802  */
803 EAPI void
804 elm_scrolled_entry_selection_copy(Evas_Object *obj)
805 {
806    ELM_CHECK_WIDTYPE(obj, widtype);
807    Widget_Data *wd = elm_widget_data_get(obj);
808    if (!wd) return;
809    elm_entry_selection_copy(wd->entry);
810 }
811
812 /**
813  * This executes a "paste" action in the scrolled entry.
814  *
815  * @param obj The scrolled entry object
816  *
817  * @ingroup Scrolled_Entry
818  */
819 EAPI void
820 elm_scrolled_entry_selection_paste(Evas_Object *obj)
821 {
822    ELM_CHECK_WIDTYPE(obj, widtype);
823    Widget_Data *wd = elm_widget_data_get(obj);
824    if (!wd) return;
825    elm_entry_selection_paste(wd->entry);
826 }
827
828 /**
829  * This clears and frees the items in a scrolled entry's contextual (right click) menu.
830  *
831  * @param obj The scrolled entry object
832  *
833  * @ingroup Scrolled_Entry
834  */
835 EAPI void
836 elm_scrolled_entry_context_menu_clear(Evas_Object *obj)
837 {
838    ELM_CHECK_WIDTYPE(obj, widtype);
839    Widget_Data *wd = elm_widget_data_get(obj);
840    if (!wd) return;
841    elm_entry_context_menu_clear(wd->entry);
842 }
843
844 /**
845  * This adds an item to the scrolled entry's contextual menu.
846  *
847  * @param obj The scrolled entry object
848  * @param label The item's text label
849  * @param icon_file The item's icon file
850  * @param icon_type The item's icon type
851  * @param func The callback to execute when the item is clicked
852  * @param data The data to associate with the item for related functions
853  *
854  * @ingroup Scrolled_Entry
855  */
856 EAPI void
857 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)
858 {
859    ELM_CHECK_WIDTYPE(obj, widtype);
860    Widget_Data *wd = elm_widget_data_get(obj);
861    if (!wd) return;
862    elm_entry_context_menu_item_add(wd->entry, label, icon_file, icon_type, func, data);
863 }
864
865 /**
866  * This disables the scrolled entry's contextual (right click) menu.
867  *
868  * @param obj The scrolled entry object
869  * @param disabled If true, the menu is disabled
870  *
871  * @ingroup Scrolled_Entry
872  */
873 EAPI void
874 elm_scrolled_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled)
875 {
876    ELM_CHECK_WIDTYPE(obj, widtype);
877    Widget_Data *wd = elm_widget_data_get(obj);
878    if (!wd) return;
879    elm_entry_context_menu_disabled_set(wd->entry, disabled);
880 }
881
882 /**
883  * This returns whether the scrolled entry's contextual (right click) menu is disabled.
884  *
885  * @param obj The scrolled entry object
886  * @return If true, the menu is disabled
887  *
888  * @ingroup Scrolled_Entry
889  */
890 EAPI Eina_Bool
891 elm_scrolled_entry_context_menu_disabled_get(const Evas_Object *obj)
892 {
893    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
894    Widget_Data *wd = elm_widget_data_get(obj);
895    if (!wd) return EINA_FALSE;
896    return elm_entry_context_menu_disabled_get(wd->entry);
897 }
898
899 /**
900  * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling them).
901  *
902  * @param obj The scrolled entry object
903  * @param h The horizontal scrollbar policy to apply
904  * @param v The vertical scrollbar policy to apply
905  *
906  * @ingroup Scrolled_Entry
907  */
908 EAPI void
909 elm_scrolled_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v)
910 {
911    ELM_CHECK_WIDTYPE(obj, widtype);
912    Widget_Data *wd = elm_widget_data_get(obj);
913    if (!wd) return;
914    wd->policy_h = h;
915    wd->policy_v = v;
916    elm_scroller_policy_set(wd->scroller, h, v);
917 }
918
919 /**
920  * This enables/disables bouncing within the entry.
921  *
922  * @param obj The scrolled entry object
923  * @param h The horizontal bounce state
924  * @param v The vertical bounce state
925  *
926  * @ingroup Scrolled_Entry
927  */
928 EAPI void
929 elm_scrolled_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
930 {
931    ELM_CHECK_WIDTYPE(obj, widtype);
932    Widget_Data *wd = elm_widget_data_get(obj);
933    if (!wd) return;
934    elm_scroller_bounce_set(wd->scroller, h_bounce, v_bounce);
935 }