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