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