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