Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / ElmSharp / ElmSharp / Entry.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Runtime.InteropServices;
20
21 namespace ElmSharp
22 {
23     /// <summary>
24     /// Enumeration for describing InputPanel layout type.
25     /// </summary>
26     public enum InputPanelLayout
27     {
28         /// <summary>
29         /// InputPanel layout type default.
30         /// </summary>
31         Normal,
32
33         /// <summary>
34         /// InputPanel layout type number.
35         /// </summary>
36         Number,
37
38         /// <summary>
39         /// InputPanel layout type email.
40         /// </summary>
41         Email,
42
43         /// <summary>
44         /// InputPanel layout type url.
45         /// </summary>
46         Url,
47
48         /// <summary>
49         /// InputPanel layout type phone.
50         /// </summary>
51         PhoneNumber,
52
53         /// <summary>
54         /// InputPanel layout type ip.
55         /// </summary>
56         Ip,
57
58         /// <summary>
59         /// InputPanel layout type month.
60         /// </summary>
61         Month,
62
63         /// <summary>
64         /// InputPanel layout type number.
65         /// </summary>
66         NumberOnly,
67
68         /// <summary>
69         /// InputPanel layout type error type. Do not use it directly!
70         /// </summary>
71         Invalid,
72
73         /// <summary>
74         /// InputPanel layout type hexadecimal.
75         /// </summary>
76         Hex,
77
78         /// <summary>
79         /// InputPanel layout type terminal type, esc, alt, ctrl, etc.
80         /// </summary>
81         Terminal,
82
83         /// <summary>
84         /// InputPanel layout type password.
85         /// </summary>
86         Password,
87
88         /// <summary>
89         /// Keyboard layout type date and time.
90         /// </summary>
91         DateTime,
92
93         /// <summary>
94         /// InputPanel layout type emoticons.
95         /// </summary>
96         Emoticon
97     }
98
99     /// <summary>
100     /// Enumeration that defines the "Return" key types on the input panel (virtual keyboard).
101     /// </summary>
102     public enum InputPanelReturnKeyType
103     {
104         /// <summary>
105         /// Default key type
106         /// </summary>
107         Default,
108
109         /// <summary>
110         /// Done key type
111         /// </summary>
112         Done,
113
114         /// <summary>
115         /// Go key type
116         /// </summary>
117         Go,
118
119         /// <summary>
120         /// Join key type
121         /// </summary>
122         Join,
123
124         /// <summary>
125         /// Login key type
126         /// </summary>
127         Login,
128
129         /// <summary>
130         /// Next key type
131         /// </summary>
132         Next,
133
134         /// <summary>
135         /// Search string or magnifier icon key type
136         /// </summary>
137         Search,
138
139         /// <summary>
140         /// Send key type
141         /// </summary>
142         Send,
143
144         /// <summary>
145         /// Sign-in key type
146         /// </summary>
147         Signin
148     }
149
150     /// <summary>
151     /// Enumeration that defines the autocapitalization types.
152     /// </summary>
153     public enum AutoCapital
154     {
155         /// <summary>
156         /// No autocapitalization when typing
157         /// </summary>
158         None,
159
160         /// <summary>
161         /// Autocapitalize each typed word
162         /// </summary>
163         Word,
164
165         /// <summary>
166         /// Autocapitalize the start of each sentence
167         /// </summary>
168         Sentence,
169
170         /// <summary>
171         /// Autocapitalize all letters
172         /// </summary>
173         All
174     }
175
176     /// <summary>
177     /// Enumeration that defines the entry's copy & paste policy.
178     /// </summary>
179     public enum CopyAndPasteMode
180     {
181         /// <summary>
182         /// Copy & paste text with markup tag
183         /// </summary>
184         Markup,
185
186         /// <summary>
187         /// Copy & paste text without item(image) tag
188         /// </summary>
189         NoImage,
190
191         /// <summary>
192         /// Copy & paste text without markup tag
193         /// </summary>
194         PlainText
195     }
196
197     /// <summary>
198     /// Enumeration that defines the text format types.
199     /// </summary>
200     public enum TextFormat
201     {
202         /// <summary>
203         /// Plain type
204         /// </summary>
205         Plain,
206
207         /// <summary>
208         /// Markup type
209         /// </summary>
210         Markup
211     }
212
213     /// <summary>
214     /// Enumeration that defines the types of Input Hints.
215     /// </summary>
216     public enum InputHints
217     {
218         /// <summary>
219         /// No active hints
220         /// </summary>
221         None,
222
223         /// <summary>
224         /// suggest word auto completion
225         /// </summary>
226         AutoComplete,
227
228         /// <summary>
229         /// typed text should not be stored.
230         /// </summary>
231         SensitiveData,
232     }
233
234     /// <summary>
235     /// Enumeration that defines the input panel (virtual keyboard) language modes.
236     /// </summary>
237     public enum InputPanelLanguage
238     {
239         /// <summary>
240         /// Automatic language mode
241         /// </summary>
242         Automatic,
243
244         /// <summary>
245         /// Alphabet language mode
246         /// </summary>
247         Alphabet,
248     }
249
250     /// <summary>
251     /// The entry is a convenience widget that shows a box in which the user can enter text.
252     /// </summary>
253     public class Entry : Layout
254     {
255         SmartEvent _clicked;
256         SmartEvent _changedByUser;
257         SmartEvent _cursorChanged;
258         SmartEvent _activated;
259
260         Dictionary<Func<string, EvasObject>, Interop.Elementary.Elm_Entry_Item_Provider_Cb> _itemsProvider = new Dictionary<Func<string, EvasObject>, Interop.Elementary.Elm_Entry_Item_Provider_Cb>();
261         Dictionary<Func<Entry, string, string>, Interop.Elementary.Elm_Entry_Filter_Cb> _textFilters = new Dictionary<Func<Entry, string, string>, Interop.Elementary.Elm_Entry_Filter_Cb>();
262
263         /// <summary>
264         /// Creates and initializes a new instance of the Entry class.
265         /// </summary>
266         /// <param name="parent">The EvasObject to which the new Entry will be attached as a child.</param>
267         public Entry(EvasObject parent) : base(parent)
268         {
269             _clicked = new SmartEvent(this, this.RealHandle, "clicked");
270             _clicked.On += (s, e) => Clicked?.Invoke(this, EventArgs.Empty);
271
272             _changedByUser = new SmartEvent(this, this.RealHandle, "changed,user");
273             _changedByUser.On += (s, e) => ChangedByUser?.Invoke(this, EventArgs.Empty);
274
275             _cursorChanged = new SmartEvent(this, this.RealHandle, "cursor,changed");
276             _cursorChanged.On += (s, e) => CursorChanged?.Invoke(this, EventArgs.Empty);
277
278             _activated = new SmartEvent(this, this.RealHandle, "activated");
279             _activated.On += (s, e) => Activated?.Invoke(this, EventArgs.Empty);
280         }
281
282         /// <summary>
283         /// Activated will be triggered when the entry in Activated stated.
284         /// </summary>
285         public event EventHandler Activated;
286
287         /// <summary>
288         /// Clicked will be triggered when the entry is clicked.
289         /// </summary>
290         public event EventHandler Clicked;
291
292         /// <summary>
293         /// ChangedByUser will be triggered when the entry changed by user.
294         /// </summary>
295         public event EventHandler ChangedByUser;
296
297         /// <summary>
298         /// CursorChanged will be triggered when the Cursor in the entry is changed.
299         /// </summary>
300         public event EventHandler CursorChanged;
301
302         /// <summary>
303         /// Sets or gets the entry to the single line mode.
304         /// </summary>
305         public bool IsSingleLine
306         {
307             get
308             {
309                 return Interop.Elementary.elm_entry_single_line_get(RealHandle);
310             }
311             set
312             {
313                 Interop.Elementary.elm_entry_single_line_set(RealHandle, value);
314             }
315         }
316
317         /// <summary>
318         /// Sets or gets the entry to the password mode.
319         /// </summary>
320         public bool IsPassword
321         {
322             get
323             {
324                 return Interop.Elementary.elm_entry_password_get(RealHandle);
325             }
326             set
327             {
328                 Interop.Elementary.elm_entry_password_set(RealHandle, value);
329             }
330         }
331
332         /// <summary>
333         /// Sets or gets whether the entry is editable.
334         /// </summary>
335         public bool IsEditable
336         {
337             get
338             {
339                 return Interop.Elementary.elm_entry_editable_get(RealHandle);
340             }
341             set
342             {
343                 Interop.Elementary.elm_entry_editable_set(RealHandle, value);
344             }
345         }
346
347         /// <summary>
348         /// Sets or gets whether the entry is empty.
349         /// </summary>
350         public bool IsEmpty
351         {
352             get
353             {
354                 return Interop.Elementary.elm_entry_is_empty(RealHandle);
355             }
356         }
357
358         /// <summary>
359         /// Sets or gets text currently shown in the object entry.
360         /// </summary>
361         public override string Text
362         {
363             get
364             {
365                 return Interop.Elementary.elm_entry_entry_get(RealHandle);
366             }
367             set
368             {
369                 Interop.Elementary.elm_entry_entry_set(RealHandle, value);
370             }
371         }
372
373         /// <summary>
374         /// Sets or gets the style on the top of the user style stack.
375         /// </summary>
376         /// <remarks>If there is styles in the user style stack, the properties in the top style of user style stack will replace the properties in current theme. The input style is specified in format tag='property=value' (i.e. DEFAULT='font=Sans font_size=60'hilight=' + font_weight=Bold').</remarks>
377         public string TextStyle
378         {
379             get
380             {
381                 return Interop.Elementary.elm_entry_text_style_user_peek(RealHandle);
382             }
383             set
384             {
385                 Interop.Elementary.elm_entry_text_style_user_push(RealHandle, value);
386             }
387         }
388
389         /// <summary>
390         /// Sets or gets the current position of the cursor in the entry.
391         /// </summary>
392         public int CursorPosition
393         {
394             get
395             {
396                 return Interop.Elementary.elm_entry_cursor_pos_get(RealHandle);
397             }
398             set
399             {
400                 Interop.Elementary.elm_entry_cursor_pos_set(RealHandle, value);
401             }
402         }
403
404         /// <summary>
405         /// Sets or gets the scrollable state of the entry.
406         /// </summary>
407         public bool Scrollable
408         {
409             get
410             {
411                 return Interop.Elementary.elm_entry_scrollable_get(RealHandle);
412             }
413             set
414             {
415                 // HACK: Enabling the scrollable property of an entry causes its internal
416                 //       hierarchy to change, making the internal edje object inaccessible.
417                 //       Access it before the property is set, to cache the edje object's handle.
418                 if (value)
419                 {
420                     var dummy = EdjeObject;
421                 }
422                 Interop.Elementary.elm_entry_scrollable_set(RealHandle, value);
423             }
424         }
425
426         /// <summary>
427         /// Sets or Gets the autocapitalization type on the immodule.
428         /// </summary>
429         public AutoCapital AutoCapital
430         {
431             get
432             {
433                 return (AutoCapital)Interop.Elementary.elm_entry_autocapital_type_get(RealHandle);
434             }
435             set
436             {
437                 Interop.Elementary.elm_entry_autocapital_type_set(RealHandle, (Interop.Elementary.AutocapitalType)value);
438             }
439         }
440
441         /// <summary>
442         /// Sets or Gets the entry object's 'autosave' status.
443         /// </summary>
444         public bool IsAutoSave
445         {
446             get
447             {
448                 return Interop.Elementary.elm_entry_autosave_get(RealHandle);
449             }
450             set
451             {
452                 Interop.Elementary.elm_entry_autosave_set(RealHandle, value);
453             }
454         }
455
456         /// <summary>
457         /// Sets or Gets entry text paste/drop mode.
458         /// </summary>
459         public CopyAndPasteMode CopyAndPasteMode
460         {
461             get
462             {
463                 return (CopyAndPasteMode)Interop.Elementary.elm_entry_cnp_mode_get(RealHandle);
464             }
465             set
466             {
467                 Interop.Elementary.elm_entry_cnp_mode_set(RealHandle, (Interop.Elementary.CopyAndPasteMode)value);
468             }
469         }
470
471         /// <summary>
472         /// Gets the geometry of the cursor.
473         /// </summary>
474         public Rect CursorGeometry
475         {
476             get
477             {
478                 int x, y, w, h;
479                 Interop.Elementary.elm_entry_cursor_geometry_get(RealHandle, out x, out y, out w, out h);
480                 return new Rect(x, y, w, h);
481             }
482         }
483
484         /// <summary>
485         /// Gets whether a format node exists at the current cursor position.
486         /// </summary>
487         public bool IsCursorFormat
488         {
489             get
490             {
491                 return Interop.Elementary.elm_entry_cursor_is_format_get(RealHandle);
492             }
493         }
494
495         /// <summary>
496         /// Gets if the current cursor position holds a visible format node.
497         /// </summary>
498         public bool IsCursorVisibelFormat
499         {
500             get
501             {
502                 return Interop.Elementary.elm_entry_cursor_is_visible_format_get(RealHandle);
503             }
504         }
505
506         /// <summary>
507         /// Sets or Gets the value of input hint.
508         /// </summary>
509         public InputHints InputHint
510         {
511             get
512             {
513                 return (InputHints)Interop.Elementary.elm_entry_input_hint_get(RealHandle);
514             }
515             set
516             {
517                 Interop.Elementary.elm_entry_input_hint_set(RealHandle, (Interop.Elementary.InputHints)value);
518             }
519         }
520
521         /// <summary>
522         ///  Sets or gets the language mode of the input panel.
523         /// </summary>
524         public InputPanelLanguage InputPanelLanguage
525         {
526             get
527             {
528                 return (InputPanelLanguage)Interop.Elementary.elm_entry_input_panel_language_get(RealHandle);
529             }
530             set
531             {
532                 Interop.Elementary.elm_entry_input_panel_language_set(RealHandle, (Interop.Elementary.InputPanelLanguage)value);
533             }
534         }
535
536         /// <summary>
537         /// Sets or gets the input panel layout variation of the entry.
538         /// </summary>
539         public int InputPanelVariation
540         {
541             get
542             {
543                 return Interop.Elementary.elm_entry_input_panel_layout_variation_get(RealHandle);
544             }
545             set
546             {
547                 Interop.Elementary.elm_entry_input_panel_layout_variation_set(RealHandle, value);
548             }
549         }
550
551         /// <summary>
552         /// Sets or gets the line wrap type to use on multi-line entries.
553         /// </summary>
554         public WrapType LineWrapType
555         {
556             get
557             {
558                 return (WrapType)Interop.Elementary.elm_entry_line_wrap_get(RealHandle);
559             }
560             set
561             {
562                 Interop.Elementary.elm_entry_line_wrap_set(RealHandle, (Interop.Elementary.WrapType)value);
563             }
564         }
565
566         /// <summary>
567         /// Sets or gets whether the entry should allow to use the text prediction.
568         /// </summary>
569         public bool PredictionAllowed
570         {
571             get
572             {
573                 return Interop.Elementary.elm_entry_prediction_allow_get(RealHandle);
574             }
575             set
576             {
577                 Interop.Elementary.elm_entry_prediction_allow_set(RealHandle, value);
578             }
579         }
580
581         /// <summary>
582         /// Sets or gets whether the return key on the input panel should be disabled or not.
583         /// </summary>
584         public bool InputPanelReturnKeyDisabled
585         {
586             get
587             {
588                 return Interop.Elementary.elm_entry_input_panel_return_key_disabled_get(RealHandle);
589             }
590             set
591             {
592                 Interop.Elementary.elm_entry_input_panel_return_key_disabled_set(RealHandle, value);
593             }
594         }
595
596         /// <summary>
597         /// Sets or gets the attribute to show the input panel in case of only an user's explicit Mouse Up event.
598         /// It doesn't request to show the input panel even though it has focus.
599         /// If true, the input panel will be shown in case of only Mouse up event. (Focus event will be ignored.)
600         /// </summary>
601         public bool InputPanelShowByOnDemand
602         {
603             get
604             {
605                 return Interop.Elementary.elm_entry_input_panel_show_on_demand_get(RealHandle);
606             }
607             set
608             {
609                 Interop.Elementary.elm_entry_input_panel_show_on_demand_set(RealHandle, value);
610             }
611         }
612
613         /// <summary>
614         /// Sets the file (and implicitly loads it) for the text to display and then edit.
615         /// </summary>
616         /// <param name="file">The path to the file to load and save</param>
617         /// <param name="textFormat">The file format</param>
618         public void SetFile(string file, TextFormat textFormat)
619         {
620             Interop.Elementary.elm_entry_file_set(RealHandle, file, (Interop.Elementary.TextFormat)textFormat);
621         }
622
623         /// <summary>
624         /// Converts a markup (HTML-like) string into UTF-8.
625         /// </summary>
626         /// <param name="markup">The string (in markup) to be converted</param>
627         /// <returns>The converted string (in UTF-8) </returns>
628         public static string ConvertMarkupToUtf8(string markup)
629         {
630             return Interop.Elementary.elm_entry_markup_to_utf8(markup);
631         }
632
633         /// <summary>
634         /// Moves the cursor by one position to the right within the entry.
635         /// </summary>
636         /// <returns></returns>
637         public bool MoveCursorNext()
638         {
639             return Interop.Elementary.elm_entry_cursor_next(RealHandle);
640         }
641
642         /// <summary>
643         /// Moves the cursor one place to the left within the entry.
644         /// </summary>
645         /// <returns>TRUE on success, otherwise FALSE on failure</returns>
646         public bool MoveCursorPrev()
647         {
648             return Interop.Elementary.elm_entry_cursor_prev(RealHandle);
649         }
650
651         /// <summary>
652         /// Moves the cursor one line up within the entry.
653         /// </summary>
654         /// <returns>TRUE on success, otherwise FALSE on failure</returns>
655         public bool MoveCursorUp()
656         {
657             return Interop.Elementary.elm_entry_cursor_up(RealHandle);
658         }
659
660         /// <summary>
661         /// Moves the cursor one line down within the entry.
662         /// </summary>
663         /// <returns>TRUE on success, otherwise FALSE on failure</returns>
664         public bool MoveCursorDown()
665         {
666             return Interop.Elementary.elm_entry_cursor_down(RealHandle);
667         }
668
669         /// <summary>
670         /// Moves the cursor to the beginning of the entry.
671         /// </summary>
672         public void MoveCursorBegin()
673         {
674             Interop.Elementary.elm_entry_cursor_begin_set(RealHandle);
675         }
676
677         /// <summary>
678         /// Moves the cursor to the end of the entry.
679         /// </summary>
680         public void MoveCursorEnd()
681         {
682             Interop.Elementary.elm_entry_cursor_end_set(RealHandle);
683         }
684
685         /// <summary>
686         /// Moves the cursor to the beginning of the current line.
687         /// </summary>
688         public void MoveCursorLineBegin()
689         {
690             Interop.Elementary.elm_entry_cursor_line_begin_set(RealHandle);
691         }
692
693         /// <summary>
694         /// Moves the cursor to the end of the current line.
695         /// </summary>
696         public void MoveCursorLineEnd()
697         {
698             Interop.Elementary.elm_entry_cursor_line_end_set(RealHandle);
699         }
700
701         /// <summary>
702         /// Sets the input panel layout of the entry.
703         /// </summary>
704         /// <param name="layout">The layout type</param>
705         public void SetInputPanelLayout(InputPanelLayout layout)
706         {
707             Interop.Elementary.elm_entry_input_panel_layout_set(RealHandle, (Interop.Elementary.InputPanelLayout)layout);
708         }
709
710         /// <summary>
711         /// Sets the attribute to show the input panel automatically.
712         /// </summary>
713         /// <param name="enabled">If true the input panel appears when the entry is clicked or has focus, otherwise false</param>
714         public void SetInputPanelEnabled(bool enabled)
715         {
716             Interop.Elementary.elm_entry_input_panel_enabled_set(RealHandle, enabled);
717         }
718
719         /// <summary>
720         /// Sets the "return" key type. This type is used to set the string or icon on the "return" key of the input panel.
721         /// </summary>
722         /// <param name="keyType">The type of "return" key on the input panel</param>
723         public void SetInputPanelReturnKeyType(InputPanelReturnKeyType keyType)
724         {
725             Interop.Elementary.elm_entry_input_panel_return_key_type_set(RealHandle, (Interop.Elementary.ReturnKeyType)keyType);
726         }
727
728         /// <summary>
729         /// Hides the input panel (virtual keyboard).
730         /// </summary>
731         /// <remark>
732         /// Note that the input panel is shown or hidden automatically according to the focus state of the entry widget.
733         /// This API can be used in case of manually controlling by using SetInputPanelEnabled(false).
734         /// </remark>
735         public void HideInputPanel()
736         {
737             Interop.Elementary.elm_entry_input_panel_hide(RealHandle);
738         }
739
740         /// <summary>
741         /// Selects all the text within the entry.
742         /// </summary>
743         public void SelectAll()
744         {
745             Interop.Elementary.elm_entry_select_all(RealHandle);
746         }
747
748         /// <summary>
749         /// Drops any existing text selection within the entry.
750         /// </summary>
751         public void SelectNone()
752         {
753             Interop.Elementary.elm_entry_select_none(RealHandle);
754         }
755
756         /// <summary>
757         /// Forces calculation of the entry size and text layouting.
758         /// </summary>
759         public void ForceCalculation()
760         {
761             Interop.Elementary.elm_entry_calc_force(RealHandle);
762         }
763
764         /// <summary>
765         /// Gets the string by the cursor at its current position.
766         /// </summary>
767         /// <returns></returns>
768         public string GetCursorContent()
769         {
770             return Interop.Elementary.elm_entry_cursor_content_get(RealHandle);
771         }
772
773         /// <summary>
774         /// Begins a selection within the entry as though the user were holding down the mouse button to make a selection.
775         /// </summary>
776         public void BeginCursorSelection()
777         {
778             Interop.Elementary.elm_entry_cursor_selection_begin(RealHandle);
779         }
780
781         /// <summary>
782         /// Appends the text of the entry.
783         /// </summary>
784         /// <param name="text">The text to be displayed</param>
785         public void AppendText(string text)
786         {
787             Interop.Elementary.elm_entry_entry_append(RealHandle, text);
788         }
789
790         /// <summary>
791         /// Inserts the given text into the entry at the current cursor position.
792         /// </summary>
793         /// <param name="text"></param>
794         public void InsertTextToCursor(string text)
795         {
796             Interop.Elementary.elm_entry_entry_insert(RealHandle, text);
797         }
798
799         /// <summary>
800         /// Ends a selection within the entry as though the user had just released the mouse button while making a selection.
801         /// </summary>
802         public void EndCursorSelection()
803         {
804             Interop.Elementary.elm_entry_cursor_selection_end(RealHandle);
805         }
806
807         /// <summary>
808         /// Writes any changes made to the file that is set by File.
809         /// </summary>
810         public void SaveFile()
811         {
812             Interop.Elementary.elm_entry_file_save(RealHandle);
813         }
814
815         /// <summary>
816         /// Show the input panel (virtual keyboard) based on the input panel property of entry such as layout, autocapital types, and so on.
817         /// </summary>
818         /// <remarks>
819         /// Note that input panel is shown or hidden automatically according to the focus state of entry widget.
820         /// This API can be used in the case of manually controlling by using SetInputPanelEnabled(false).
821         /// </remarks>
822         public void ShowInputPanel()
823         {
824             Interop.Elementary.elm_entry_input_panel_show(RealHandle);
825         }
826
827         /// <summary>
828         /// This appends a custom item provider to the list for that entry.
829         /// </summary>
830         /// <param name="func">This function is used to provide items.</param>
831         public void AppendItemProvider(Func<string, EvasObject> func)
832         {
833             if (func != null)
834             {
835                 if (!_itemsProvider.ContainsKey(func))
836                 {
837                     Interop.Elementary.Elm_Entry_Item_Provider_Cb itemProviderCallback;
838
839                     itemProviderCallback = (d, o, t) =>
840                     {
841                         return func?.Invoke(t);
842                     };
843                     Interop.Elementary.elm_entry_item_provider_append(RealHandle, itemProviderCallback, IntPtr.Zero);
844                     _itemsProvider.Add(func, itemProviderCallback);
845                 }
846             }
847         }
848
849         /// <summary>
850         /// This prepends a custom item provider to the list for that entry.
851         /// </summary>
852         /// <param name="func">This function is used to provide items.</param>
853         public void PrependItemProvider(Func<string, EvasObject> func)
854         {
855             if (!_itemsProvider.ContainsKey(func))
856             {
857                 Interop.Elementary.Elm_Entry_Item_Provider_Cb itemProviderCallback;
858
859                 itemProviderCallback = (d, o, t) =>
860                 {
861                     return func?.Invoke(t);
862                 };
863                 Interop.Elementary.elm_entry_item_provider_prepend(RealHandle, itemProviderCallback, IntPtr.Zero);
864                 _itemsProvider.Add(func, itemProviderCallback);
865             }
866         }
867
868         /// <summary>
869         /// This removes a custom item provider to the list for that entry.
870         /// </summary>
871         /// <param name="itemProvider">This function is used to provide items.</param>
872         public void RemoveItemProvider(Func<string, EvasObject> func)
873         {
874             if (_itemsProvider.ContainsKey(func))
875             {
876                 Interop.Elementary.Elm_Entry_Item_Provider_Cb itemProviderCallback;
877                 _itemsProvider.TryGetValue(func, out itemProviderCallback);
878
879                 Interop.Elementary.elm_entry_item_provider_remove(RealHandle, itemProviderCallback, IntPtr.Zero);
880                 _itemsProvider.Remove(func);
881             }
882         }
883
884         /// <summary>
885         /// Append a markup filter function for text inserted in the entry.
886         /// </summary>
887         /// <param name="filter">This function type is used by entry filters to modify text.</param>
888         public void AppendMarkUpFilter(Func<Entry, string, string> filter)
889         {
890             if (!_textFilters.ContainsKey(filter))
891             {
892                 Interop.Elementary.Elm_Entry_Filter_Cb textFilterCallback = (IntPtr d, IntPtr e, ref IntPtr t) =>
893                 {
894                     var text = Marshal.PtrToStringAnsi(t);
895
896                     var updateText = filter(this, text);
897
898                     if (updateText != text)
899                     {
900                         Interop.Libc.Free(t);
901                         t = Marshal.StringToHGlobalAnsi(updateText);
902                     }
903                 };
904                 Interop.Elementary.elm_entry_markup_filter_append(RealHandle, textFilterCallback, IntPtr.Zero);
905                 _textFilters.Add(filter, textFilterCallback);
906             }
907         }
908
909         /// <summary>
910         /// Prepend a markup filter function for text inserted in the entry.
911         /// </summary>
912         /// <param name="filter">This function type is used by entry filters to modify text.</param>
913         public void PrependMarkUpFilter(Func<Entry, string, string> filter)
914         {
915             if (!_textFilters.ContainsKey(filter))
916             {
917                 Interop.Elementary.Elm_Entry_Filter_Cb textFilterCallback = (IntPtr d, IntPtr e, ref IntPtr t) =>
918                 {
919                     var text = Marshal.PtrToStringAnsi(t);
920
921                     var updateText = filter(this, text);
922
923                     if (updateText != text)
924                     {
925                         Interop.Libc.Free(t);
926                         t = Marshal.StringToHGlobalAnsi(updateText);
927                     }
928                 };
929                 Interop.Elementary.elm_entry_markup_filter_prepend(RealHandle, textFilterCallback, IntPtr.Zero);
930                 _textFilters.Add(filter, textFilterCallback);
931             }
932         }
933
934         /// <summary>
935         /// Remove a markup filter
936         /// </summary>
937         /// <param name="filter">This function type is used by entry filters to modify text.</param>
938         public void RemoveMarkUpFilter(Func<Entry, string, string> filter)
939         {
940             if (_textFilters.ContainsKey(filter))
941             {
942                 Interop.Elementary.Elm_Entry_Filter_Cb textFilterCallback;
943                 _textFilters.TryGetValue(filter, out textFilterCallback);
944
945                 Interop.Elementary.elm_entry_markup_filter_remove(RealHandle, textFilterCallback, IntPtr.Zero);
946                 _textFilters.Remove(filter);
947             }
948         }
949
950         /// <summary>
951         /// This executes a "copy" action on the selected text in the entry.
952         /// </summary>
953         public void CopySelection()
954         {
955             Interop.Elementary.elm_entry_selection_copy(RealHandle);
956         }
957
958         /// <summary>
959         /// This executes a "cut" action on the selected text in the entry.
960         /// </summary>
961         public void CutSelection()
962         {
963             Interop.Elementary.elm_entry_selection_cut(RealHandle);
964         }
965
966         /// <summary>
967         /// This executes a "paste" action in the entry.
968         /// </summary>
969         public void PasteSelection()
970         {
971             Interop.Elementary.elm_entry_selection_paste(RealHandle);
972         }
973
974         /// <summary>
975         /// This disabled the entry's selection.
976         /// </summary>
977         /// <param name="disable">If true, the selection are disabled.</param>
978         public void DisableSelection(bool disable)
979         {
980             Interop.Elementary.elm_entry_selection_handler_disabled_set(RealHandle, disable);
981         }
982
983         /// <summary>
984         /// Get any selected text within the entry.
985         /// </summary>
986         /// <returns>Selection's value</returns>
987         public string GetSelection()
988         {
989             return Interop.Elementary.elm_entry_selection_get(RealHandle);
990         }
991
992         /// <summary>
993         /// This selects a region of text within the entry.
994         /// </summary>
995         /// <param name="start">The starting position.</param>
996         /// <param name="end">The end position.</param>
997         public void SetSelectionRegion(int start, int end)
998         {
999             Interop.Elementary.elm_entry_select_region_set(RealHandle, start, end);
1000         }
1001
1002         /// <summary>
1003         /// Sets the visibility of the left-side widget of the entry
1004         /// </summary>
1005         /// <param name="isDisplay">true if the object should be displayed, false if not.</param>
1006         public void SetIconVisible(bool isDisplay)
1007         {
1008             Interop.Elementary.elm_entry_icon_visible_set(RealHandle, isDisplay);
1009         }
1010
1011         /// <summary>
1012         /// Set whether the return key on the input panel is disabled automatically when entry has no text.
1013         /// </summary>
1014         /// <param name="enable">If enabled is true, the return key is automatically disabled when the entry has no text.</param>
1015         public void SetInputPanelReturnKeyAutoEnable(bool enable)
1016         {
1017             Interop.Elementary.elm_entry_input_panel_return_key_autoenabled_set(RealHandle, enable);
1018         }
1019
1020         protected override IntPtr CreateHandle(EvasObject parent)
1021         {
1022             return Interop.Elementary.elm_entry_add(parent.Handle);
1023         }
1024     }
1025 }