1fbbc1ffdf7112c49c01235bb3d6cefe8fa7b182
[framework/uifw/elementary.git] / src / lib / elm_entry.h
1 typedef enum
2 {
3    ELM_TEXT_FORMAT_PLAIN_UTF8,
4    ELM_TEXT_FORMAT_MARKUP_UTF8
5 } Elm_Text_Format;
6
7 /**
8  * Line wrapping types.
9  */
10 typedef enum
11 {
12    ELM_WRAP_NONE = 0, /**< No wrap - value is zero */
13    ELM_WRAP_CHAR, /**< Char wrap - wrap between characters */
14    ELM_WRAP_WORD, /**< Word wrap - wrap in allowed wrapping points (as defined in the unicode standard) */
15    ELM_WRAP_MIXED, /**< Mixed wrap - Word wrap, and if that fails, char wrap. */
16    ELM_WRAP_LAST
17 } Elm_Wrap_Type; /**< Type of word or character wrapping to use */
18
19 typedef enum
20 {
21    ELM_INPUT_PANEL_LAYOUT_NORMAL, /**< Default layout */
22    ELM_INPUT_PANEL_LAYOUT_NUMBER, /**< Number layout */
23    ELM_INPUT_PANEL_LAYOUT_EMAIL, /**< Email layout */
24    ELM_INPUT_PANEL_LAYOUT_URL, /**< URL layout */
25    ELM_INPUT_PANEL_LAYOUT_PHONENUMBER, /**< Phone Number layout */
26    ELM_INPUT_PANEL_LAYOUT_IP, /**< IP layout */
27    ELM_INPUT_PANEL_LAYOUT_MONTH, /**< Month layout */
28    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY, /**< Number Only layout */
29    ELM_INPUT_PANEL_LAYOUT_INVALID, /**< Never use this */
30    ELM_INPUT_PANEL_LAYOUT_HEX, /**< Hexadecimal layout */
31    ELM_INPUT_PANEL_LAYOUT_TERMINAL, /**< Command-line terminal layout */
32    ELM_INPUT_PANEL_LAYOUT_PASSWORD /**< Like normal, but no auto-correct, no auto-capitalization etc. */
33 } Elm_Input_Panel_Layout; /**< Type of input panel (virtual keyboard) to use - this is a hint and may not provide exactly what is desired. */
34
35 typedef enum
36 {
37    ELM_AUTOCAPITAL_TYPE_NONE, /**< No auto-capitalization when typing */
38    ELM_AUTOCAPITAL_TYPE_WORD, /**< Autocapitalize each word typed */
39    ELM_AUTOCAPITAL_TYPE_SENTENCE, /**< Autocapitalize the start of each sentence */
40    ELM_AUTOCAPITAL_TYPE_ALLCHARACTER, /**< Autocapitalize all letters */
41 } Elm_Autocapital_Type; /**< Choose method of auto-capitalization */
42
43 /**
44     * @enum _Elm_CNP_Mode
45     * @typedef Elm_CNP_Mode
46     * Enum of entry's copy & paste policy.
47     *
48     * @see elm_entry_cnp_mode_set()
49     * @see elm_entry_cnp_mode_get()
50     */
51    typedef enum _Elm_CNP_Mode {
52       ELM_CNP_MODE_MARKUP = 0,       /**< copy & paste text with markup tag */
53       ELM_CNP_MODE_NO_IMAGE = 1,     /**< copy & paste text without item(image) tag */
54       ELM_CNP_MODE_PLAINTEXT = 2     /**< copy & paste text without markup tag */
55    } Elm_CNP_Mode;
56
57 /**
58  * @defgroup Entry Entry
59  *
60  * @image html img/widget/entry/preview-00.png
61  * @image latex img/widget/entry/preview-00.eps width=\textwidth
62  * @image html img/widget/entry/preview-01.png
63  * @image latex img/widget/entry/preview-01.eps width=\textwidth
64  * @image html img/widget/entry/preview-02.png
65  * @image latex img/widget/entry/preview-02.eps width=\textwidth
66  * @image html img/widget/entry/preview-03.png
67  * @image latex img/widget/entry/preview-03.eps width=\textwidth
68  *
69  * An entry is a convenience widget which shows a box that the user can
70  * enter text into. Entries by default don't scroll, so they grow to
71  * accomodate the entire text, resizing the parent window as needed. This
72  * can be changed with the elm_entry_scrollable_set() function.
73  *
74  * They can also be single line or multi line (the default) and when set
75  * to multi line mode they support text wrapping in any of the modes
76  * indicated by Elm_Wrap_Type.
77  *
78  * Other features include password mode, filtering of inserted text with
79  * elm_entry_text_filter_append() and related functions, inline "items" and
80  * formatted markup text.
81  *
82  * @section entry-markup Formatted text
83  *
84  * The markup tags supported by the Entry are defined by the theme, but
85  * even when writing new themes or extensions it's a good idea to stick to
86  * a sane default, to maintain coherency and avoid application breakages.
87  * Currently defined by the default theme are the following tags:
88  * @li \<br\>: Inserts a line break.
89  * @li \<ps\>: Inserts a paragraph separator. This is preferred over line
90  * breaks.
91  * @li \<tab\>: Inserts a tab.
92  * @li \<em\>...\</em\>: Emphasis. Sets the @em oblique style for the
93  * enclosed text.
94  * @li \<b\>...\</b\>: Sets the @b bold style for the enclosed text.
95  * @li \<link\>...\</link\>: Underlines the enclosed text.
96  * @li \<hilight\>...\</hilight\>: Hilights the enclosed text.
97  *
98  * @section entry-special Special markups
99  *
100  * Besides those used to format text, entries support two special markup
101  * tags used to insert clickable portions of text or items inlined within
102  * the text.
103  *
104  * @subsection entry-anchors Anchors
105  *
106  * Anchors are similar to HTML anchors. Text can be surrounded by \<a\> and
107  * \</a\> tags and an event will be generated when this text is clicked,
108  * like this:
109  *
110  * @code
111  * This text is outside <a href=anc-01>but this one is an anchor</a>
112  * @endcode
113  *
114  * The @c href attribute in the opening tag gives the name that will be
115  * used to identify the anchor and it can be any valid utf8 string.
116  *
117  * When an anchor is clicked, an @c "anchor,clicked" signal is emitted with
118  * an #Elm_Entry_Anchor_Info in the @c event_info parameter for the
119  * callback function. The same applies for "anchor,in" (mouse in), "anchor,out"
120  * (mouse out), "anchor,down" (mouse down), and "anchor,up" (mouse up) events on
121  * an anchor.
122  *
123  * @subsection entry-items Items
124  *
125  * Inlined in the text, any other @c Evas_Object can be inserted by using
126  * \<item\> tags this way:
127  *
128  * @code
129  * <item size=16x16 vsize=full href=emoticon/haha></item>
130  * @endcode
131  *
132  * Just like with anchors, the @c href identifies each item, but these need,
133  * in addition, to indicate their size, which is done using any one of
134  * @c size, @c absize or @c relsize attributes. These attributes take their
135  * value in the WxH format, where W is the width and H the height of the
136  * item.
137  *
138  * @li absize: Absolute pixel size for the item. Whatever value is set will
139  * be the item's size regardless of any scale value the object may have
140  * been set to. The final line height will be adjusted to fit larger items.
141  * @li size: Similar to @c absize, but it's adjusted to the scale value set
142  * for the object.
143  * @li relsize: Size is adjusted for the item to fit within the current
144  * line height.
145  *
146  * Besides their size, items are specificed a @c vsize value that affects
147  * how their final size and position are calculated. The possible values
148  * are:
149  * @li ascent: Item will be placed within the line's baseline and its
150  * ascent. That is, the height between the line where all characters are
151  * positioned and the highest point in the line. For @c size and @c absize
152  * items, the descent value will be added to the total line height to make
153  * them fit. @c relsize items will be adjusted to fit within this space.
154  * @li full: Items will be placed between the descent and ascent, or the
155  * lowest point in the line and its highest.
156  *
157  * The next image shows different configurations of items and how
158  * the previously mentioned options affect their sizes. In all cases,
159  * the green line indicates the ascent, blue for the baseline and red for
160  * the descent.
161  *
162  * @image html entry_item.png
163  * @image latex entry_item.eps width=\textwidth
164  *
165  * And another one to show how size differs from absize. In the first one,
166  * the scale value is set to 1.0, while the second one is using one of 2.0.
167  *
168  * @image html entry_item_scale.png
169  * @image latex entry_item_scale.eps width=\textwidth
170  *
171  * After the size for an item is calculated, the entry will request an
172  * object to place in its space. For this, the functions set with
173  * elm_entry_item_provider_append() and related functions will be called
174  * in order until one of them returns a @c non-NULL value. If no providers
175  * are available, or all of them return @c NULL, then the entry falls back
176  * to one of the internal defaults, provided the name matches with one of
177  * them.
178  *
179  * All of the following are currently supported:
180  *
181  * - emoticon/angry
182  * - emoticon/angry-shout
183  * - emoticon/crazy-laugh
184  * - emoticon/evil-laugh
185  * - emoticon/evil
186  * - emoticon/goggle-smile
187  * - emoticon/grumpy
188  * - emoticon/grumpy-smile
189  * - emoticon/guilty
190  * - emoticon/guilty-smile
191  * - emoticon/haha
192  * - emoticon/half-smile
193  * - emoticon/happy-panting
194  * - emoticon/happy
195  * - emoticon/indifferent
196  * - emoticon/kiss
197  * - emoticon/knowing-grin
198  * - emoticon/laugh
199  * - emoticon/little-bit-sorry
200  * - emoticon/love-lots
201  * - emoticon/love
202  * - emoticon/minimal-smile
203  * - emoticon/not-happy
204  * - emoticon/not-impressed
205  * - emoticon/omg
206  * - emoticon/opensmile
207  * - emoticon/smile
208  * - emoticon/sorry
209  * - emoticon/squint-laugh
210  * - emoticon/surprised
211  * - emoticon/suspicious
212  * - emoticon/tongue-dangling
213  * - emoticon/tongue-poke
214  * - emoticon/uh
215  * - emoticon/unhappy
216  * - emoticon/very-sorry
217  * - emoticon/what
218  * - emoticon/wink
219  * - emoticon/worried
220  * - emoticon/wtf
221  *
222  * Alternatively, an item may reference an image by its path, using
223  * the URI form @c file:///path/to/an/image.png and the entry will then
224  * use that image for the item.
225  *
226  * @section entry-files Loading and saving files
227  *
228  * Entries have convinience functions to load text from a file and save
229  * changes back to it after a short delay. The automatic saving is enabled
230  * by default, but can be disabled with elm_entry_autosave_set() and files
231  * can be loaded directly as plain text or have any markup in them
232  * recognized. See elm_entry_file_set() for more details.
233  *
234  * @section entry-signals Emitted signals
235  *
236  * This widget emits the following signals:
237  *
238  * @li "changed": The text within the entry was changed.
239  * @li "changed,user": The text within the entry was changed because of user interaction.
240  * @li "activated": The enter key was pressed on a single line entry.
241  * @li "press": A mouse button has been pressed on the entry.
242  * @li "longpressed": A mouse button has been pressed and held for a couple
243  * seconds.
244  * @li "clicked": The entry has been clicked (mouse press and release).
245  * @li "clicked,double": The entry has been double clicked.
246  * @li "clicked,triple": The entry has been triple clicked.
247  * @li "focused": The entry has received focus.
248  * @li "unfocused": The entry has lost focus.
249  * @li "selection,paste": A paste of the clipboard contents was requested.
250  * @li "selection,copy": A copy of the selected text into the clipboard was
251  * requested.
252  * @li "selection,cut": A cut of the selected text into the clipboard was
253  * requested.
254  * @li "selection,start": A selection has begun and no previous selection
255  * existed.
256  * @li "selection,changed": The current selection has changed.
257  * @li "selection,cleared": The current selection has been cleared.
258  * @li "cursor,changed": The cursor has changed position.
259  * @li "anchor,clicked": An anchor has been clicked. The event_info
260  * parameter for the callback will be an #Elm_Entry_Anchor_Info.
261  * @li "anchor,in": Mouse cursor has moved into an anchor. The event_info
262  * parameter for the callback will be an #Elm_Entry_Anchor_Info.
263  * @li "anchor,out": Mouse cursor has moved out of an anchor. The event_info
264  * parameter for the callback will be an #Elm_Entry_Anchor_Info.
265  * @li "anchor,up": Mouse button has been unpressed on an anchor. The event_info
266  * parameter for the callback will be an #Elm_Entry_Anchor_Info.
267  * @li "anchor,down": Mouse button has been pressed on an anchor. The event_info
268  * parameter for the callback will be an #Elm_Entry_Anchor_Info.
269  * @li "preedit,changed": The preedit string has changed.
270  * @li "language,changed": Program language changed.
271  *
272  * Default contents parts of the entry items that you can use for are:
273  * @li "icon" - An icon in the entry
274  * @li "end" - A content in the end of the entry
275  *
276  * Default text parts of the entry that you can use for are:
277  * @li "default" - text of the entry
278  *
279  * Supported elm_object common APIs.
280  * @li elm_object_signal_emit
281  * @li elm_object_part_text_set
282  * @li elm_object_part_text_get
283  * @li elm_object_part_content_set
284  * @li elm_object_part_content_get
285  * @li elm_object_part_content_unset
286  * @li elm_object_signal_callback_add
287  * @li elm_object_signal_callback_del
288  * @li elm_object_disabled_set
289  * @li elm_object_disabled_get
290  *
291  * @section entry-examples
292  *
293  * An overview of the Entry API can be seen in @ref entry_example_01
294  *
295  * @{
296  */
297
298 /**
299  * @typedef Elm_Entry_Anchor_Info
300  *
301  * The info sent in the callback for the "anchor,clicked" signals emitted
302  * by entries.
303  */
304 typedef struct _Elm_Entry_Anchor_Info Elm_Entry_Anchor_Info;
305
306 /**
307  * @struct _Elm_Entry_Anchor_Info
308  *
309  * The info sent in the callback for the "anchor,clicked" signals emitted
310  * by entries.
311  */
312 struct _Elm_Entry_Anchor_Info
313 {
314    const char *name; /**< The name of the anchor, as stated in its href */
315    int         button; /**< The mouse button used to click on it */
316    Evas_Coord  x, /**< Anchor geometry, relative to canvas */
317                y, /**< Anchor geometry, relative to canvas */
318                w, /**< Anchor geometry, relative to canvas */
319                h; /**< Anchor geometry, relative to canvas */
320 };
321
322 /**
323  * @typedef Elm_Entry_Filter_Cb
324  * This callback type is used by entry filters to modify text.
325  * @param data The data specified as the last param when adding the filter
326  * @param entry The entry object
327  * @param text A pointer to the location of the text being filtered. This data can be modified,
328  * but any additional allocations must be managed by the user.
329  * @see elm_entry_text_filter_append
330  * @see elm_entry_text_filter_prepend
331  */
332 typedef void (*Elm_Entry_Filter_Cb)(void *data, Evas_Object *entry, char **text);
333
334 /**
335  * @typedef Elm_Entry_Change_Info
336  * This corresponds to Edje_Entry_Change_Info. Includes information about
337  * a change in the entry.
338  */
339 typedef Edje_Entry_Change_Info Elm_Entry_Change_Info;
340
341 /**
342  * This adds an entry to @p parent object.
343  *
344  * By default, entries are:
345  * @li not scrolled
346  * @li multi-line
347  * @li word wrapped
348  * @li autosave is enabled
349  *
350  * @param parent The parent object
351  * @return The new object or NULL if it cannot be created
352  */
353 EAPI Evas_Object       *elm_entry_add(Evas_Object *parent);
354
355 /**
356  * Sets the entry to single line mode.
357  *
358  * In single line mode, entries don't ever wrap when the text reaches the
359  * edge, and instead they keep growing horizontally. Pressing the @c Enter
360  * key will generate an @c "activate" event instead of adding a new line.
361  *
362  * When @p single_line is @c EINA_FALSE, line wrapping takes effect again
363  * and pressing enter will break the text into a different line
364  * without generating any events.
365  *
366  * @param obj The entry object
367  * @param single_line If true, the text in the entry
368  * will be on a single line.
369  */
370 EAPI void               elm_entry_single_line_set(Evas_Object *obj, Eina_Bool single_line);
371
372 /**
373  * Gets whether the entry is set to be single line.
374  *
375  * @param obj The entry object
376  * @return single_line If true, the text in the entry is set to display
377  * on a single line.
378  *
379  * @see elm_entry_single_line_set()
380  */
381 EAPI Eina_Bool          elm_entry_single_line_get(const Evas_Object *obj);
382
383 /**
384  * Sets the entry to password mode.
385  *
386  * In password mode, entries are implicitly single line and the display of
387  * any text in them is replaced with asterisks (*).
388  *
389  * @param obj The entry object
390  * @param password If true, password mode is enabled.
391  */
392 EAPI void               elm_entry_password_set(Evas_Object *obj, Eina_Bool password);
393
394 /**
395  * Gets whether the entry is set to password mode.
396  *
397  * @param obj The entry object
398  * @return If true, the entry is set to display all characters
399  * as asterisks (*).
400  *
401  * @see elm_entry_password_set()
402  */
403 EAPI Eina_Bool          elm_entry_password_get(const Evas_Object *obj);
404
405 /**
406  * This sets the text displayed within the entry to @p entry.
407  *
408  * @param obj The entry object
409  * @param entry The text to be displayed
410  *
411  * @note Using this function bypasses text filters
412  */
413 EAPI void               elm_entry_entry_set(Evas_Object *obj, const char *entry);
414
415 /**
416  * This returns the text currently shown in object @p entry.
417  * See also elm_entry_entry_set().
418  *
419  * @param obj The entry object
420  * @return The currently displayed text or NULL on failure
421  */
422 EAPI const char        *elm_entry_entry_get(const Evas_Object *obj);
423
424 /**
425  * Appends @p entry to the text of the entry.
426  *
427  * Adds the text in @p entry to the end of any text already present in the
428  * widget.
429  *
430  * The appended text is subject to any filters set for the widget.
431  *
432  * @param obj The entry object
433  * @param entry The text to be displayed
434  *
435  * @see elm_entry_text_filter_append()
436  */
437 EAPI void               elm_entry_entry_append(Evas_Object *obj, const char *entry);
438
439 /**
440  * Gets whether the entry is empty.
441  *
442  * Empty means no text at all. If there are any markup tags, like an item
443  * tag for which no provider finds anything, and no text is displayed, this
444  * function still returns EINA_FALSE.
445  *
446  * @param obj The entry object
447  * @return EINA_TRUE if the entry is empty, EINA_FALSE otherwise.
448  */
449 EAPI Eina_Bool          elm_entry_is_empty(const Evas_Object *obj);
450
451 /**
452  * Gets any selected text within the entry.
453  *
454  * If there's any selected text in the entry, this function returns it as
455  * a string in markup format. NULL is returned if no selection exists or
456  * if an error occurred.
457  *
458  * The returned value points to an internal string and should not be freed
459  * or modified in any way. If the @p entry object is deleted or its
460  * contents are changed, the returned pointer should be considered invalid.
461  *
462  * @param obj The entry object
463  * @return The selected text within the entry or NULL on failure
464  */
465 EAPI const char        *elm_entry_selection_get(const Evas_Object *obj);
466
467 /**
468  * Returns the actual textblock object of the entry.
469  *
470  * This function exposes the internal textblock object that actually
471  * contains and draws the text. This should be used for low-level
472  * manipulations that are otherwise not possible.
473  *
474  * Changing the textblock directly from here will not notify edje/elm to
475  * recalculate the textblock size automatically, so any modifications
476  * done to the textblock returned by this function should be followed by
477  * a call to elm_entry_calc_force().
478  *
479  * The return value is marked as const as an additional warning.
480  * One should not use the returned object with any of the generic evas
481  * functions (geometry_get/resize/move and etc), but only with the textblock
482  * functions; The former will either not work at all, or break the correct
483  * functionality.
484  *
485  * IMPORTANT: Many functions may change (i.e delete and create a new one)
486  * the internal textblock object. Do NOT cache the returned object, and try
487  * not to mix calls on this object with regular elm_entry calls (which may
488  * change the internal textblock object). This applies to all cursors
489  * returned from textblock calls, and all the other derivative values.
490  *
491  * @param obj The entry object
492  * @return The textblock object.
493  */
494 EAPI Evas_Object *      elm_entry_textblock_get(Evas_Object *obj);
495
496 /**
497  * Forces calculation of the entry size and text layouting.
498  *
499  * This should be used after modifying the textblock object directly. See
500  * elm_entry_textblock_get() for more information.
501  *
502  * @param obj The entry object
503  *
504  * @see elm_entry_textblock_get()
505  */
506 EAPI void               elm_entry_calc_force(Evas_Object *obj);
507
508 /**
509  * Inserts the given text into the entry at the current cursor position.
510  *
511  * This inserts text at the cursor position as if it was typed
512  * by the user (note that this also allows markup which a user
513  * can't just "type" as it would be converted to escaped text, so this
514  * call can be used to insert things like emoticon items or bold push/pop
515  * tags, other font and color change tags etc.)
516  *
517  * If any selection exists, it will be replaced by the inserted text.
518  *
519  * The inserted text is subject to any filters set for the widget.
520  *
521  * @param obj The entry object
522  * @param entry The text to insert
523  *
524  * @see elm_entry_text_filter_append()
525  */
526 EAPI void               elm_entry_entry_insert(Evas_Object *obj, const char *entry);
527
528 /**
529  * Set the line wrap type to use on multi-line entries.
530  *
531  * Sets the wrap type used by the entry to any of the specified in
532  * Elm_Wrap_Type. This tells how the text will be implicitly cut into a new
533  * line (without inserting a line break or paragraph separator) when it
534  * reaches the far edge of the widget.
535  *
536  * Note that this only makes sense for multi-line entries. A widget set
537  * to be single line will never wrap.
538  *
539  * @param obj The entry object
540  * @param wrap The wrap mode to use. See Elm_Wrap_Type for details on them
541  */
542 EAPI void               elm_entry_line_wrap_set(Evas_Object *obj, Elm_Wrap_Type wrap);
543
544 /**
545  * Gets the wrap mode the entry was set to use.
546  *
547  * @param obj The entry object
548  * @return Wrap type
549  *
550  * @see also elm_entry_line_wrap_set()
551  */
552 EAPI Elm_Wrap_Type      elm_entry_line_wrap_get(const Evas_Object *obj);
553
554 /**
555  * Sets if the entry is to be editable or not.
556  *
557  * By default, entries are editable and when focused, any text input by the
558  * user will be inserted at the current cursor position. But calling this
559  * function with @p editable as EINA_FALSE will prevent the user from
560  * inputting text into the entry.
561  *
562  * The only way to change the text of a non-editable entry is to use
563  * elm_object_text_set(), elm_entry_entry_insert() and other related
564  * functions.
565  *
566  * @param obj The entry object
567  * @param editable If EINA_TRUE, user input will be inserted in the entry,
568  * if not, the entry is read-only and no user input is allowed.
569  */
570 EAPI void               elm_entry_editable_set(Evas_Object *obj, Eina_Bool editable);
571
572 /**
573  * Gets whether the entry is editable or not.
574  *
575  * @param obj The entry object
576  * @return If true, the entry is editable by the user.
577  * If false, it is not editable by the user
578  *
579  * @see elm_entry_editable_set()
580  */
581 EAPI Eina_Bool          elm_entry_editable_get(const Evas_Object *obj);
582
583 /**
584  * This drops any existing text selection within the entry.
585  *
586  * @param obj The entry object
587  */
588 EAPI void               elm_entry_select_none(Evas_Object *obj);
589
590 /**
591  * This selects all text within the entry.
592  *
593  * @param obj The entry object
594  */
595 EAPI void               elm_entry_select_all(Evas_Object *obj);
596
597 /**
598  * This moves the cursor one place to the right within the entry.
599  *
600  * @param obj The entry object
601  * @return EINA_TRUE upon success, EINA_FALSE upon failure
602  */
603 EAPI Eina_Bool          elm_entry_cursor_next(Evas_Object *obj);
604
605 /**
606  * This moves the cursor one place to the left within the entry.
607  *
608  * @param obj The entry object
609  * @return EINA_TRUE upon success, EINA_FALSE upon failure
610  */
611 EAPI Eina_Bool          elm_entry_cursor_prev(Evas_Object *obj);
612
613 /**
614  * This moves the cursor one line up within the entry.
615  *
616  * @param obj The entry object
617  * @return EINA_TRUE upon success, EINA_FALSE upon failure
618  */
619 EAPI Eina_Bool          elm_entry_cursor_up(Evas_Object *obj);
620
621 /**
622  * This moves the cursor one line down within the entry.
623  *
624  * @param obj The entry object
625  * @return EINA_TRUE upon success, EINA_FALSE upon failure
626  */
627 EAPI Eina_Bool          elm_entry_cursor_down(Evas_Object *obj);
628
629 /**
630  * This moves the cursor to the beginning of the entry.
631  *
632  * @param obj The entry object
633  */
634 EAPI void               elm_entry_cursor_begin_set(Evas_Object *obj);
635
636 /**
637  * This moves the cursor to the end of the entry.
638  *
639  * @param obj The entry object
640  */
641 EAPI void               elm_entry_cursor_end_set(Evas_Object *obj);
642
643 /**
644  * This moves the cursor to the beginning of the current line.
645  *
646  * @param obj The entry object
647  */
648 EAPI void               elm_entry_cursor_line_begin_set(Evas_Object *obj);
649
650 /**
651  * This moves the cursor to the end of the current line.
652  *
653  * @param obj The entry object
654  */
655 EAPI void               elm_entry_cursor_line_end_set(Evas_Object *obj);
656
657 /**
658  * This begins a selection within the entry as though
659  * the user were holding down the mouse button to make a selection.
660  *
661  * @param obj The entry object
662  */
663 EAPI void               elm_entry_cursor_selection_begin(Evas_Object *obj);
664
665 /**
666  * This ends a selection within the entry as though
667  * the user had just released the mouse button while making a selection.
668  *
669  * @param obj The entry object
670  */
671 EAPI void               elm_entry_cursor_selection_end(Evas_Object *obj);
672
673 /**
674  * Gets whether a format node exists at the current cursor position.
675  *
676  * A format node is anything that defines how the text is rendered. It can
677  * be a visible format node, such as a line break or a paragraph separator,
678  * or an invisible one, such as bold begin or end tag.
679  * This function returns whether any format node exists at the current
680  * cursor position.
681  *
682  * @param obj The entry object
683  * @return EINA_TRUE if the current cursor position contains a format node,
684  * EINA_FALSE otherwise.
685  *
686  * @see elm_entry_cursor_is_visible_format_get()
687  */
688 EAPI Eina_Bool          elm_entry_cursor_is_format_get(const Evas_Object *obj);
689
690 /**
691  * Gets if the current cursor position holds a visible format node.
692  *
693  * @param obj The entry object
694  * @return EINA_TRUE if the current cursor is a visible format, EINA_FALSE
695  * if it's an invisible one or no format exists.
696  *
697  * @see elm_entry_cursor_is_format_get()
698  */
699 EAPI Eina_Bool          elm_entry_cursor_is_visible_format_get(const Evas_Object *obj);
700
701 /**
702  * Gets the character pointed by the cursor at its current position.
703  *
704  * This function returns a string with the utf8 character stored at the
705  * current cursor position.
706  * Only the text is returned, any format that may exist will not be part
707  * of the return value. You must free the string when done with free().
708  *
709  * @param obj The entry object
710  * @return The text pointed by the cursors.
711  */
712 EAPI char              *elm_entry_cursor_content_get(const Evas_Object *obj);
713
714 /**
715  * This function returns the geometry of the cursor.
716  *
717  * It's useful if you want to draw something on the cursor (or where it is),
718  * or for example in the case of scrolled entry where you want to show the
719  * cursor.
720  *
721  * @param obj The entry object
722  * @param x returned geometry
723  * @param y returned geometry
724  * @param w returned geometry
725  * @param h returned geometry
726  * @return EINA_TRUE upon success, EINA_FALSE upon failure
727  */
728 EAPI Eina_Bool          elm_entry_cursor_geometry_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
729
730 /**
731  * Sets the cursor position in the entry to the given value
732  *
733  * The value in @p pos is the index of the character position within the
734  * contents of the string as returned by elm_entry_cursor_pos_get().
735  *
736  * @param obj The entry object
737  * @param pos The position of the cursor
738  */
739 EAPI void               elm_entry_cursor_pos_set(Evas_Object *obj, int pos);
740
741 /**
742  * Retrieves the current position of the cursor in the entry
743  *
744  * @param obj The entry object
745  * @return The cursor position
746  */
747 EAPI int                elm_entry_cursor_pos_get(const Evas_Object *obj);
748
749 /**
750  * This executes a "cut" action on the selected text in the entry.
751  *
752  * @param obj The entry object
753  */
754 EAPI void               elm_entry_selection_cut(Evas_Object *obj);
755
756 /**
757  * This executes a "copy" action on the selected text in the entry.
758  *
759  * @param obj The entry object
760  */
761 EAPI void               elm_entry_selection_copy(Evas_Object *obj);
762
763 /**
764  * This executes a "paste" action in the entry.
765  *
766  * @param obj The entry object
767  */
768 EAPI void               elm_entry_selection_paste(Evas_Object *obj);
769
770 /**
771  * This clears and frees the items in a entry's contextual (longpress)
772  * menu.
773  *
774  * @param obj The entry object
775  *
776  * @see elm_entry_context_menu_item_add()
777  */
778 EAPI void               elm_entry_context_menu_clear(Evas_Object *obj);
779
780 /**
781  * This adds an item to the entry's contextual menu.
782  *
783  * A longpress on an entry will make the contextual menu show up, if this
784  * hasn't been disabled with elm_entry_context_menu_disabled_set().
785  * By default, this menu provides a few options like enabling selection mode,
786  * which is useful on embedded devices that need to be explicit about it,
787  * and when a selection exists it also shows the copy and cut actions.
788  *
789  * With this function, developers can add other options to this menu to
790  * perform any action they deem necessary.
791  *
792  * @param obj The entry object
793  * @param label The item's text label
794  * @param icon_file The item's icon file
795  * @param icon_type The item's icon type
796  * @param func The callback to execute when the item is clicked
797  * @param data The data to associate with the item for related functions
798  */
799 EAPI void               elm_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);
800
801 /**
802  * This disables the entry's contextual (longpress) menu.
803  *
804  * @param obj The entry object
805  * @param disabled If true, the menu is disabled
806  */
807 EAPI void               elm_entry_context_menu_disabled_set(Evas_Object *obj, Eina_Bool disabled);
808
809 /**
810  * This returns whether the entry's contextual (longpress) menu is
811  * disabled.
812  *
813  * @param obj The entry object
814  * @return If true, the menu is disabled
815  */
816 EAPI Eina_Bool          elm_entry_context_menu_disabled_get(const Evas_Object *obj);
817
818 /**
819  * This disables the entry's magnifer feature.
820  *
821  * @param obj The entry object
822  * @param disabled If true, the magnifier is not displayed
823  */
824
825 EAPI void         elm_entry_magnifier_disabled_set(Evas_Object *obj, Eina_Bool disabled);
826 /**
827  * This returns whether the entry's magnifier feature is disabled.
828  *
829  * @param obj The entry object
830  * @return If true, the feature is disabled
831  */
832 EAPI Eina_Bool    elm_entry_magnifier_disabled_get(const Evas_Object *obj);
833
834 /**
835  * This appends a custom item provider to the list for that entry
836  *
837  * This appends the given callback. The list is walked from beginning to end
838  * with each function called given the item href string in the text. If the
839  * function returns an object handle other than NULL (it should create an
840  * object to do this), then this object is used to replace that item. If
841  * not the next provider is called until one provides an item object, or the
842  * default provider in entry does.
843  *
844  * @param obj The entry object
845  * @param func The function called to provide the item object
846  * @param data The data passed to @p func
847  *
848  * @see @ref entry-items
849  */
850 EAPI void               elm_entry_item_provider_append(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * entry, const char *item), void *data);
851
852 /**
853  * This prepends a custom item provider to the list for that entry
854  *
855  * This prepends the given callback. See elm_entry_item_provider_append() for
856  * more information
857  *
858  * @param obj The entry object
859  * @param func The function called to provide the item object
860  * @param data The data passed to @p func
861  */
862 EAPI void               elm_entry_item_provider_prepend(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * entry, const char *item), void *data);
863
864 /**
865  * This removes a custom item provider to the list for that entry
866  *
867  * This removes the given callback. See elm_entry_item_provider_append() for
868  * more information
869  *
870  * @param obj The entry object
871  * @param func The function called to provide the item object
872  * @param data The data passed to @p func
873  */
874 EAPI void               elm_entry_item_provider_remove(Evas_Object *obj, Evas_Object * (*func)(void *data, Evas_Object * entry, const char *item), void *data);
875
876 /**
877  * Append a filter function for text inserted in the entry
878  *
879  * Append the given callback to the list. This functions will be called
880  * whenever any text is inserted into the entry, with the text to be inserted
881  * as a parameter. The callback function is free to alter the text in any way
882  * it wants, but it must remember to free the given pointer and update it.
883  * If the new text is to be discarded, the function can free it and set its
884  * text parameter to NULL. This will also prevent any following filters from
885  * being called.
886  *
887  * @param obj The entry object
888  * @param func The function to use as text filter
889  * @param data User data to pass to @p func
890  */
891 EAPI void               elm_entry_text_filter_append(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data);
892
893 /**
894  * Prepend a filter function for text insdrted in the entry
895  *
896  * Prepend the given callback to the list. See elm_entry_text_filter_append()
897  * for more information
898  *
899  * @param obj The entry object
900  * @param func The function to use as text filter
901  * @param data User data to pass to @p func
902  */
903 EAPI void               elm_entry_text_filter_prepend(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data);
904
905 /**
906  * Remove a filter from the list
907  *
908  * Removes the given callback from the filter list. See
909  * elm_entry_text_filter_append() for more information.
910  *
911  * @param obj The entry object
912  * @param func The filter function to remove
913  * @param data The user data passed when adding the function
914  */
915 EAPI void               elm_entry_text_filter_remove(Evas_Object *obj, Elm_Entry_Filter_Cb func, void *data);
916
917 /**
918  * This converts a markup (HTML-like) string into UTF-8.
919  *
920  * The returned string is a malloc'ed buffer and it should be freed when
921  * not needed anymore.
922  *
923  * @param s The string (in markup) to be converted
924  * @return The converted string (in UTF-8). It should be freed.
925  */
926 EAPI char              *elm_entry_markup_to_utf8(const char *s);
927
928 /**
929  * This converts a UTF-8 string into markup (HTML-like).
930  *
931  * The returned string is a malloc'ed buffer and it should be freed when
932  * not needed anymore.
933  *
934  * @param s The string (in UTF-8) to be converted
935  * @return The converted string (in markup). It should be freed.
936  */
937 EAPI char              *elm_entry_utf8_to_markup(const char *s);
938
939 /**
940  * This sets the file (and implicitly loads it) for the text to display and
941  * then edit. All changes are written back to the file after a short delay if
942  * the entry object is set to autosave (which is the default).
943  *
944  * If the entry had any other file set previously, any changes made to it
945  * will be saved if the autosave feature is enabled, otherwise, the file
946  * will be silently discarded and any non-saved changes will be lost.
947  *
948  * @param obj The entry object
949  * @param file The path to the file to load and save
950  * @param format The file format
951  */
952 EAPI void               elm_entry_file_set(Evas_Object *obj, const char *file, Elm_Text_Format format);
953
954 /**
955  * Gets the file being edited by the entry.
956  *
957  * This function can be used to retrieve any file set on the entry for
958  * edition, along with the format used to load and save it.
959  *
960  * @param obj The entry object
961  * @param file The path to the file to load and save
962  * @param format The file format
963  */
964 EAPI void               elm_entry_file_get(const Evas_Object *obj, const char **file, Elm_Text_Format *format);
965
966 /**
967  * This function writes any changes made to the file set with
968  * elm_entry_file_set()
969  *
970  * @param obj The entry object
971  */
972 EAPI void               elm_entry_file_save(Evas_Object *obj);
973
974 /**
975  * This sets the entry object to 'autosave' the loaded text file or not.
976  *
977  * @param obj The entry object
978  * @param autosave Autosave the loaded file or not
979  *
980  * @see elm_entry_file_set()
981  */
982 EAPI void               elm_entry_autosave_set(Evas_Object *obj, Eina_Bool autosave);
983
984 /**
985  * This gets the entry object's 'autosave' status.
986  *
987  * @param obj The entry object
988  * @return Autosave the loaded file or not
989  *
990  * @see elm_entry_file_set()
991  */
992 EAPI Eina_Bool          elm_entry_autosave_get(const Evas_Object *obj);
993
994 /**
995  * Control pasting of text and images for the widget.
996  *
997  * Normally the entry allows both text and images to be pasted.
998  * By setting textonly to be ELM_CNP_MODE_NO_IMAGE, this prevents images from being copy or past.
999  * By setting textonly to be ELM_CNP_MODE_PLAINTEXT, this remove all tags in text .
1000  *
1001  * @note this only changes the behaviour of text.
1002  *
1003  * @param obj The entry object
1004  * @param mode One of #Elm_CNP_Mode: #ELM_CNP_MODE_MARKUP,
1005  * #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT.
1006  */
1007 EAPI void         elm_entry_cnp_mode_set(Evas_Object *obj, Elm_CNP_Mode cnp_mode);
1008
1009 /**
1010  * Getting elm_entry text paste/drop mode.
1011  *
1012  * Normally the entry allows both text and images to be pasted.
1013  * This gets the copy & paste mode of the entry.
1014  *
1015  * @param obj The entry object
1016  * @return mode One of #Elm_CNP_Mode: #ELM_CNP_MODE_MARKUP,
1017  * #ELM_CNP_MODE_NO_IMAGE, #ELM_CNP_MODE_PLAINTEXT.
1018  */
1019 EAPI Elm_CNP_Mode elm_entry_cnp_mode_get(const Evas_Object *obj);
1020
1021 /**
1022  * Control pasting of text and images for the widget.
1023  *
1024  * Normally the entry allows both text and images to be pasted.  By setting
1025  * textonly to be true, this prevents images from being pasted.
1026  *
1027  * Note this only changes the behaviour of text.
1028  *
1029  * @param obj The entry object
1030  * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is
1031  * text+image+other.
1032  */
1033
1034 /**
1035  * Control pasting of text and images for the widget.
1036  *
1037  * Normally the entry allows both text and images to be pasted.  By setting
1038  * textonly to be true, this prevents images from being pasted.
1039  *
1040  * Note this only changes the behaviour of text.
1041  *
1042  * @param obj The entry object
1043  * @param textonly paste mode - EINA_TRUE is text only, EINA_FALSE is
1044  * text+image+other.
1045  */
1046 EAPI void               elm_entry_cnp_textonly_set(Evas_Object *obj, Eina_Bool textonly);
1047
1048 /**
1049  * Getting elm_entry text paste/drop mode.
1050  *
1051  * In textonly mode, only text may be pasted or dropped into the widget.
1052  *
1053  * @param obj The entry object
1054  * @return If the widget only accepts text from pastes.
1055  */
1056 EAPI Eina_Bool          elm_entry_cnp_textonly_get(const Evas_Object *obj);
1057
1058 /**
1059  * Enable or disable scrolling in entry
1060  *
1061  * Normally the entry is not scrollable unless you enable it with this call.
1062  *
1063  * @param obj The entry object
1064  * @param scroll EINA_TRUE if it is to be scrollable, EINA_FALSE otherwise
1065  */
1066 EAPI void               elm_entry_scrollable_set(Evas_Object *obj, Eina_Bool scroll);
1067
1068 /**
1069  * Get the scrollable state of the entry
1070  *
1071  * Normally the entry is not scrollable. This gets the scrollable state
1072  * of the entry. See elm_entry_scrollable_set() for more information.
1073  *
1074  * @param obj The entry object
1075  * @return The scrollable state
1076  */
1077 EAPI Eina_Bool          elm_entry_scrollable_get(const Evas_Object *obj);
1078
1079 /**
1080  * Sets the visibility of the left-side widget of the scrolled entry,
1081  * set by elm_entry_icon_set().
1082  *
1083  * @param obj The scrolled entry object
1084  * @param setting EINA_TRUE if the object should be displayed,
1085  * EINA_FALSE if not.
1086  */
1087 EAPI void               elm_entry_icon_visible_set(Evas_Object *obj, Eina_Bool setting);
1088
1089 /**
1090  * Sets the visibility of the end widget of the scrolled entry, set by
1091  * elm_object_part_content_set(ent, "end", content).
1092  *
1093  * @param obj The scrolled entry object
1094  * @param setting EINA_TRUE if the object should be displayed,
1095  * EINA_FALSE if not.
1096  */
1097 EAPI void               elm_entry_end_visible_set(Evas_Object *obj, Eina_Bool setting);
1098
1099 /**
1100  * This sets the scrolled entry's scrollbar policy (ie. enabling/disabling
1101  * them).
1102  *
1103  * Setting an entry to single-line mode with elm_entry_single_line_set()
1104  * will automatically disable the display of scrollbars when the entry
1105  * moves inside its scroller.
1106  *
1107  * @param obj The scrolled entry object
1108  * @param h The horizontal scrollbar policy to apply
1109  * @param v The vertical scrollbar policy to apply
1110  */
1111 EAPI void               elm_entry_scrollbar_policy_set(Evas_Object *obj, Elm_Scroller_Policy h, Elm_Scroller_Policy v);
1112
1113 /**
1114  * This enables/disables bouncing within the entry.
1115  *
1116  * This function sets whether the entry will bounce when scrolling reaches
1117  * the end of the contained entry.
1118  *
1119  * @param obj The scrolled entry object
1120  * @param h_bounce The horizontal bounce state
1121  * @param v_bounce The vertical bounce state
1122  */
1123 EAPI void               elm_entry_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce);
1124
1125 /**
1126  * Get the bounce mode
1127  *
1128  * @param obj The Entry object
1129  * @param h_bounce Allow bounce horizontally
1130  * @param v_bounce Allow bounce vertically
1131  */
1132 EAPI void               elm_entry_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce);
1133
1134 /**
1135  * Set the input panel layout of the entry
1136  *
1137  * @param obj The entry object
1138  * @param layout layout type
1139  */
1140 EAPI void                   elm_entry_input_panel_layout_set(Evas_Object *obj, Elm_Input_Panel_Layout layout);
1141
1142 /**
1143  * Get the input panel layout of the entry
1144  *
1145  * @param obj The entry object
1146  * @return layout type
1147  *
1148  * @see elm_entry_input_panel_layout_set
1149  */
1150 EAPI Elm_Input_Panel_Layout elm_entry_input_panel_layout_get(Evas_Object *obj);
1151
1152 /**
1153  * Set the autocapitalization type on the immodule.
1154  *
1155  * @param obj The entry object
1156  * @param autocapital_type The type of autocapitalization
1157  */
1158 EAPI void                   elm_entry_autocapital_type_set(Evas_Object *obj, Elm_Autocapital_Type autocapital_type);
1159
1160 /**
1161  * Retrieve the autocapitalization type on the immodule.
1162  *
1163  * @param obj The entry object
1164  * @return autocapitalization type
1165  */
1166 EAPI Elm_Autocapital_Type   elm_entry_autocapital_type_get(Evas_Object *obj);
1167
1168 /**
1169  * Sets the attribute to show the input panel automatically.
1170  *
1171  * @param obj The entry object
1172  * @param enabled If true, the input panel is appeared when entry is clicked or has a focus
1173  */
1174 EAPI void                   elm_entry_input_panel_enabled_set(Evas_Object *obj, Eina_Bool enabled);
1175
1176 /**
1177  * Retrieve the attribute to show the input panel automatically.
1178  *
1179  * @param obj The entry object
1180  * @return EINA_TRUE if input panel will be appeared when the entry is clicked or has a focus, EINA_FALSE otherwise
1181  */
1182 EAPI Eina_Bool              elm_entry_input_panel_enabled_get(Evas_Object *obj);
1183
1184 /* pre-made filters for entries */
1185
1186 /**
1187  * @typedef Elm_Entry_Filter_Limit_Size
1188  *
1189  * Data for the elm_entry_filter_limit_size() entry filter.
1190  */
1191 typedef struct _Elm_Entry_Filter_Limit_Size Elm_Entry_Filter_Limit_Size;
1192
1193 /**
1194  * @struct _Elm_Entry_Filter_Limit_Size
1195  *
1196  * Data for the elm_entry_filter_limit_size() entry filter.
1197  */
1198 struct _Elm_Entry_Filter_Limit_Size
1199 {
1200    int max_char_count;      /**< The maximum number of characters allowed. */
1201    int max_byte_count;      /**< The maximum number of bytes allowed*/
1202 };
1203
1204 /**
1205  * Filter inserted text based on user defined character and byte limits
1206  *
1207  * Add this filter to an entry to limit the characters that it will accept
1208  * based the the contents of the provided #Elm_Entry_Filter_Limit_Size.
1209  * The funtion works on the UTF-8 representation of the string, converting
1210  * it from the set markup, thus not accounting for any format in it.
1211  *
1212  * The user must create an #Elm_Entry_Filter_Limit_Size structure and pass
1213  * it as data when setting the filter. In it, it's possible to set limits
1214  * by character count or bytes (any of them is disabled if 0), and both can
1215  * be set at the same time. In that case, it first checks for characters,
1216  * then bytes.
1217  *
1218  * The function will cut the inserted text in order to allow only the first
1219  * number of characters that are still allowed. The cut is made in
1220  * characters, even when limiting by bytes, in order to always contain
1221  * valid ones and avoid half unicode characters making it in.
1222  *
1223  * This filter, like any others, does not apply when setting the entry text
1224  * directly with elm_object_text_set().
1225  */
1226 EAPI void elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text);
1227
1228 /**
1229  * @typedef Elm_Entry_Filter_Accept_Set
1230  *
1231  * Data for the elm_entry_filter_accept_set() entry filter.
1232  */
1233 typedef struct _Elm_Entry_Filter_Accept_Set Elm_Entry_Filter_Accept_Set;
1234
1235 /**
1236  * @struct _Elm_Entry_Filter_Accept_Set
1237  *
1238  * Data for the elm_entry_filter_accept_set() entry filter.
1239  */
1240 struct _Elm_Entry_Filter_Accept_Set
1241 {
1242    const char *accepted;      /**< Set of characters accepted in the entry. */
1243    const char *rejected;      /**< Set of characters rejected from the entry. */
1244 };
1245
1246 /**
1247  * Filter inserted text based on accepted or rejected sets of characters
1248  *
1249  * Add this filter to an entry to restrict the set of accepted characters
1250  * based on the sets in the provided #Elm_Entry_Filter_Accept_Set.
1251  * This structure contains both accepted and rejected sets, but they are
1252  * mutually exclusive.
1253  *
1254  * The @c accepted set takes preference, so if it is set, the filter will
1255  * only work based on the accepted characters, ignoring anything in the
1256  * @c rejected value. If @c accepted is @c NULL, then @c rejected is used.
1257  *
1258  * In both cases, the function filters by matching utf8 characters to the
1259  * raw markup text, so it can be used to remove formatting tags.
1260  *
1261  * This filter, like any others, does not apply when setting the entry text
1262  * directly with elm_object_text_set()
1263  */
1264 EAPI void                   elm_entry_filter_accept_set(void *data, Evas_Object *entry, char **text);
1265
1266 EAPI void                   elm_entry_autocapitalization_set(Evas_Object *obj, Eina_Bool autocap);
1267 EINA_DEPRECATED EAPI void   elm_entry_autoperiod_set(Evas_Object *obj, Eina_Bool autoperiod);
1268 EINA_DEPRECATED EAPI void   elm_entry_autoenable_returnkey_set(Evas_Object *obj, Eina_Bool on);
1269 EAPI Ecore_IMF_Context     *elm_entry_imf_context_get(Evas_Object *obj);
1270 EAPI void                   elm_entry_matchlist_set(Evas_Object *obj, Eina_List *match_list, Eina_Bool case_sensitive);
1271 EAPI void                   elm_entry_magnifier_type_set(Evas_Object *obj, int type);
1272
1273 /**
1274  * @}
1275  */