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