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