williamr@2
|
1 |
/*
|
williamr@2
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
3 |
* All rights reserved.
|
williamr@2
|
4 |
* This component and the accompanying materials are made available
|
williamr@4
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
6 |
* which accompanies this distribution, and is available
|
williamr@4
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
8 |
*
|
williamr@2
|
9 |
* Initial Contributors:
|
williamr@2
|
10 |
* Nokia Corporation - initial contribution.
|
williamr@2
|
11 |
*
|
williamr@2
|
12 |
* Contributors:
|
williamr@2
|
13 |
*
|
williamr@2
|
14 |
* Description: Text utilities e.g. truncating and wrapping to be used in code
|
williamr@2
|
15 |
* that needs to support text that requires conversion from logical
|
williamr@2
|
16 |
* to visual order, e.g. Arabic/Hebrew.
|
williamr@2
|
17 |
* Logical text is given as input to all methods.
|
williamr@2
|
18 |
* Output text is in visual order.
|
williamr@2
|
19 |
*
|
williamr@2
|
20 |
*
|
williamr@2
|
21 |
*/
|
williamr@2
|
22 |
|
williamr@2
|
23 |
|
williamr@2
|
24 |
|
williamr@2
|
25 |
#ifndef AKN_BIDI_TEXT_UTILS_H
|
williamr@2
|
26 |
#define AKN_BIDI_TEXT_UTILS_H
|
williamr@2
|
27 |
|
williamr@2
|
28 |
// INCLUDES
|
williamr@2
|
29 |
#include <e32base.h>
|
williamr@2
|
30 |
#include <uikon.hrh> // KEllipsis
|
williamr@2
|
31 |
#include <gdi.h> // For CCFont::TMeasureTextInput::TFlags
|
williamr@2
|
32 |
|
williamr@2
|
33 |
// CONSTANTS
|
williamr@2
|
34 |
|
williamr@2
|
35 |
const TInt KAknBidiExtraSpacePerLine = 4;
|
williamr@2
|
36 |
|
williamr@2
|
37 |
// FORWARD DECLARATIONS
|
williamr@2
|
38 |
|
williamr@2
|
39 |
|
williamr@2
|
40 |
// CLASS DECLARATION
|
williamr@2
|
41 |
|
williamr@2
|
42 |
/**
|
williamr@2
|
43 |
* Text utilities e.g. truncating and wrapping to be used in code that needs to
|
williamr@2
|
44 |
* support text that requires conversion from logical to visual order,
|
williamr@2
|
45 |
* e.g. Arabic/Hebrew Logical text is given as input to all
|
williamr@2
|
46 |
* methods. Output text is in visual order.
|
williamr@2
|
47 |
*
|
williamr@2
|
48 |
* Input text buffers given as parameters must contain extra space for some additional
|
williamr@2
|
49 |
* characters as stated in method descriptions.
|
williamr@2
|
50 |
*
|
williamr@2
|
51 |
* @lib avkon.dll
|
williamr@2
|
52 |
* @since 2.0
|
williamr@2
|
53 |
*/
|
williamr@2
|
54 |
class AknBidiTextUtils
|
williamr@2
|
55 |
{
|
williamr@2
|
56 |
public:
|
williamr@2
|
57 |
|
williamr@2
|
58 |
/**
|
williamr@2
|
59 |
* Overall paragraph directionality
|
williamr@2
|
60 |
*/
|
williamr@2
|
61 |
enum TParagraphDirectionality
|
williamr@2
|
62 |
{
|
williamr@2
|
63 |
EImplicit = 0, // implicit directionality of input text
|
williamr@2
|
64 |
ELeftToRight = 1,
|
williamr@2
|
65 |
ERightToLeft = 2
|
williamr@2
|
66 |
};
|
williamr@2
|
67 |
|
williamr@2
|
68 |
public: // New functions
|
williamr@2
|
69 |
|
williamr@2
|
70 |
/**
|
williamr@2
|
71 |
* Generic text clipping. This method allocates memory for visual buffer,
|
williamr@2
|
72 |
* and can leave in OOM situations.
|
williamr@2
|
73 |
*
|
williamr@2
|
74 |
* @since 2.0
|
williamr@2
|
75 |
*
|
williamr@2
|
76 |
* @param aLogicalText String to be clipped in logical order. This method
|
williamr@2
|
77 |
* converts it in visual order and clips it if necessary.
|
williamr@2
|
78 |
* The descriptor must contain extra space of at least
|
williamr@2
|
79 |
* KAknBidiExtraSpacePerLine. Otherwise, a panic is raised.
|
williamr@2
|
80 |
*
|
williamr@2
|
81 |
* @param aFont Font used when drawing the text.
|
williamr@2
|
82 |
*
|
williamr@2
|
83 |
* @param aMaxWidthInPixels Maximum width of text that is not be clipped.
|
williamr@2
|
84 |
*
|
williamr@2
|
85 |
* @param aMaxClippedWidthInPixels Maximum width of text that is clipped.
|
williamr@2
|
86 |
* Note that this should not be many pixels bigger than aMaxWidthInPixels
|
williamr@2
|
87 |
* because then truncation character could appear after fully fitting text.
|
williamr@2
|
88 |
*
|
williamr@2
|
89 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
90 |
*
|
williamr@2
|
91 |
* @param aClipChar The truncation character.
|
williamr@2
|
92 |
* 0xFFFF if no truncation character is to be used.
|
williamr@2
|
93 |
*
|
williamr@2
|
94 |
* @return ETrue if the text was clipped, EFalse otherwise.
|
williamr@2
|
95 |
*/
|
williamr@2
|
96 |
IMPORT_C static TBool ConvertToVisualAndClipL(
|
williamr@2
|
97 |
TDes& aLogicalText,
|
williamr@2
|
98 |
const CFont& aFont,
|
williamr@2
|
99 |
TInt aMaxWidthInPixels,
|
williamr@2
|
100 |
TInt aMaxClippedWidthInPixels,
|
williamr@2
|
101 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit,
|
williamr@2
|
102 |
TChar aClipChar = KEllipsis );
|
williamr@2
|
103 |
|
williamr@2
|
104 |
/**
|
williamr@2
|
105 |
* Generic text clipping. This method does not allocate memory and can
|
williamr@2
|
106 |
* be used in non-leaving functions. You must give a preallocated visual
|
williamr@2
|
107 |
* buffer as a parameter.
|
williamr@2
|
108 |
*
|
williamr@2
|
109 |
* @since 2.0
|
williamr@2
|
110 |
*
|
williamr@2
|
111 |
* @param aLogicalText String to be clipped in logical order.
|
williamr@2
|
112 |
*
|
williamr@2
|
113 |
* @param aVisualText The reordered text in visual form is returned here.
|
williamr@2
|
114 |
* This method converts aLogicalText into visual order
|
williamr@2
|
115 |
* and clips it if necessary. Maximum length of this
|
williamr@2
|
116 |
* descriptor must be at least
|
williamr@2
|
117 |
* aLogicalText.Length() + KAknBidiExtraSpacePerLine.
|
williamr@2
|
118 |
* otherwise a panic is raised.
|
williamr@2
|
119 |
*
|
williamr@2
|
120 |
* @param aFont Font used when drawing the text.
|
williamr@2
|
121 |
*
|
williamr@2
|
122 |
* @param aMaxWidthInPixels Maximum width of text that is not clipped.
|
williamr@2
|
123 |
*
|
williamr@2
|
124 |
* @param aMaxClippedWidthInPixels Maximum width of text that is clipped.
|
williamr@2
|
125 |
* Note that this should not be many pixels bigger than aMaxWidthInPixels
|
williamr@2
|
126 |
* because then truncation character could appear after fully fitting text.
|
williamr@2
|
127 |
*
|
williamr@2
|
128 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
129 |
*
|
williamr@2
|
130 |
* @param aClipChar The truncation character.
|
williamr@2
|
131 |
* 0xFFFF if no truncation character is to be used.
|
williamr@2
|
132 |
*
|
williamr@2
|
133 |
* @return ETrue if the text was clipped, EFalse otherwise.
|
williamr@2
|
134 |
*/
|
williamr@2
|
135 |
IMPORT_C static TBool ConvertToVisualAndClip(
|
williamr@2
|
136 |
const TDesC& aLogicalText,
|
williamr@2
|
137 |
TDes& aVisualText,
|
williamr@2
|
138 |
const CFont& aFont,
|
williamr@2
|
139 |
TInt aMaxWidthInPixels,
|
williamr@2
|
140 |
TInt aMaxClippedWidthInPixels,
|
williamr@2
|
141 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit,
|
williamr@2
|
142 |
TChar aClipChar = KEllipsis );
|
williamr@2
|
143 |
|
williamr@2
|
144 |
/**
|
williamr@2
|
145 |
* Tests how big run info array the given text requires and
|
williamr@2
|
146 |
* tries to increase the size of the array if required (stored in CAknEnv).
|
williamr@2
|
147 |
*
|
williamr@2
|
148 |
* This method is useful with the non-leaving version of
|
williamr@2
|
149 |
* ConvertToVisualAndClip(). By calling this method successfully
|
williamr@2
|
150 |
* (means KErrNone is returned) at any point during the lifetime of the application
|
williamr@2
|
151 |
* it is guaranteed that the text gets correctly converted in visual form even
|
williamr@2
|
152 |
* in out-of-memory situation when calling ConvertToVisualAndClip().
|
williamr@2
|
153 |
*
|
williamr@2
|
154 |
* Note that there is no use calling this method if you do not handle the
|
williamr@2
|
155 |
* return code, because the truncating methods already do that.
|
williamr@2
|
156 |
*
|
williamr@2
|
157 |
* @since 2.0
|
williamr@2
|
158 |
*
|
williamr@2
|
159 |
* @param aLogicalText Text in logical order.
|
williamr@2
|
160 |
*
|
williamr@2
|
161 |
* @return KErrNone or KErrNoMemory.
|
williamr@2
|
162 |
*/
|
williamr@2
|
163 |
IMPORT_C static TInt PrepareRunInfoArray( const TDesC& aLogicalText );
|
williamr@2
|
164 |
|
williamr@2
|
165 |
/**
|
williamr@2
|
166 |
* Converts a string in visual order and wraps it to an array of pointers.
|
williamr@2
|
167 |
* The maximum number of lines and line widths are specified in
|
williamr@2
|
168 |
* aLineWidthArray. The pointers in aWrappedArray are set to point to
|
williamr@2
|
169 |
* positions inside descriptor given in aLogicalText.
|
williamr@2
|
170 |
*
|
williamr@2
|
171 |
* @since 2.0
|
williamr@2
|
172 |
*
|
williamr@2
|
173 |
* @param aLogicalText Logical text to be wrapped. This method
|
williamr@2
|
174 |
* converts it in visual form (in strictly left to
|
williamr@2
|
175 |
* right order) and wraps it to lines.
|
williamr@2
|
176 |
* These lines can then be renderered using e.g.
|
williamr@2
|
177 |
* CGraphicsContext::DrawText().
|
williamr@2
|
178 |
* The descriptor must contain extra space of at least
|
williamr@2
|
179 |
* (aLineWidthArray.Count() * KAknBidiExtraSpacePerLine).
|
williamr@2
|
180 |
* Otherwise, a panic is raised.
|
williamr@2
|
181 |
*
|
williamr@2
|
182 |
* @param aLineWidthArray Line widths in pixels. Also determines maximum
|
williamr@2
|
183 |
* number of lines.
|
williamr@2
|
184 |
*
|
williamr@2
|
185 |
* @param aFont Used font.
|
williamr@2
|
186 |
*
|
williamr@2
|
187 |
* @param aWrappedArray Pointers to wrapped lines.
|
williamr@2
|
188 |
*
|
williamr@2
|
189 |
* @param aInsertTruncationChar Whether to insert truncation character
|
williamr@2
|
190 |
* (KEllipsis) or not if the text does not fit in
|
williamr@2
|
191 |
* given maximum number of lines.
|
williamr@2
|
192 |
*
|
williamr@2
|
193 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
194 |
*/
|
williamr@2
|
195 |
IMPORT_C static void ConvertToVisualAndWrapToArrayL(
|
williamr@2
|
196 |
TDes& aLogicalText,
|
williamr@2
|
197 |
const CArrayFix<TInt>& aLineWidthArray,
|
williamr@2
|
198 |
const CFont& aFont,
|
williamr@2
|
199 |
CArrayFix<TPtrC>& aWrappedArray,
|
williamr@2
|
200 |
TBool aInsertTruncationChar,
|
williamr@2
|
201 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit );
|
williamr@2
|
202 |
|
williamr@2
|
203 |
/**
|
williamr@2
|
204 |
* Converts a string in visual order and wraps it to an array of pointers.
|
williamr@2
|
205 |
* Constant line width is given. The pointers in aWrappedArray are set to
|
williamr@2
|
206 |
* point to positions inside the returned heap descriptor.
|
williamr@2
|
207 |
*
|
williamr@2
|
208 |
* @since 2.0
|
williamr@2
|
209 |
*
|
williamr@2
|
210 |
* @param aLogicalText Logical text to be wrapped. This method
|
williamr@2
|
211 |
* converts it in visual form (in strictly left to
|
williamr@2
|
212 |
* right order) and wraps it to lines. (The returned
|
williamr@2
|
213 |
* heap descriptor contains the string in visual
|
williamr@2
|
214 |
* order.)
|
williamr@2
|
215 |
* These lines can then be renderered using e.g.
|
williamr@2
|
216 |
* CGraphicsContext::DrawText().
|
williamr@2
|
217 |
*
|
williamr@2
|
218 |
* @param aLineWidth Constant line width in pixels.
|
williamr@2
|
219 |
*
|
williamr@2
|
220 |
* @param aFont Used font.
|
williamr@2
|
221 |
*
|
williamr@2
|
222 |
* @param aWrappedArray Pointers to wrapped lines.
|
williamr@2
|
223 |
*
|
williamr@2
|
224 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
225 |
*
|
williamr@2
|
226 |
* @return Heap descriptor containing the wrapped string in visual form.
|
williamr@2
|
227 |
* Ownership is transferred to the caller.
|
williamr@2
|
228 |
*/
|
williamr@2
|
229 |
IMPORT_C static HBufC* ConvertToVisualAndWrapToArrayL(
|
williamr@2
|
230 |
const TDesC& aLogicalText,
|
williamr@2
|
231 |
TInt aLineWidth,
|
williamr@2
|
232 |
const CFont& aFont,
|
williamr@2
|
233 |
CArrayFix<TPtrC>& aWrappedArray,
|
williamr@2
|
234 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit );
|
williamr@2
|
235 |
|
williamr@2
|
236 |
/**
|
williamr@2
|
237 |
* Converts a string in visual order and chops each line when a line break
|
williamr@2
|
238 |
* character is encountered.
|
williamr@2
|
239 |
* Clips at the end of each line if there isn't enough space
|
williamr@2
|
240 |
* on that line. When clipping, KEllipsis (shown as 3 dots) is inserted at
|
williamr@2
|
241 |
* the end of the line. The pointers in aChoppedArray are set to point to
|
williamr@2
|
242 |
* positions inside aLogicalText.
|
williamr@2
|
243 |
*
|
williamr@2
|
244 |
* @since 2.0
|
williamr@2
|
245 |
*
|
williamr@2
|
246 |
* @param aLogicalText Logical text to be chopped. This method
|
williamr@2
|
247 |
* converts it in visual form (in strictly left to
|
williamr@2
|
248 |
* right order) and chops each line when a line break
|
williamr@2
|
249 |
* character is encountered.
|
williamr@2
|
250 |
* These lines can then be renderered using e.g.
|
williamr@2
|
251 |
* CGraphicsContext::DrawText().
|
williamr@2
|
252 |
* The descriptor must contain extra space of at least
|
williamr@2
|
253 |
* (aLineWidthArray.Count() * KAknBidiExtraSpacePerLine).
|
williamr@2
|
254 |
* Otherwise, a panic is raised.
|
williamr@2
|
255 |
*
|
williamr@2
|
256 |
* @param aLineWidthArray Line widths in pixels. Also determines maximum
|
williamr@2
|
257 |
* number of lines.
|
williamr@2
|
258 |
*
|
williamr@2
|
259 |
* @param aFont Used font.
|
williamr@2
|
260 |
*
|
williamr@2
|
261 |
* @param aChoppedArray Pointers to chopped lines.
|
williamr@2
|
262 |
*
|
williamr@2
|
263 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
264 |
*/
|
williamr@2
|
265 |
IMPORT_C static void ConvertToVisualAndChopToArrayL(
|
williamr@2
|
266 |
TDes& aLogicalText,
|
williamr@2
|
267 |
const CArrayFix<TInt>& aLineWidthArray,
|
williamr@2
|
268 |
const CFont& aFont,
|
williamr@2
|
269 |
CArrayFix<TPtrC>& aChoppedArray,
|
williamr@2
|
270 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit );
|
williamr@2
|
271 |
|
williamr@2
|
272 |
/**
|
williamr@2
|
273 |
* Converts a string in visual order and chops each line when a line break
|
williamr@2
|
274 |
* character is encountered.
|
williamr@2
|
275 |
* Clips at the end of each line if there isn't enough space
|
williamr@2
|
276 |
* on that line. When clipping, KEllipsis (shown as 3 dots) is inserted at
|
williamr@2
|
277 |
* the end of the line. The pointers in aChoppedArray are set to point to
|
williamr@2
|
278 |
* positions inside the returned heap descriptor.
|
williamr@2
|
279 |
*
|
williamr@2
|
280 |
* @since 2.0
|
williamr@2
|
281 |
*
|
williamr@2
|
282 |
* @param aLogicalText Logical text to be chopped. This method
|
williamr@2
|
283 |
* converts it in visual form (in strictly left to
|
williamr@2
|
284 |
* right order) and chops each line when a line break
|
williamr@2
|
285 |
* character is encountered. (The returned
|
williamr@2
|
286 |
* heap descriptor contains the string in visual
|
williamr@2
|
287 |
* order.)
|
williamr@2
|
288 |
* These lines can then be renderered using e.g.
|
williamr@2
|
289 |
* CGraphicsContext::DrawText().
|
williamr@2
|
290 |
*
|
williamr@2
|
291 |
* @param aLineWidth Constant line width in pixels
|
williamr@2
|
292 |
*
|
williamr@2
|
293 |
* @param aFont Used font.
|
williamr@2
|
294 |
*
|
williamr@2
|
295 |
* @param aChoppedArray Pointers to chopped lines.
|
williamr@2
|
296 |
*
|
williamr@2
|
297 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
298 |
*
|
williamr@2
|
299 |
* @return Heap descriptor containing the chopped string in visual form.
|
williamr@2
|
300 |
* Ownership is transferred to the caller.
|
williamr@2
|
301 |
*/
|
williamr@2
|
302 |
IMPORT_C static HBufC* ConvertToVisualAndChopToArrayL(
|
williamr@2
|
303 |
const TDesC& aLogicalText,
|
williamr@2
|
304 |
TInt aLineWidth,
|
williamr@2
|
305 |
const CFont& aFont,
|
williamr@2
|
306 |
CArrayFix<TPtrC>& aChoppedArray,
|
williamr@2
|
307 |
TParagraphDirectionality aDirectionality = EImplicit );
|
williamr@2
|
308 |
|
williamr@2
|
309 |
/**
|
williamr@2
|
310 |
* Converts a string in visual order and wraps it to lines by inserting
|
williamr@2
|
311 |
* '\n' after each line in text.
|
williamr@2
|
312 |
* The result is copied into aWrappedString.
|
williamr@2
|
313 |
*
|
williamr@2
|
314 |
* @since 2.0
|
williamr@2
|
315 |
*
|
williamr@2
|
316 |
* @param aLogicalText Logical text to be wrapped. This method
|
williamr@2
|
317 |
* converts it in visual form (in strictly left to
|
williamr@2
|
318 |
* right order) and wraps it to lines in aWrappedString.
|
williamr@2
|
319 |
* '\n' is inserted after each line.
|
williamr@2
|
320 |
* These lines can then be renderered using e.g.
|
williamr@2
|
321 |
* CGraphicsContext::DrawText().
|
williamr@2
|
322 |
*
|
williamr@2
|
323 |
* @param aLineWidthArray Line widths in pixels. Also determines maximum
|
williamr@2
|
324 |
* number of lines.
|
williamr@2
|
325 |
*
|
williamr@2
|
326 |
* @param aFont Used font.
|
williamr@2
|
327 |
*
|
williamr@2
|
328 |
* @param aWrappedString Wrapped string. The maximum length of the descriptor
|
williamr@2
|
329 |
* must be at least
|
williamr@2
|
330 |
* ( aLogicalText.Length() +
|
williamr@2
|
331 |
* aLineWidthArray.Count() * (KAknBidiExtraSpacePerLine+1) ).
|
williamr@2
|
332 |
* Otherwise, a panic is raised.
|
williamr@2
|
333 |
*
|
williamr@2
|
334 |
* @param aInsertTruncationChar Whether to insert truncation character
|
williamr@2
|
335 |
* (KEllipsis) or not if the text does not fit in
|
williamr@2
|
336 |
* given maximum number of lines.
|
williamr@2
|
337 |
*
|
williamr@2
|
338 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
339 |
*/
|
williamr@2
|
340 |
IMPORT_C static void ConvertToVisualAndWrapToStringL(
|
williamr@2
|
341 |
const TDesC& aLogicalText,
|
williamr@2
|
342 |
const CArrayFix<TInt>& aLineWidthArray,
|
williamr@2
|
343 |
const CFont& aFont,
|
williamr@2
|
344 |
TDes& aWrappedString,
|
williamr@2
|
345 |
TBool aInsertTruncationChar,
|
williamr@2
|
346 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit );
|
williamr@2
|
347 |
|
williamr@2
|
348 |
// -------------------------------------------------------------------------
|
williamr@2
|
349 |
// The following methods are introduced in release 2.1
|
williamr@2
|
350 |
// -------------------------------------------------------------------------
|
williamr@2
|
351 |
|
williamr@2
|
352 |
/**
|
williamr@2
|
353 |
* Converts a string in visual order and wraps it to an array of pointers.
|
williamr@2
|
354 |
* Line widths are specified in aLineWidthArray. If all the text does not fit
|
williamr@2
|
355 |
* in the amount of lines in aLineWidthArray, the last line width in the array
|
williamr@2
|
356 |
* is used for all the remaining lines. The pointers in aWrappedArray are set
|
williamr@2
|
357 |
* to point to positions inside the returned heap descriptor.
|
williamr@2
|
358 |
*
|
williamr@2
|
359 |
* @since 2.1
|
williamr@2
|
360 |
*
|
williamr@2
|
361 |
* @param aLogicalText Logical text to be wrapped. This method
|
williamr@2
|
362 |
* converts it in visual form (in strictly left to
|
williamr@2
|
363 |
* right order) and wraps it to lines. (The returned
|
williamr@2
|
364 |
* heap descriptor contains the string in visual
|
williamr@2
|
365 |
* order.)
|
williamr@2
|
366 |
* These lines can then be renderered using e.g.
|
williamr@2
|
367 |
* CGraphicsContext::DrawText().
|
williamr@2
|
368 |
*
|
williamr@2
|
369 |
* @param aLineWidthArray Line widths in pixels. If the whole text does
|
williamr@2
|
370 |
* not fit in the number of lines specified in the
|
williamr@2
|
371 |
* array, the last width is used for the remaining
|
williamr@2
|
372 |
* lines.
|
williamr@2
|
373 |
*
|
williamr@2
|
374 |
* @param aFont Used font.
|
williamr@2
|
375 |
*
|
williamr@2
|
376 |
* @param aWrappedArray Pointers to wrapped lines.
|
williamr@2
|
377 |
*
|
williamr@2
|
378 |
* @param aDirectionality Paragraph directionality.
|
williamr@2
|
379 |
*
|
williamr@2
|
380 |
* @return Heap descriptor containing the wrapped string in visual form.
|
williamr@2
|
381 |
* Ownership is transferred to the caller.
|
williamr@2
|
382 |
*/
|
williamr@2
|
383 |
IMPORT_C static HBufC* ConvertToVisualAndWrapToArrayWholeTextL(
|
williamr@2
|
384 |
const TDesC& aLogicalText,
|
williamr@2
|
385 |
const CArrayFix<TInt>& aLineWidthArray,
|
williamr@2
|
386 |
const CFont& aFont,
|
williamr@2
|
387 |
CArrayFix<TPtrC>& aWrappedArray,
|
williamr@2
|
388 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality = EImplicit );
|
williamr@2
|
389 |
|
williamr@2
|
390 |
/**
|
williamr@2
|
391 |
* Measures the full horizontal width in pixels of the passed-in text using a particular font,
|
williamr@2
|
392 |
* including in the width any side-bearings of the glyphs at the ends of the text, and any
|
williamr@2
|
393 |
* declared "advance" of the run of glyphs.
|
williamr@2
|
394 |
*
|
williamr@2
|
395 |
* It cannot be used for vertical text measurement.
|
williamr@2
|
396 |
*
|
williamr@2
|
397 |
* Side-bearings are parts of glyphs that extend left or right from the normal width
|
williamr@2
|
398 |
* or "advance" of the glyph. A left side-bearing, for instance, will overlap with a glyph
|
williamr@2
|
399 |
* to its left. Another way of thinking about this is that the origin (0,0) of the glyph is
|
williamr@2
|
400 |
* not at its bottom left.
|
williamr@2
|
401 |
*
|
williamr@2
|
402 |
* The advance of a run of glyphs is the sum of the advances - once in visual ordering and
|
williamr@2
|
403 |
* shaping has been performed - of all the glyphs. It is defined relative to a drawing origin.
|
williamr@2
|
404 |
*
|
williamr@2
|
405 |
* Within runs of text, side-bearings do not contribute to the width of the text. However,
|
williamr@2
|
406 |
* at the (visual) ends of text, they are likely to need to be counted, depending upon the
|
williamr@2
|
407 |
* exact use case.
|
williamr@2
|
408 |
*
|
williamr@2
|
409 |
* This method returns the width of the horizontal envelope of the text by taking the extreme
|
williamr@2
|
410 |
* horizontal extents of the text bounds rectangle (which includes side-bearings on either end)
|
williamr@2
|
411 |
* and the extent of the advance. Thus it returns the width of :
|
williamr@2
|
412 |
* Min(<left_text_bound>, 0), Max( <right_text_bound>, <advance>)
|
williamr@2
|
413 |
*
|
williamr@2
|
414 |
* This method should be used when the proposed text is going to be drawn using any horizontal
|
williamr@2
|
415 |
* CGraphicsContext::DrawText drawing API.
|
williamr@2
|
416 |
*
|
williamr@2
|
417 |
* The text can be in visual or logical order.
|
williamr@2
|
418 |
*
|
williamr@2
|
419 |
* @since 3.1
|
williamr@2
|
420 |
* @param aFont Font to use
|
williamr@2
|
421 |
* @param aText Text to be measured
|
williamr@2
|
422 |
* @param aOrder Whether the text provided is in visual or logical order
|
williamr@2
|
423 |
* @return width of the text in pixels.
|
williamr@2
|
424 |
*/
|
williamr@2
|
425 |
IMPORT_C static TInt AknBidiTextUtils::MeasureTextBoundsWidth(
|
williamr@2
|
426 |
const CFont& aFont,
|
williamr@2
|
427 |
const TDesC& aText,
|
williamr@2
|
428 |
CFont::TMeasureTextInput::TFlags aOrder);
|
williamr@2
|
429 |
|
williamr@2
|
430 |
private:
|
williamr@2
|
431 |
|
williamr@2
|
432 |
static TBool DoConvertToVisualAndClip(
|
williamr@2
|
433 |
const TDesC& aLogicalText,
|
williamr@2
|
434 |
TDes& aVisualText,
|
williamr@2
|
435 |
const CFont& aFont,
|
williamr@2
|
436 |
TInt aMaxWidthInPixels,
|
williamr@2
|
437 |
TInt aMaxClippedWidthInPixels,
|
williamr@2
|
438 |
AknBidiTextUtils::TParagraphDirectionality aDirectionality,
|
williamr@2
|
439 |
TChar aClipChar );
|
williamr@2
|
440 |
|
williamr@2
|
441 |
/**
|
williamr@2
|
442 |
* C++ default constructor.
|
williamr@2
|
443 |
*/
|
williamr@2
|
444 |
AknBidiTextUtils();
|
williamr@2
|
445 |
};
|
williamr@2
|
446 |
|
williamr@2
|
447 |
#endif // AKN_BIDI_TEXT_UTILS_H
|
williamr@2
|
448 |
|
williamr@2
|
449 |
// End of File
|