2 * Copyright(c) 2020 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.
19 using System.ComponentModel;
21 using System.Collections.Generic;
23 namespace Tizen.NUI.BaseComponents
27 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public static class TextGeometry
31 private static void ValidateRange(int start, int end)
34 throw new global::System.ArgumentOutOfRangeException(nameof(start), "Value is less than zero");
36 throw new global::System.ArgumentOutOfRangeException(nameof(end), "Value is less than zero");
39 private static List<Size2D> GetSizeListFromNativeVector(System.IntPtr ptr)
41 using (VectorVector2 sizeVector = new VectorVector2 (ptr, true))
43 int count = sizeVector.Size();
44 List<Size2D> list = new List<Size2D>();
46 for(int i = 0; i < count; i++)
47 list.Add(sizeVector.ValueOfIndex( (uint)i ));
53 private static List<Position2D> GetPositionListFromNativeVector(System.IntPtr ptr)
55 using (VectorVector2 positionVector = new VectorVector2 (ptr, true))
57 int count = positionVector.Size();
58 List<Position2D> list = new List<Position2D>();
60 for(int i = 0; i < count; i++)
61 list.Add(positionVector.ValueOfIndex( (uint)i ));
67 private static void CheckSWIGPendingException()
69 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
73 /// Get the rendered size of the text between start and end (included). <br />
74 /// if the requested text is at multilines, multiple sizes will be returned for each text located in a separate line. <br />
75 /// if a line contains characters with different directions, multiple sizes will be returned for each block of contiguous characters with the same direction. <br />
77 /// <param name="textEditor">The TextEditor control containing the text.</param>
78 /// <param name="start">The start index of the text to get the size for</param>
79 /// <param name="end">The end index of the text to get the size for.</param>
80 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
81 [EditorBrowsable(EditorBrowsableState.Never)]
82 public static List<Size2D> GetTextSize(TextEditor textEditor, int start, int end)
84 if (textEditor == null)
86 throw new ArgumentNullException(null, "textEditor object is null");
89 ValidateRange(start, end);
91 List<Size2D> list = GetSizeListFromNativeVector(Interop.TextEditor.GetTextSize(textEditor.SwigCPtr, (uint)start, (uint)end));
92 CheckSWIGPendingException();
97 /// Get the rendered size of the text between start and end (included). <br />
98 /// if the requested text is at multilines, multiple sizes will be returned for each text located in a separate line. <br />
99 /// if a line contains characters with different directions, multiple sizes will be returned for each block of contiguous characters with the same direction. <br />
101 /// <param name="textField">The TextField control containing the text.</param>
102 /// <param name="start">The start index of the text to get the size for</param>
103 /// <param name="end">The end index of the text to get the size for.</param>
104 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public static List<Size2D> GetTextSize(TextField textField, int start, int end)
108 if (textField == null)
110 throw new ArgumentNullException(null, "textField object is null");
113 ValidateRange(start, end);
115 List<Size2D> list = GetSizeListFromNativeVector(Interop.TextField.GetTextSize(textField.SwigCPtr, (uint)start, (uint)end));
116 CheckSWIGPendingException();
121 /// Get the rendered size of the text between start and end (included). <br />
122 /// if the requested text is at multilines, multiple sizes will be returned for each text located in a separate line. <br />
123 /// if a line contains characters with different directions, multiple sizes will be returned for each block of contiguous characters with the same direction. <br />
125 /// <param name="textLabel">The TextLabel control containing the text.</param>
126 /// <param name="start">The start index of the text to get the size for</param>
127 /// <param name="end">The end index of the text to get the size for.</param>
128 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 public static List<Size2D> GetTextSize(TextLabel textLabel, int start, int end)
132 if (textLabel == null)
134 throw new ArgumentNullException(null, "textLabel object is null");
137 ValidateRange(start, end);
139 List<Size2D> list = GetSizeListFromNativeVector(Interop.TextLabel.GetTextSize(textLabel.SwigCPtr, (uint)start, (uint)end));
140 CheckSWIGPendingException();
145 /// Get the rendered position (top-left) of the text between start and end (included). <br />
146 /// if the requested text is at multilines, multiple positions will be returned for each text located in a separate line. <br />
147 /// if a line contains characters with different directions, multiple positions will be returned for each block of contiguous characters with the same direction. <br />
149 /// <param name="textEditor">The TextEditor control containing the text.</param>
150 /// <param name="start">The start index of the text to get the position for</param>
151 /// <param name="end">The end index of the text to get the position for.</param>
152 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
153 [EditorBrowsable(EditorBrowsableState.Never)]
154 public static List<Position2D> GetTextPosition(TextEditor textEditor, int start, int end)
156 if (textEditor == null)
158 throw new ArgumentNullException(null, "textEditor object is null");
161 ValidateRange(start, end);
163 List<Position2D> list = GetPositionListFromNativeVector(Interop.TextEditor.GetTextPosition(textEditor.SwigCPtr, (uint)start, (uint)end));
164 CheckSWIGPendingException();
169 /// Get the rendered position (top-left) of the text between start and end (included). <br />
170 /// if the requested text is at multilines, multiple positions will be returned for each text located in a separate line. <br />
171 /// if a line contains characters with different directions, multiple positions will be returned for each block of contiguous characters with the same direction. <br />
173 /// <param name="textField">The TextField control containing the text.</param>
174 /// <param name="start">The start index of the text to get the position for</param>
175 /// <param name="end">The end index of the text to get the position for.</param>
176 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
177 [EditorBrowsable(EditorBrowsableState.Never)]
178 public static List<Position2D> GetTextPosition(TextField textField, int start, int end)
180 if (textField == null)
182 throw new ArgumentNullException(null, "textField object is null");
185 ValidateRange(start, end);
187 List<Position2D> list = GetPositionListFromNativeVector(Interop.TextField.GetTextPosition(textField.SwigCPtr, (uint)start, (uint)end));
188 CheckSWIGPendingException();
193 /// Get the rendered position (top-left) of the text between start and end (included). <br />
194 /// if the requested text is at multilines, multiple positions will be returned for each text located in a separate line. <br />
195 /// if a line contains characters with different directions, multiple positions will be returned for each block of contiguous characters with the same direction. <br />
197 /// <param name="textLabel">The TextLabel control containing the text.</param>
198 /// <param name="start">The start index of the text to get the position for</param>
199 /// <param name="end">The end index of the text to get the position for.</param>
200 // This will be public opened after ACR done. (Before ACR, need to be hidden as Inhouse API)
201 [EditorBrowsable(EditorBrowsableState.Never)]
202 public static List<Position2D> GetTextPosition(TextLabel textLabel, int start, int end)
204 if (textLabel == null)
206 throw new ArgumentNullException(null, "textLabel object is null");
209 ValidateRange(start, end);
211 List<Position2D> list = GetPositionListFromNativeVector(Interop.TextLabel.GetTextPosition(textLabel.SwigCPtr, (uint)start, (uint)end));
212 CheckSWIGPendingException();