1 tagma.h |
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // The main header file for TAGMA, the low-level text formatting engine for EPOC. |
|
15 // 'Tm' stands for 'TAGMA' and is the standard prefix for TAGMA classes, after |
|
16 // the C, T, or whatever. |
|
17 // |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 #ifndef __TAGMA_H__ |
|
23 #define __TAGMA_H__ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <openfont.h> |
|
27 #include <txtfrmat.h> |
|
28 #include <txtstyle.h> |
|
29 #include <linebreak.h> |
|
30 |
|
31 // forward declarations |
|
32 class TTmLineInfo; |
|
33 class CTmTextImp; |
|
34 class RWindow; |
|
35 class RWsSession; |
|
36 class RParagraphStyleInfo; |
|
37 class CStyleList; |
|
38 class TTmDocPosSpec; |
|
39 class TTmDocPos; |
|
40 class TCursorSelection; |
|
41 class TTmHighlightExtensions; |
|
42 class TBidirectionalContext; |
|
43 |
|
44 /** |
|
45 A bit mask for selecting one or more attributes of a TTmCharFormat object. |
|
46 @internalComponent |
|
47 */ |
|
48 class TTmCharFormatMask |
|
49 |
|
50 { |
|
51 public: |
|
52 /** Constants, that are also bit assignments, representing character format attributes */ |
|
53 enum TAttrib |
|
54 { |
|
55 EFontName = 0x1, |
|
56 EFontCoverage = 0x2, |
|
57 EBold = 0x4, |
|
58 EItalic = 0x8, |
|
59 ESerif = 0x10, |
|
60 EMonoWidth = 0x20, |
|
61 EHeight = 0x40, |
|
62 EPrintPosition = 0x80, |
|
63 ETextColor = 0x100, |
|
64 EBackgroundColor = 0x200, |
|
65 EBackground = 0x400, |
|
66 EUnderline = 0x800, |
|
67 EStrikethrough = 0x1000, |
|
68 EShadow = 0x2000, |
|
69 EUserDefinedEffects = 0x4000, |
|
70 ELanguage = 0x8000, |
|
71 EPictureAlignment = 0x10000 |
|
72 }; |
|
73 |
|
74 inline TTmCharFormatMask(); |
|
75 IMPORT_C TTmCharFormatMask(const TCharFormatMask& aMask); |
|
76 IMPORT_C void GetTCharFormatMask(TCharFormatMask& aMask) const; |
|
77 inline void Clear(TAttrib aAttrib); |
|
78 inline void Set(TAttrib aAttrib); |
|
79 inline TBool IsSet(TAttrib aAttrib); |
|
80 |
|
81 TUint iFlags; |
|
82 }; |
|
83 |
|
84 /** |
|
85 A character format; all dimensions are in twips. A character format object |
|
86 stores all text style attributes that can differ from any one character to the |
|
87 next. Attributes that affect an entire paragraph only are kept in RTmParFormat |
|
88 objects. |
|
89 @internalComponent |
|
90 */ |
|
91 class TTmCharFormat |
|
92 { |
|
93 public: |
|
94 /** Bit assignments for effects */ |
|
95 enum |
|
96 { |
|
97 EBackground = 1, ///< Text background is drawn in the background colour |
|
98 ERounded = 2, ///< Text background (if any) has rounded corners |
|
99 EUnderline = 4, ///< Text is underlined |
|
100 EStrikethrough = 8, ///< Text is struck through with a horizontal line. |
|
101 EShadow = 16, ///< Text has a drop shadow. |
|
102 /** Bits 24-31 are reserved for styles defined by the custom drawer. */ |
|
103 EUserDefinedMask = 0xFF000000, |
|
104 /** Shift TCharFormat highlight styles left by this to get the |
|
105 TTmCharFormat effects portion. */ |
|
106 EUserDefinedShift = 24, |
|
107 /** For custom drawers: draw whatever is wanted for "no matches" in the FEP. */ |
|
108 ENoMatchesIndicator = 0x4000000, |
|
109 /** Reset if the effect in bits 24-30 is defined defined by Symbian, |
|
110 set if it is defined externally. */ |
|
111 ECustomDrawEffectIsExternallyDefined = 0x80000000 |
|
112 }; |
|
113 |
|
114 /** Picture alignment */ |
|
115 enum TPictureAlignment |
|
116 { |
|
117 EPictureAlignBaseline, |
|
118 EPictureAlignTop, |
|
119 EPictureAlignBottom, |
|
120 EPictureAlignCenter |
|
121 }; |
|
122 |
|
123 IMPORT_C TTmCharFormat(); |
|
124 IMPORT_C TTmCharFormat(const TDesC& aFontName,TInt aFontHeight); |
|
125 IMPORT_C void operator=(const TCharFormat& aFormat); |
|
126 inline TTmCharFormat(const TCharFormat& aFormat); |
|
127 IMPORT_C void GetTCharFormat(TCharFormat& aFormat) const; |
|
128 IMPORT_C TBool operator==(const TTmCharFormat& aFormat) const; |
|
129 inline TBool operator!=(const TTmCharFormat& aFormat) const; |
|
130 |
|
131 TOpenFontSpec iFontSpec; |
|
132 TLogicalRgb iTextColor; |
|
133 TLogicalRgb iBackgroundColor; // used only when EBackground flag is set in iEffects |
|
134 TUint iEffects; // bit flags as defined above; |
|
135 // note that effects NEVER change character metrics and so can |
|
136 // be ignored when measuring text |
|
137 TUint iLanguage; // language used for proofing |
|
138 TPictureAlignment iPictureAlignment;// vertical alignment of embedded objects |
|
139 TUint iTag; // tag for use by URL parsers, etc.; a way of marking a range of |
|
140 // text without using any typographic attributes |
|
141 }; |
|
142 |
|
143 /** |
|
144 A tabulation position, measured from the start of the line, which will be |
|
145 the left end for paragraphs with a left-to-right base direction, and vice |
|
146 versa. |
|
147 @internalComponent |
|
148 */ |
|
149 class TTmTab |
|
150 |
|
151 { |
|
152 public: |
|
153 /** Tab type */ |
|
154 enum TType |
|
155 { |
|
156 EStandardTab, // text is placed after the tab, in the current paragraph direction |
|
157 ECenterTab, // text is centred around the tab |
|
158 EReverseTab // text is placed before the tab, in the current paragraph direction |
|
159 }; |
|
160 |
|
161 inline TTmTab(); |
|
162 inline TTmTab(const TTabStop& aTab); |
|
163 IMPORT_C void operator=(const TTabStop& aTab); |
|
164 IMPORT_C void GetTTabStop(TTabStop& aTab) const; |
|
165 IMPORT_C TBool operator==(const TTmTab& aTab) const; |
|
166 inline TBool operator!=(const TTmTab& aTab) const; |
|
167 |
|
168 TInt iPosition; |
|
169 TType iType; |
|
170 }; |
|
171 |
|
172 /** |
|
173 A bullet or other label inserted automatically at the start of a paragraph. |
|
174 As well as an actual bullet, it can be a number or a letter. |
|
175 @internalComponent |
|
176 */ |
|
177 class TTmBullet |
|
178 |
|
179 { |
|
180 public: |
|
181 /** Bullet style */ |
|
182 enum TStyle |
|
183 { |
|
184 EBulletStyle, |
|
185 EArabicNumberStyle, |
|
186 ESmallRomanNumberStyle, |
|
187 ECapitalRomanNumberStyle, |
|
188 ESmallLetterStyle, |
|
189 ECapitalLetterStyle |
|
190 }; |
|
191 |
|
192 /** The alignment within the margin of bullets or other text used in TTmBullet objects */ |
|
193 enum TAlignment |
|
194 { |
|
195 /** Bullet forward aligned. */ |
|
196 ELeftAlign, |
|
197 /** Bullet centre aligned. */ |
|
198 ECenterAlign, |
|
199 /** Bullet reverse aligned. */ |
|
200 ERightAlign |
|
201 }; |
|
202 |
|
203 IMPORT_C TTmBullet(); |
|
204 IMPORT_C void operator=(const TBullet& aBullet); |
|
205 inline TTmBullet(const TBullet& aBullet); |
|
206 IMPORT_C void GetTBullet(TBullet& aBullet) const; |
|
207 IMPORT_C TBool operator==(const TTmBullet& aBullet) const; |
|
208 inline TBool operator!=(const TTmBullet& aBullet) const; |
|
209 |
|
210 TChar iCharacterCode; // the bullet or other symbol used if iStyle is EBulletStyle |
|
211 TOpenFontSpec iFontSpec; |
|
212 TBool iHangingIndent; |
|
213 TLogicalRgb iColor; |
|
214 TStyle iStyle; // is this a bullet or a number or a letter? |
|
215 TInt iStartNumber; // the number of the first paragraph in a run of paragraphs in this style |
|
216 TAlignment iAlignment; // alignment of the bullet or number within the margin |
|
217 }; |
|
218 |
|
219 /** |
|
220 A specification of a paragraph border rule: that is, a line or lines drawn |
|
221 above, below, to the left, or to the right of a paragraph. |
|
222 @internalComponent |
|
223 */ |
|
224 class TTmParBorder |
|
225 |
|
226 { |
|
227 public: |
|
228 /** Paragraph border style */ |
|
229 enum TStyle |
|
230 { |
|
231 ESolidStyle, |
|
232 EDoubleStyle, |
|
233 EDotStyle, |
|
234 EDashStyle, |
|
235 EDotDashStyle, |
|
236 EDotDotDashStyle |
|
237 }; |
|
238 |
|
239 IMPORT_C TTmParBorder(); |
|
240 IMPORT_C void operator=(const TParaBorder& aBorder); |
|
241 inline TTmParBorder(const TParaBorder& aBorder); |
|
242 IMPORT_C void GetTParaBorder(TParaBorder& aBorder) const; |
|
243 IMPORT_C TBool operator==(const TTmParBorder& aBorder) const; |
|
244 inline TBool operator!=(const TTmParBorder& aBorder) const; |
|
245 |
|
246 TStyle iStyle; |
|
247 TInt iWeight; |
|
248 TLogicalRgb iColor; |
|
249 TBool iAutoColor; |
|
250 }; |
|
251 |
|
252 |
|
253 /** |
|
254 A bit mask for selecting one or more attributes of an RTmParFormat. |
|
255 @internalComponent |
|
256 */ |
|
257 class TTmParFormatMask |
|
258 |
|
259 { |
|
260 public: |
|
261 /** Constants, that are also bit assignments, representing paragraph format attributes */ |
|
262 enum TAttrib |
|
263 { |
|
264 EAlignment = 0x1, |
|
265 EDirection = 0x2, |
|
266 EKeepTogether = 0x4, |
|
267 EKeepWithNext = 0x8, |
|
268 EStartNewPage = 0x10, |
|
269 EWidowOrphan = 0x20, |
|
270 ENoWrap = 0x40, |
|
271 EExactLineSpacing = 0x80, |
|
272 EPixelLineSpacing = 0x100, |
|
273 ELeadingMargin = 0x200, |
|
274 ETrailingMargin = 0x400, |
|
275 EFirstLineIndent = 0x800, |
|
276 ELineSpacing = 0x1000, |
|
277 ESpaceAbove = 0x2000, |
|
278 ESpaceBelow = 0x4000, |
|
279 ETabSize = 0x8000, |
|
280 EBorderMargin = 0x10000, |
|
281 ETabList = 0x20000, |
|
282 EBullet = 0x40000, |
|
283 EBorder = 0x80000 |
|
284 }; |
|
285 |
|
286 inline TTmParFormatMask(); |
|
287 IMPORT_C TTmParFormatMask(const TParaFormatMask& aMask); |
|
288 IMPORT_C void GetTParaFormatMask(TParaFormatMask& aMask) const; |
|
289 inline void Clear(TAttrib aAttrib); |
|
290 inline void Set(TAttrib aAttrib); |
|
291 inline TBool IsSet(TAttrib aAttrib); |
|
292 |
|
293 TUint iFlags; |
|
294 }; |
|
295 |
|
296 /** |
|
297 Paragraph format; all dimensions are in twips unless otherwise specified. |
|
298 @internalComponent |
|
299 */ |
|
300 class RTmParFormat |
|
301 |
|
302 { |
|
303 public: |
|
304 /** Index used to select one of the four borders of a paragraph */ |
|
305 enum TBorderIndex |
|
306 { |
|
307 ETopBorder = 0, |
|
308 EBottomBorder = 1, |
|
309 ELeadingBorder = 2, |
|
310 ETrailingBorder = 3, |
|
311 }; |
|
312 |
|
313 /** Bit assignments for RTmParFormat::iFlags. */ |
|
314 enum |
|
315 { |
|
316 /** Base direction of paragraph is right-to-left (as for Arabic) */ |
|
317 ERightToLeft = 1, |
|
318 /** Do not allow paragraph to straddle page boundaries. */ |
|
319 EKeepTogether = 2, |
|
320 /** Put this paragraph on the same page as the next. */ |
|
321 EKeepWithNext = 4, |
|
322 /** Put this paragraph at the start of a new page. */ |
|
323 EStartNewPage = 8, |
|
324 /** Suppress widows and orphans. */ |
|
325 EWidowOrphan = 16, |
|
326 /** Suppresses line breaking. */ |
|
327 ENoWrap = 32, |
|
328 /** Force line spacing distance to be respected even on lines that are |
|
329 * taller than the specified height. */ |
|
330 EExactLineSpacing = 64, |
|
331 /** Line spaceing is in pixels, not twips. */ |
|
332 EPixelLineSpacing = 128, |
|
333 /** Work out paragraph directionality from the text. */ |
|
334 EDirectionalityFromText = 256 |
|
335 }; |
|
336 |
|
337 /** Paragraph alignment */ |
|
338 enum TAlignment |
|
339 { |
|
340 EAlignNormalBidirectional, |
|
341 EAlignNormal = EAlignNormalBidirectional, /** @deprecated in 7.0s */ |
|
342 EAlignCenter, |
|
343 EAlignReverseBidirectional, |
|
344 EAlignReverse = EAlignReverseBidirectional, /** @deprecated in 7.0s */ |
|
345 EAlignJustify, |
|
346 EAlignAbsoluteLeft, |
|
347 EAlignAbsoluteRight |
|
348 }; |
|
349 |
|
350 IMPORT_C RTmParFormat(); |
|
351 IMPORT_C void Close(); |
|
352 #ifdef _DEBUG |
|
353 inline ~RTmParFormat(); |
|
354 #endif |
|
355 IMPORT_C void CopyL(const RTmParFormat& aFormat); |
|
356 IMPORT_C void CopyL(const CParaFormat& aFormat); |
|
357 IMPORT_C void GetCParaFormatL(CParaFormat& aFormat) const; |
|
358 IMPORT_C TBool operator==(const RTmParFormat& aFormat) const; |
|
359 inline TBool operator!=(const RTmParFormat& aFormat) const; |
|
360 IMPORT_C TInt Tabs() const; |
|
361 inline const TTmTab& Tab(TInt aIndex) const; |
|
362 inline const TTmBullet* Bullet() const; |
|
363 inline const TTmParBorder* Border(TBorderIndex aIndex) const; |
|
364 IMPORT_C TBool HaveBorders() const; |
|
365 inline TBool RightToLeft() const; |
|
366 |
|
367 TAlignment iAlignment; |
|
368 TUint iFlags; // bit flags as defined above |
|
369 TInt iLeadingMargin; // left margin, or right if right-to-left |
|
370 TInt iTrailingMargin; // right margin, or left if right-to-left |
|
371 TInt iFirstLineIndent; // added to first line leading margin |
|
372 TInt iLineSpacing; // distance between baselines |
|
373 TInt iSpaceAbove; // space above the paragraph |
|
374 TInt iSpaceBelow; // space below the paragraph |
|
375 TInt iTabSize; // default size of tabs |
|
376 TInt iBorderMargin; // distance between the text and the border if any |
|
377 TLogicalRgb iBackgroundColor; // paragraph background colour |
|
378 |
|
379 private: |
|
380 RTmParFormat(const RTmParFormat& aFormat); // deliberately unimplemented |
|
381 void operator=(const RTmParFormat& aFormat);// deliberately unimplemented |
|
382 |
|
383 RArray<TTmTab>* iTabList; // custom tabs if any |
|
384 TTmBullet* iBullet; // bullet if any |
|
385 TTmParBorder* iBorder[4]; // borders if any |
|
386 }; |
|
387 |
|
388 /** |
|
389 The text customization interface. You can customize the colors, word |
|
390 spacing, line breaking, line height calculation, background drawing, and text |
|
391 appearance, of a text object by supplying an implementation of the MTmCustom |
|
392 class, either directly (as in CTmText::CustomizeL, which takes a pointer to |
|
393 MTmCustom) or indirectly, making use of the fact that MTmSource is derived from |
|
394 MTmCustom (as in CTmTextLayout::SetTextL, which takes a reference to |
|
395 MTmSource). |
|
396 @publishedAll |
|
397 @released |
|
398 */ |
|
399 class MTmCustom |
|
400 : public MLineBreaker |
|
401 { |
|
402 public: |
|
403 /** |
|
404 TLineHeightParam structure is used in MTmCustom::SetLineHeight() method to set |
|
405 text line height related parameters such as max character height, max ascent and descent, |
|
406 height and depth of the tallest pictures (top-aligned, bottom-aligned or centered). |
|
407 @see MTmCustom::SetLineHeight() |
|
408 @publishedAll |
|
409 @released |
|
410 */ |
|
411 class TLineHeightParam |
|
412 { |
|
413 public: |
|
414 inline TLineHeightParam(); |
|
415 /** Height of the highest character in the line. */ |
|
416 TInt iMaxCharHeight; |
|
417 /** Depth of the deepest character in the line. */ |
|
418 TInt iMaxCharDepth; |
|
419 /** Height plus depth of the tallest top-aligned picture. */ |
|
420 TInt iMaxTopPictureHeight; |
|
421 /** Height plus depth of the tallest bottom-aligned picture. */ |
|
422 TInt iMaxBottomPictureHeight; |
|
423 /** Height plus depth of the tallest centred picture. */ |
|
424 TInt iMaxCenterPictureHeight; |
|
425 /** Height of the tallest character of any in the fonts in the line. */ |
|
426 TInt iFontMaxCharHeight; |
|
427 /** Depth of the deepest character of any in the fonts in the line. */ |
|
428 TInt iFontMaxCharDepth; |
|
429 /** Maximum ascent of the fonts in the line. */ |
|
430 TInt iFontMaxAscent; |
|
431 /** Maximum descent of the fonts in the line. */ |
|
432 TInt iFontMaxDescent; |
|
433 /** Desired precise or minimum line height. */ |
|
434 TInt iDesiredLineHeight; |
|
435 /** True if the line height must be precise. */ |
|
436 TBool iExactLineHeight; |
|
437 }; |
|
438 |
|
439 /** The Unicode line breaking classes; see Unicode Technical Report 14. |
|
440 Not a named enumerated type, so that overriding applications can add new |
|
441 line breaking classes freely. |
|
442 The description of each constant gives the name of the line-breaking |
|
443 class, an example and a brief, imprecise description of the default |
|
444 behaviour of characters of that class. |
|
445 */ |
|
446 enum |
|
447 { |
|
448 /** Opening Punctuation (e.g. '['). Breaking after prohibited. */ |
|
449 EOpLineBreakClass, |
|
450 /** Closing Punctuation (e.g. ']'). Breaking before prohibited. */ |
|
451 EClLineBreakClass, |
|
452 /** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */ |
|
453 EQuLineBreakClass, |
|
454 /** Glue (e.g. Non-breaking space). Breaking before and after prohibited |
|
455 unless spaces are present. */ |
|
456 EGlLineBreakClass, |
|
457 /** Non-Starter (e.g. small Japanese kana). Breaking before prohibited |
|
458 if no spaces present. */ |
|
459 ENsLineBreakClass, |
|
460 /** Exclamation or Interrogation (e.g. '?'). Like closing punctuation |
|
461 except before Postfix or Non-starter. */ |
|
462 EExLineBreakClass, |
|
463 /** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before |
|
464 Alphabetic. */ |
|
465 ESyLineBreakClass, |
|
466 /** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before |
|
467 Numeric. */ |
|
468 EIsLineBreakClass, |
|
469 /** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */ |
|
470 EPrLineBreakClass, |
|
471 /** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */ |
|
472 EPoLineBreakClass, |
|
473 /** Numeric (e.g. '1'). */ |
|
474 ENuLineBreakClass, |
|
475 /** Alphabetic (e.g. 'a'). */ |
|
476 EAlLineBreakClass, |
|
477 /** Ideographic (e.g. Japanese Kanji). Generally break before or after */ |
|
478 EIdLineBreakClass, |
|
479 /** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */ |
|
480 EInLineBreakClass, |
|
481 /** Hyphen (e.g. '-'). Allows a break after except before Numeric. */ |
|
482 EHyLineBreakClass, |
|
483 /** Break After. Generally allow a break after. Breaking between Break |
|
484 Afters not separated by spaces is prohibited. */ |
|
485 EBaLineBreakClass, |
|
486 /** Break Before. Generally allow a break before. Breaking between Break |
|
487 Befores not separated by spaces is prohibited. */ |
|
488 EBbLineBreakClass, |
|
489 /** Break Before and After. Generally allow a break before or after. |
|
490 Breaking between Break Before and Afters is prohibited, even if spaces |
|
491 are present. */ |
|
492 EB2LineBreakClass, |
|
493 /** Zero-Width Space. Allow a break. */ |
|
494 EZwLineBreakClass, |
|
495 /** Combining Mark. Takes on the class of its base class. */ |
|
496 ECmLineBreakClass, |
|
497 /** Mandatory Break. */ |
|
498 EBkLineBreakClass, |
|
499 /** Carriage Return. Break after unless part of a CRLF pair. */ |
|
500 ECrLineBreakClass, |
|
501 /** Line Feed. Break after. */ |
|
502 ELfLineBreakClass, |
|
503 /** Surrogate. Half of a surrogate pair. */ |
|
504 ESgLineBreakClass, |
|
505 /** Contingent Break (e.g. embedded pictures). Uses external |
|
506 information */ |
|
507 ECbLineBreakClass, |
|
508 |
|
509 /** Space. Intervening characters of class Space are indicated by |
|
510 aHaveSpaces in LineBreakPossible. */ |
|
511 ESpLineBreakClass, |
|
512 |
|
513 /** Complex Context (e.g. Thai). Runs of Complex Context are passed to |
|
514 GetLineBreakInContext. */ |
|
515 ESaLineBreakClass, |
|
516 |
|
517 /** Ambiguous. Characters of ambiguous East Asian width are treated |
|
518 as Alphabetic, unless they are resolved as being "Wide", in which case |
|
519 they are treated as Ideographic. */ |
|
520 EAiLineBreakClass, |
|
521 |
|
522 /** The Xx class is used when the class is unknown; e.g.; outside the provided context. */ |
|
523 EXxLineBreakClass, |
|
524 |
|
525 /** The number of Unicode line break classes. */ |
|
526 ELineBreakClasses |
|
527 }; |
|
528 |
|
529 IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; |
|
530 IMPORT_C virtual TInt Stretch(TUint aChar) const; |
|
531 IMPORT_C virtual TUint Map(TUint aChar) const; |
|
532 IMPORT_C virtual void SetLineHeight(const TLineHeightParam& aParam,TInt& aAscent,TInt& aDescent) const; |
|
533 IMPORT_C virtual void DrawBackground(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, |
|
534 const TLogicalRgb& aBackground,TRect& aRectDrawn) const; |
|
535 IMPORT_C virtual void DrawLineGraphics(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, |
|
536 const TTmLineInfo& aLineInfo) const; |
|
537 IMPORT_C virtual void DrawText(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect, |
|
538 const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat, |
|
539 const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const; |
|
540 IMPORT_C virtual void DrawPicture(CGraphicsContext& aGc, |
|
541 const TPoint& aTextLayoutTopLeft, const TRect& aRect, |
|
542 MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const; |
|
543 IMPORT_C virtual TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const; |
|
544 IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const; |
|
545 IMPORT_C virtual TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos, |
|
546 TBool aForwards,TInt& aBreakPos) const; |
|
547 IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const; |
|
548 |
|
549 // non-virtuals |
|
550 IMPORT_C void SetPenColor(CGraphicsContext& aGc,TLogicalRgb aColor) const; |
|
551 IMPORT_C void SetBrushColor(CGraphicsContext& aGc,TLogicalRgb aColor) const; |
|
552 IMPORT_C TRgb SystemColor(TLogicalRgb aColor) const; |
|
553 }; |
|
554 |
|
555 /** |
|
556 MTmTextDrawExt interface UID. |
|
557 @internalComponent |
|
558 */ |
|
559 const TUid KTmTextDrawExtId = {0x10203665}; |
|
560 |
|
561 /** |
|
562 Text drawing - an extension interface. It offfers |
|
563 DrawLine(), DrawText() and DrawRect() methods. |
|
564 The idea is to move out from RTm<Name>Interpreter implementations all |
|
565 CGraphicsContext::Draw<Item> calls and replace them with the corresponding |
|
566 MTmTextDrawExt::Draw<Item> calls. The implementations of MTmTextDrawExt interface can customize |
|
567 drawing methods implementations - for example - including opaque drawing support. |
|
568 The MTmTextDrawExt interface UID is KTmTextDrawExtId. The interface implementation can be queried |
|
569 through a MTmSource::GetExtendedInterface() call. |
|
570 @internalComponent |
|
571 */ |
|
572 class MTmTextDrawExt |
|
573 { |
|
574 public: |
|
575 virtual void DrawLine(CGraphicsContext& aGc, const TPoint& aPt1, const TPoint& aPt2) const = 0; |
|
576 virtual void DrawText(CGraphicsContext& aGc, const TDesC& aText, const TPoint& aPt) const = 0; |
|
577 virtual void DrawRect(CGraphicsContext& aGc, const TRect& aRc) const = 0; |
|
578 }; |
|
579 |
|
580 /** |
|
581 @internalComponent |
|
582 */ |
|
583 const TUid KFormLabelApiExtensionUid = { 0x101FD03C}; |
|
584 |
|
585 /** |
|
586 MTmSource is an interface class that must be implemented by users of |
|
587 CTmTextLayout to provide text content and attributes. MTmSource is derived from |
|
588 MTmCustom, which contains the functions to customise the layout and display, so |
|
589 that this can be done in CTmText without affecting the content. |
|
590 @internalComponent |
|
591 */ |
|
592 class MTmSource: public MTmCustom |
|
593 |
|
594 { |
|
595 public: |
|
596 /** Label type used in LabelModeSelect */ |
|
597 enum TLabelType |
|
598 { |
|
599 /** Not a label; used for TLabelTypes not yet assigned. */ |
|
600 ENoLabel, |
|
601 |
|
602 /** Paragraph label of the type supported by FORM. */ |
|
603 EParLabel |
|
604 }; |
|
605 |
|
606 enum |
|
607 { |
|
608 /** |
|
609 The maximum number of characters supplied to GetLineBreak, after aMaxBreakPos, |
|
610 and after trailing whitespace, to provide context for line breaking decisions. |
|
611 */ |
|
612 ELineBreakContext = 32 |
|
613 }; |
|
614 |
|
615 // pure virtuals |
|
616 |
|
617 /** Return the device used to format the text. */ |
|
618 virtual MGraphicsDeviceMap& FormatDevice() const = 0; |
|
619 |
|
620 /** |
|
621 Return the device used to draw the text and when converting between x-y coordinates and document positions. |
|
622 If the formatting and interpreting devices are different, text is scaled appropriately when it is drawn; |
|
623 this allows text to be formatted for printer fonts and displayed on the screen, giving a wysiwyg print preview. |
|
624 */ |
|
625 virtual MGraphicsDeviceMap& InterpretDevice() const = 0; |
|
626 |
|
627 /** Return the length of the document in characters. */ |
|
628 virtual TInt DocumentLength() const = 0; |
|
629 |
|
630 /** |
|
631 Return at least one character of text, but preferably as many as possible, starting at aPos. Put its character |
|
632 format in aFormat. The text must be a run of characters sharing the same character format. |
|
633 */ |
|
634 virtual void GetText(TInt aPos,TPtrC& aText,TTmCharFormat& aFormat) const = 0; |
|
635 |
|
636 /** |
|
637 Return the paragraph format of the paragraph containing aPos. End-of-paragraph characters belong to the preceding |
|
638 paragraph. |
|
639 */ |
|
640 virtual void GetParagraphFormatL(TInt aPos,RTmParFormat& aFormat) const = 0; |
|
641 |
|
642 /** |
|
643 Return the document position of the start of the paragraph containing aPos. End-of-paragraph characters belong to |
|
644 the preceding paragraph. |
|
645 */ |
|
646 virtual TInt ParagraphStart(TInt aPos) const = 0; |
|
647 |
|
648 // ordinary virtuals |
|
649 IMPORT_C virtual CPicture* PictureL(TInt aPos) const; |
|
650 IMPORT_C virtual TInt GetPictureSizeInTwipsL(TInt aPos,TSize& aSize) const; |
|
651 IMPORT_C virtual TAny* GetExtendedInterface(const TUid& aInterfaceId); |
|
652 IMPORT_C virtual void MTmSource_Reserved_1(); |
|
653 IMPORT_C virtual void MTmSource_Reserved_2(); |
|
654 IMPORT_C virtual TBool PageBreakInRange(TInt aStartPos,TInt aEndPos) const; |
|
655 |
|
656 // non-virtuals |
|
657 IMPORT_C TInt ParagraphEnd(TInt aPos) const; |
|
658 IMPORT_C TBool GetLineBreakL(const TDesC& aText,TInt aDocPos,TInt aMinBreakPos,TInt aMaxBreakPos,TBool aForwards, |
|
659 TInt& aBreakPos,TInt& aHangingChars,TInt& aBreakPosAfterSpaces) const; |
|
660 IMPORT_C static void GetStandardLineBreak(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos, |
|
661 TInt& aBreakPos,TInt& aNextLineStart); |
|
662 }; |
|
663 |
|
664 /** |
|
665 Class used to provide label functionality within Form |
|
666 as an extended interface (via the GetExtendedInterface mechanism |
|
667 supplied in MTmSource). This class is entirely internal to Form. |
|
668 @internalComponent |
|
669 @see MTmSource::GetExtendedInterface |
|
670 @since Sirocco |
|
671 */ |
|
672 class MFormLabelApi |
|
673 { |
|
674 public: |
|
675 IMPORT_C virtual TBool LabelModeSelect(MTmSource::TLabelType aType, TInt aPos); |
|
676 IMPORT_C virtual void LabelModeCancel(); |
|
677 IMPORT_C virtual void LabelMetrics(MTmSource::TLabelType aType, TSize& aLabelSize, TInt& aMarginSize) const; |
|
678 }; |
|
679 |
|
680 /** |
|
681 @internalTechnology |
|
682 */ |
|
683 class CTmBufSeg: public CBufSeg |
|
684 { |
|
685 public: |
|
686 inline CTmBufSeg(TInt aExpandSize); |
|
687 TInt MemoryUsed() const; |
|
688 }; |
|
689 |
|
690 /** @internalTechnology */ |
|
691 class CTmCode: public CBase |
|
692 { |
|
693 public: |
|
694 inline ~CTmCode(); |
|
695 void InsertByteL(TUint8 aByte,TInt aPos); |
|
696 TInt InsertNumberL(TInt aNumber,TInt aPos); |
|
697 TInt InsertRectL(const TRect& aRect,TInt aPos); |
|
698 void AppendByteL(TUint8 aByte); |
|
699 TInt AppendNumberL(TInt aNumber); |
|
700 TInt AppendRectL(const TRect& aRect); |
|
701 void ChangeL(TInt aStart,TInt aEnd,CTmCode& aNewCode); |
|
702 TInt MemoryUsed() const; |
|
703 TInt Size() const; |
|
704 void Delete(TInt aPos,TInt aLength); |
|
705 void Reset(); |
|
706 inline TPtr8 Ptr(TInt aPos); |
|
707 void CreateBufferL(); |
|
708 inline CBufBase* Buffer(); |
|
709 inline const CBufBase* Buffer() const; |
|
710 |
|
711 private: |
|
712 enum |
|
713 { |
|
714 EExpandSize = 512 |
|
715 }; |
|
716 TInt WriteNumber(TInt aNumber,TUint8* aBuffer); |
|
717 |
|
718 CTmBufSeg* iBuffer; |
|
719 }; |
|
720 |
|
721 /** |
|
722 Formatting parameters used when formatting part of a layout object. |
|
723 @internalComponent |
|
724 */ |
|
725 class TTmFormatParamBase |
|
726 |
|
727 { |
|
728 public: |
|
729 enum |
|
730 { |
|
731 EWrap = 1, // wrap the text at iWrapWidth |
|
732 EAtLeastMaxHeight = 2, // stop adding text only when iMaxHeight has been reached or exceeded |
|
733 ETruncateWithEllipsis = 4, // truncate any text that sticks out; see iEllipsis below |
|
734 ELegalLineBreaksOnly = 8 // break only at allowed line breaks, even if that |
|
735 // results in the text not fitting the measure |
|
736 }; |
|
737 |
|
738 IMPORT_C TTmFormatParamBase(); |
|
739 inline TBool IsWrapping() const; |
|
740 inline TBool IsTruncatingWithEllipsis() const; |
|
741 inline TBool LegalLineBreaksOnly() const; |
|
742 |
|
743 TInt iWrapWidth; // wrapping width of the text including margins and indents, if wrapping is on |
|
744 TInt iMaxHeight; // maximum height of the text |
|
745 TInt iMaxLines; // maximum number of lines to be formatted |
|
746 TInt iFlags; // flags defined above |
|
747 TChar iEllipsis; // if truncating and not 0xFFFF, insert this ellipsis char (defaults to '...'). |
|
748 |
|
749 }; |
|
750 |
|
751 /** |
|
752 Formatting parameters used when formatting an entire layout object or |
|
753 creating a section of format code. |
|
754 @internalComponent |
|
755 */ |
|
756 class TTmFormatParam: public TTmFormatParamBase |
|
757 |
|
758 { |
|
759 public: |
|
760 IMPORT_C TTmFormatParam(); |
|
761 IMPORT_C TTmFormatParam(const TTmFormatParamBase& aBase); |
|
762 |
|
763 TInt iStartChar; // first character position to be formatted |
|
764 TInt iEndChar; // last character position to be formatted |
|
765 TInt iLineInPar; // starting line number in the paragraph |
|
766 }; |
|
767 |
|
768 /** |
|
769 Additional parameters used when reformatting. |
|
770 @internalComponent |
|
771 */ |
|
772 class TTmReformatParam |
|
773 |
|
774 { |
|
775 public: |
|
776 IMPORT_C TTmReformatParam(); |
|
777 |
|
778 TInt iStartChar; // start of changed text |
|
779 TInt iOldLength; // length of text before the change |
|
780 TInt iNewLength; // length of text after the change |
|
781 TInt iMaxExtraLines; // maximum lines in the partial paragraph after the end of the changed text |
|
782 // to format in one go; the remainder can be handled by background formatting |
|
783 TBool iParFormatChanged; // TRUE if the paragraph format of the changed text has changed |
|
784 TBool iParInvalid; // format to the end of the paragraph |
|
785 }; |
|
786 |
|
787 /** |
|
788 Information returned when reformatting. |
|
789 @internalComponent |
|
790 */ |
|
791 class TTmReformatResult |
|
792 |
|
793 { |
|
794 public: |
|
795 IMPORT_C TTmReformatResult(); |
|
796 |
|
797 TRect iRedrawRect; // rectangle to be redrawn |
|
798 TInt iHeightChange; // change in height of the reformatted text |
|
799 TInt iUnchangedTop; // y coordinate, before formatting, of the top of text needing no change, |
|
800 // including text in any section not yet formatted by this call |
|
801 TInt iUnformattedStart; // start of any unformatted section; KMaxTInt if none |
|
802 }; |
|
803 |
|
804 /** |
|
805 A structure for returning information about a line. One of these is |
|
806 returned by all hit-detection functions. Typically, after finding the position |
|
807 in the document that corresponds to given x-y coordinates, you will want some |
|
808 more information like the line's bounding rectangle. When you call, for |
|
809 example, CTmTextLayout::FindXyPos you will receive a TTmLineInfo object that |
|
810 will tell you this, and much more. |
|
811 @publishedAll |
|
812 @released |
|
813 */ |
|
814 class TTmLineInfo |
|
815 |
|
816 { |
|
817 public: |
|
818 // bit values for iFlags |
|
819 enum |
|
820 { |
|
821 EParStart = 1, |
|
822 EParEnd = 2, |
|
823 EParRightToLeft = 4, |
|
824 ELineEndsInForcedLineBreak = 8, |
|
825 EPictureButtsLowerEdge = 16, /**< @deprecated - no effect, present for compatibility only */ |
|
826 EPictureButtsUpperEdge = 32 /**< @deprecated - no effect, present for compatibility only */ |
|
827 }; |
|
828 |
|
829 inline TTmLineInfo(); |
|
830 |
|
831 /** Outer enclosing rectangle including margins */ |
|
832 TRect iOuterRect; |
|
833 |
|
834 /** Inner enclosing rectangle: the text only */ |
|
835 TRect iInnerRect; |
|
836 |
|
837 /** y coordinate of the baseline */ |
|
838 TInt iBaseline; |
|
839 |
|
840 /** Start document position */ |
|
841 TInt iStart; |
|
842 |
|
843 /** End document position */ |
|
844 TInt iEnd; |
|
845 |
|
846 /** Line number */ |
|
847 TInt iLineNumber; |
|
848 |
|
849 /** Paragraph number */ |
|
850 TInt iParNumber; |
|
851 |
|
852 /** Line number in the paragraph */ |
|
853 TInt iLineInPar; |
|
854 |
|
855 /** y coordinate of the top of the paragraph */ |
|
856 TInt iParTop; |
|
857 |
|
858 /** Start of paragraph, end of paragraph, etc. */ |
|
859 TUint iFlags; |
|
860 }; |
|
861 |
|
862 /** |
|
863 A structure to hold a logical document position that can be converted to a raw |
|
864 document position or an x-y position. |
|
865 |
|
866 A document position can specify a leading or trailing edge or a text |
|
867 directionality so that bidirectional hit testing can use both these |
|
868 distinctions. |
|
869 |
|
870 The leading edge at position N is the position before character N in logical |
|
871 order, and the trailing edge is the position after character in logical order. |
|
872 |
|
873 Specification by directionality works differently. Character N in left-to-right |
|
874 text is preceded by position N (left-to-right) and followed by position N+1 |
|
875 (left-to-right). Character N in right-to-left text is preceded (in display |
|
876 order) by position N+1 (right-to-left) and followed by position N |
|
877 (right-to-left). |
|
878 @publishedAll |
|
879 @released |
|
880 */ |
|
881 class TTmDocPosSpec |
|
882 |
|
883 { |
|
884 public: |
|
885 /** |
|
886 The cursor type. |
|
887 */ |
|
888 enum TType |
|
889 { |
|
890 /** trailing edge */ |
|
891 ETrailing, |
|
892 |
|
893 /** leading edge */ |
|
894 ELeading, |
|
895 |
|
896 /** left-to-right */ |
|
897 ELeftToRight, |
|
898 |
|
899 /** right-to-left */ |
|
900 ERightToLeft |
|
901 }; |
|
902 |
|
903 inline TTmDocPosSpec(); |
|
904 inline TTmDocPosSpec(TInt aPos,TType aType); |
|
905 inline TTmDocPosSpec(const TTmDocPos& aRawDocPos); |
|
906 |
|
907 /** the edge position in the document; 0 ... document length */ |
|
908 TInt iPos; |
|
909 /** the type as specified above */ |
|
910 TType iType; |
|
911 }; |
|
912 |
|
913 /** |
|
914 A structure for holding a raw document position that can be converted to or |
|
915 from an x-y position and compared ordinally, which cannot be done with the more |
|
916 abstract TTmDocPosSpec class. Leading edges are distinguished from trailing |
|
917 edges so that bidirectional hit testing and cursor positioning can distinguish |
|
918 between 'after character N', and 'before character N + 1', which may be some |
|
919 distance apart if N and N + 1 are in runs of opposite directionality. |
|
920 @publishedAll |
|
921 @released |
|
922 */ |
|
923 class TTmDocPos |
|
924 |
|
925 { |
|
926 public: |
|
927 inline TTmDocPos(); |
|
928 inline TTmDocPos(TInt aPos,TBool aLeadingEdge); |
|
929 IMPORT_C TBool operator==(const TTmDocPos& aPos) const; |
|
930 inline TBool operator!=(const TTmDocPos& aPos) const; |
|
931 IMPORT_C TBool operator>(const TTmDocPos& aPos) const; |
|
932 IMPORT_C TBool operator>=(const TTmDocPos& aPos) const; |
|
933 inline TBool operator<(const TTmDocPos& aPos) const; |
|
934 inline TBool operator<=(const TTmDocPos& aPos) const; |
|
935 |
|
936 /** the edge position in the document; 0 ... document length */ |
|
937 TInt iPos; |
|
938 /** true if the position is a leading edge */ |
|
939 TBool iLeadingEdge; |
|
940 }; |
|
941 |
|
942 /** |
|
943 Holds information about a position in a document. |
|
944 @publishedAll |
|
945 @released |
|
946 */ |
|
947 class TTmPosInfo2 |
|
948 |
|
949 { |
|
950 public: |
|
951 /** Document position. */ |
|
952 TTmDocPos iDocPos; |
|
953 /** True if the position is attatched to text flowing right-to-left. */ |
|
954 TBool iRightToLeft; |
|
955 /** Intersection of the character edge with the baseline. */ |
|
956 TPoint iEdge; |
|
957 }; |
|
958 |
|
959 /** |
|
960 A structure for returning information about a position in a line. |
|
961 @deprecated 7.0s |
|
962 @internalComponent |
|
963 */ |
|
964 class TTmPosInfo |
|
965 |
|
966 { |
|
967 public: |
|
968 TTmPosInfo() {} |
|
969 TTmPosInfo(const TTmPosInfo2& a) : iDocPos(a.iDocPos), iEdge(a.iEdge) {} |
|
970 TTmDocPos iDocPos; // the document position |
|
971 TPoint iEdge; // intersection of the character edge at iDocPos with the baseline |
|
972 }; |
|
973 |
|
974 /** |
|
975 @internalComponent |
|
976 */ |
|
977 class TTmHighlightExtensions |
|
978 |
|
979 { |
|
980 public: |
|
981 inline TTmHighlightExtensions(); |
|
982 inline void SetAll(TInt aExtension); |
|
983 inline void SetLeftExtension(TInt aExtension); |
|
984 inline void SetRightExtension(TInt aExtension); |
|
985 inline void SetTopExtension(TInt aExtension); |
|
986 inline void SetBottomExtension(TInt aExtension); |
|
987 inline TInt LeftExtension() const; |
|
988 inline TInt RightExtension() const; |
|
989 inline TInt TopExtension() const; |
|
990 inline TInt BottomExtension() const; |
|
991 inline TBool Extends() const; |
|
992 inline TBool Shrinks() const; |
|
993 inline void ExtendRect(TRect& aRect) const; |
|
994 inline void AdjustRect(TRect& aRect) const; |
|
995 inline TBool IsNull() const; |
|
996 inline void AbsExtendRect(TRect& aRect) const; |
|
997 public: |
|
998 TInt iLeftExtension; |
|
999 TInt iRightExtension; |
|
1000 TInt iTopExtension; |
|
1001 TInt iBottomExtension; |
|
1002 }; |
|
1003 |
|
1004 /** |
|
1005 Cursor placement. Used as an argument to CTextView::SetCursorPlacement(). |
|
1006 @see CTextView::SetCursorPlacement() |
|
1007 @publishedAll |
|
1008 */ |
|
1009 enum TTmCursorPlacement |
|
1010 { |
|
1011 /** The text cursor is a vertical line at the insertion position, with its height |
|
1012 and depth based on the metrics of the previous character in the paragraph |
|
1013 or if none, the next character. */ |
|
1014 ECursorVertical, |
|
1015 /** The text cursor is an underline below the character logically after the insertion |
|
1016 position. */ |
|
1017 ECursorUnderlineNext, |
|
1018 /** The text cursor is an underline below the character logically before the insertion |
|
1019 position. */ |
|
1020 ECursorUnderlinePrev |
|
1021 }; |
|
1022 |
|
1023 /** |
|
1024 The text layout for a single rectangular piece of text. The object does not own its text or format attributes but |
|
1025 gets them from an interface class called MTmSource. |
|
1026 |
|
1027 There are functions for setting the text, drawing it, and converting between x-y coordinates and document positions. |
|
1028 |
|
1029 Ranges |
|
1030 |
|
1031 All ranges of character positions and pixels include the start but not the end. This means that if a line is described |
|
1032 by a TTmLineInfo object as starting at document position 345 and ending at 389, character positions 345 to 388 are in |
|
1033 the line; 389 is in the next line if any. |
|
1034 |
|
1035 Coordinates and units |
|
1036 |
|
1037 All coordinates used in TAGMA classes and function arguments are in pixels and are relative to the origin of the object, |
|
1038 which is the top left corner of the ordinary text, not including paragraph labels. Vertical coordinates increase from |
|
1039 top to bottom. |
|
1040 |
|
1041 Document format and positions |
|
1042 |
|
1043 A TAGMA document, as supplied by the MTmSource interface, has a length as returned by MTmSource::DocumentLength of |
|
1044 zero or more characters. It consists of Unicode text split into paragraphs by standard Unicode paragraph delimiters |
|
1045 (character value 0x2029), so the number of paragraphs in the entire document is one more than the number of |
|
1046 paragraph delimiters. A document position is a value in the range 0 to one more than the document length. |
|
1047 Lines contain all document positions from their start to one less than their end position. These conventions allow |
|
1048 all lines to end in a delimiter; the last line contains an imaginary paragraph end, which need not be supplied by |
|
1049 the MTmSource interface, at a position equal to the document length. A CTmTextLayout object formatted for an |
|
1050 empty document will thus have a start position (returned by StartChar) of 0 and an end position |
|
1051 (returned by EndChar) of 1. |
|
1052 @internalComponent |
|
1053 */ |
|
1054 class CTmTextLayout: public CBase |
|
1055 |
|
1056 { |
|
1057 public: |
|
1058 |
|
1059 class TTmChunkDescription |
|
1060 /** |
|
1061 Output from FindAdjacentChunks. Describes a chunk of text that is of a |
|
1062 constant format and directionality. |
|
1063 @internalComponent |
|
1064 */ |
|
1065 { |
|
1066 public: |
|
1067 /** Position of the first character in the chunk. A negative number |
|
1068 indicates "no such chunk". */ |
|
1069 TInt iStart; |
|
1070 /** One past the position of the last character in the chunk. */ |
|
1071 TInt iEnd; |
|
1072 /** ETrue if the chunk is displayed right-to-left. */ |
|
1073 TBool iRightToLeft; |
|
1074 }; |
|
1075 |
|
1076 IMPORT_C CTmTextLayout(); |
|
1077 IMPORT_C ~CTmTextLayout(); |
|
1078 IMPORT_C void SetTextL(MTmSource& aSource,const TTmFormatParam& aParam); |
|
1079 IMPORT_C void FormatL(const TTmFormatParamBase& aParam,const TTmReformatParam& aReformatParam, |
|
1080 TTmReformatResult& TTmReformatResult); |
|
1081 IMPORT_C TBool AddParL(const TTmFormatParamBase& aParam,TBool aAtStart,TInt& aHeightIncrease,TInt& aParagraphsIncrease); |
|
1082 IMPORT_C TBool DeletePar(const TTmFormatParamBase& aParam,TBool aAtStart,TInt aMaxDeletedHeight,TInt& aHeightDecrease); |
|
1083 IMPORT_C void Clear(); |
|
1084 IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1085 const TLogicalRgb* aDocBackground,TBool aDrawParBackground) const; |
|
1086 IMPORT_C void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1087 const TLogicalRgb& aBackground) const; |
|
1088 IMPORT_C void InvertLayout(CGraphicsContext& aGc, const TPoint& aTopLeft, |
|
1089 TInt aStartDocPos, TInt aEndDocPos) const; |
|
1090 IMPORT_C void HighlightSection(CGraphicsContext& aGc, const TPoint& aTopLeft, |
|
1091 TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect) const; |
|
1092 IMPORT_C void DrawSection(CGraphicsContext& aGc, const TPoint& aTopLeft, |
|
1093 TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect) const; |
|
1094 IMPORT_C void HighlightSection(CGraphicsContext& aGc, const TPoint& aTopLeft, |
|
1095 TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect, const TTmHighlightExtensions& aHighlightExtensions, |
|
1096 TInt aHighlightStartDocPos, TInt aHighlightEndDocPos) const; |
|
1097 IMPORT_C void InvertLayout(CGraphicsContext& aGc, |
|
1098 const TPoint& aTopLeft, TInt aStartDocPos,TInt aEndDocPos, const TTmHighlightExtensions& aHighlightExtensions, |
|
1099 TInt aHighlightStartDocPos, TInt aHighlightEndDocPos) const; |
|
1100 IMPORT_C void DrawSection(CGraphicsContext& aGc, const TPoint& aTopLeft, |
|
1101 TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect, const TTmHighlightExtensions& aHighlightExtensions, |
|
1102 TInt aHighlightStartDocPos, TInt aHighlightEndDocPos) const; |
|
1103 IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1104 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1105 IMPORT_C TBool FindXyPosWithDisambiguation(const TPoint& aXyPos, |
|
1106 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight, |
|
1107 TTmLineInfo& aLineInfo) const; |
|
1108 IMPORT_C TInt FindNextPos(TInt aStart) const; |
|
1109 IMPORT_C TInt FindPreviousPos(TInt aStart) const; |
|
1110 IMPORT_C TInt Lines() const; |
|
1111 IMPORT_C TInt Paragraphs() const; |
|
1112 IMPORT_C TBool DocPosToLine(const TTmDocPosSpec& aDocPos,TTmLineInfo& aLineInfo) const; |
|
1113 IMPORT_C TBool LineNumberToLine(TInt aLineNumber,TTmLineInfo& aLineInfo) const; |
|
1114 IMPORT_C TBool ParNumberToLine(TInt aParNumber,TInt aLineInPar,TTmLineInfo& aLineInfo) const; |
|
1115 IMPORT_C TBool YPosToLine(TInt aYPos,TTmLineInfo& aLineInfo) const; |
|
1116 IMPORT_C TBool GetDisplayedTextL(TInt aLineNumber,TDes& aText,TInt& aNeeded) const; |
|
1117 IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TSize& aSize) const; |
|
1118 IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize) const; |
|
1119 IMPORT_C TInt WidthOfWidestLine(TInt aTop = 0,TInt aBottom = KMaxTInt) const; |
|
1120 IMPORT_C void HorizontalExtremes(TInt &aLeft, TInt &aRight, |
|
1121 TInt aTopY = 0, TInt aBottomY = KMaxTInt) const; |
|
1122 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aInfo,TBool aToLeft) const; |
|
1123 IMPORT_C TBool GetNextPosLeftWithDisambiguation(const TTmDocPosSpec& aDocPos, |
|
1124 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; |
|
1125 IMPORT_C TBool GetNextPosRightWithDisambiguation(const TTmDocPosSpec& aDocPos, |
|
1126 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; |
|
1127 IMPORT_C TBool LineExtreme(const TTmDocPosSpec& aPos, TBool aToRight, |
|
1128 TTmDocPos& aExtreme) const; |
|
1129 IMPORT_C TBool FindAdjacentChunks(const TTmDocPosSpec& aPos, |
|
1130 TTmChunkDescription& aLeft, TTmChunkDescription& aRight) const; |
|
1131 IMPORT_C TBool GetCursor(const TTmDocPosSpec& aDocPos,TTmCursorPlacement aPlacement, |
|
1132 TTmLineInfo& aLineInfo,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const; |
|
1133 IMPORT_C TInt MemoryUsed() const; |
|
1134 inline TInt StartChar() const; |
|
1135 inline TInt EndChar() const; |
|
1136 inline TInt LayoutWidth() const; |
|
1137 inline TInt LayoutHeight() const; |
|
1138 inline MTmSource* Source(); |
|
1139 inline const MTmSource* Source() const; |
|
1140 inline const CTmCode& Code() const; |
|
1141 IMPORT_C void MakeVisible(TBool aVisible); |
|
1142 TInt GetDrawingInterpFlags() const; |
|
1143 IMPORT_C void DeleteFormattingFromEndL( |
|
1144 const TTmFormatParamBase& aParam, TInt aMaxDeletedHeight, TInt& aHeightDecrease); |
|
1145 IMPORT_C void ExtendFormattingDownwardsL(TTmFormatParam& aParam); |
|
1146 |
|
1147 // deprecated functions |
|
1148 // deprecated 7.0 |
|
1149 IMPORT_C TBool GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const; |
|
1150 // deprecated 7.0s |
|
1151 IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1152 // deprecated 7.0s |
|
1153 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1154 // deprecated 7.0s |
|
1155 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const; |
|
1156 // deprecated 7.0s |
|
1157 IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const; |
|
1158 // deprecated 7.0s |
|
1159 IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos, |
|
1160 TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo, |
|
1161 TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const; |
|
1162 |
|
1163 IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1164 const TLogicalRgb* aDocBackground,TBool aDrawParBackground, |
|
1165 const TCursorSelection* aHighlight, |
|
1166 const TTmHighlightExtensions* aHighlightExtensions) const; |
|
1167 IMPORT_C void GetUpdateBoundingRect(TInt aStartDocPos, TInt aEndDocPos, const TPoint& aTopLeft, |
|
1168 TRect& aBoundingRect) const; |
|
1169 |
|
1170 IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo, TInt& aSubscript) const; |
|
1171 private: |
|
1172 TBool LastLine(TTmLineInfo& aLine); |
|
1173 #ifdef _DEBUG |
|
1174 void Invariant() const; |
|
1175 #else |
|
1176 void Invariant() const { } |
|
1177 #endif |
|
1178 void AdjustWidth(const TTmFormatParamBase& aParam,TInt aWidthOfNewText); |
|
1179 |
|
1180 MTmSource* iSource; // source of text and text attributes; not owned |
|
1181 CTmCode iCode; // the layout bytecode |
|
1182 TInt iWidth; // width in pixels |
|
1183 TInt iHeight; // height in pixels |
|
1184 TInt iStartChar; // start character position in the document |
|
1185 TInt iEndChar; // end character position in the document |
|
1186 TBidirectionalContext* iBdStateAtEnd; //bidirectional state at end of formatted range |
|
1187 TInt iDrawingInterpFlags; // flags destined for the RTmDrawingInterpreter object |
|
1188 // please try to avoid removing or adding any new members to this class. although it |
|
1189 // is internal, it is included by value in CTextLayout which is published. therefore |
|
1190 // a size change in this class would mean a size change in CTextLayout and a BC break. |
|
1191 // if adding or removing members is unavoidable, please remember to update the dummy |
|
1192 // member in CTextLayout accordingly. |
|
1193 }; |
|
1194 |
|
1195 /** |
|
1196 A mixin class to make it easy for higher-level classes that own a CTmTextLayout |
|
1197 object to have enquiry functions without it being necessary to implement them |
|
1198 all as forwarding functions. The owner class just implements TextLayout and |
|
1199 overrides GetOrigin if necessary. |
|
1200 |
|
1201 Non-const CTmTextLayout functions like Clear are not included because allowing |
|
1202 them to be called on owner classes would probably put the owner class into an |
|
1203 inconsistent state. |
|
1204 |
|
1205 The word Layout is prefixed, suffixed or infixed to functions with names that |
|
1206 would usually conflict with owner class names. For example, we have DrawLayout, |
|
1207 not Draw, and GetMinimumLayoutSizeL, not GetMinimumSizeL. |
|
1208 @internalComponent |
|
1209 */ |
|
1210 class MTmTextLayoutForwarder |
|
1211 |
|
1212 { |
|
1213 public: |
|
1214 IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1215 const TLogicalRgb* aDocBackground,TBool aDrawParBackground) const; |
|
1216 IMPORT_C void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1217 const TLogicalRgb& aBackground) const; |
|
1218 IMPORT_C void InvertLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,TInt aStartDocPos,TInt aEndDocPos); |
|
1219 IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1220 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1221 IMPORT_C TBool FindXyPosWithDisambiguation(const TPoint& aXyPos, |
|
1222 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight, |
|
1223 TTmLineInfo& aLineInfo) const; |
|
1224 IMPORT_C TBool DocPosToLine(const TTmDocPosSpec& aDocPos,TTmLineInfo& aLineInfo) const; |
|
1225 IMPORT_C TBool LineNumberToLine(TInt aLineNumber,TTmLineInfo& aLineInfo) const; |
|
1226 IMPORT_C TBool ParNumberToLine(TInt aParNumber,TInt aLineInPar,TTmLineInfo& aLineInfo) const; |
|
1227 IMPORT_C TBool YPosToLine(TInt aYPos,TTmLineInfo& aLineInfo) const; |
|
1228 IMPORT_C TInt WidthOfWidestLine(TInt aTop = 0,TInt aBottom = KMaxTInt) const; |
|
1229 IMPORT_C void HorizontalExtremes(TInt &aLeft, TInt &aRight, |
|
1230 TInt aTopY = 0, TInt aBottomY = KMaxTInt) const; |
|
1231 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aInfo,TBool aToLeft) const; |
|
1232 IMPORT_C TBool GetNextPosLeftWithDisambiguation(const TTmDocPosSpec& aDocPos, |
|
1233 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; |
|
1234 IMPORT_C TBool GetNextPosRightWithDisambiguation(const TTmDocPosSpec& aDocPos, |
|
1235 TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; |
|
1236 IMPORT_C TBool GetCursor(const TTmDocPosSpec& aDocPos,TTmCursorPlacement aPlacement, |
|
1237 TTmLineInfo& aLineInfo,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const; |
|
1238 |
|
1239 IMPORT_C TInt Lines() const; |
|
1240 IMPORT_C TInt Paragraphs() const; |
|
1241 IMPORT_C TBool GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const; |
|
1242 IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TSize& aSize) const; |
|
1243 IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize) const; |
|
1244 IMPORT_C TInt StartChar() const; |
|
1245 IMPORT_C TInt EndChar() const; |
|
1246 IMPORT_C TInt LayoutWidth() const; |
|
1247 IMPORT_C TInt LayoutHeight() const; |
|
1248 |
|
1249 // deprecated functions |
|
1250 // deprecated 7.0s |
|
1251 IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1252 // deprecated 7.0s |
|
1253 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; |
|
1254 // deprecated 7.0s |
|
1255 IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const; |
|
1256 // deprecated 7.0s |
|
1257 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const; |
|
1258 // deprecated 7.0s |
|
1259 IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos, |
|
1260 TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo, |
|
1261 TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const; |
|
1262 private: |
|
1263 /** Returns a reference to the CTmTextLayoutObject this |
|
1264 MTmTextLayoutForwarder forwards inquiries to. */ |
|
1265 virtual const CTmTextLayout& TextLayout() const = 0; |
|
1266 |
|
1267 /** The origin is subtracted from coordinates passed in and added to those |
|
1268 passed out. */ |
|
1269 IMPORT_C virtual void GetOrigin(TPoint& aPoint) const; |
|
1270 |
|
1271 void FixUpLineInfo(TTmLineInfo& aInfo,const TPoint* aOrigin = NULL) const; |
|
1272 }; |
|
1273 |
|
1274 /** |
|
1275 A character format layer. Unmasked attributes are transparent. |
|
1276 @internalComponent |
|
1277 */ |
|
1278 class TTmCharFormatLayer |
|
1279 |
|
1280 { |
|
1281 public: |
|
1282 inline TTmCharFormatLayer(); |
|
1283 IMPORT_C TTmCharFormatLayer(const CCharFormatLayer& aFormat); |
|
1284 |
|
1285 TTmCharFormat iFormat; |
|
1286 TTmCharFormatMask iMask; |
|
1287 }; |
|
1288 |
|
1289 /** |
|
1290 A paragraph format layer. Unmasked attributes are transparent. |
|
1291 @internalComponent |
|
1292 */ |
|
1293 class RTmParFormatLayer |
|
1294 |
|
1295 { |
|
1296 public: |
|
1297 inline void Close(); |
|
1298 IMPORT_C void CopyL(const CParaFormatLayer& aFormat); |
|
1299 |
|
1300 RTmParFormat iFormat; |
|
1301 TTmParFormatMask iMask; |
|
1302 }; |
|
1303 |
|
1304 /** |
|
1305 A style. |
|
1306 @internalComponent |
|
1307 */ |
|
1308 class RTmStyle |
|
1309 |
|
1310 { |
|
1311 public: |
|
1312 enum |
|
1313 { |
|
1314 EMaxName = KMaxParagraphStyleName |
|
1315 }; |
|
1316 |
|
1317 inline void Close(); |
|
1318 IMPORT_C void CopyL(const RParagraphStyleInfo& aStyle); |
|
1319 IMPORT_C void GetRParagraphStyleInfoL(RParagraphStyleInfo& aStyle, |
|
1320 const CParaFormatLayer& aGlobalParaFormatLayer,const CCharFormatLayer& aGlobalCharFormatLayer, |
|
1321 const CStyleList& aList) const; |
|
1322 |
|
1323 TBuf<KMaxName> iName; |
|
1324 TBuf<KMaxName> iNextStyleName; |
|
1325 TTmCharFormatLayer iCharFormat; |
|
1326 RTmParFormatLayer iParFormat; |
|
1327 TInt iOutlineLevel; |
|
1328 }; |
|
1329 |
|
1330 /** |
|
1331 A self-contained text object. It owns both layout and content. It is |
|
1332 intended for labels and the general display of small-to-medium-sized amounts of |
|
1333 text. |
|
1334 @internalComponent |
|
1335 */ |
|
1336 class CTmText: public CBase, public MTmTextLayoutForwarder |
|
1337 |
|
1338 { |
|
1339 public: |
|
1340 IMPORT_C static CTmText* NewL(MGraphicsDeviceMap* aDevice = NULL,const TTmFormatParamBase* aFormatParam = NULL); |
|
1341 IMPORT_C static CTmText* NewL(MGraphicsDeviceMap& aDevice,const TTmFormatParamBase& aFormatParam); |
|
1342 IMPORT_C static CTmText* NewL(MGraphicsDeviceMap& aDevice,TInt aWrapWidth,TInt aFlags); |
|
1343 IMPORT_C ~CTmText(); |
|
1344 IMPORT_C void InsertL(TInt aPos,const TDesC& aText, |
|
1345 const TTmCharFormat* aCharFormat = NULL,const RTmParFormat* aParFormat = NULL, |
|
1346 TRect* aRedrawRect = NULL,TInt* aScroll = NULL); |
|
1347 IMPORT_C void GetFormat(TTmFormatParamBase& aFormatParam) const; |
|
1348 IMPORT_C void SetWrapWidthL(TInt aWrapWidth); |
|
1349 IMPORT_C void ChangeFormatL(const TTmFormatParamBase& aFormatParam); |
|
1350 IMPORT_C void Clear(); |
|
1351 IMPORT_C void CustomizeL(const MTmCustom* aCustom); |
|
1352 IMPORT_C TInt MemoryUsed() const; |
|
1353 inline void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1354 const TLogicalRgb* aDocBackground,TBool aDrawParBackground); |
|
1355 |
|
1356 private: |
|
1357 CTmText(); |
|
1358 IMPORT_C void Spare1(); |
|
1359 |
|
1360 // implementations of MTmTextLayoutForwarder virtual functions |
|
1361 const CTmTextLayout& TextLayout() const; |
|
1362 |
|
1363 CTmTextImp* iImp; // the implementation |
|
1364 }; |
|
1365 |
|
1366 // inline functions |
|
1367 /** Constructs a TTmCharFormatMask. Turns all the flags on. */ |
|
1368 TTmCharFormatMask::TTmCharFormatMask(): iFlags(0xFFFFFFFF) |
|
1369 { |
|
1370 } |
|
1371 |
|
1372 /** Clears the selected flag.*/ |
|
1373 void TTmCharFormatMask::Clear(TAttrib aAttrib) |
|
1374 { |
|
1375 iFlags &= ~aAttrib; |
|
1376 } |
|
1377 |
|
1378 /** Sets the selected flag. */ |
|
1379 void TTmCharFormatMask::Set(TAttrib aAttrib) |
|
1380 { |
|
1381 iFlags |= aAttrib; |
|
1382 } |
|
1383 |
|
1384 /** Returns true if the selected attribute is set. */ |
|
1385 TBool TTmCharFormatMask::IsSet(TAttrib aAttrib) |
|
1386 { |
|
1387 return iFlags & aAttrib; |
|
1388 } |
|
1389 |
|
1390 /** Constructs a TTmCharFormat by converting the information in a TCharFormat. */ |
|
1391 TTmCharFormat::TTmCharFormat(const TCharFormat& aFormat) |
|
1392 { |
|
1393 *this = aFormat; |
|
1394 } |
|
1395 |
|
1396 /** The inequality operator. Return TRUE if this object and aFormat differ in any way. */ |
|
1397 TBool TTmCharFormat::operator!=(const TTmCharFormat& aFormat) const |
|
1398 { |
|
1399 return !operator==(aFormat); |
|
1400 } |
|
1401 |
|
1402 /** Constructs a TTmTab and set it to a standard tab stop with a position of 0. */ |
|
1403 TTmTab::TTmTab(): |
|
1404 iPosition(0), |
|
1405 iType(EStandardTab) |
|
1406 { |
|
1407 } |
|
1408 |
|
1409 /** Constructs a TTmTab by converting the information in a TTabStop. */ |
|
1410 TTmTab::TTmTab(const TTabStop& aTab) |
|
1411 { |
|
1412 *this = aTab; |
|
1413 } |
|
1414 |
|
1415 /** The inequality operator. Returns TRUE if this object and aTab differ in any |
|
1416 way. */ |
|
1417 TBool TTmTab::operator!=(const TTmTab& aTab) const |
|
1418 { |
|
1419 return !operator==(aTab); |
|
1420 } |
|
1421 |
|
1422 /** Constructs a TTmBullet by converting the information in a TBullet. */ |
|
1423 TTmBullet::TTmBullet(const TBullet& aBullet) |
|
1424 { |
|
1425 *this = aBullet; |
|
1426 } |
|
1427 |
|
1428 /** The inequality operator. Returns true if this object and aBullet differ in |
|
1429 any way. */ |
|
1430 TBool TTmBullet::operator!=(const TTmBullet& aBullet) const |
|
1431 { |
|
1432 return !operator==(aBullet); |
|
1433 } |
|
1434 |
|
1435 /** Constructs a TTmParBorder by converting the information in a TParaBorder. */ |
|
1436 TTmParBorder::TTmParBorder(const TParaBorder& aBorder) |
|
1437 { |
|
1438 *this = aBorder; |
|
1439 } |
|
1440 |
|
1441 /** The inequality operator. Returns TRUE if this object and aBorder differ in |
|
1442 any way. */ |
|
1443 TBool TTmParBorder::operator!=(const TTmParBorder& aBorder) const |
|
1444 { |
|
1445 return !operator==(aBorder); |
|
1446 } |
|
1447 |
|
1448 /** Constructs a TTmParFormatMask with all the flags on. */ |
|
1449 TTmParFormatMask::TTmParFormatMask(): |
|
1450 iFlags(0xFFFFFFFF) |
|
1451 { |
|
1452 } |
|
1453 |
|
1454 /** Clears the selected flag. */ |
|
1455 void TTmParFormatMask::Clear(TAttrib aAttrib) |
|
1456 { |
|
1457 iFlags &= ~aAttrib; |
|
1458 } |
|
1459 |
|
1460 /** Sets the selected flag. */ |
|
1461 void TTmParFormatMask::Set(TAttrib aAttrib) |
|
1462 { |
|
1463 iFlags |= aAttrib; |
|
1464 } |
|
1465 |
|
1466 /** |
|
1467 Returns true if the selected flag is Set. |
|
1468 */ |
|
1469 TBool TTmParFormatMask::IsSet(TAttrib aAttrib) |
|
1470 { |
|
1471 return iFlags & aAttrib; |
|
1472 } |
|
1473 |
|
1474 #ifdef _DEBUG |
|
1475 RTmParFormat::~RTmParFormat() |
|
1476 { |
|
1477 __ASSERT_DEBUG(!iTabList && !iBullet && !HaveBorders(), User::Invariant()); |
|
1478 } |
|
1479 #endif |
|
1480 |
|
1481 /** The inequality operator. Returns true if this object and aFormat differ in |
|
1482 any way. |
|
1483 */ |
|
1484 TBool RTmParFormat::operator!=(const RTmParFormat& aFormat) const |
|
1485 { |
|
1486 return !operator==(aFormat); |
|
1487 } |
|
1488 |
|
1489 /** Returns a reference to the tab selected by aIndex. */ |
|
1490 const TTmTab& RTmParFormat::Tab(TInt aIndex) const |
|
1491 { |
|
1492 return (*iTabList)[aIndex]; |
|
1493 } |
|
1494 |
|
1495 /** Returns a pointer to the TTmBullet object if any. Returns null if the |
|
1496 RTmParFormat does not contain a TTmBullet. */ |
|
1497 const TTmBullet* RTmParFormat::Bullet() const |
|
1498 { |
|
1499 return iBullet; |
|
1500 } |
|
1501 |
|
1502 /** Returns a pointer to the border selected by aIndex. Returns null if the |
|
1503 selected border is not present. */ |
|
1504 const TTmParBorder* RTmParFormat::Border(TBorderIndex aIndex) const |
|
1505 { |
|
1506 return iBorder[aIndex]; |
|
1507 } |
|
1508 |
|
1509 /** Returns true if the paragraph's base direction is right-to-left. */ |
|
1510 TBool RTmParFormat::RightToLeft() const |
|
1511 { |
|
1512 return iFlags & ERightToLeft; |
|
1513 } |
|
1514 |
|
1515 /** Constructs a line height parameter structure, setting all the data members |
|
1516 to zero. */ |
|
1517 MTmCustom::TLineHeightParam::TLineHeightParam() |
|
1518 { |
|
1519 Mem::FillZ(this,sizeof(*this)); |
|
1520 } |
|
1521 |
|
1522 CTmBufSeg::CTmBufSeg(TInt aExpandSize): |
|
1523 CBufSeg(aExpandSize) |
|
1524 { |
|
1525 } |
|
1526 |
|
1527 CTmCode::~CTmCode() |
|
1528 { |
|
1529 delete iBuffer; |
|
1530 } |
|
1531 |
|
1532 TPtr8 CTmCode::Ptr(TInt aPos) |
|
1533 { |
|
1534 return iBuffer->Ptr(aPos); |
|
1535 } |
|
1536 |
|
1537 CBufBase* CTmCode::Buffer() |
|
1538 { |
|
1539 return iBuffer; |
|
1540 } |
|
1541 |
|
1542 const CBufBase* CTmCode::Buffer() const |
|
1543 { |
|
1544 return iBuffer; |
|
1545 } |
|
1546 |
|
1547 /** Returns true if wrapping is turned on. */ |
|
1548 TBool TTmFormatParamBase::IsWrapping() const |
|
1549 { |
|
1550 return iFlags & EWrap; |
|
1551 } |
|
1552 |
|
1553 /** Returns true if truncation with ellipsis is turned on. */ |
|
1554 TBool TTmFormatParamBase::IsTruncatingWithEllipsis() const |
|
1555 { |
|
1556 return iFlags & ETruncateWithEllipsis; |
|
1557 } |
|
1558 |
|
1559 /** Returns true if line breaking must only occur at legal line breaks, even if |
|
1560 the line cannot legally be broken at the desired wrap width. */ |
|
1561 TBool TTmFormatParamBase::LegalLineBreaksOnly() const |
|
1562 { |
|
1563 return iFlags & ELegalLineBreaksOnly; |
|
1564 } |
|
1565 |
|
1566 /** Constructs a TTmLineInfo object, setting all data members to 0. */ |
|
1567 TTmLineInfo::TTmLineInfo() |
|
1568 { |
|
1569 Mem::FillZ(this,sizeof(*this)); |
|
1570 } |
|
1571 |
|
1572 /** Constructs a TTmDocPos object, setting iPos to 0 and iLeadingEdge to false. |
|
1573 This is the lowest legal value for a TTmDocPos object. A trailing edge comes |
|
1574 before a leading edge because it is the trailing edge of the character before |
|
1575 the position, while the leading edge is that of the character after the |
|
1576 position. ('Leading' means the first to be encountered when traversing the |
|
1577 document in logical order). */ |
|
1578 TTmDocPos::TTmDocPos(): |
|
1579 iPos(0), |
|
1580 iLeadingEdge(FALSE) |
|
1581 { |
|
1582 } |
|
1583 |
|
1584 /** Constructs a TTmDocPos object, setting iPos to aPos and iLeadingEdge to |
|
1585 aLeadingEdge. |
|
1586 */ |
|
1587 TTmDocPos::TTmDocPos(TInt aPos,TBool aLeadingEdge): |
|
1588 iPos(aPos), |
|
1589 iLeadingEdge(aLeadingEdge) |
|
1590 { |
|
1591 } |
|
1592 |
|
1593 /** Constructs a TTmDocPosSpec, setting the position to 0 and the type to |
|
1594 trailing. */ |
|
1595 TTmDocPosSpec::TTmDocPosSpec(): |
|
1596 iPos(0), |
|
1597 iType(ETrailing) |
|
1598 { |
|
1599 } |
|
1600 |
|
1601 |
|
1602 /** |
|
1603 The not equal operator. |
|
1604 @return True if both sides have different values. |
|
1605 */ |
|
1606 TBool TTmDocPos::operator!=(const TTmDocPos& aPos) const { return !((*this)==aPos); } |
|
1607 |
|
1608 /** |
|
1609 Smaller than operator. |
|
1610 @return |
|
1611 True if the right side of the operator is further on in the document than |
|
1612 the left hand side. |
|
1613 */ |
|
1614 TBool TTmDocPos::operator<(const TTmDocPos& aPos) const { return !((*this)>=aPos); } |
|
1615 |
|
1616 /** |
|
1617 Smaller than or equal to operator. |
|
1618 @return |
|
1619 True if the right side of the operator is further on in the document than |
|
1620 the left hand side or if both sides are identical. |
|
1621 */ |
|
1622 TBool TTmDocPos::operator<=(const TTmDocPos& aPos) const { return !((*this)>aPos); } |
|
1623 |
|
1624 /** Constructs a TTmDocPosSpec, setting the position to aPos and the type to |
|
1625 aType. |
|
1626 */ |
|
1627 TTmDocPosSpec::TTmDocPosSpec(TInt aPos,TType aType): |
|
1628 iPos(aPos), |
|
1629 iType(aType) |
|
1630 { |
|
1631 } |
|
1632 |
|
1633 /** Constructs a TTmDocPosSpec from a TTmDocPos. */ |
|
1634 TTmDocPosSpec::TTmDocPosSpec(const TTmDocPos& aDocPos): |
|
1635 iPos(aDocPos.iPos), |
|
1636 iType(aDocPos.iLeadingEdge ? ELeading : ETrailing) |
|
1637 { |
|
1638 } |
|
1639 |
|
1640 /** Returns the first formatted character. */ |
|
1641 TInt CTmTextLayout::StartChar() const |
|
1642 { |
|
1643 return iStartChar; |
|
1644 } |
|
1645 |
|
1646 /** Returns the character after the last formatted character. */ |
|
1647 TInt CTmTextLayout::EndChar() const |
|
1648 { |
|
1649 return iEndChar; |
|
1650 } |
|
1651 |
|
1652 /** Return the width in pixels of the formatted text, not including paragraph |
|
1653 labels if present. */ |
|
1654 TInt CTmTextLayout::LayoutWidth() const |
|
1655 { |
|
1656 return iWidth; |
|
1657 } |
|
1658 |
|
1659 /** Returns the height in pixels of the formatted text. */ |
|
1660 TInt CTmTextLayout::LayoutHeight() const |
|
1661 { |
|
1662 return iHeight; |
|
1663 } |
|
1664 |
|
1665 /** Returns a pointer to to the MTmSource object, if any, that provides text |
|
1666 and formatting to this object. Returns null if no source object has been set. */ |
|
1667 MTmSource* CTmTextLayout::Source() |
|
1668 { |
|
1669 return iSource; |
|
1670 } |
|
1671 |
|
1672 const MTmSource* CTmTextLayout::Source() const |
|
1673 { |
|
1674 return iSource; |
|
1675 } |
|
1676 |
|
1677 /** |
|
1678 Returns a reference to the CTmCode object containing the bytecode |
|
1679 representing the text layout. |
|
1680 @internalComponent |
|
1681 */ |
|
1682 const CTmCode& CTmTextLayout::Code() const |
|
1683 { |
|
1684 return iCode; |
|
1685 } |
|
1686 |
|
1687 /** Constructs a TTmCharFormatLayer object containing default TTmCharFormat and |
|
1688 TTmCharFormatMask objects. */ |
|
1689 TTmCharFormatLayer::TTmCharFormatLayer() |
|
1690 { |
|
1691 } |
|
1692 |
|
1693 /** Closes an RTmParFormatLayer object by freeing any objects allocated on the |
|
1694 heap. */ |
|
1695 void RTmParFormatLayer::Close() |
|
1696 { |
|
1697 iFormat.Close(); |
|
1698 } |
|
1699 |
|
1700 /** Closes an RTmStyle object by freeing any objects allocated on the heap. |
|
1701 */ |
|
1702 void RTmStyle::Close() |
|
1703 { |
|
1704 iParFormat.Close(); |
|
1705 } |
|
1706 |
|
1707 /** Draws the formatted text. This inline function just calls |
|
1708 CTmText::DrawLayout and is identical to it. It is provided for coding |
|
1709 convenience because of the expectation that a drawing function called Draw |
|
1710 exists. */ |
|
1711 void CTmText::Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, |
|
1712 const TLogicalRgb* aDocBackground,TBool aDrawParBackground) |
|
1713 { |
|
1714 DrawLayout(aGc,aTopLeft,aClipRect,aDocBackground,aDrawParBackground); |
|
1715 } |
|
1716 |
|
1717 /** Contains the extensions to character rectangle used when highlighting |
|
1718 the text in reverse video |
|
1719 */ |
|
1720 TTmHighlightExtensions::TTmHighlightExtensions() |
|
1721 { |
|
1722 } |
|
1723 |
|
1724 void TTmHighlightExtensions::SetAll(TInt aExtension) |
|
1725 { |
|
1726 iLeftExtension=iRightExtension=iTopExtension=iBottomExtension=aExtension; |
|
1727 } |
|
1728 |
|
1729 void TTmHighlightExtensions::SetLeftExtension(TInt aExtension) |
|
1730 { |
|
1731 iLeftExtension=aExtension; |
|
1732 } |
|
1733 |
|
1734 void TTmHighlightExtensions::SetRightExtension(TInt aExtension) |
|
1735 { |
|
1736 iRightExtension=aExtension; |
|
1737 } |
|
1738 |
|
1739 void TTmHighlightExtensions::SetTopExtension(TInt aExtension) |
|
1740 { |
|
1741 iTopExtension=aExtension; |
|
1742 } |
|
1743 |
|
1744 void TTmHighlightExtensions::SetBottomExtension(TInt aExtension) |
|
1745 { |
|
1746 iBottomExtension=aExtension; |
|
1747 } |
|
1748 |
|
1749 TInt TTmHighlightExtensions::LeftExtension() const |
|
1750 { |
|
1751 return iLeftExtension; |
|
1752 } |
|
1753 |
|
1754 TInt TTmHighlightExtensions::RightExtension() const |
|
1755 { |
|
1756 return iRightExtension; |
|
1757 } |
|
1758 |
|
1759 TInt TTmHighlightExtensions::TopExtension() const |
|
1760 { |
|
1761 return iTopExtension; |
|
1762 } |
|
1763 |
|
1764 TInt TTmHighlightExtensions::BottomExtension() const |
|
1765 { |
|
1766 return iBottomExtension; |
|
1767 } |
|
1768 |
|
1769 inline TBool TTmHighlightExtensions::Extends() const |
|
1770 { |
|
1771 return (iTopExtension > 0 || iBottomExtension > 0 || iLeftExtension > 0 || iRightExtension > 0); |
|
1772 } |
|
1773 |
|
1774 inline TBool TTmHighlightExtensions::Shrinks() const |
|
1775 { |
|
1776 return (iTopExtension < 0 || iBottomExtension < 0 || iLeftExtension < 0 || iRightExtension < 0); |
|
1777 } |
|
1778 |
|
1779 inline void TTmHighlightExtensions::ExtendRect(TRect& aRect) const |
|
1780 { |
|
1781 if (iLeftExtension>0) |
|
1782 aRect.iTl.iX-=iLeftExtension; |
|
1783 if (iRightExtension>0) |
|
1784 aRect.iBr.iX+=iRightExtension; |
|
1785 if (iTopExtension>0) |
|
1786 aRect.iTl.iY-=iTopExtension; |
|
1787 if (iBottomExtension>0) |
|
1788 aRect.iBr.iY+=iBottomExtension; |
|
1789 } |
|
1790 |
|
1791 inline void TTmHighlightExtensions::AdjustRect(TRect& aRect) const |
|
1792 { |
|
1793 aRect.iTl.iX-=iLeftExtension; |
|
1794 aRect.iTl.iY-=iTopExtension; |
|
1795 aRect.iBr.iX+=iRightExtension; |
|
1796 aRect.iBr.iY+=iBottomExtension; |
|
1797 } |
|
1798 |
|
1799 inline TBool TTmHighlightExtensions::IsNull() const |
|
1800 { |
|
1801 return 0 == iLeftExtension && 0 == iTopExtension && 0 == iRightExtension && 0 == iBottomExtension; |
|
1802 } |
|
1803 |
|
1804 inline void TTmHighlightExtensions::AbsExtendRect(TRect& aRect) const |
|
1805 { |
|
1806 if (iLeftExtension>0) |
|
1807 aRect.iTl.iX-=iLeftExtension; |
|
1808 else |
|
1809 aRect.iTl.iX+=iLeftExtension; |
|
1810 |
|
1811 if (iRightExtension>0) |
|
1812 aRect.iBr.iX+=iRightExtension; |
|
1813 else |
|
1814 aRect.iBr.iX-=iRightExtension; |
|
1815 |
|
1816 if (iTopExtension>0) |
|
1817 aRect.iTl.iY-=iTopExtension; |
|
1818 else |
|
1819 aRect.iTl.iY+=iTopExtension; |
|
1820 |
|
1821 if (iBottomExtension>0) |
|
1822 aRect.iBr.iY+=iBottomExtension; |
|
1823 else |
|
1824 aRect.iBr.iY-=iBottomExtension; |
|
1825 } |
|
1826 |
|
1827 #endif // __TAGMA_H__ |