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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
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.
29 #include <linebreak.h>
31 // forward declarations
36 class RParagraphStyleInfo;
40 class TCursorSelection;
41 class TTmHighlightExtensions;
42 class TBidirectionalContext;
45 A bit mask for selecting one or more attributes of a TTmCharFormat object.
48 class TTmCharFormatMask
52 /** Constants, that are also bit assignments, representing character format attributes */
62 EPrintPosition = 0x80,
64 EBackgroundColor = 0x200,
67 EStrikethrough = 0x1000,
69 EUserDefinedEffects = 0x4000,
71 EPictureAlignment = 0x10000
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);
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
94 /** Bit assignments for effects */
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
114 /** Picture alignment */
115 enum TPictureAlignment
117 EPictureAlignBaseline,
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;
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
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
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
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;
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.
186 ESmallRomanNumberStyle,
187 ECapitalRomanNumberStyle,
192 /** The alignment within the margin of bullets or other text used in TTmBullet objects */
195 /** Bullet forward aligned. */
197 /** Bullet centre aligned. */
199 /** Bullet reverse aligned. */
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;
210 TChar iCharacterCode; // the bullet or other symbol used if iStyle is EBulletStyle
211 TOpenFontSpec iFontSpec;
212 TBool iHangingIndent;
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
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.
228 /** Paragraph border style */
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;
254 A bit mask for selecting one or more attributes of an RTmParFormat.
257 class TTmParFormatMask
261 /** Constants, that are also bit assignments, representing paragraph format attributes */
268 EStartNewPage = 0x10,
271 EExactLineSpacing = 0x80,
272 EPixelLineSpacing = 0x100,
273 ELeadingMargin = 0x200,
274 ETrailingMargin = 0x400,
275 EFirstLineIndent = 0x800,
276 ELineSpacing = 0x1000,
277 ESpaceAbove = 0x2000,
278 ESpaceBelow = 0x4000,
280 EBorderMargin = 0x10000,
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);
297 Paragraph format; all dimensions are in twips unless otherwise specified.
304 /** Index used to select one of the four borders of a paragraph */
313 /** Bit assignments for RTmParFormat::iFlags. */
316 /** Base direction of paragraph is right-to-left (as for Arabic) */
318 /** Do not allow paragraph to straddle page boundaries. */
320 /** Put this paragraph on the same page as the next. */
322 /** Put this paragraph at the start of a new page. */
324 /** Suppress widows and orphans. */
326 /** Suppresses line breaking. */
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
337 /** Paragraph alignment */
340 EAlignNormalBidirectional,
341 EAlignNormal = EAlignNormalBidirectional, /** @deprecated in 7.0s */
343 EAlignReverseBidirectional,
344 EAlignReverse = EAlignReverseBidirectional, /** @deprecated in 7.0s */
350 IMPORT_C RTmParFormat();
351 IMPORT_C void Close();
353 inline ~RTmParFormat();
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;
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
380 RTmParFormat(const RTmParFormat& aFormat); // deliberately unimplemented
381 void operator=(const RTmParFormat& aFormat);// deliberately unimplemented
383 RArray<TTmTab>* iTabList; // custom tabs if any
384 TTmBullet* iBullet; // bullet if any
385 TTmParBorder* iBorder[4]; // borders if any
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
400 : public MLineBreaker
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()
411 class TLineHeightParam
414 inline TLineHeightParam();
415 /** Height of the highest character in the line. */
417 /** Depth of the deepest character in the line. */
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. */
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;
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.
448 /** Opening Punctuation (e.g. '['). Breaking after prohibited. */
450 /** Closing Punctuation (e.g. ']'). Breaking before prohibited. */
452 /** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */
454 /** Glue (e.g. Non-breaking space). Breaking before and after prohibited
455 unless spaces are present. */
457 /** Non-Starter (e.g. small Japanese kana). Breaking before prohibited
458 if no spaces present. */
460 /** Exclamation or Interrogation (e.g. '?'). Like closing punctuation
461 except before Postfix or Non-starter. */
463 /** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before
466 /** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before
469 /** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */
471 /** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */
473 /** Numeric (e.g. '1'). */
475 /** Alphabetic (e.g. 'a'). */
477 /** Ideographic (e.g. Japanese Kanji). Generally break before or after */
479 /** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */
481 /** Hyphen (e.g. '-'). Allows a break after except before Numeric. */
483 /** Break After. Generally allow a break after. Breaking between Break
484 Afters not separated by spaces is prohibited. */
486 /** Break Before. Generally allow a break before. Breaking between Break
487 Befores not separated by spaces is prohibited. */
489 /** Break Before and After. Generally allow a break before or after.
490 Breaking between Break Before and Afters is prohibited, even if spaces
493 /** Zero-Width Space. Allow a break. */
495 /** Combining Mark. Takes on the class of its base class. */
497 /** Mandatory Break. */
499 /** Carriage Return. Break after unless part of a CRLF pair. */
501 /** Line Feed. Break after. */
503 /** Surrogate. Half of a surrogate pair. */
505 /** Contingent Break (e.g. embedded pictures). Uses external
509 /** Space. Intervening characters of class Space are indicated by
510 aHaveSpaces in LineBreakPossible. */
513 /** Complex Context (e.g. Thai). Runs of Complex Context are passed to
514 GetLineBreakInContext. */
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. */
522 /** The Xx class is used when the class is unknown; e.g.; outside the provided context. */
525 /** The number of Unicode line break classes. */
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;
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;
556 MTmTextDrawExt interface UID.
559 const TUid KTmTextDrawExtId = {0x10203665};
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.
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;
583 const TUid KFormLabelApiExtensionUid = { 0x101FD03C};
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.
592 class MTmSource: public MTmCustom
596 /** Label type used in LabelModeSelect */
599 /** Not a label; used for TLabelTypes not yet assigned. */
602 /** Paragraph label of the type supported by FORM. */
609 The maximum number of characters supplied to GetLineBreak, after aMaxBreakPos,
610 and after trailing whitespace, to provide context for line breaking decisions.
612 ELineBreakContext = 32
617 /** Return the device used to format the text. */
618 virtual MGraphicsDeviceMap& FormatDevice() const = 0;
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.
625 virtual MGraphicsDeviceMap& InterpretDevice() const = 0;
627 /** Return the length of the document in characters. */
628 virtual TInt DocumentLength() const = 0;
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.
634 virtual void GetText(TInt aPos,TPtrC& aText,TTmCharFormat& aFormat) const = 0;
637 Return the paragraph format of the paragraph containing aPos. End-of-paragraph characters belong to the preceding
640 virtual void GetParagraphFormatL(TInt aPos,RTmParFormat& aFormat) const = 0;
643 Return the document position of the start of the paragraph containing aPos. End-of-paragraph characters belong to
644 the preceding paragraph.
646 virtual TInt ParagraphStart(TInt aPos) const = 0;
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;
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);
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.
669 @see MTmSource::GetExtendedInterface
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;
683 class CTmBufSeg: public CBufSeg
686 inline CTmBufSeg(TInt aExpandSize);
687 TInt MemoryUsed() const;
690 /** @internalTechnology */
691 class CTmCode: public CBase
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;
704 void Delete(TInt aPos,TInt aLength);
706 inline TPtr8 Ptr(TInt aPos);
707 void CreateBufferL();
708 inline CBufBase* Buffer();
709 inline const CBufBase* Buffer() const;
716 TInt WriteNumber(TInt aNumber,TUint8* aBuffer);
722 Formatting parameters used when formatting part of a layout object.
725 class TTmFormatParamBase
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
738 IMPORT_C TTmFormatParamBase();
739 inline TBool IsWrapping() const;
740 inline TBool IsTruncatingWithEllipsis() const;
741 inline TBool LegalLineBreaksOnly() const;
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 '...').
752 Formatting parameters used when formatting an entire layout object or
753 creating a section of format code.
756 class TTmFormatParam: public TTmFormatParamBase
760 IMPORT_C TTmFormatParam();
761 IMPORT_C TTmFormatParam(const TTmFormatParamBase& aBase);
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
769 Additional parameters used when reformatting.
772 class TTmReformatParam
776 IMPORT_C TTmReformatParam();
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
788 Information returned when reformatting.
791 class TTmReformatResult
795 IMPORT_C TTmReformatResult();
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
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.
818 // bit values for iFlags
824 ELineEndsInForcedLineBreak = 8,
825 EPictureButtsLowerEdge = 16, /**< @deprecated - no effect, present for compatibility only */
826 EPictureButtsUpperEdge = 32 /**< @deprecated - no effect, present for compatibility only */
829 inline TTmLineInfo();
831 /** Outer enclosing rectangle including margins */
834 /** Inner enclosing rectangle: the text only */
837 /** y coordinate of the baseline */
840 /** Start document position */
843 /** End document position */
849 /** Paragraph number */
852 /** Line number in the paragraph */
855 /** y coordinate of the top of the paragraph */
858 /** Start of paragraph, end of paragraph, etc. */
863 A structure to hold a logical document position that can be converted to a raw
864 document position or an x-y position.
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
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.
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
903 inline TTmDocPosSpec();
904 inline TTmDocPosSpec(TInt aPos,TType aType);
905 inline TTmDocPosSpec(const TTmDocPos& aRawDocPos);
907 /** the edge position in the document; 0 ... document length */
909 /** the type as specified above */
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.
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;
936 /** the edge position in the document; 0 ... document length */
938 /** true if the position is a leading edge */
943 Holds information about a position in a document.
951 /** Document position. */
953 /** True if the position is attatched to text flowing right-to-left. */
955 /** Intersection of the character edge with the baseline. */
960 A structure for returning information about a position in a line.
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
977 class TTmHighlightExtensions
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;
999 TInt iRightExtension;
1001 TInt iBottomExtension;
1005 Cursor placement. Used as an argument to CTextView::SetCursorPlacement().
1006 @see CTextView::SetCursorPlacement()
1009 enum TTmCursorPlacement
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. */
1015 /** The text cursor is an underline below the character logically after the insertion
1017 ECursorUnderlineNext,
1018 /** The text cursor is an underline below the character logically before the insertion
1020 ECursorUnderlinePrev
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.
1027 There are functions for setting the text, drawing it, and converting between x-y coordinates and document positions.
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.
1035 Coordinates and units
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
1041 Document format and positions
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.
1054 class CTmTextLayout: public CBase
1059 class TTmChunkDescription
1061 Output from FindAdjacentChunks. Describes a chunk of text that is of a
1062 constant format and directionality.
1067 /** Position of the first character in the chunk. A negative number
1068 indicates "no such chunk". */
1070 /** One past the position of the last character in the chunk. */
1072 /** ETrue if the chunk is displayed right-to-left. */
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);
1147 // deprecated functions
1149 IMPORT_C TBool GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const;
1151 IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const;
1153 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const;
1155 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const;
1157 IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const;
1159 IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos,
1160 TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo,
1161 TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const;
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;
1170 IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo, TInt& aSubscript) const;
1172 TBool LastLine(TTmLineInfo& aLine);
1174 void Invariant() const;
1176 void Invariant() const { }
1178 void AdjustWidth(const TTmFormatParamBase& aParam,TInt aWidthOfNewText);
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.
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.
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
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.
1210 class MTmTextLayoutForwarder
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;
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;
1249 // deprecated functions
1251 IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const;
1253 IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const;
1255 IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const;
1257 IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const;
1259 IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos,
1260 TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo,
1261 TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const;
1263 /** Returns a reference to the CTmTextLayoutObject this
1264 MTmTextLayoutForwarder forwards inquiries to. */
1265 virtual const CTmTextLayout& TextLayout() const = 0;
1267 /** The origin is subtracted from coordinates passed in and added to those
1269 IMPORT_C virtual void GetOrigin(TPoint& aPoint) const;
1271 void FixUpLineInfo(TTmLineInfo& aInfo,const TPoint* aOrigin = NULL) const;
1275 A character format layer. Unmasked attributes are transparent.
1278 class TTmCharFormatLayer
1282 inline TTmCharFormatLayer();
1283 IMPORT_C TTmCharFormatLayer(const CCharFormatLayer& aFormat);
1285 TTmCharFormat iFormat;
1286 TTmCharFormatMask iMask;
1290 A paragraph format layer. Unmasked attributes are transparent.
1293 class RTmParFormatLayer
1297 inline void Close();
1298 IMPORT_C void CopyL(const CParaFormatLayer& aFormat);
1300 RTmParFormat iFormat;
1301 TTmParFormatMask iMask;
1314 EMaxName = KMaxParagraphStyleName
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;
1323 TBuf<KMaxName> iName;
1324 TBuf<KMaxName> iNextStyleName;
1325 TTmCharFormatLayer iCharFormat;
1326 RTmParFormatLayer iParFormat;
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
1336 class CTmText: public CBase, public MTmTextLayoutForwarder
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);
1358 IMPORT_C void Spare1();
1360 // implementations of MTmTextLayoutForwarder virtual functions
1361 const CTmTextLayout& TextLayout() const;
1363 CTmTextImp* iImp; // the implementation
1367 /** Constructs a TTmCharFormatMask. Turns all the flags on. */
1368 TTmCharFormatMask::TTmCharFormatMask(): iFlags(0xFFFFFFFF)
1372 /** Clears the selected flag.*/
1373 void TTmCharFormatMask::Clear(TAttrib aAttrib)
1378 /** Sets the selected flag. */
1379 void TTmCharFormatMask::Set(TAttrib aAttrib)
1384 /** Returns true if the selected attribute is set. */
1385 TBool TTmCharFormatMask::IsSet(TAttrib aAttrib)
1387 return iFlags & aAttrib;
1390 /** Constructs a TTmCharFormat by converting the information in a TCharFormat. */
1391 TTmCharFormat::TTmCharFormat(const TCharFormat& aFormat)
1396 /** The inequality operator. Return TRUE if this object and aFormat differ in any way. */
1397 TBool TTmCharFormat::operator!=(const TTmCharFormat& aFormat) const
1399 return !operator==(aFormat);
1402 /** Constructs a TTmTab and set it to a standard tab stop with a position of 0. */
1409 /** Constructs a TTmTab by converting the information in a TTabStop. */
1410 TTmTab::TTmTab(const TTabStop& aTab)
1415 /** The inequality operator. Returns TRUE if this object and aTab differ in any
1417 TBool TTmTab::operator!=(const TTmTab& aTab) const
1419 return !operator==(aTab);
1422 /** Constructs a TTmBullet by converting the information in a TBullet. */
1423 TTmBullet::TTmBullet(const TBullet& aBullet)
1428 /** The inequality operator. Returns true if this object and aBullet differ in
1430 TBool TTmBullet::operator!=(const TTmBullet& aBullet) const
1432 return !operator==(aBullet);
1435 /** Constructs a TTmParBorder by converting the information in a TParaBorder. */
1436 TTmParBorder::TTmParBorder(const TParaBorder& aBorder)
1441 /** The inequality operator. Returns TRUE if this object and aBorder differ in
1443 TBool TTmParBorder::operator!=(const TTmParBorder& aBorder) const
1445 return !operator==(aBorder);
1448 /** Constructs a TTmParFormatMask with all the flags on. */
1449 TTmParFormatMask::TTmParFormatMask():
1454 /** Clears the selected flag. */
1455 void TTmParFormatMask::Clear(TAttrib aAttrib)
1460 /** Sets the selected flag. */
1461 void TTmParFormatMask::Set(TAttrib aAttrib)
1467 Returns true if the selected flag is Set.
1469 TBool TTmParFormatMask::IsSet(TAttrib aAttrib)
1471 return iFlags & aAttrib;
1475 RTmParFormat::~RTmParFormat()
1477 __ASSERT_DEBUG(!iTabList && !iBullet && !HaveBorders(), User::Invariant());
1481 /** The inequality operator. Returns true if this object and aFormat differ in
1484 TBool RTmParFormat::operator!=(const RTmParFormat& aFormat) const
1486 return !operator==(aFormat);
1489 /** Returns a reference to the tab selected by aIndex. */
1490 const TTmTab& RTmParFormat::Tab(TInt aIndex) const
1492 return (*iTabList)[aIndex];
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
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
1506 return iBorder[aIndex];
1509 /** Returns true if the paragraph's base direction is right-to-left. */
1510 TBool RTmParFormat::RightToLeft() const
1512 return iFlags & ERightToLeft;
1515 /** Constructs a line height parameter structure, setting all the data members
1517 MTmCustom::TLineHeightParam::TLineHeightParam()
1519 Mem::FillZ(this,sizeof(*this));
1522 CTmBufSeg::CTmBufSeg(TInt aExpandSize):
1523 CBufSeg(aExpandSize)
1532 TPtr8 CTmCode::Ptr(TInt aPos)
1534 return iBuffer->Ptr(aPos);
1537 CBufBase* CTmCode::Buffer()
1542 const CBufBase* CTmCode::Buffer() const
1547 /** Returns true if wrapping is turned on. */
1548 TBool TTmFormatParamBase::IsWrapping() const
1550 return iFlags & EWrap;
1553 /** Returns true if truncation with ellipsis is turned on. */
1554 TBool TTmFormatParamBase::IsTruncatingWithEllipsis() const
1556 return iFlags & ETruncateWithEllipsis;
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
1563 return iFlags & ELegalLineBreaksOnly;
1566 /** Constructs a TTmLineInfo object, setting all data members to 0. */
1567 TTmLineInfo::TTmLineInfo()
1569 Mem::FillZ(this,sizeof(*this));
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():
1584 /** Constructs a TTmDocPos object, setting iPos to aPos and iLeadingEdge to
1587 TTmDocPos::TTmDocPos(TInt aPos,TBool aLeadingEdge):
1589 iLeadingEdge(aLeadingEdge)
1593 /** Constructs a TTmDocPosSpec, setting the position to 0 and the type to
1595 TTmDocPosSpec::TTmDocPosSpec():
1603 The not equal operator.
1604 @return True if both sides have different values.
1606 TBool TTmDocPos::operator!=(const TTmDocPos& aPos) const { return !((*this)==aPos); }
1609 Smaller than operator.
1611 True if the right side of the operator is further on in the document than
1614 TBool TTmDocPos::operator<(const TTmDocPos& aPos) const { return !((*this)>=aPos); }
1617 Smaller than or equal to operator.
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.
1622 TBool TTmDocPos::operator<=(const TTmDocPos& aPos) const { return !((*this)>aPos); }
1624 /** Constructs a TTmDocPosSpec, setting the position to aPos and the type to
1627 TTmDocPosSpec::TTmDocPosSpec(TInt aPos,TType aType):
1633 /** Constructs a TTmDocPosSpec from a TTmDocPos. */
1634 TTmDocPosSpec::TTmDocPosSpec(const TTmDocPos& aDocPos):
1636 iType(aDocPos.iLeadingEdge ? ELeading : ETrailing)
1640 /** Returns the first formatted character. */
1641 TInt CTmTextLayout::StartChar() const
1646 /** Returns the character after the last formatted character. */
1647 TInt CTmTextLayout::EndChar() const
1652 /** Return the width in pixels of the formatted text, not including paragraph
1653 labels if present. */
1654 TInt CTmTextLayout::LayoutWidth() const
1659 /** Returns the height in pixels of the formatted text. */
1660 TInt CTmTextLayout::LayoutHeight() const
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()
1672 const MTmSource* CTmTextLayout::Source() const
1678 Returns a reference to the CTmCode object containing the bytecode
1679 representing the text layout.
1682 const CTmCode& CTmTextLayout::Code() const
1687 /** Constructs a TTmCharFormatLayer object containing default TTmCharFormat and
1688 TTmCharFormatMask objects. */
1689 TTmCharFormatLayer::TTmCharFormatLayer()
1693 /** Closes an RTmParFormatLayer object by freeing any objects allocated on the
1695 void RTmParFormatLayer::Close()
1700 /** Closes an RTmStyle object by freeing any objects allocated on the heap.
1702 void RTmStyle::Close()
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
1711 void CTmText::Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,
1712 const TLogicalRgb* aDocBackground,TBool aDrawParBackground)
1714 DrawLayout(aGc,aTopLeft,aClipRect,aDocBackground,aDrawParBackground);
1717 /** Contains the extensions to character rectangle used when highlighting
1718 the text in reverse video
1720 TTmHighlightExtensions::TTmHighlightExtensions()
1724 void TTmHighlightExtensions::SetAll(TInt aExtension)
1726 iLeftExtension=iRightExtension=iTopExtension=iBottomExtension=aExtension;
1729 void TTmHighlightExtensions::SetLeftExtension(TInt aExtension)
1731 iLeftExtension=aExtension;
1734 void TTmHighlightExtensions::SetRightExtension(TInt aExtension)
1736 iRightExtension=aExtension;
1739 void TTmHighlightExtensions::SetTopExtension(TInt aExtension)
1741 iTopExtension=aExtension;
1744 void TTmHighlightExtensions::SetBottomExtension(TInt aExtension)
1746 iBottomExtension=aExtension;
1749 TInt TTmHighlightExtensions::LeftExtension() const
1751 return iLeftExtension;
1754 TInt TTmHighlightExtensions::RightExtension() const
1756 return iRightExtension;
1759 TInt TTmHighlightExtensions::TopExtension() const
1761 return iTopExtension;
1764 TInt TTmHighlightExtensions::BottomExtension() const
1766 return iBottomExtension;
1769 inline TBool TTmHighlightExtensions::Extends() const
1771 return (iTopExtension > 0 || iBottomExtension > 0 || iLeftExtension > 0 || iRightExtension > 0);
1774 inline TBool TTmHighlightExtensions::Shrinks() const
1776 return (iTopExtension < 0 || iBottomExtension < 0 || iLeftExtension < 0 || iRightExtension < 0);
1779 inline void TTmHighlightExtensions::ExtendRect(TRect& aRect) const
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;
1791 inline void TTmHighlightExtensions::AdjustRect(TRect& aRect) const
1793 aRect.iTl.iX-=iLeftExtension;
1794 aRect.iTl.iY-=iTopExtension;
1795 aRect.iBr.iX+=iRightExtension;
1796 aRect.iBr.iY+=iBottomExtension;
1799 inline TBool TTmHighlightExtensions::IsNull() const
1801 return 0 == iLeftExtension && 0 == iTopExtension && 0 == iRightExtension && 0 == iBottomExtension;
1804 inline void TTmHighlightExtensions::AbsExtendRect(TRect& aRect) const
1806 if (iLeftExtension>0)
1807 aRect.iTl.iX-=iLeftExtension;
1809 aRect.iTl.iX+=iLeftExtension;
1811 if (iRightExtension>0)
1812 aRect.iBr.iX+=iRightExtension;
1814 aRect.iBr.iX-=iRightExtension;
1816 if (iTopExtension>0)
1817 aRect.iTl.iY-=iTopExtension;
1819 aRect.iTl.iY+=iTopExtension;
1821 if (iBottomExtension>0)
1822 aRect.iBr.iY+=iBottomExtension;
1824 aRect.iBr.iY-=iBottomExtension;
1827 #endif // __TAGMA_H__