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