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