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