1 #ifndef ELM_ENTRY_COMMON_H_
2 #define ELM_ENTRY_COMMON_H_
3 
4 /**
5  * @addtogroup Elm_Entry_Group
6  *
7  * @{
8  */
9 
10 /**
11  * @typedef Elm_Input_Panel_Layout_Normal_Variation
12  * @brief Enumeration for defining the types of Elm Input Panel Layout for normal variation.
13  * @since 1.12
14  */
15 typedef enum
16 {
17    ELM_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_NORMAL,          /**< The plain normal layout @since 1.12 */
18    ELM_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_FILENAME,        /**< Filename layout. Symbols such as '/' should be disabled. @since 1.12 */
19    ELM_INPUT_PANEL_LAYOUT_NORMAL_VARIATION_PERSON_NAME      /**< The name of a person. @since 1.12 */
20 } Elm_Input_Panel_Layout_Normal_Variation;
21 
22 /**
23  * @typedef Elm_Input_Panel_Layout_Numberonly_Variation
24  * @brief Enumeration for defining the types of Elm Input Panel Layout for number only variation.
25  * @since 1.8
26  */
27 typedef enum
28 {
29    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_NORMAL,              /**< The plain normal number layout @since 1.8 */
30    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_SIGNED,              /**< The number layout to allow a positive or negative sign at the start @since 1.8 */
31    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_DECIMAL,             /**< The number layout to allow decimal point to provide fractional value @since 1.8 */
32    ELM_INPUT_PANEL_LAYOUT_NUMBERONLY_VARIATION_SIGNED_AND_DECIMAL   /**< The number layout to allow decimal point and negative sign @since 1.8 */
33 } Elm_Input_Panel_Layout_Numberonly_Variation;
34 
35 /**
36  * @typedef Elm_Input_Panel_Layout_Password_Variation
37  * @brief Enumeration for defining the types of Elm Input Panel Layout for password variation.
38  * @since 1.12
39  */
40 typedef enum
41 {
42    ELM_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NORMAL,    /**< The normal password layout @since 1.12 */
43    ELM_INPUT_PANEL_LAYOUT_PASSWORD_VARIATION_NUMBERONLY /**< The password layout to allow only number @since 1.12 */
44 } Elm_Input_Panel_Layout_Password_Variation;
45 
46 /**
47  * The info sent in the callback for the "anchor,clicked" signals emitted
48  * by entries.
49  */
50 typedef struct _Elm_Entry_Anchor_Info Elm_Entry_Anchor_Info;
51 
52 /**
53  * The info sent in the callback for the "anchor,clicked" signals emitted
54  * by entries.
55  */
56 struct _Elm_Entry_Anchor_Info
57 {
58    const char *name; /**< The name of the anchor, as stated in its href */
59    int         button; /**< The mouse button used to click on it */
60    Evas_Coord  x, /**< Anchor geometry, relative to canvas */
61                y, /**< Anchor geometry, relative to canvas */
62                w, /**< Anchor geometry, relative to canvas */
63                h; /**< Anchor geometry, relative to canvas */
64 };
65 
66 /**
67  * The info sent in the callback for "anchor,clicked" signals emitted by
68  * the Anchor_Hover widget.
69  */
70 typedef struct _Elm_Entry_Anchor_Hover_Info Elm_Entry_Anchor_Hover_Info;
71 
72 /**
73  * Type of contextual item that can be added in to long press menu.
74  * @since 1.8
75  */
76 typedef struct _Elm_Entry_Context_Menu_Item Elm_Entry_Context_Menu_Item;
77 
78 /**
79  * The info sent in the callback for "anchor,clicked" signals emitted by
80  * the Anchor_Hover widget.
81  */
82 struct _Elm_Entry_Anchor_Hover_Info
83 {
84    const Elm_Entry_Anchor_Info *anchor_info; /**< The actual anchor info. */
85    Evas_Object *hover; /**< The hover object to use for the popup */
86    struct
87    {
88       Evas_Coord x, y, w, h;
89    } hover_parent; /**< Geometry of the object used as parent by the
90                         hover */
91    Eina_Bool    hover_left : 1; /**< Hint indicating if there's space
92                                      for content on the left side of
93                                      the hover. Before calling the
94                                      callback, the widget will make the
95                                      necessary calculations to check
96                                      which sides are fit to be set with
97                                      content, based on the position the
98                                      hover is activated and its distance
99                                      to the edges of its parent object
100                                  */
101    Eina_Bool    hover_right : 1; /**< Hint indicating content fits on
102                                       the right side of the hover.
103                                       See @ref hover_left */
104    Eina_Bool    hover_top : 1; /**< Hint indicating content fits on top
105                                     of the hover. See @ref hover_left */
106    Eina_Bool    hover_bottom : 1; /**< Hint indicating content fits
107                                        below the hover. See @ref
108                                        hover_left */
109 };
110 
111 /**
112  * This callback type is used to provide items.
113  * If it returns an object handle other than NULL (it should create an
114  * object to do this), then this object is used to replace the current item.
115  * If not the next provider is called until one provides an item object, or the
116  * default provider in entry does.
117  * @param data The data specified as the last param when adding the provider
118  * @param entry The entry object
119  * @param text A pointer to the item href string in the text
120  * @return The object to be placed in the entry like an icon, or other element
121  * @see elm_entry_item_provider_append
122  * @see elm_entry_item_provider_prepend
123  * @see elm_entry_item_provider_remove
124  */
125 typedef Evas_Object * (*Elm_Entry_Item_Provider_Cb)(void *data, Evas_Object * entry, const char *item);
126 
127 /**
128  * This callback type is used by entry filters to modify text.
129  * @param data The data specified as the last param when adding the filter
130  * @param entry The entry object
131  * @param text A pointer to the location of the text being filtered. The type of text is always markup. This data can be modified, but any additional allocations must be managed by the user.
132  * @see elm_entry_markup_filter_append
133  * @see elm_entry_markup_filter_prepend
134  * @see elm_entry_markup_filter_remove
135  */
136 typedef void (*Elm_Entry_Filter_Cb)(void *data, Evas_Object *entry, char **text);
137 
138 /**
139  * This corresponds to Edje_Entry_Change_Info. Includes information about
140  * a change in the entry.
141  */
142 typedef Edje_Entry_Change_Info Elm_Entry_Change_Info;
143 
144 /**
145  * This converts a markup (HTML-like) string into UTF-8.
146  *
147  * The returned string is a malloc'ed buffer and it should be freed when
148  * not needed anymore.
149  *
150  * @param s The string (in markup) to be converted
151  * @return The converted string (in UTF-8). It should be freed.
152  */
153 EAPI char              *elm_entry_markup_to_utf8(const char *s);
154 
155 /**
156  * This converts a UTF-8 string into markup (HTML-like).
157  *
158  * The returned string is a malloc'ed buffer and it should be freed when
159  * not needed anymore.
160  *
161  * @param s The string (in UTF-8) to be converted
162  * @return The converted string (in markup). It should be freed.
163  *
164  * For example, passing "<align=center>hello</align>&gt;" will return
165  * "&lt;align=center&gt;hello&lt;/align&gt; &amp;gt;". This is useful when you
166  * want to display "&" in label, entry, and some widgets which use textblock
167  * internally.
168  */
169 EAPI char              *elm_entry_utf8_to_markup(const char *s);
170 
171 
172 
173 /* pre-made filters for entries */
174 
175 /**
176  * Data for the elm_entry_filter_limit_size() entry filter.
177  */
178 typedef struct _Elm_Entry_Filter_Limit_Size Elm_Entry_Filter_Limit_Size;
179 
180 /**
181  * Data for the elm_entry_filter_limit_size() entry filter.
182  */
183 struct _Elm_Entry_Filter_Limit_Size
184 {
185    int max_char_count;      /**< The maximum number of characters allowed. */
186    int max_byte_count;      /**< The maximum number of bytes allowed*/
187 };
188 
189 /**
190  * Filter inserted text based on user defined character and byte limits
191  *
192  * Add this filter to an entry to limit the characters that it will accept
193  * based the contents of the provided #Elm_Entry_Filter_Limit_Size.
194  * The function works on the UTF-8 representation of the string, converting
195  * it from the set markup, thus not accounting for any format in it.
196  *
197  * @param[in] data The data passed to this function.
198  * @param[in] entry The object.
199  * @param[in,out] text The entry's text to limit size
200  *
201  * The user must create an #Elm_Entry_Filter_Limit_Size structure and pass
202  * it as data when setting the filter. In it, it's possible to set limits
203  * by character count or bytes (any of them is disabled if 0), and both can
204  * be set at the same time. In that case, it first checks for characters,
205  * then bytes. The #Elm_Entry_Filter_Limit_Size structure must be alive and
206  * valid for as long as the entry is alive AND the elm_entry_filter_limit_size
207  * filter is set.
208  *
209  * The function will cut the inserted text in order to allow only the first
210  * number of characters that are still allowed. The cut is made in
211  * characters, even when limiting by bytes, in order to always contain
212  * valid ones and avoid half unicode characters making it in.
213  *
214  * This filter, like any others, does not apply when setting the entry text
215  * directly with elm_object_text_set().
216  */
217 EAPI void elm_entry_filter_limit_size(void *data, Evas_Object *entry, char **text);
218 
219 /**
220  * Data for the elm_entry_filter_accept_set() entry filter.
221  */
222 typedef struct _Elm_Entry_Filter_Accept_Set Elm_Entry_Filter_Accept_Set;
223 
224 /**
225  * Data for the elm_entry_filter_accept_set() entry filter.
226  */
227 struct _Elm_Entry_Filter_Accept_Set
228 {
229    const char *accepted;      /**< Set of characters accepted in the entry. */
230    const char *rejected;      /**< Set of characters rejected from the entry. */
231 };
232 
233 /**
234  * Filter inserted text based on accepted or rejected sets of characters
235  *
236  * Add this filter to an entry to restrict the set of accepted characters
237  * based on the sets in the provided #Elm_Entry_Filter_Accept_Set.
238  * This structure contains both accepted and rejected sets, but they are
239  * mutually exclusive. This structure must be available for as long as
240  * the entry is alive AND the elm_entry_filter_accept_set is being used.
241  *
242  * @param[in] data The data passed to this function.
243  * @param[in] entry The object.
244  * @param[in,out] text The entry's text to accept or reject filter
245  *
246  * The @c accepted set takes preference, so if it is set, the filter will
247  * only work based on the accepted characters, ignoring anything in the
248  * @c rejected value. If @c accepted is @c NULL, then @c rejected is used.
249  *
250  * In both cases, the function filters by matching utf8 characters to the
251  * raw markup text, so it can be used to remove formatting tags.
252  *
253  * This filter, like any others, does not apply when setting the entry text
254  * directly with elm_object_text_set()
255  */
256 EAPI void                   elm_entry_filter_accept_set(void *data, Evas_Object *entry, char **text);
257 
258 /**
259  * Get the text of the contextual menu item of entry.
260  *
261  * @param item The item to get the label
262  * @return The text of contextual menu item
263  *
264  * @see elm_entry_context_menu_item_add()
265  * @since 1.8
266  */
267 EAPI const char                  *elm_entry_context_menu_item_label_get(const Elm_Entry_Context_Menu_Item *item);
268 
269 /**
270  * Get the icon object packed in the contextual menu item of entry.
271  *
272  * @param item The item to get the icon from
273  * @param icon_file The image file path on disk used for the icon or standard
274  * icon name
275  * @param icon_group The edje group used if @p icon_file is an edje file. NULL
276  * if the icon is not an edje file
277  * @param icon_type The icon type
278  *
279  * @see elm_entry_context_menu_item_add()
280  * @since 1.8
281  */
282 EAPI void                         elm_entry_context_menu_item_icon_get(const Elm_Entry_Context_Menu_Item *item, const char **icon_file, const char **icon_group, Elm_Icon_Type *icon_type);
283 
284 
285 /**
286  * @}
287  */
288 #endif //ELM_ENTRY_COMMON_H_
289