2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
19 using System.Runtime.InteropServices;
24 /// Enumeration for describing InputPanel layout type.
26 public enum InputPanelLayout
29 /// InputPanel layout type default.
34 /// InputPanel layout type number.
39 /// InputPanel layout type email.
44 /// InputPanel layout type url.
49 /// InputPanel layout type phone.
54 /// InputPanel layout type ip.
59 /// InputPanel layout type month.
64 /// InputPanel layout type number.
69 /// InputPanel layout type error type. Do not use it directly!
74 /// InputPanel layout type hexadecimal.
79 /// InputPanel layout type terminal type, esc, alt, ctrl, etc.
84 /// InputPanel layout type password.
89 /// Keyboard layout type date and time.
94 /// InputPanel layout type emoticons.
100 /// Enumeration that defines the "Return" key types on the input panel (virtual keyboard).
102 public enum InputPanelReturnKeyType
135 /// Search string or magnifier icon key type
151 /// Enumeration that defines the autocapitalization types.
153 public enum AutoCapital
156 /// No autocapitalization when typing
161 /// Autocapitalize each typed word
166 /// Autocapitalize the start of each sentence
171 /// Autocapitalize all letters
177 /// Enumeration that defines the entry's copy and paste policy.
179 public enum CopyAndPasteMode
182 /// Copy and paste text with markup tag
187 /// Copy and paste text without item(image) tag
192 /// Copy and paste text without markup tag
198 /// Enumeration that defines the text format types.
200 public enum TextFormat
214 /// Enumeration that defines the types of Input Hints.
216 public enum InputHints
224 /// suggest word auto completion
229 /// typed text should not be stored.
235 /// Enumeration that defines the input panel (virtual keyboard) language modes.
237 public enum InputPanelLanguage
240 /// Automatic language mode
245 /// Alphabet language mode
251 /// The entry is a convenience widget that shows a box in which the user can enter text.
253 public class Entry : Layout, IScrollable
255 ScrollableAdapter _scroller;
257 SmartEvent _changedByUser;
258 SmartEvent _cursorChanged;
259 SmartEvent _activated;
261 Dictionary<Func<string, EvasObject>, Interop.Elementary.Elm_Entry_Item_Provider_Cb> _itemsProvider = new Dictionary<Func<string, EvasObject>, Interop.Elementary.Elm_Entry_Item_Provider_Cb>();
262 Dictionary<Func<Entry, string, string>, Interop.Elementary.Elm_Entry_Filter_Cb> _textFilters = new Dictionary<Func<Entry, string, string>, Interop.Elementary.Elm_Entry_Filter_Cb>();
265 /// Creates and initializes a new instance of the Entry class.
267 /// <param name="parent">The EvasObject to which the new Entry will be attached as a child.</param>
268 public Entry(EvasObject parent) : base(parent)
270 _clicked = new SmartEvent(this, this.RealHandle, "clicked");
271 _clicked.On += (s, e) => Clicked?.Invoke(this, EventArgs.Empty);
273 _changedByUser = new SmartEvent(this, this.RealHandle, "changed,user");
274 _changedByUser.On += (s, e) => ChangedByUser?.Invoke(this, EventArgs.Empty);
276 _cursorChanged = new SmartEvent(this, this.RealHandle, "cursor,changed");
277 _cursorChanged.On += (s, e) => CursorChanged?.Invoke(this, EventArgs.Empty);
279 _activated = new SmartEvent(this, this.RealHandle, "activated");
280 _activated.On += (s, e) => Activated?.Invoke(this, EventArgs.Empty);
282 _scroller = new ScrollableAdapter(this);
286 /// Activated will be triggered when the entry in Activated stated.
288 public event EventHandler Activated;
291 /// Clicked will be triggered when the entry is clicked.
293 public event EventHandler Clicked;
296 /// ChangedByUser will be triggered when the entry changed by user.
298 public event EventHandler ChangedByUser;
301 /// CursorChanged will be triggered when the Cursor in the entry is changed.
303 public event EventHandler CursorChanged;
306 /// Sets or gets the entry to the single line mode.
308 public bool IsSingleLine
312 return Interop.Elementary.elm_entry_single_line_get(RealHandle);
316 Interop.Elementary.elm_entry_single_line_set(RealHandle, value);
321 /// Sets or gets the entry to the password mode.
323 public bool IsPassword
327 return Interop.Elementary.elm_entry_password_get(RealHandle);
331 Interop.Elementary.elm_entry_password_set(RealHandle, value);
336 /// Sets or gets whether the entry is editable.
338 public bool IsEditable
342 return Interop.Elementary.elm_entry_editable_get(RealHandle);
346 Interop.Elementary.elm_entry_editable_set(RealHandle, value);
351 /// Sets or gets whether the entry is empty.
357 return Interop.Elementary.elm_entry_is_empty(RealHandle);
362 /// Sets or gets text currently shown in the object entry.
364 public override string Text
368 return Interop.Elementary.elm_entry_entry_get(RealHandle);
372 Interop.Elementary.elm_entry_entry_set(RealHandle, value);
377 /// Sets or gets the style on the top of the user style stack.
379 /// <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>
380 public string TextStyle
384 return Interop.Elementary.elm_entry_text_style_user_peek(RealHandle);
388 Interop.Elementary.elm_entry_text_style_user_push(RealHandle, value);
393 /// Sets or gets the current position of the cursor in the entry.
395 public int CursorPosition
399 return Interop.Elementary.elm_entry_cursor_pos_get(RealHandle);
403 Interop.Elementary.elm_entry_cursor_pos_set(RealHandle, value);
408 /// Sets or gets the scrollable state of the entry.
410 public bool Scrollable
414 return Interop.Elementary.elm_entry_scrollable_get(RealHandle);
418 // HACK: Enabling the scrollable property of an entry causes its internal
419 // hierarchy to change, making the internal edje object inaccessible.
420 // Access it before the property is set, to cache the edje object's handle.
423 var dummy = EdjeObject;
425 Interop.Elementary.elm_entry_scrollable_set(RealHandle, value);
430 /// Sets or Gets the autocapitalization type on the immodule.
432 public AutoCapital AutoCapital
436 return (AutoCapital)Interop.Elementary.elm_entry_autocapital_type_get(RealHandle);
440 Interop.Elementary.elm_entry_autocapital_type_set(RealHandle, (Interop.Elementary.AutocapitalType)value);
445 /// Sets or Gets the entry object's 'autosave' status.
447 public bool IsAutoSave
451 return Interop.Elementary.elm_entry_autosave_get(RealHandle);
455 Interop.Elementary.elm_entry_autosave_set(RealHandle, value);
460 /// Sets or Gets entry text paste/drop mode.
462 public CopyAndPasteMode CopyAndPasteMode
466 return (CopyAndPasteMode)Interop.Elementary.elm_entry_cnp_mode_get(RealHandle);
470 Interop.Elementary.elm_entry_cnp_mode_set(RealHandle, (Interop.Elementary.CopyAndPasteMode)value);
475 /// Gets the geometry of the cursor.
477 public Rect CursorGeometry
482 Interop.Elementary.elm_entry_cursor_geometry_get(RealHandle, out x, out y, out w, out h);
483 return new Rect(x, y, w, h);
488 /// Gets whether a format node exists at the current cursor position.
490 public bool IsCursorFormat
494 return Interop.Elementary.elm_entry_cursor_is_format_get(RealHandle);
499 /// Gets if the current cursor position holds a visible format node.
501 public bool IsCursorVisibelFormat
505 return Interop.Elementary.elm_entry_cursor_is_visible_format_get(RealHandle);
510 /// Sets or Gets the value of input hint.
512 public InputHints InputHint
516 return (InputHints)Interop.Elementary.elm_entry_input_hint_get(RealHandle);
520 Interop.Elementary.elm_entry_input_hint_set(RealHandle, (Interop.Elementary.InputHints)value);
525 /// Sets or gets the language mode of the input panel.
527 public InputPanelLanguage InputPanelLanguage
531 return (InputPanelLanguage)Interop.Elementary.elm_entry_input_panel_language_get(RealHandle);
535 Interop.Elementary.elm_entry_input_panel_language_set(RealHandle, (Interop.Elementary.InputPanelLanguage)value);
540 /// Sets or gets the input panel layout variation of the entry.
542 public int InputPanelVariation
546 return Interop.Elementary.elm_entry_input_panel_layout_variation_get(RealHandle);
550 Interop.Elementary.elm_entry_input_panel_layout_variation_set(RealHandle, value);
555 /// Sets or gets the line wrap type to use on multi-line entries.
557 public WrapType LineWrapType
561 return (WrapType)Interop.Elementary.elm_entry_line_wrap_get(RealHandle);
565 Interop.Elementary.elm_entry_line_wrap_set(RealHandle, (Interop.Elementary.WrapType)value);
570 /// Sets or gets whether the entry should allow to use the text prediction.
572 public bool PredictionAllowed
576 return Interop.Elementary.elm_entry_prediction_allow_get(RealHandle);
580 Interop.Elementary.elm_entry_prediction_allow_set(RealHandle, value);
585 /// Sets or gets whether the return key on the input panel should be disabled or not.
587 public bool InputPanelReturnKeyDisabled
591 return Interop.Elementary.elm_entry_input_panel_return_key_disabled_get(RealHandle);
595 Interop.Elementary.elm_entry_input_panel_return_key_disabled_set(RealHandle, value);
600 /// Sets or gets the attribute to show the input panel in case of only an user's explicit Mouse Up event.
601 /// It doesn't request to show the input panel even though it has focus.
602 /// If true, the input panel will be shown in case of only Mouse up event. (Focus event will be ignored.)
604 public bool InputPanelShowByOnDemand
608 return Interop.Elementary.elm_entry_input_panel_show_on_demand_get(RealHandle);
612 Interop.Elementary.elm_entry_input_panel_show_on_demand_set(RealHandle, value);
617 /// Sets the file (and implicitly loads it) for the text to display and then edit.
619 /// <param name="file">The path to the file to load and save</param>
620 /// <param name="textFormat">The file format</param>
621 public void SetFile(string file, TextFormat textFormat)
623 Interop.Elementary.elm_entry_file_set(RealHandle, file, (Interop.Elementary.TextFormat)textFormat);
627 /// Converts a markup (HTML-like) string into UTF-8.
629 /// <param name="markup">The string (in markup) to be converted</param>
630 /// <returns>The converted string (in UTF-8) </returns>
631 public static string ConvertMarkupToUtf8(string markup)
633 return Interop.Elementary.elm_entry_markup_to_utf8(markup);
637 /// Moves the cursor by one position to the right within the entry.
639 /// <returns></returns>
640 public bool MoveCursorNext()
642 return Interop.Elementary.elm_entry_cursor_next(RealHandle);
646 /// Moves the cursor one place to the left within the entry.
648 /// <returns>TRUE on success, otherwise FALSE on failure</returns>
649 public bool MoveCursorPrev()
651 return Interop.Elementary.elm_entry_cursor_prev(RealHandle);
655 /// Moves the cursor one line up within the entry.
657 /// <returns>TRUE on success, otherwise FALSE on failure</returns>
658 public bool MoveCursorUp()
660 return Interop.Elementary.elm_entry_cursor_up(RealHandle);
664 /// Moves the cursor one line down within the entry.
666 /// <returns>TRUE on success, otherwise FALSE on failure</returns>
667 public bool MoveCursorDown()
669 return Interop.Elementary.elm_entry_cursor_down(RealHandle);
673 /// Moves the cursor to the beginning of the entry.
675 public void MoveCursorBegin()
677 Interop.Elementary.elm_entry_cursor_begin_set(RealHandle);
681 /// Moves the cursor to the end of the entry.
683 public void MoveCursorEnd()
685 Interop.Elementary.elm_entry_cursor_end_set(RealHandle);
689 /// Moves the cursor to the beginning of the current line.
691 public void MoveCursorLineBegin()
693 Interop.Elementary.elm_entry_cursor_line_begin_set(RealHandle);
697 /// Moves the cursor to the end of the current line.
699 public void MoveCursorLineEnd()
701 Interop.Elementary.elm_entry_cursor_line_end_set(RealHandle);
705 /// Sets the input panel layout of the entry.
707 /// <param name="layout">The layout type</param>
708 public void SetInputPanelLayout(InputPanelLayout layout)
710 Interop.Elementary.elm_entry_input_panel_layout_set(RealHandle, (Interop.Elementary.InputPanelLayout)layout);
714 /// Sets the attribute to show the input panel automatically.
716 /// <param name="enabled">If true the input panel appears when the entry is clicked or has focus, otherwise false</param>
717 public void SetInputPanelEnabled(bool enabled)
719 Interop.Elementary.elm_entry_input_panel_enabled_set(RealHandle, enabled);
723 /// Sets the "return" key type. This type is used to set the string or icon on the "return" key of the input panel.
725 /// <param name="keyType">The type of "return" key on the input panel</param>
726 public void SetInputPanelReturnKeyType(InputPanelReturnKeyType keyType)
728 Interop.Elementary.elm_entry_input_panel_return_key_type_set(RealHandle, (Interop.Elementary.ReturnKeyType)keyType);
732 /// Hides the input panel (virtual keyboard).
735 /// Note that the input panel is shown or hidden automatically according to the focus state of the entry widget.
736 /// This API can be used in case of manually controlling by using SetInputPanelEnabled(false).
738 public void HideInputPanel()
740 Interop.Elementary.elm_entry_input_panel_hide(RealHandle);
744 /// Selects all the text within the entry.
746 public void SelectAll()
748 Interop.Elementary.elm_entry_select_all(RealHandle);
752 /// Drops any existing text selection within the entry.
754 public void SelectNone()
756 Interop.Elementary.elm_entry_select_none(RealHandle);
760 /// Forces calculation of the entry size and text layouting.
762 public void ForceCalculation()
764 Interop.Elementary.elm_entry_calc_force(RealHandle);
768 /// Gets the string by the cursor at its current position.
770 /// <returns></returns>
771 public string GetCursorContent()
773 return Interop.Elementary.elm_entry_cursor_content_get(RealHandle);
777 /// Begins a selection within the entry as though the user were holding down the mouse button to make a selection.
779 public void BeginCursorSelection()
781 Interop.Elementary.elm_entry_cursor_selection_begin(RealHandle);
785 /// Appends the text of the entry.
787 /// <param name="text">The text to be displayed</param>
788 public void AppendText(string text)
790 Interop.Elementary.elm_entry_entry_append(RealHandle, text);
794 /// Inserts the given text into the entry at the current cursor position.
796 /// <param name="text"></param>
797 public void InsertTextToCursor(string text)
799 Interop.Elementary.elm_entry_entry_insert(RealHandle, text);
803 /// Ends a selection within the entry as though the user had just released the mouse button while making a selection.
805 public void EndCursorSelection()
807 Interop.Elementary.elm_entry_cursor_selection_end(RealHandle);
811 /// Writes any changes made to the file that is set by File.
813 public void SaveFile()
815 Interop.Elementary.elm_entry_file_save(RealHandle);
819 /// Show the input panel (virtual keyboard) based on the input panel property of entry such as layout, autocapital types, and so on.
822 /// Note that input panel is shown or hidden automatically according to the focus state of entry widget.
823 /// This API can be used in the case of manually controlling by using SetInputPanelEnabled(false).
825 public void ShowInputPanel()
827 Interop.Elementary.elm_entry_input_panel_show(RealHandle);
831 /// This appends a custom item provider to the list for that entry.
833 /// <param name="func">This function is used to provide items.</param>
834 public void AppendItemProvider(Func<string, EvasObject> func)
838 if (!_itemsProvider.ContainsKey(func))
840 Interop.Elementary.Elm_Entry_Item_Provider_Cb itemProviderCallback;
842 itemProviderCallback = (d, o, t) =>
844 return func?.Invoke(t);
846 Interop.Elementary.elm_entry_item_provider_append(RealHandle, itemProviderCallback, IntPtr.Zero);
847 _itemsProvider.Add(func, itemProviderCallback);
853 /// This prepends a custom item provider to the list for that entry.
855 /// <param name="func">This function is used to provide items.</param>
856 public void PrependItemProvider(Func<string, EvasObject> func)
858 if (!_itemsProvider.ContainsKey(func))
860 Interop.Elementary.Elm_Entry_Item_Provider_Cb itemProviderCallback;
862 itemProviderCallback = (d, o, t) =>
864 return func?.Invoke(t);
866 Interop.Elementary.elm_entry_item_provider_prepend(RealHandle, itemProviderCallback, IntPtr.Zero);
867 _itemsProvider.Add(func, itemProviderCallback);
872 /// This removes a custom item provider to the list for that entry.
874 /// <param name="func">This function is used to provide items.</param>
875 public void RemoveItemProvider(Func<string, EvasObject> func)
877 if (_itemsProvider.ContainsKey(func))
879 Interop.Elementary.Elm_Entry_Item_Provider_Cb itemProviderCallback;
880 _itemsProvider.TryGetValue(func, out itemProviderCallback);
882 Interop.Elementary.elm_entry_item_provider_remove(RealHandle, itemProviderCallback, IntPtr.Zero);
883 _itemsProvider.Remove(func);
888 /// Append a markup filter function for text inserted in the entry.
890 /// <param name="filter">This function type is used by entry filters to modify text.</param>
891 public void AppendMarkUpFilter(Func<Entry, string, string> filter)
893 if (!_textFilters.ContainsKey(filter))
895 Interop.Elementary.Elm_Entry_Filter_Cb textFilterCallback = (IntPtr d, IntPtr e, ref IntPtr t) =>
897 var text = Marshal.PtrToStringAnsi(t);
899 var updateText = filter(this, text);
901 if (updateText != text)
903 Interop.Libc.Free(t);
904 t = Marshal.StringToHGlobalAnsi(updateText);
907 Interop.Elementary.elm_entry_markup_filter_append(RealHandle, textFilterCallback, IntPtr.Zero);
908 _textFilters.Add(filter, textFilterCallback);
913 /// Prepend a markup filter function for text inserted in the entry.
915 /// <param name="filter">This function type is used by entry filters to modify text.</param>
916 public void PrependMarkUpFilter(Func<Entry, string, string> filter)
918 if (!_textFilters.ContainsKey(filter))
920 Interop.Elementary.Elm_Entry_Filter_Cb textFilterCallback = (IntPtr d, IntPtr e, ref IntPtr t) =>
922 var text = Marshal.PtrToStringAnsi(t);
924 var updateText = filter(this, text);
926 if (updateText != text)
928 Interop.Libc.Free(t);
929 t = Marshal.StringToHGlobalAnsi(updateText);
932 Interop.Elementary.elm_entry_markup_filter_prepend(RealHandle, textFilterCallback, IntPtr.Zero);
933 _textFilters.Add(filter, textFilterCallback);
938 /// Remove a markup filter
940 /// <param name="filter">This function type is used by entry filters to modify text.</param>
941 public void RemoveMarkUpFilter(Func<Entry, string, string> filter)
943 if (_textFilters.ContainsKey(filter))
945 Interop.Elementary.Elm_Entry_Filter_Cb textFilterCallback;
946 _textFilters.TryGetValue(filter, out textFilterCallback);
948 Interop.Elementary.elm_entry_markup_filter_remove(RealHandle, textFilterCallback, IntPtr.Zero);
949 _textFilters.Remove(filter);
954 /// This executes a "copy" action on the selected text in the entry.
956 public void CopySelection()
958 Interop.Elementary.elm_entry_selection_copy(RealHandle);
962 /// This executes a "cut" action on the selected text in the entry.
964 public void CutSelection()
966 Interop.Elementary.elm_entry_selection_cut(RealHandle);
970 /// This executes a "paste" action in the entry.
972 public void PasteSelection()
974 Interop.Elementary.elm_entry_selection_paste(RealHandle);
978 /// This disabled the entry's selection.
980 /// <param name="disable">If true, the selection are disabled.</param>
981 public void DisableSelection(bool disable)
983 Interop.Elementary.elm_entry_selection_handler_disabled_set(RealHandle, disable);
987 /// Get any selected text within the entry.
989 /// <returns>Selection's value</returns>
990 public string GetSelection()
992 return Interop.Elementary.elm_entry_selection_get(RealHandle);
996 /// This selects a region of text within the entry.
998 /// <param name="start">The starting position.</param>
999 /// <param name="end">The end position.</param>
1000 public void SetSelectionRegion(int start, int end)
1002 Interop.Elementary.elm_entry_select_region_set(RealHandle, start, end);
1006 /// Sets the visibility of the left-side widget of the entry
1008 /// <param name="isDisplay">true if the object should be displayed, false if not.</param>
1009 public void SetIconVisible(bool isDisplay)
1011 Interop.Elementary.elm_entry_icon_visible_set(RealHandle, isDisplay);
1015 /// Set whether the return key on the input panel is disabled automatically when entry has no text.
1017 /// <param name="enable">If enabled is true, the return key is automatically disabled when the entry has no text.</param>
1018 public void SetInputPanelReturnKeyAutoEnable(bool enable)
1020 Interop.Elementary.elm_entry_input_panel_return_key_autoenabled_set(RealHandle, enable);
1024 /// Creates a widget handle.
1026 /// <param name="parent">Parent EvasObject</param>
1027 /// <returns>Handle IntPtr</returns>
1028 protected override IntPtr CreateHandle(EvasObject parent)
1030 return Interop.Elementary.elm_entry_add(parent.Handle);
1033 #region IScroller Implementation
1036 /// Scrolled will be triggered when the content has been scrolled.
1038 public event EventHandler Scrolled
1040 add => _scroller.Scrolled += value;
1041 remove => _scroller.Scrolled -= value;
1045 /// DragStart will be triggered when dragging the contents around has started.
1047 public event EventHandler DragStart
1049 add => _scroller.DragStart += value;
1050 remove => _scroller.DragStart -= value;
1054 /// DragStop will be triggered when dragging the contents around has stopped.
1056 public event EventHandler DragStop
1058 add => _scroller.DragStop += value;
1059 remove => _scroller.DragStop -= value;
1063 /// PageScrolled will be triggered when the visible page has changed.
1065 public event EventHandler PageScrolled
1067 add => _scroller.PageScrolled += value;
1068 remove => _scroller.PageScrolled -= value;
1072 /// Gets the current region in the content object that is visible through the Scroller.
1074 public Rect CurrentRegion => _scroller.CurrentRegion;
1077 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy
1080 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, and otherwise kept hidden.
1081 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
1083 public virtual ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
1085 get => _scroller.HorizontalScrollBarVisiblePolicy;
1086 set => _scroller.HorizontalScrollBarVisiblePolicy = value;
1090 /// Sets or gets the value of VerticalScrollBarVisiblePolicy
1093 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, and otherwise kept hidden.
1094 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
1096 public virtual ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
1098 get => _scroller.VerticalScrollBarVisiblePolicy;
1099 set => _scroller.VerticalScrollBarVisiblePolicy = value;
1103 /// Sets or gets the value of ScrollBlock.
1106 /// This function will block scrolling movement in a given direction.One can disable movements in the X axis, the Y axis or both.
1107 /// The default value is ScrollBlock.None, where movements are allowed in both directions.
1109 public ScrollBlock ScrollBlock
1111 get => _scroller.ScrollBlock;
1112 set => _scroller.ScrollBlock = value;
1116 /// Sets or gets scroll current page number.
1119 /// Current page means the page which meets the top of the viewport.
1120 /// If there are two or more pages in the viewport, it returns the number of the page which meets the top of the viewport.
1121 /// The page number starts from 0. 0 is the first page.
1123 public int VerticalPageIndex => _scroller.VerticalPageIndex;
1126 /// Sets or gets scroll current page number.
1129 /// Current page means the page which meets the left of the viewport.
1130 /// If there are two or more pages in the viewport, it returns the number of the page which meets the left of the viewport.
1131 /// The page number starts from 0. 0 is the first page.
1133 public int HorizontalPageIndex => _scroller.HorizontalPageIndex;
1136 /// Sets or gets the maximum limit of the movable page at vertical direction.
1138 public int VerticalPageScrollLimit
1140 get => _scroller.VerticalPageScrollLimit;
1141 set => _scroller.VerticalPageScrollLimit = value;
1145 /// Sets or gets the maximum limit of the movable page at horizontal direction.
1147 public int HorizontalPageScrollLimit
1149 get => _scroller.HorizontalPageScrollLimit;
1150 set => _scroller.HorizontalPageScrollLimit = value;
1154 /// Sets or gets the vertical bounce behaviour.
1155 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
1156 /// This is a visual way to indicate the end has been reached.
1157 /// This is enabled by default for both axis.
1158 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
1160 public bool VerticalBounce
1162 get => _scroller.VerticalBounce;
1163 set => _scroller.VerticalBounce = value;
1167 /// Sets or gets the horizontal bounce behaviour.
1168 /// When scrolling, the scroller may "bounce" when reaching an edge of the content object.
1169 /// This is a visual way to indicate the end has been reached.
1170 /// This is enabled by default for both axis.
1171 /// This API will set if it is enabled for the given axis with the boolean parameters for each axis.
1173 public bool HorizontalBounce
1175 get => _scroller.HorizontalBounce;
1176 set => _scroller.HorizontalBounce = value;
1180 /// Gets the width of the content object of the scroller.
1182 public int ChildWidth
1184 get => _scroller.ChildWidth;
1188 /// Gets the height of the content object of the scroller.
1190 public int ChildHeight
1192 get => _scroller.ChildHeight;
1196 /// Set scrolling gravity values for a scroller.
1197 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
1198 /// The scroller will adjust the view to glue itself as follows.
1199 /// x=0.0, for staying where it is relative to the left edge of the content x=1.0, for staying where it is relative to the rigth edge of the content y=0.0, for staying where it is relative to the top edge of the content y=1.0, for staying where it is relative to the bottom edge of the content
1200 /// Default values for x and y are 0.0
1202 public double HorizontalGravity
1204 get => _scroller.HorizontalGravity;
1205 set => _scroller.HorizontalGravity = value;
1209 /// Set scrolling gravity values for a scroller.
1210 /// The gravity, defines how the scroller will adjust its view when the size of the scroller contents increase.
1211 /// The scroller will adjust the view to glue itself as follows.
1212 /// x=0.0, for staying where it is relative to the left edge of the content x=1.0, for staying where it is relative to the rigth edge of the content y=0.0, for staying where it is relative to the top edge of the content y=1.0, for staying where it is relative to the bottom edge of the content
1213 /// Default values for x and y are 0.0
1215 public double VerticalGravity
1217 get => _scroller.VerticalGravity;
1218 set => _scroller.VerticalGravity = value;
1222 /// Get scroll last page number.
1223 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
1225 public int LastVerticalPageNumber => _scroller.LastVerticalPageNumber;
1228 /// Get scroll last page number.
1229 /// The page number starts from 0. 0 is the first page. This returns the last page number among the pages.
1231 public int LastHorizontalPageNumber => _scroller.LastHorizontalPageNumber;
1234 /// Set an infinite loop_ for a scroller.
1235 /// This function sets the infinite loop vertically.
1236 /// If the content is set, it will be shown repeatedly.
1238 public bool VerticalLoop
1240 get => _scroller.VerticalLoop;
1241 set => _scroller.VerticalLoop = value;
1245 /// Set an infinite loop_ for a scroller.
1246 /// This function sets the infinite loop horizontally.
1247 /// If the content is set, it will be shown repeatedly.
1249 public bool HorizontalLoop
1251 get => _scroller.HorizontalLoop;
1252 set => _scroller.HorizontalLoop = value;
1256 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
1258 public int HorizontalPageSize
1260 get => _scroller.HorizontalPageSize;
1261 set => _scroller.HorizontalPageSize = value;
1265 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
1267 public int VerticalPageSize
1269 get => _scroller.VerticalPageSize;
1270 set => _scroller.VerticalPageSize = value;
1274 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
1276 public double VerticalRelativePageSize
1278 get => _scroller.VerticalRelativePageSize;
1279 set => _scroller.VerticalRelativePageSize = value;
1283 /// Gets or sets a given scroller widget's scrolling page size, relative to its viewport size.
1285 public double HorizontalRelativePageSize
1287 get => _scroller.HorizontalRelativePageSize;
1288 set => _scroller.HorizontalRelativePageSize = value;
1292 /// Gets or Sets the page snapping behavior of a scroller.
1295 /// When scrolling, if a scroller is paged (see VerticalRelativePageSize),
1296 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
1297 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
1298 /// This function will set if it that is enabled or not, for each axis.
1300 public bool VerticalSnap
1302 get => _scroller.VerticalSnap;
1303 set => _scroller.VerticalSnap = value;
1307 /// Gets or Sets the page snapping behavior of a scroller.
1310 /// When scrolling, if a scroller is paged (see HorizontalRelativePageSize),
1311 /// the scroller may snap to pages when being scrolled, i.e., even if it had momentum to scroll further,
1312 /// it will stop at the next page boundaries. This is disabled, by default, for both axis.
1313 /// This function will set if it that is enabled or not, for each axis.
1315 public bool HorizontalSnap
1317 get => _scroller.HorizontalSnap;
1318 set => _scroller.HorizontalSnap = value;
1322 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
1324 public int PageHeight
1326 get => _scroller.PageHeight;
1327 set => _scroller.PageHeight = value;
1331 /// Gets or sets the page size to an absolute fixed value, with 0 turning it off for that axis.
1333 public int PageWidth
1335 get => _scroller.PageWidth;
1336 set => _scroller.PageWidth = value;
1340 /// Gets or sets the step size to move scroller by key event.
1342 public int HorizontalStepSize
1344 get => _scroller.HorizontalStepSize;
1345 set => _scroller.HorizontalStepSize = value;
1349 /// Gets or sets the step size to move scroller by key event.
1351 public int VerticalStepSize
1353 get => _scroller.VerticalStepSize;
1354 set => _scroller.VerticalStepSize = value;
1358 /// Gets or sets a value whether mouse wheel is enabled or not over the scroller.
1360 public bool WheelDisabled
1362 get => _scroller.WheelDisabled;
1363 set => _scroller.WheelDisabled = value;
1367 /// Gets or sets the type of single direction scroll.
1369 public ScrollSingleDirection SingleDirection
1371 get => _scroller.SingleDirection;
1372 set => _scroller.SingleDirection = value;
1376 /// Sets the scroller minimum size limited to the minimum size of the content.
1377 /// By default the scroller will be as small as its design allows, irrespective of its content.
1378 /// This will make the scroller minimum size the right size horizontally and/or vertically to perfectly fit its content in that direction.
1380 /// <param name="horizontal">Enable limiting minimum size horizontally</param>
1381 /// <param name="vertical">Enable limiting minimum size vertically</param>
1382 public void MinimumLimit(bool horizontal, bool vertical)
1384 _scroller.MinimumLimit(horizontal, vertical);
1388 /// Shows a specific virtual region within the scroller content object by the page number.
1389 /// (0, 0) of the indicated page is located at the top-left corner of the viewport.
1391 /// <param name="horizontalPageIndex">The horizontal page number.</param>
1392 /// <param name="verticalPageIndex">The vertical page number.</param>
1393 /// <param name="animated">True means slider with animation.</param>
1394 public void ScrollTo(int horizontalPageIndex, int verticalPageIndex, bool animated)
1396 _scroller.ScrollTo(horizontalPageIndex, verticalPageIndex, animated);
1400 /// Shows a specific virtual region within the scroller content object.
1403 /// This ensures that all (or part, if it does not fit) of the designated region in the virtual content object ((0, 0)
1404 /// starting at the top-left of the virtual content object) is shown within the scroller.
1405 /// If set "animated" to true, it will allows the scroller to "smoothly slide" to this location
1406 /// (if configuration in general calls for transitions).
1407 /// It may not jump immediately to the new location and may take a while and show other content along the way.
1409 /// <param name="region">Rect struct of region.</param>
1410 /// <param name="animated">True means allows the scroller to "smoothly slide" to this location.</param>
1411 public void ScrollTo(Rect region, bool animated)
1413 _scroller.ScrollTo(region, animated);