2 * Copyright(c) 2018 Samsung Electronics Co., Ltd.
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 extern alias TizenSystemSettings;
19 using TizenSystemSettings.Tizen.System;
22 using System.Globalization;
23 using System.ComponentModel;
25 namespace Tizen.NUI.BaseComponents
28 /// A control which provides a multi-line editable text editor.
30 /// <since_tizen> 3 </since_tizen>
31 public partial class TextEditor : View
33 private string textEditorTextSid = null;
34 private string textEditorPlaceHolderTextSid = null;
35 private bool systemlangTextFlag = false;
36 private InputMethodContext inputMethodContext = null;
37 private float fontSizeScale = 1.0f;
38 private bool hasFontSizeChangedCallback = false;
41 /// Creates the TextEditor control.
43 /// <since_tizen> 3 </since_tizen>
44 public TextEditor() : this(Interop.TextEditor.New(), true)
46 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50 /// Creates the TextEditor with setting the status of shown or hidden.
52 /// <param name="shown">false : Not displayed (hidden), true : displayed (shown)</param>
53 /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI).
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public TextEditor(bool shown) : this(Interop.TextEditor.New(), true)
57 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61 internal TextEditor(TextEditor handle, bool shown = true) : this(Interop.TextEditor.NewTextEditor(TextEditor.getCPtr(handle)), true)
63 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71 internal TextEditor(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn)
80 /// The TranslatableText property.<br />
81 /// The text can set the SID value.<br />
83 /// <exception cref='ArgumentNullException'>
84 /// ResourceManager about multilingual is null.
86 /// <since_tizen> 4 </since_tizen>
87 public string TranslatableText
91 return textEditorTextSid;
95 if (NUIApplication.MultilingualResourceManager == null)
97 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
99 textEditorTextSid = value;
100 Text = SetTranslatable(textEditorTextSid);
101 NotifyPropertyChanged();
105 /// The TranslatablePlaceholderText property.<br />
106 /// The text can set the SID value.<br />
108 /// <exception cref='ArgumentNullException'>
109 /// ResourceManager about multilingual is null.
111 /// <since_tizen> 4 </since_tizen>
112 public string TranslatablePlaceholderText
116 return textEditorPlaceHolderTextSid;
120 if (NUIApplication.MultilingualResourceManager == null)
122 throw new ArgumentNullException(null, "ResourceManager about multilingual is null");
124 textEditorPlaceHolderTextSid = value;
125 PlaceholderText = SetTranslatable(textEditorPlaceHolderTextSid);
126 NotifyPropertyChanged();
131 /// The Text property.
133 /// <since_tizen> 3 </since_tizen>
138 return (string)GetValue(TextProperty);
142 SetValueAndForceSendChangeSignal(TextProperty, value);
143 NotifyPropertyChanged();
148 /// The TextColor property.
151 /// The property cascade chaining set is possible. For example, this (textEditor.TextColor.X = 0.1f;) is possible.
153 /// <since_tizen> 3 </since_tizen>
154 public Vector4 TextColor
158 Vector4 temp = (Vector4)GetValue(TextColorProperty);
159 return new Vector4(OnTextColorChanged, temp.X, temp.Y, temp.Z, temp.W);
163 SetValue(TextColorProperty, value);
164 NotifyPropertyChanged();
169 /// The FontFamily property.
171 /// <since_tizen> 3 </since_tizen>
172 public string FontFamily
176 return (string)GetValue(FontFamilyProperty);
180 SetValue(FontFamilyProperty, value);
181 NotifyPropertyChanged();
186 /// The FontStyle property.
188 /// <since_tizen> 3 </since_tizen>
189 public PropertyMap FontStyle
193 return (PropertyMap)GetValue(FontStyleProperty);
197 SetValue(FontStyleProperty, value);
198 NotifyPropertyChanged();
203 /// The PointSize property.
205 /// <since_tizen> 3 </since_tizen>
206 public float PointSize
210 return (float)GetValue(PointSizeProperty);
214 SetValue(PointSizeProperty, value);
215 NotifyPropertyChanged();
220 /// The HorizontalAlignment property.
222 /// <since_tizen> 3 </since_tizen>
223 public HorizontalAlignment HorizontalAlignment
227 return (HorizontalAlignment)GetValue(HorizontalAlignmentProperty);
231 SetValue(HorizontalAlignmentProperty, value);
232 NotifyPropertyChanged();
237 /// The ScrollThreshold property.
239 /// <since_tizen> 3 </since_tizen>
240 public float ScrollThreshold
244 return (float)GetValue(ScrollThresholdProperty);
248 SetValue(ScrollThresholdProperty, value);
249 NotifyPropertyChanged();
254 /// The ScrollSpeed property.
256 /// <since_tizen> 3 </since_tizen>
257 public float ScrollSpeed
261 return (float)GetValue(ScrollSpeedProperty);
265 SetValue(ScrollSpeedProperty, value);
266 NotifyPropertyChanged();
271 /// The PrimaryCursorColor property.
274 /// The property cascade chaining set is possible. For example, this (textEditor.PrimaryCursorColor.X = 0.1f;) is possible.
276 /// <since_tizen> 3 </since_tizen>
277 public Vector4 PrimaryCursorColor
281 Vector4 temp = (Vector4)GetValue(PrimaryCursorColorProperty);
282 return new Vector4(OnPrimaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
286 SetValue(PrimaryCursorColorProperty, value);
287 NotifyPropertyChanged();
292 /// The SecondaryCursorColor property.
295 /// The property cascade chaining set is possible. For example, this (textEditor.SecondaryCursorColor.X = 0.1f;) is possible.
297 /// <since_tizen> 3 </since_tizen>
298 public Vector4 SecondaryCursorColor
302 Vector4 temp = (Vector4)GetValue(SecondaryCursorColorProperty);
303 return new Vector4(OnSecondaryCursorColorChanged, temp.X, temp.Y, temp.Z, temp.W);
307 SetValue(SecondaryCursorColorProperty, value);
308 NotifyPropertyChanged();
313 /// The EnableCursorBlink property.
315 /// <since_tizen> 3 </since_tizen>
316 public bool EnableCursorBlink
320 return (bool)GetValue(EnableCursorBlinkProperty);
324 SetValue(EnableCursorBlinkProperty, value);
325 NotifyPropertyChanged();
330 /// The CursorBlinkInterval property.
332 /// <since_tizen> 3 </since_tizen>
333 public float CursorBlinkInterval
337 return (float)GetValue(CursorBlinkIntervalProperty);
341 SetValue(CursorBlinkIntervalProperty, value);
342 NotifyPropertyChanged();
347 /// The CursorBlinkDuration property.
349 /// <since_tizen> 3 </since_tizen>
350 public float CursorBlinkDuration
354 return (float)GetValue(CursorBlinkDurationProperty);
358 SetValue(CursorBlinkDurationProperty, value);
359 NotifyPropertyChanged();
364 /// The CursorWidth property.
366 /// <since_tizen> 3 </since_tizen>
367 public int CursorWidth
371 return (int)GetValue(CursorWidthProperty);
375 SetValue(CursorWidthProperty, value);
376 NotifyPropertyChanged();
381 /// The GrabHandleImage property.
383 /// <since_tizen> 3 </since_tizen>
384 public string GrabHandleImage
388 return (string)GetValue(GrabHandleImageProperty);
392 SetValue(GrabHandleImageProperty, value);
393 NotifyPropertyChanged();
398 /// The GrabHandlePressedImage property.
400 /// <since_tizen> 3 </since_tizen>
401 public string GrabHandlePressedImage
405 return (string)GetValue(GrabHandlePressedImageProperty);
409 SetValue(GrabHandlePressedImageProperty, value);
410 NotifyPropertyChanged();
415 /// The SelectionHandleImageLeft property.
417 /// <since_tizen> 3 </since_tizen>
418 public PropertyMap SelectionHandleImageLeft
422 return (PropertyMap)GetValue(SelectionHandleImageLeftProperty);
426 SetValue(SelectionHandleImageLeftProperty, value);
427 NotifyPropertyChanged();
432 /// The SelectionHandleImageRight property.
434 /// <since_tizen> 3 </since_tizen>
435 public PropertyMap SelectionHandleImageRight
439 return (PropertyMap)GetValue(SelectionHandleImageRightProperty);
443 SetValue(SelectionHandleImageRightProperty, value);
444 NotifyPropertyChanged();
449 /// The SelectionHandlePressedImageLeft property.
451 /// <since_tizen> 3 </since_tizen>
452 public PropertyMap SelectionHandlePressedImageLeft
456 return (PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty);
460 SetValue(SelectionHandlePressedImageLeftProperty, value);
461 NotifyPropertyChanged();
466 /// The SelectionHandlePressedImageRight property.
468 /// <since_tizen> 3 </since_tizen>
469 public PropertyMap SelectionHandlePressedImageRight
473 return (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty);
477 SetValue(SelectionHandlePressedImageRightProperty, value);
478 NotifyPropertyChanged();
483 /// The SelectionHandleMarkerImageLeft property.
485 /// <since_tizen> 3 </since_tizen>
486 public PropertyMap SelectionHandleMarkerImageLeft
490 return (PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty);
494 SetValue(SelectionHandleMarkerImageLeftProperty, value);
495 NotifyPropertyChanged();
500 /// The SelectionHandleMarkerImageRight property.
502 /// <since_tizen> 3 </since_tizen>
503 public PropertyMap SelectionHandleMarkerImageRight
507 return (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty);
511 SetValue(SelectionHandleMarkerImageRightProperty, value);
512 NotifyPropertyChanged();
517 /// The SelectionHighlightColor property.
520 /// The property cascade chaining set is possible. For example, this (textEditor.SelectionHighlightColor.X = 0.1f;) is possible.
522 /// <since_tizen> 3 </since_tizen>
523 public Vector4 SelectionHighlightColor
527 Vector4 temp = (Vector4)GetValue(SelectionHighlightColorProperty);
528 return new Vector4(OnSelectionHighlightColorChanged, temp.X, temp.Y, temp.Z, temp.W);
532 SetValue(SelectionHighlightColorProperty, value);
533 NotifyPropertyChanged();
538 /// The DecorationBoundingBox property.
541 /// The property cascade chaining set is possible. For example, this (textEditor.DecorationBoundingBox.X = 1;) is possible.
543 /// <since_tizen> 3 </since_tizen>
544 public Rectangle DecorationBoundingBox
548 Rectangle temp = (Rectangle)GetValue(DecorationBoundingBoxProperty);
549 return new Rectangle(OnDecorationBoundingBoxChanged, temp.X, temp.Y, temp.Width, temp.Height);
553 SetValue(DecorationBoundingBoxProperty, value);
554 NotifyPropertyChanged();
559 /// The EnableMarkup property.
561 /// <since_tizen> 3 </since_tizen>
562 public bool EnableMarkup
566 return (bool)GetValue(EnableMarkupProperty);
570 SetValue(EnableMarkupProperty, value);
571 NotifyPropertyChanged();
576 /// The InputColor property.
579 /// The property cascade chaining set is possible. For example, this (textEditor.InputColor.X = 0.1f;) is possible.
581 /// <since_tizen> 3 </since_tizen>
582 public Vector4 InputColor
586 Vector4 temp = (Vector4)GetValue(InputColorProperty);
587 return new Vector4(OnInputColorChanged, temp.X, temp.Y, temp.Z, temp.W);
591 SetValue(InputColorProperty, value);
592 NotifyPropertyChanged();
597 /// The InputFontFamily property.
599 /// <since_tizen> 3 </since_tizen>
600 public string InputFontFamily
604 return (string)GetValue(InputFontFamilyProperty);
608 SetValue(InputFontFamilyProperty, value);
609 NotifyPropertyChanged();
614 /// The InputFontStyle property.
616 /// <since_tizen> 3 </since_tizen>
617 public PropertyMap InputFontStyle
621 return (PropertyMap)GetValue(InputFontStyleProperty);
625 SetValue(InputFontStyleProperty, value);
626 NotifyPropertyChanged();
631 /// The InputPointSize property.
633 /// <since_tizen> 3 </since_tizen>
634 public float InputPointSize
638 return (float)GetValue(InputPointSizeProperty);
642 SetValue(InputPointSizeProperty, value);
643 NotifyPropertyChanged();
648 /// The LineSpacing property.
650 /// <since_tizen> 3 </since_tizen>
651 public float LineSpacing
655 return (float)GetValue(LineSpacingProperty);
659 SetValue(LineSpacingProperty, value);
660 NotifyPropertyChanged();
665 /// The InputLineSpacing property.
667 /// <since_tizen> 3 </since_tizen>
668 public float InputLineSpacing
672 return (float)GetValue(InputLineSpacingProperty);
676 SetValue(InputLineSpacingProperty, value);
677 NotifyPropertyChanged();
682 /// The Underline property.
684 /// <since_tizen> 3 </since_tizen>
685 public PropertyMap Underline
689 return (PropertyMap)GetValue(UnderlineProperty);
693 SetValue(UnderlineProperty, value);
694 NotifyPropertyChanged();
699 /// The InputUnderline property.
701 /// <since_tizen> 3 </since_tizen>
702 public string InputUnderline
706 return (string)GetValue(InputUnderlineProperty);
710 SetValue(InputUnderlineProperty, value);
711 NotifyPropertyChanged();
716 /// The Shadow property.
718 /// <since_tizen> 3 </since_tizen>
719 public PropertyMap Shadow
723 return (PropertyMap)GetValue(ShadowProperty);
727 SetValue(ShadowProperty, value);
728 NotifyPropertyChanged();
733 /// The InputShadow property.
735 /// <since_tizen> 3 </since_tizen>
736 public string InputShadow
740 return (string)GetValue(InputShadowProperty);
744 SetValue(InputShadowProperty, value);
745 NotifyPropertyChanged();
750 /// The Emboss property.
752 /// <since_tizen> 3 </since_tizen>
757 return (string)GetValue(EmbossProperty);
761 SetValue(EmbossProperty, value);
762 NotifyPropertyChanged();
767 /// The InputEmboss property.
769 /// <since_tizen> 3 </since_tizen>
770 public string InputEmboss
774 return (string)GetValue(InputEmbossProperty);
778 SetValue(InputEmbossProperty, value);
779 NotifyPropertyChanged();
784 /// The Outline property.
786 /// <since_tizen> 3 </since_tizen>
787 public PropertyMap Outline
791 return (PropertyMap)GetValue(OutlineProperty);
795 SetValue(OutlineProperty, value);
796 NotifyPropertyChanged();
801 /// The InputOutline property.
803 /// <since_tizen> 3 </since_tizen>
804 public string InputOutline
808 return (string)GetValue(InputOutlineProperty);
812 SetValue(InputOutlineProperty, value);
813 NotifyPropertyChanged();
818 /// The SmoothScroll property.
820 /// <since_tizen> 3 </since_tizen>
821 public bool SmoothScroll
825 return (bool)GetValue(SmoothScrollProperty);
829 SetValue(SmoothScrollProperty, value);
830 NotifyPropertyChanged();
835 /// The SmoothScrollDuration property.
837 /// <since_tizen> 3 </since_tizen>
838 public float SmoothScrollDuration
842 return (float)GetValue(SmoothScrollDurationProperty);
846 SetValue(SmoothScrollDurationProperty, value);
847 NotifyPropertyChanged();
852 /// The EnableScrollBar property.
854 /// <since_tizen> 3 </since_tizen>
855 public bool EnableScrollBar
859 return (bool)GetValue(EnableScrollBarProperty);
863 SetValue(EnableScrollBarProperty, value);
864 NotifyPropertyChanged();
869 /// The ScrollBarShowDuration property.
871 /// <since_tizen> 3 </since_tizen>
872 public float ScrollBarShowDuration
876 return (float)GetValue(ScrollBarShowDurationProperty);
880 SetValue(ScrollBarShowDurationProperty, value);
881 NotifyPropertyChanged();
886 /// The ScrollBarFadeDuration property.
888 /// <since_tizen> 3 </since_tizen>
889 public float ScrollBarFadeDuration
893 return (float)GetValue(ScrollBarFadeDurationProperty);
897 SetValue(ScrollBarFadeDurationProperty, value);
898 NotifyPropertyChanged();
903 /// The PixelSize property.
905 /// <since_tizen> 3 </since_tizen>
906 public float PixelSize
910 return (float)GetValue(PixelSizeProperty);
914 SetValue(PixelSizeProperty, value);
915 NotifyPropertyChanged();
920 /// The line count of the text.
922 /// <since_tizen> 3 </since_tizen>
928 GetProperty(TextEditor.Property.LineCount).Get(out temp);
934 /// The text to display when the TextEditor is empty and inactive.
936 /// <since_tizen> 3 </since_tizen>
937 public string PlaceholderText
941 return (string)GetValue(PlaceholderTextProperty);
945 SetValue(PlaceholderTextProperty, value);
946 NotifyPropertyChanged();
951 /// The Selected Text property (read-only).
953 [EditorBrowsable(EditorBrowsableState.Never)]
954 public string SelectedText
959 GetProperty(TextEditor.Property.SelectedText).Get(out temp);
965 /// The Placeholder text color.
968 /// The property cascade chaining set is possible. For example, this (textEditor.PlaceholderTextColor.X = 0.1f;) is possible.
970 /// <since_tizen> 3 </since_tizen>
971 public Color PlaceholderTextColor
975 Color temp = (Color)GetValue(PlaceholderTextColorProperty);
976 return new Color(OnPlaceholderTextColorChanged, temp.R, temp.G, temp.B, temp.A);
980 SetValue(PlaceholderTextColorProperty, value);
981 NotifyPropertyChanged();
986 /// The EnableSelection property.
988 /// <since_tizen> 3 </since_tizen>
989 public bool EnableSelection
993 return (bool)GetValue(EnableSelectionProperty);
997 SetValue(EnableSelectionProperty, value);
998 NotifyPropertyChanged();
1003 /// The start index for selection.
1005 /// <since_tizen> 8 </since_tizen>
1006 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1007 [EditorBrowsable(EditorBrowsableState.Never)]
1008 public int SelectedTextStart
1013 GetProperty(TextEditor.Property.SelectedTextStart).Get(out temp);
1018 SetProperty(TextEditor.Property.SelectedTextStart, new PropertyValue(value));
1019 NotifyPropertyChanged();
1024 /// The end index for selection.
1026 /// <since_tizen> 8 </since_tizen>
1027 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1028 [EditorBrowsable(EditorBrowsableState.Never)]
1029 public int SelectedTextEnd
1034 GetProperty(TextEditor.Property.SelectedTextEnd).Get(out temp);
1039 SetProperty(TextEditor.Property.SelectedTextEnd, new PropertyValue(value));
1040 NotifyPropertyChanged();
1045 /// Enable editing in text control.
1047 /// <since_tizen> 8 </since_tizen>
1048 /// This will be public opened in tizen_6.0 after ACR done, Before ACR, need to be hidden as inhouse API.
1049 [EditorBrowsable(EditorBrowsableState.Never)]
1050 public bool EnableEditing
1055 GetProperty(TextEditor.Property.EnableEditing).Get(out temp);
1060 SetProperty(TextEditor.Property.EnableEditing, new PropertyValue(value));
1061 NotifyPropertyChanged();
1066 /// Specify horizontal scroll position in text control.
1068 [EditorBrowsable(EditorBrowsableState.Never)]
1069 public int HorizontalScrollPosition
1074 using (PropertyValue propertyValue = GetProperty(TextEditor.Property.HorizontalScrollPosition))
1076 propertyValue.Get(out temp);
1082 using (PropertyValue propertyValue = new PropertyValue(value))
1084 SetProperty(TextEditor.Property.HorizontalScrollPosition, propertyValue);
1085 NotifyPropertyChanged();
1091 /// Specify vertical scroll position in text control.
1093 [EditorBrowsable(EditorBrowsableState.Never)]
1094 public int VerticalScrollPosition
1099 using (PropertyValue propertyValue = GetProperty(TextEditor.Property.VerticalScrollPosition))
1101 propertyValue.Get(out temp);
1107 using (PropertyValue propertyValue = new PropertyValue(value))
1109 SetProperty(TextEditor.Property.VerticalScrollPosition, propertyValue);
1110 NotifyPropertyChanged();
1116 /// Specify primary cursor (caret) position in text control.
1118 [EditorBrowsable(EditorBrowsableState.Never)]
1119 public int PrimaryCursorPosition
1124 using (PropertyValue propertyValue = GetProperty(TextEditor.Property.PrimaryCursorPosition))
1126 propertyValue.Get(out temp);
1132 using (PropertyValue propertyValue = new PropertyValue(value))
1134 SetProperty(TextEditor.Property.PrimaryCursorPosition, propertyValue);
1135 NotifyPropertyChanged();
1141 /// The Placeholder property.
1142 /// Gets or sets the placeholder: text, color, font family, font style, point size, and pixel size.
1145 /// The following example demonstrates how to set the placeholder property.
1147 /// PropertyMap propertyMap = new PropertyMap();
1148 /// propertyMap.Add("text", new PropertyValue("Setting Placeholder Text"));
1149 /// propertyMap.Add("textFocused", new PropertyValue("Setting Placeholder Text Focused"));
1150 /// propertyMap.Add("color", new PropertyValue(Color.Red));
1151 /// propertyMap.Add("fontFamily", new PropertyValue("Arial"));
1152 /// propertyMap.Add("pointSize", new PropertyValue(12.0f));
1154 /// PropertyMap fontStyleMap = new PropertyMap();
1155 /// fontStyleMap.Add("weight", new PropertyValue("bold"));
1156 /// fontStyleMap.Add("width", new PropertyValue("condensed"));
1157 /// fontStyleMap.Add("slant", new PropertyValue("italic"));
1158 /// propertyMap.Add("fontStyle", new PropertyValue(fontStyleMap));
1160 /// TextEditor editor = new TextEditor();
1161 /// editor.Placeholder = propertyMap;
1164 /// <since_tizen> 3 </since_tizen>
1165 public Tizen.NUI.PropertyMap Placeholder
1169 return (PropertyMap)GetValue(PlaceholderProperty);
1173 SetValue(PlaceholderProperty, value);
1174 NotifyPropertyChanged();
1179 /// The LineWrapMode property.<br />
1180 /// The line wrap mode when the text lines over the layout width.<br />
1182 /// <since_tizen> 4 </since_tizen>
1183 public LineWrapMode LineWrapMode
1187 return (LineWrapMode)GetValue(LineWrapModeProperty);
1191 SetValue(LineWrapModeProperty, value);
1192 NotifyPropertyChanged();
1197 /// Enables Text selection using Shift key.
1199 /// <since_tizen> 5 </since_tizen>
1200 /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
1201 [EditorBrowsable(EditorBrowsableState.Never)]
1202 public bool EnableShiftSelection
1206 return (bool)GetValue(EnableShiftSelectionProperty);
1210 SetValue(EnableShiftSelectionProperty, value);
1211 NotifyPropertyChanged();
1216 /// The text alignment to match the direction of the system language.
1218 /// <since_tizen> 6 </since_tizen>
1219 public bool MatchSystemLanguageDirection
1223 return (bool)GetValue(MatchSystemLanguageDirectionProperty);
1227 SetValue(MatchSystemLanguageDirectionProperty, value);
1228 NotifyPropertyChanged();
1233 /// The MaxLength property.
1235 /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1236 [EditorBrowsable(EditorBrowsableState.Never)]
1237 public int MaxLength
1241 return (int)GetValue(MaxLengthProperty);
1245 SetValue(MaxLengthProperty, value);
1246 NotifyPropertyChanged();
1250 /// Only used by the IL of xaml, will never changed to not hidden.
1251 [EditorBrowsable(EditorBrowsableState.Never)]
1252 public override bool IsCreateByXaml
1256 return base.IsCreateByXaml;
1260 base.IsCreateByXaml = value;
1264 this.TextChanged += (obj, e) =>
1266 this.Text = e.TextEditor.Text;
1273 /// The FontSizeScale property. <br />
1274 /// The default value is 1.0. <br />
1275 /// If FontSizeScale.UseSystemSetting, will use the SystemSettings.FontSize internally. <br />
1277 /// <since_tizen> 9 </since_tizen>
1278 /// This will be public opened in tizen_6.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1279 [EditorBrowsable(EditorBrowsableState.Never)]
1280 public float FontSizeScale
1284 return fontSizeScale;
1288 float newFontSizeScale;
1290 if (fontSizeScale == value) return;
1292 fontSizeScale = value;
1293 if (fontSizeScale == Tizen.NUI.FontSizeScale.UseSystemSetting)
1295 SystemSettingsFontSize systemSettingsFontSize;
1299 systemSettingsFontSize = SystemSettings.FontSize;
1303 Console.WriteLine("{0} Exception caught.", e);
1304 systemSettingsFontSize = SystemSettingsFontSize.Normal;
1306 newFontSizeScale = TextUtils.GetFontSizeScale(systemSettingsFontSize);
1307 addFontSizeChangedCallback();
1311 newFontSizeScale = fontSizeScale;
1312 removeFontSizeChangedCallback();
1315 SetValue(FontSizeScaleProperty, newFontSizeScale);
1316 NotifyPropertyChanged();
1321 /// Scroll the text control by specific amount..
1323 /// <param name="scroll">The amount (in pixels) of scrolling in horizontal & vertical directions.</param>
1324 [EditorBrowsable(EditorBrowsableState.Never)]
1325 public void ScrollBy(Vector2 scroll)
1327 Interop.TextEditor.ScrollBy(SwigCPtr, Vector2.getCPtr(scroll));
1328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1332 /// Get the InputMethodContext instance.
1334 /// <returns>The InputMethodContext instance.</returns>
1335 /// <since_tizen> 5 </since_tizen>
1336 public InputMethodContext GetInputMethodContext()
1338 if (inputMethodContext == null)
1340 /*Avoid raising InputMethodContext reference count.*/
1341 inputMethodContext = new InputMethodContext(Interop.TextEditor.GetInputMethodContext(SwigCPtr), true);
1342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1344 return inputMethodContext;
1348 /// Select the whole text.
1350 [EditorBrowsable(EditorBrowsableState.Never)]
1351 public void SelectWholeText()
1353 Interop.TextEditor.SelectWholeText(SwigCPtr);
1354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1358 /// Clear selection of the text.
1360 [EditorBrowsable(EditorBrowsableState.Never)]
1361 public void SelectNone()
1363 _ = Interop.TextEditor.SelectNone(SwigCPtr);
1364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1367 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextEditor obj)
1369 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1372 internal SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t InputStyleChangedSignal()
1374 SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t ret = new SWIGTYPE_p_Dali__SignalT_void_fDali__Toolkit__TextEditor_Dali__Toolkit__TextEditor__InputStyle__MaskF_t(Interop.TextEditor.InputStyleChangedSignal(SwigCPtr));
1375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1382 /// <since_tizen> 3 </since_tizen>
1383 protected override void Dispose(DisposeTypes type)
1390 if (systemlangTextFlag)
1392 SystemSettings.LocaleLanguageChanged -= SystemSettings_LocaleLanguageChanged;
1395 removeFontSizeChangedCallback();
1397 //Release your own unmanaged resources here.
1398 //You should not access any managed member here except static instance.
1399 //because the execution order of Finalizes is non-deterministic.
1403 if (_textEditorTextChangedCallbackDelegate != null)
1405 TextChangedSignal().Disconnect(_textEditorTextChangedCallbackDelegate);
1408 if (_textEditorMaxLengthReachedCallbackDelegate != null)
1410 this.MaxLengthReachedSignal().Disconnect(_textEditorMaxLengthReachedCallbackDelegate);
1417 /// This will not be public opened.
1418 [EditorBrowsable(EditorBrowsableState.Never)]
1419 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1421 // In order to speed up IME hide, temporarily add
1422 GetInputMethodContext()?.DestroyContext();
1423 Interop.TextEditor.DeleteTextEditor(swigCPtr);
1426 private string SetTranslatable(string textEditorSid)
1428 string translatableText = null;
1429 translatableText = NUIApplication.MultilingualResourceManager?.GetString(textEditorSid, new CultureInfo(SystemSettings.LocaleLanguage.Replace("_", "-")));
1430 if (translatableText != null)
1432 if (systemlangTextFlag == false)
1434 SystemSettings.LocaleLanguageChanged += SystemSettings_LocaleLanguageChanged;
1435 systemlangTextFlag = true;
1437 return translatableText;
1441 translatableText = "";
1442 return translatableText;
1446 private void SystemSettings_LocaleLanguageChanged(object sender, LocaleLanguageChangedEventArgs e)
1448 if (textEditorTextSid != null)
1450 Text = NUIApplication.MultilingualResourceManager?.GetString(textEditorTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1452 if (textEditorPlaceHolderTextSid != null)
1454 PlaceholderText = NUIApplication.MultilingualResourceManager?.GetString(textEditorPlaceHolderTextSid, new CultureInfo(e.Value.Replace("_", "-")));
1458 private void SystemSettingsFontSizeChanged(object sender, FontSizeChangedEventArgs e)
1460 float newFontSizeScale = TextUtils.GetFontSizeScale(e.Value);
1461 SetValue(FontSizeScaleProperty, newFontSizeScale);
1462 NotifyPropertyChanged();
1465 private void addFontSizeChangedCallback()
1467 if (hasFontSizeChangedCallback != true)
1471 SystemSettings.FontSizeChanged += SystemSettingsFontSizeChanged;
1472 hasFontSizeChangedCallback = true;
1476 Console.WriteLine("{0} Exception caught.", e);
1477 hasFontSizeChangedCallback = false;
1482 private void removeFontSizeChangedCallback()
1484 if (hasFontSizeChangedCallback == true)
1488 SystemSettings.FontSizeChanged -= SystemSettingsFontSizeChanged;
1489 hasFontSizeChangedCallback = false;
1493 Console.WriteLine("{0} Exception caught.", e);
1494 hasFontSizeChangedCallback = true;
1499 internal new class Property
1501 internal static readonly int TEXT = Interop.TextEditor.TextGet();
1502 internal static readonly int TextColor = Interop.TextEditor.TextColorGet();
1503 internal static readonly int FontFamily = Interop.TextEditor.FontFamilyGet();
1504 internal static readonly int FontStyle = Interop.TextEditor.FontStyleGet();
1505 internal static readonly int PointSize = Interop.TextEditor.PointSizeGet();
1506 internal static readonly int HorizontalAlignment = Interop.TextEditor.HorizontalAlignmentGet();
1507 internal static readonly int ScrollThreshold = Interop.TextEditor.ScrollThresholdGet();
1508 internal static readonly int ScrollSpeed = Interop.TextEditor.ScrollSpeedGet();
1509 internal static readonly int PrimaryCursorColor = Interop.TextEditor.PrimaryCursorColorGet();
1510 internal static readonly int SecondaryCursorColor = Interop.TextEditor.SecondaryCursorColorGet();
1511 internal static readonly int EnableCursorBlink = Interop.TextEditor.EnableCursorBlinkGet();
1512 internal static readonly int CursorBlinkInterval = Interop.TextEditor.CursorBlinkIntervalGet();
1513 internal static readonly int CursorBlinkDuration = Interop.TextEditor.CursorBlinkDurationGet();
1514 internal static readonly int CursorWidth = Interop.TextEditor.CursorWidthGet();
1515 internal static readonly int GrabHandleImage = Interop.TextEditor.GrabHandleImageGet();
1516 internal static readonly int GrabHandlePressedImage = Interop.TextEditor.GrabHandlePressedImageGet();
1517 internal static readonly int SelectionHandleImageLeft = Interop.TextEditor.SelectionHandleImageLeftGet();
1518 internal static readonly int SelectionHandleImageRight = Interop.TextEditor.SelectionHandleImageRightGet();
1519 internal static readonly int SelectionHandlePressedImageLeft = Interop.TextEditor.SelectionHandlePressedImageLeftGet();
1520 internal static readonly int SelectionHandlePressedImageRight = Interop.TextEditor.SelectionHandlePressedImageRightGet();
1521 internal static readonly int SelectionHandleMarkerImageLeft = Interop.TextEditor.SelectionHandleMarkerImageLeftGet();
1522 internal static readonly int SelectionHandleMarkerImageRight = Interop.TextEditor.SelectionHandleMarkerImageRightGet();
1523 internal static readonly int SelectionHighlightColor = Interop.TextEditor.SelectionHighlightColorGet();
1524 internal static readonly int DecorationBoundingBox = Interop.TextEditor.DecorationBoundingBoxGet();
1525 internal static readonly int EnableMarkup = Interop.TextEditor.EnableMarkupGet();
1526 internal static readonly int InputColor = Interop.TextEditor.InputColorGet();
1527 internal static readonly int InputFontFamily = Interop.TextEditor.InputFontFamilyGet();
1528 internal static readonly int InputFontStyle = Interop.TextEditor.InputFontStyleGet();
1529 internal static readonly int InputPointSize = Interop.TextEditor.InputPointSizeGet();
1530 internal static readonly int LineSpacing = Interop.TextEditor.LineSpacingGet();
1531 internal static readonly int InputLineSpacing = Interop.TextEditor.InputLineSpacingGet();
1532 internal static readonly int UNDERLINE = Interop.TextEditor.UnderlineGet();
1533 internal static readonly int InputUnderline = Interop.TextEditor.InputUnderlineGet();
1534 internal static readonly int SHADOW = Interop.TextEditor.ShadowGet();
1535 internal static readonly int InputShadow = Interop.TextEditor.InputShadowGet();
1536 internal static readonly int EMBOSS = Interop.TextEditor.EmbossGet();
1537 internal static readonly int InputEmboss = Interop.TextEditor.InputEmbossGet();
1538 internal static readonly int OUTLINE = Interop.TextEditor.OutlineGet();
1539 internal static readonly int InputOutline = Interop.TextEditor.InputOutlineGet();
1540 internal static readonly int SmoothScroll = Interop.TextEditor.SmoothScrollGet();
1541 internal static readonly int SmoothScrollDuration = Interop.TextEditor.SmoothScrollDurationGet();
1542 internal static readonly int EnableScrollBar = Interop.TextEditor.EnableScrollBarGet();
1543 internal static readonly int ScrollBarShowDuration = Interop.TextEditor.ScrollBarShowDurationGet();
1544 internal static readonly int ScrollBarFadeDuration = Interop.TextEditor.ScrollBarFadeDurationGet();
1545 internal static readonly int PixelSize = Interop.TextEditor.PixelSizeGet();
1546 internal static readonly int LineCount = Interop.TextEditor.LineCountGet();
1547 internal static readonly int EnableSelection = Interop.TextEditor.EnableSelectionGet();
1548 internal static readonly int PLACEHOLDER = Interop.TextEditor.PlaceholderGet();
1549 internal static readonly int LineWrapMode = Interop.TextEditor.LineWrapModeGet();
1550 internal static readonly int PlaceholderText = Interop.TextEditor.PlaceholderTextGet();
1551 internal static readonly int PlaceholderTextColor = Interop.TextEditor.PlaceholderTextColorGet();
1552 internal static readonly int EnableShiftSelection = Interop.TextEditor.EnableShiftSelectionGet();
1553 internal static readonly int MatchSystemLanguageDirection = Interop.TextEditor.MatchSystemLanguageDirectionGet();
1554 internal static readonly int MaxLength = Interop.TextEditor.MaxLengthGet();
1555 internal static readonly int SelectedTextStart = Interop.TextEditor.SelectedTextStartGet();
1556 internal static readonly int SelectedTextEnd = Interop.TextEditor.SelectedTextEndGet();
1557 internal static readonly int EnableEditing = Interop.TextEditor.EnableEditingGet();
1558 internal static readonly int SelectedText = Interop.TextEditor.SelectedTextGet();
1559 internal static readonly int HorizontalScrollPosition = Interop.TextEditor.HorizontalScrollPositionGet();
1560 internal static readonly int VerticalScrollPosition = Interop.TextEditor.VerticalScrollPositionGet();
1561 internal static readonly int PrimaryCursorPosition = Interop.TextEditor.PrimaryCursorPositionGet();
1562 internal static readonly int FontSizeScale = Interop.TextEditor.FontSizeScaleGet();
1565 internal class InputStyle
1571 FontFamily = 0x0002,
1574 LineSpacing = 0x0010,
1582 private void OnDecorationBoundingBoxChanged(int x, int y, int width, int height)
1584 DecorationBoundingBox = new Rectangle(x, y, width, height);
1586 private void OnInputColorChanged(float x, float y, float z, float w)
1588 InputColor = new Vector4(x, y, z, w);
1590 private void OnPlaceholderTextColorChanged(float r, float g, float b, float a)
1592 PlaceholderTextColor = new Color(r, g, b, a);
1594 private void OnPrimaryCursorColorChanged(float x, float y, float z, float w)
1596 PrimaryCursorColor = new Vector4(x, y, z, w);
1598 private void OnSecondaryCursorColorChanged(float x, float y, float z, float w)
1600 SecondaryCursorColor = new Vector4(x, y, z, w);
1602 private void OnSelectionHighlightColorChanged(float x, float y, float z, float w)
1604 SelectionHighlightColor = new Vector4(x, y, z, w);
1606 private void OnTextColorChanged(float x, float y, float z, float w)
1608 TextColor = new Vector4(x, y, z, w);