williamr@2: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // 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 williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // The main header file for TAGMA, the low-level text formatting engine for EPOC. williamr@2: // 'Tm' stands for 'TAGMA' and is the standard prefix for TAGMA classes, after williamr@2: // the C, T, or whatever. williamr@2: // williamr@2: // williamr@2: williamr@2: williamr@2: williamr@2: #ifndef __TAGMA_H__ williamr@2: #define __TAGMA_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // forward declarations williamr@2: class TTmLineInfo; williamr@2: class CTmTextImp; williamr@2: class RWindow; williamr@2: class RWsSession; williamr@2: class RParagraphStyleInfo; williamr@2: class CStyleList; williamr@2: class TTmDocPosSpec; williamr@2: class TTmDocPos; williamr@2: class TCursorSelection; williamr@2: class TTmHighlightExtensions; williamr@2: class TBidirectionalContext; williamr@2: williamr@2: /** williamr@2: A bit mask for selecting one or more attributes of a TTmCharFormat object. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmCharFormatMask williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Constants, that are also bit assignments, representing character format attributes */ williamr@2: enum TAttrib williamr@2: { williamr@2: EFontName = 0x1, williamr@2: EFontCoverage = 0x2, williamr@2: EBold = 0x4, williamr@2: EItalic = 0x8, williamr@2: ESerif = 0x10, williamr@2: EMonoWidth = 0x20, williamr@2: EHeight = 0x40, williamr@2: EPrintPosition = 0x80, williamr@2: ETextColor = 0x100, williamr@2: EBackgroundColor = 0x200, williamr@2: EBackground = 0x400, williamr@2: EUnderline = 0x800, williamr@2: EStrikethrough = 0x1000, williamr@2: EShadow = 0x2000, williamr@2: EUserDefinedEffects = 0x4000, williamr@2: ELanguage = 0x8000, williamr@2: EPictureAlignment = 0x10000 williamr@2: }; williamr@2: williamr@2: inline TTmCharFormatMask(); williamr@2: IMPORT_C TTmCharFormatMask(const TCharFormatMask& aMask); williamr@2: IMPORT_C void GetTCharFormatMask(TCharFormatMask& aMask) const; williamr@2: inline void Clear(TAttrib aAttrib); williamr@2: inline void Set(TAttrib aAttrib); williamr@2: inline TBool IsSet(TAttrib aAttrib); williamr@2: williamr@2: TUint iFlags; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A character format; all dimensions are in twips. A character format object williamr@2: stores all text style attributes that can differ from any one character to the williamr@2: next. Attributes that affect an entire paragraph only are kept in RTmParFormat williamr@2: objects. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmCharFormat williamr@2: { williamr@2: public: williamr@2: /** Bit assignments for effects */ williamr@2: enum williamr@2: { williamr@2: EBackground = 1, ///< Text background is drawn in the background colour williamr@2: ERounded = 2, ///< Text background (if any) has rounded corners williamr@2: EUnderline = 4, ///< Text is underlined williamr@2: EStrikethrough = 8, ///< Text is struck through with a horizontal line. williamr@2: EShadow = 16, ///< Text has a drop shadow. williamr@2: /** Bits 24-31 are reserved for styles defined by the custom drawer. */ williamr@2: EUserDefinedMask = 0xFF000000, williamr@2: /** Shift TCharFormat highlight styles left by this to get the williamr@2: TTmCharFormat effects portion. */ williamr@2: EUserDefinedShift = 24, williamr@2: /** For custom drawers: draw whatever is wanted for "no matches" in the FEP. */ williamr@2: ENoMatchesIndicator = 0x4000000, williamr@2: /** Reset if the effect in bits 24-30 is defined defined by Symbian, williamr@2: set if it is defined externally. */ williamr@2: ECustomDrawEffectIsExternallyDefined = 0x80000000 williamr@2: }; williamr@2: williamr@2: /** Picture alignment */ williamr@2: enum TPictureAlignment williamr@2: { williamr@2: EPictureAlignBaseline, williamr@2: EPictureAlignTop, williamr@2: EPictureAlignBottom, williamr@2: EPictureAlignCenter williamr@2: }; williamr@2: williamr@2: IMPORT_C TTmCharFormat(); williamr@2: IMPORT_C TTmCharFormat(const TDesC& aFontName,TInt aFontHeight); williamr@2: IMPORT_C void operator=(const TCharFormat& aFormat); williamr@2: inline TTmCharFormat(const TCharFormat& aFormat); williamr@2: IMPORT_C void GetTCharFormat(TCharFormat& aFormat) const; williamr@2: IMPORT_C TBool operator==(const TTmCharFormat& aFormat) const; williamr@2: inline TBool operator!=(const TTmCharFormat& aFormat) const; williamr@2: williamr@2: TOpenFontSpec iFontSpec; williamr@2: TLogicalRgb iTextColor; williamr@2: TLogicalRgb iBackgroundColor; // used only when EBackground flag is set in iEffects williamr@2: TUint iEffects; // bit flags as defined above; williamr@2: // note that effects NEVER change character metrics and so can williamr@2: // be ignored when measuring text williamr@2: TUint iLanguage; // language used for proofing williamr@2: TPictureAlignment iPictureAlignment;// vertical alignment of embedded objects williamr@2: TUint iTag; // tag for use by URL parsers, etc.; a way of marking a range of williamr@2: // text without using any typographic attributes williamr@2: }; williamr@2: williamr@2: /** williamr@2: A tabulation position, measured from the start of the line, which will be williamr@2: the left end for paragraphs with a left-to-right base direction, and vice williamr@2: versa. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmTab williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Tab type */ williamr@2: enum TType williamr@2: { williamr@2: EStandardTab, // text is placed after the tab, in the current paragraph direction williamr@2: ECenterTab, // text is centred around the tab williamr@2: EReverseTab // text is placed before the tab, in the current paragraph direction williamr@2: }; williamr@2: williamr@2: inline TTmTab(); williamr@2: inline TTmTab(const TTabStop& aTab); williamr@2: IMPORT_C void operator=(const TTabStop& aTab); williamr@2: IMPORT_C void GetTTabStop(TTabStop& aTab) const; williamr@2: IMPORT_C TBool operator==(const TTmTab& aTab) const; williamr@2: inline TBool operator!=(const TTmTab& aTab) const; williamr@2: williamr@2: TInt iPosition; williamr@2: TType iType; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A bullet or other label inserted automatically at the start of a paragraph. williamr@2: As well as an actual bullet, it can be a number or a letter. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmBullet williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Bullet style */ williamr@2: enum TStyle williamr@2: { williamr@2: EBulletStyle, williamr@2: EArabicNumberStyle, williamr@2: ESmallRomanNumberStyle, williamr@2: ECapitalRomanNumberStyle, williamr@2: ESmallLetterStyle, williamr@2: ECapitalLetterStyle williamr@2: }; williamr@2: williamr@2: /** The alignment within the margin of bullets or other text used in TTmBullet objects */ williamr@2: enum TAlignment williamr@2: { williamr@2: /** Bullet forward aligned. */ williamr@2: ELeftAlign, williamr@2: /** Bullet centre aligned. */ williamr@2: ECenterAlign, williamr@2: /** Bullet reverse aligned. */ williamr@2: ERightAlign williamr@2: }; williamr@2: williamr@2: IMPORT_C TTmBullet(); williamr@2: IMPORT_C void operator=(const TBullet& aBullet); williamr@2: inline TTmBullet(const TBullet& aBullet); williamr@2: IMPORT_C void GetTBullet(TBullet& aBullet) const; williamr@2: IMPORT_C TBool operator==(const TTmBullet& aBullet) const; williamr@2: inline TBool operator!=(const TTmBullet& aBullet) const; williamr@2: williamr@2: TChar iCharacterCode; // the bullet or other symbol used if iStyle is EBulletStyle williamr@2: TOpenFontSpec iFontSpec; williamr@2: TBool iHangingIndent; williamr@2: TLogicalRgb iColor; williamr@2: TStyle iStyle; // is this a bullet or a number or a letter? williamr@2: TInt iStartNumber; // the number of the first paragraph in a run of paragraphs in this style williamr@2: TAlignment iAlignment; // alignment of the bullet or number within the margin williamr@2: }; williamr@2: williamr@2: /** williamr@2: A specification of a paragraph border rule: that is, a line or lines drawn williamr@2: above, below, to the left, or to the right of a paragraph. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmParBorder williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Paragraph border style */ williamr@2: enum TStyle williamr@2: { williamr@2: ESolidStyle, williamr@2: EDoubleStyle, williamr@2: EDotStyle, williamr@2: EDashStyle, williamr@2: EDotDashStyle, williamr@2: EDotDotDashStyle williamr@2: }; williamr@2: williamr@2: IMPORT_C TTmParBorder(); williamr@2: IMPORT_C void operator=(const TParaBorder& aBorder); williamr@2: inline TTmParBorder(const TParaBorder& aBorder); williamr@2: IMPORT_C void GetTParaBorder(TParaBorder& aBorder) const; williamr@2: IMPORT_C TBool operator==(const TTmParBorder& aBorder) const; williamr@2: inline TBool operator!=(const TTmParBorder& aBorder) const; williamr@2: williamr@2: TStyle iStyle; williamr@2: TInt iWeight; williamr@2: TLogicalRgb iColor; williamr@2: TBool iAutoColor; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: A bit mask for selecting one or more attributes of an RTmParFormat. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmParFormatMask williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Constants, that are also bit assignments, representing paragraph format attributes */ williamr@2: enum TAttrib williamr@2: { williamr@2: EAlignment = 0x1, williamr@2: EDirection = 0x2, williamr@2: EKeepTogether = 0x4, williamr@2: EKeepWithNext = 0x8, williamr@2: EStartNewPage = 0x10, williamr@2: EWidowOrphan = 0x20, williamr@2: ENoWrap = 0x40, williamr@2: EExactLineSpacing = 0x80, williamr@2: EPixelLineSpacing = 0x100, williamr@2: ELeadingMargin = 0x200, williamr@2: ETrailingMargin = 0x400, williamr@2: EFirstLineIndent = 0x800, williamr@2: ELineSpacing = 0x1000, williamr@2: ESpaceAbove = 0x2000, williamr@2: ESpaceBelow = 0x4000, williamr@2: ETabSize = 0x8000, williamr@2: EBorderMargin = 0x10000, williamr@2: ETabList = 0x20000, williamr@2: EBullet = 0x40000, williamr@2: EBorder = 0x80000 williamr@2: }; williamr@2: williamr@2: inline TTmParFormatMask(); williamr@2: IMPORT_C TTmParFormatMask(const TParaFormatMask& aMask); williamr@2: IMPORT_C void GetTParaFormatMask(TParaFormatMask& aMask) const; williamr@2: inline void Clear(TAttrib aAttrib); williamr@2: inline void Set(TAttrib aAttrib); williamr@2: inline TBool IsSet(TAttrib aAttrib); williamr@2: williamr@2: TUint iFlags; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Paragraph format; all dimensions are in twips unless otherwise specified. williamr@2: @internalComponent williamr@2: */ williamr@2: class RTmParFormat williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Index used to select one of the four borders of a paragraph */ williamr@2: enum TBorderIndex williamr@2: { williamr@2: ETopBorder = 0, williamr@2: EBottomBorder = 1, williamr@2: ELeadingBorder = 2, williamr@2: ETrailingBorder = 3, williamr@2: }; williamr@2: williamr@2: /** Bit assignments for RTmParFormat::iFlags. */ williamr@2: enum williamr@2: { williamr@2: /** Base direction of paragraph is right-to-left (as for Arabic) */ williamr@2: ERightToLeft = 1, williamr@2: /** Do not allow paragraph to straddle page boundaries. */ williamr@2: EKeepTogether = 2, williamr@2: /** Put this paragraph on the same page as the next. */ williamr@2: EKeepWithNext = 4, williamr@2: /** Put this paragraph at the start of a new page. */ williamr@2: EStartNewPage = 8, williamr@2: /** Suppress widows and orphans. */ williamr@2: EWidowOrphan = 16, williamr@2: /** Suppresses line breaking. */ williamr@2: ENoWrap = 32, williamr@2: /** Force line spacing distance to be respected even on lines that are williamr@2: * taller than the specified height. */ williamr@2: EExactLineSpacing = 64, williamr@2: /** Line spaceing is in pixels, not twips. */ williamr@2: EPixelLineSpacing = 128, williamr@2: /** Work out paragraph directionality from the text. */ williamr@2: EDirectionalityFromText = 256 williamr@2: }; williamr@2: williamr@2: /** Paragraph alignment */ williamr@2: enum TAlignment williamr@2: { williamr@2: EAlignNormalBidirectional, williamr@2: EAlignNormal = EAlignNormalBidirectional, /** @deprecated in 7.0s */ williamr@2: EAlignCenter, williamr@2: EAlignReverseBidirectional, williamr@2: EAlignReverse = EAlignReverseBidirectional, /** @deprecated in 7.0s */ williamr@2: EAlignJustify, williamr@2: EAlignAbsoluteLeft, williamr@2: EAlignAbsoluteRight williamr@2: }; williamr@2: williamr@2: IMPORT_C RTmParFormat(); williamr@2: IMPORT_C void Close(); williamr@2: #ifdef _DEBUG williamr@2: inline ~RTmParFormat(); williamr@2: #endif williamr@2: IMPORT_C void CopyL(const RTmParFormat& aFormat); williamr@2: IMPORT_C void CopyL(const CParaFormat& aFormat); williamr@2: IMPORT_C void GetCParaFormatL(CParaFormat& aFormat) const; williamr@2: IMPORT_C TBool operator==(const RTmParFormat& aFormat) const; williamr@2: inline TBool operator!=(const RTmParFormat& aFormat) const; williamr@2: IMPORT_C TInt Tabs() const; williamr@2: inline const TTmTab& Tab(TInt aIndex) const; williamr@2: inline const TTmBullet* Bullet() const; williamr@2: inline const TTmParBorder* Border(TBorderIndex aIndex) const; williamr@2: IMPORT_C TBool HaveBorders() const; williamr@2: inline TBool RightToLeft() const; williamr@2: williamr@2: TAlignment iAlignment; williamr@2: TUint iFlags; // bit flags as defined above williamr@2: TInt iLeadingMargin; // left margin, or right if right-to-left williamr@2: TInt iTrailingMargin; // right margin, or left if right-to-left williamr@2: TInt iFirstLineIndent; // added to first line leading margin williamr@2: TInt iLineSpacing; // distance between baselines williamr@2: TInt iSpaceAbove; // space above the paragraph williamr@2: TInt iSpaceBelow; // space below the paragraph williamr@2: TInt iTabSize; // default size of tabs williamr@2: TInt iBorderMargin; // distance between the text and the border if any williamr@2: TLogicalRgb iBackgroundColor; // paragraph background colour williamr@2: williamr@2: private: williamr@2: RTmParFormat(const RTmParFormat& aFormat); // deliberately unimplemented williamr@2: void operator=(const RTmParFormat& aFormat);// deliberately unimplemented williamr@2: williamr@2: RArray* iTabList; // custom tabs if any williamr@2: TTmBullet* iBullet; // bullet if any williamr@2: TTmParBorder* iBorder[4]; // borders if any williamr@2: }; williamr@2: williamr@2: /** williamr@2: The text customization interface. You can customize the colors, word williamr@2: spacing, line breaking, line height calculation, background drawing, and text williamr@2: appearance, of a text object by supplying an implementation of the MTmCustom williamr@2: class, either directly (as in CTmText::CustomizeL, which takes a pointer to williamr@2: MTmCustom) or indirectly, making use of the fact that MTmSource is derived from williamr@2: MTmCustom (as in CTmTextLayout::SetTextL, which takes a reference to williamr@2: MTmSource). williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class MTmCustom williamr@2: : public MLineBreaker williamr@2: { williamr@2: public: williamr@2: /** williamr@2: TLineHeightParam structure is used in MTmCustom::SetLineHeight() method to set williamr@2: text line height related parameters such as max character height, max ascent and descent, williamr@2: height and depth of the tallest pictures (top-aligned, bottom-aligned or centered). williamr@2: @see MTmCustom::SetLineHeight() williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TLineHeightParam williamr@2: { williamr@2: public: williamr@2: inline TLineHeightParam(); williamr@2: /** Height of the highest character in the line. */ williamr@2: TInt iMaxCharHeight; williamr@2: /** Depth of the deepest character in the line. */ williamr@2: TInt iMaxCharDepth; williamr@2: /** Height plus depth of the tallest top-aligned picture. */ williamr@2: TInt iMaxTopPictureHeight; williamr@2: /** Height plus depth of the tallest bottom-aligned picture. */ williamr@2: TInt iMaxBottomPictureHeight; williamr@2: /** Height plus depth of the tallest centred picture. */ williamr@2: TInt iMaxCenterPictureHeight; williamr@2: /** Height of the tallest character of any in the fonts in the line. */ williamr@2: TInt iFontMaxCharHeight; williamr@2: /** Depth of the deepest character of any in the fonts in the line. */ williamr@2: TInt iFontMaxCharDepth; williamr@2: /** Maximum ascent of the fonts in the line. */ williamr@2: TInt iFontMaxAscent; williamr@2: /** Maximum descent of the fonts in the line. */ williamr@2: TInt iFontMaxDescent; williamr@2: /** Desired precise or minimum line height. */ williamr@2: TInt iDesiredLineHeight; williamr@2: /** True if the line height must be precise. */ williamr@2: TBool iExactLineHeight; williamr@2: }; williamr@2: williamr@2: /** The Unicode line breaking classes; see Unicode Technical Report 14. williamr@2: Not a named enumerated type, so that overriding applications can add new williamr@2: line breaking classes freely. williamr@2: The description of each constant gives the name of the line-breaking williamr@2: class, an example and a brief, imprecise description of the default williamr@2: behaviour of characters of that class. williamr@2: */ williamr@2: enum williamr@2: { williamr@2: /** Opening Punctuation (e.g. '['). Breaking after prohibited. */ williamr@2: EOpLineBreakClass, williamr@2: /** Closing Punctuation (e.g. ']'). Breaking before prohibited. */ williamr@2: EClLineBreakClass, williamr@2: /** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */ williamr@2: EQuLineBreakClass, williamr@2: /** Glue (e.g. Non-breaking space). Breaking before and after prohibited williamr@2: unless spaces are present. */ williamr@2: EGlLineBreakClass, williamr@2: /** Non-Starter (e.g. small Japanese kana). Breaking before prohibited williamr@2: if no spaces present. */ williamr@2: ENsLineBreakClass, williamr@2: /** Exclamation or Interrogation (e.g. '?'). Like closing punctuation williamr@2: except before Postfix or Non-starter. */ williamr@2: EExLineBreakClass, williamr@2: /** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before williamr@2: Alphabetic. */ williamr@2: ESyLineBreakClass, williamr@2: /** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before williamr@2: Numeric. */ williamr@2: EIsLineBreakClass, williamr@2: /** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */ williamr@2: EPrLineBreakClass, williamr@2: /** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */ williamr@2: EPoLineBreakClass, williamr@2: /** Numeric (e.g. '1'). */ williamr@2: ENuLineBreakClass, williamr@2: /** Alphabetic (e.g. 'a'). */ williamr@2: EAlLineBreakClass, williamr@2: /** Ideographic (e.g. Japanese Kanji). Generally break before or after */ williamr@2: EIdLineBreakClass, williamr@2: /** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */ williamr@2: EInLineBreakClass, williamr@2: /** Hyphen (e.g. '-'). Allows a break after except before Numeric. */ williamr@2: EHyLineBreakClass, williamr@2: /** Break After. Generally allow a break after. Breaking between Break williamr@2: Afters not separated by spaces is prohibited. */ williamr@2: EBaLineBreakClass, williamr@2: /** Break Before. Generally allow a break before. Breaking between Break williamr@2: Befores not separated by spaces is prohibited. */ williamr@2: EBbLineBreakClass, williamr@2: /** Break Before and After. Generally allow a break before or after. williamr@2: Breaking between Break Before and Afters is prohibited, even if spaces williamr@2: are present. */ williamr@2: EB2LineBreakClass, williamr@2: /** Zero-Width Space. Allow a break. */ williamr@2: EZwLineBreakClass, williamr@2: /** Combining Mark. Takes on the class of its base class. */ williamr@2: ECmLineBreakClass, williamr@2: /** Mandatory Break. */ williamr@2: EBkLineBreakClass, williamr@2: /** Carriage Return. Break after unless part of a CRLF pair. */ williamr@2: ECrLineBreakClass, williamr@2: /** Line Feed. Break after. */ williamr@2: ELfLineBreakClass, williamr@2: /** Surrogate. Half of a surrogate pair. */ williamr@2: ESgLineBreakClass, williamr@2: /** Contingent Break (e.g. embedded pictures). Uses external williamr@2: information */ williamr@2: ECbLineBreakClass, williamr@2: williamr@2: /** Space. Intervening characters of class Space are indicated by williamr@2: aHaveSpaces in LineBreakPossible. */ williamr@2: ESpLineBreakClass, williamr@2: williamr@2: /** Complex Context (e.g. Thai). Runs of Complex Context are passed to williamr@2: GetLineBreakInContext. */ williamr@2: ESaLineBreakClass, williamr@2: williamr@2: /** Ambiguous. Characters of ambiguous East Asian width are treated williamr@2: as Alphabetic, unless they are resolved as being "Wide", in which case williamr@2: they are treated as Ideographic. */ williamr@2: EAiLineBreakClass, williamr@2: williamr@2: /** The Xx class is used when the class is unknown; e.g.; outside the provided context. */ williamr@2: EXxLineBreakClass, williamr@2: williamr@2: /** The number of Unicode line break classes. */ williamr@2: ELineBreakClasses williamr@2: }; williamr@2: williamr@2: IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; williamr@2: IMPORT_C virtual TInt Stretch(TUint aChar) const; williamr@2: IMPORT_C virtual TUint Map(TUint aChar) const; williamr@2: IMPORT_C virtual void SetLineHeight(const TLineHeightParam& aParam,TInt& aAscent,TInt& aDescent) const; williamr@2: IMPORT_C virtual void DrawBackground(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, williamr@2: const TLogicalRgb& aBackground,TRect& aRectDrawn) const; williamr@2: IMPORT_C virtual void DrawLineGraphics(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, williamr@2: const TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C virtual void DrawText(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect, williamr@2: const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat, williamr@2: const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const; williamr@2: IMPORT_C virtual void DrawPicture(CGraphicsContext& aGc, williamr@2: const TPoint& aTextLayoutTopLeft, const TRect& aRect, williamr@2: MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const; williamr@2: IMPORT_C virtual TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const; williamr@2: IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const; williamr@2: IMPORT_C virtual TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos, williamr@2: TBool aForwards,TInt& aBreakPos) const; williamr@2: IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const; williamr@2: williamr@2: // non-virtuals williamr@2: IMPORT_C void SetPenColor(CGraphicsContext& aGc,TLogicalRgb aColor) const; williamr@2: IMPORT_C void SetBrushColor(CGraphicsContext& aGc,TLogicalRgb aColor) const; williamr@2: IMPORT_C TRgb SystemColor(TLogicalRgb aColor) const; williamr@2: }; williamr@2: williamr@2: /** williamr@2: MTmTextDrawExt interface UID. williamr@2: @internalComponent williamr@2: */ williamr@2: const TUid KTmTextDrawExtId = {0x10203665}; williamr@2: williamr@2: /** williamr@2: Text drawing - an extension interface. It offfers williamr@2: DrawLine(), DrawText() and DrawRect() methods. williamr@2: The idea is to move out from RTmInterpreter implementations all williamr@2: CGraphicsContext::Draw calls and replace them with the corresponding williamr@2: MTmTextDrawExt::Draw calls. The implementations of MTmTextDrawExt interface can customize williamr@2: drawing methods implementations - for example - including opaque drawing support. williamr@2: The MTmTextDrawExt interface UID is KTmTextDrawExtId. The interface implementation can be queried williamr@2: through a MTmSource::GetExtendedInterface() call. williamr@2: @internalComponent williamr@2: */ williamr@2: class MTmTextDrawExt williamr@2: { williamr@2: public: williamr@2: virtual void DrawLine(CGraphicsContext& aGc, const TPoint& aPt1, const TPoint& aPt2) const = 0; williamr@2: virtual void DrawText(CGraphicsContext& aGc, const TDesC& aText, const TPoint& aPt) const = 0; williamr@2: virtual void DrawRect(CGraphicsContext& aGc, const TRect& aRc) const = 0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TUid KFormLabelApiExtensionUid = { 0x101FD03C}; williamr@2: williamr@2: /** williamr@2: MTmSource is an interface class that must be implemented by users of williamr@2: CTmTextLayout to provide text content and attributes. MTmSource is derived from williamr@2: MTmCustom, which contains the functions to customise the layout and display, so williamr@2: that this can be done in CTmText without affecting the content. williamr@2: @internalComponent williamr@2: */ williamr@2: class MTmSource: public MTmCustom williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Label type used in LabelModeSelect */ williamr@2: enum TLabelType williamr@2: { williamr@2: /** Not a label; used for TLabelTypes not yet assigned. */ williamr@2: ENoLabel, williamr@2: williamr@2: /** Paragraph label of the type supported by FORM. */ williamr@2: EParLabel williamr@2: }; williamr@2: williamr@2: enum williamr@2: { williamr@2: /** williamr@2: The maximum number of characters supplied to GetLineBreak, after aMaxBreakPos, williamr@2: and after trailing whitespace, to provide context for line breaking decisions. williamr@2: */ williamr@2: ELineBreakContext = 32 williamr@2: }; williamr@2: williamr@2: // pure virtuals williamr@2: williamr@2: /** Return the device used to format the text. */ williamr@2: virtual MGraphicsDeviceMap& FormatDevice() const = 0; williamr@2: williamr@2: /** williamr@2: Return the device used to draw the text and when converting between x-y coordinates and document positions. williamr@2: If the formatting and interpreting devices are different, text is scaled appropriately when it is drawn; williamr@2: this allows text to be formatted for printer fonts and displayed on the screen, giving a wysiwyg print preview. williamr@2: */ williamr@2: virtual MGraphicsDeviceMap& InterpretDevice() const = 0; williamr@2: williamr@2: /** Return the length of the document in characters. */ williamr@2: virtual TInt DocumentLength() const = 0; williamr@2: williamr@2: /** williamr@2: Return at least one character of text, but preferably as many as possible, starting at aPos. Put its character williamr@2: format in aFormat. The text must be a run of characters sharing the same character format. williamr@2: */ williamr@2: virtual void GetText(TInt aPos,TPtrC& aText,TTmCharFormat& aFormat) const = 0; williamr@2: williamr@2: /** williamr@2: Return the paragraph format of the paragraph containing aPos. End-of-paragraph characters belong to the preceding williamr@2: paragraph. williamr@2: */ williamr@2: virtual void GetParagraphFormatL(TInt aPos,RTmParFormat& aFormat) const = 0; williamr@2: williamr@2: /** williamr@2: Return the document position of the start of the paragraph containing aPos. End-of-paragraph characters belong to williamr@2: the preceding paragraph. williamr@2: */ williamr@2: virtual TInt ParagraphStart(TInt aPos) const = 0; williamr@2: williamr@2: // ordinary virtuals williamr@2: IMPORT_C virtual CPicture* PictureL(TInt aPos) const; williamr@2: IMPORT_C virtual TInt GetPictureSizeInTwipsL(TInt aPos,TSize& aSize) const; williamr@2: IMPORT_C virtual TAny* GetExtendedInterface(const TUid& aInterfaceId); williamr@2: IMPORT_C virtual void MTmSource_Reserved_1(); williamr@2: IMPORT_C virtual void MTmSource_Reserved_2(); williamr@2: IMPORT_C virtual TBool PageBreakInRange(TInt aStartPos,TInt aEndPos) const; williamr@2: williamr@2: // non-virtuals williamr@2: IMPORT_C TInt ParagraphEnd(TInt aPos) const; williamr@2: IMPORT_C TBool GetLineBreakL(const TDesC& aText,TInt aDocPos,TInt aMinBreakPos,TInt aMaxBreakPos,TBool aForwards, williamr@2: TInt& aBreakPos,TInt& aHangingChars,TInt& aBreakPosAfterSpaces) const; williamr@2: IMPORT_C static void GetStandardLineBreak(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos, williamr@2: TInt& aBreakPos,TInt& aNextLineStart); williamr@2: }; williamr@2: williamr@2: /** williamr@2: Class used to provide label functionality within Form williamr@2: as an extended interface (via the GetExtendedInterface mechanism williamr@2: supplied in MTmSource). This class is entirely internal to Form. williamr@2: @internalComponent williamr@2: @see MTmSource::GetExtendedInterface williamr@2: @since Sirocco williamr@2: */ williamr@2: class MFormLabelApi williamr@2: { williamr@2: public: williamr@2: IMPORT_C virtual TBool LabelModeSelect(MTmSource::TLabelType aType, TInt aPos); williamr@2: IMPORT_C virtual void LabelModeCancel(); williamr@2: IMPORT_C virtual void LabelMetrics(MTmSource::TLabelType aType, TSize& aLabelSize, TInt& aMarginSize) const; williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalTechnology williamr@2: */ williamr@2: class CTmBufSeg: public CBufSeg williamr@2: { williamr@2: public: williamr@2: inline CTmBufSeg(TInt aExpandSize); williamr@2: TInt MemoryUsed() const; williamr@2: }; williamr@2: williamr@2: /** @internalTechnology */ williamr@2: class CTmCode: public CBase williamr@2: { williamr@2: public: williamr@2: inline ~CTmCode(); williamr@2: void InsertByteL(TUint8 aByte,TInt aPos); williamr@2: TInt InsertNumberL(TInt aNumber,TInt aPos); williamr@2: TInt InsertRectL(const TRect& aRect,TInt aPos); williamr@2: void AppendByteL(TUint8 aByte); williamr@2: TInt AppendNumberL(TInt aNumber); williamr@2: TInt AppendRectL(const TRect& aRect); williamr@2: void ChangeL(TInt aStart,TInt aEnd,CTmCode& aNewCode); williamr@2: TInt MemoryUsed() const; williamr@2: TInt Size() const; williamr@2: void Delete(TInt aPos,TInt aLength); williamr@2: void Reset(); williamr@2: inline TPtr8 Ptr(TInt aPos); williamr@2: void CreateBufferL(); williamr@2: inline CBufBase* Buffer(); williamr@2: inline const CBufBase* Buffer() const; williamr@2: williamr@2: private: williamr@2: enum williamr@2: { williamr@2: EExpandSize = 512 williamr@2: }; williamr@2: TInt WriteNumber(TInt aNumber,TUint8* aBuffer); williamr@2: williamr@2: CTmBufSeg* iBuffer; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Formatting parameters used when formatting part of a layout object. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmFormatParamBase williamr@2: williamr@2: { williamr@2: public: williamr@2: enum williamr@2: { williamr@2: EWrap = 1, // wrap the text at iWrapWidth williamr@2: EAtLeastMaxHeight = 2, // stop adding text only when iMaxHeight has been reached or exceeded williamr@2: ETruncateWithEllipsis = 4, // truncate any text that sticks out; see iEllipsis below williamr@2: ELegalLineBreaksOnly = 8 // break only at allowed line breaks, even if that williamr@2: // results in the text not fitting the measure williamr@2: }; williamr@2: williamr@2: IMPORT_C TTmFormatParamBase(); williamr@2: inline TBool IsWrapping() const; williamr@2: inline TBool IsTruncatingWithEllipsis() const; williamr@2: inline TBool LegalLineBreaksOnly() const; williamr@2: williamr@2: TInt iWrapWidth; // wrapping width of the text including margins and indents, if wrapping is on williamr@2: TInt iMaxHeight; // maximum height of the text williamr@2: TInt iMaxLines; // maximum number of lines to be formatted williamr@2: TInt iFlags; // flags defined above williamr@2: TChar iEllipsis; // if truncating and not 0xFFFF, insert this ellipsis char (defaults to '...'). williamr@2: williamr@2: }; williamr@2: williamr@2: /** williamr@2: Formatting parameters used when formatting an entire layout object or williamr@2: creating a section of format code. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmFormatParam: public TTmFormatParamBase williamr@2: williamr@2: { williamr@2: public: williamr@2: IMPORT_C TTmFormatParam(); williamr@2: IMPORT_C TTmFormatParam(const TTmFormatParamBase& aBase); williamr@2: williamr@2: TInt iStartChar; // first character position to be formatted williamr@2: TInt iEndChar; // last character position to be formatted williamr@2: TInt iLineInPar; // starting line number in the paragraph williamr@2: }; williamr@2: williamr@2: /** williamr@2: Additional parameters used when reformatting. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmReformatParam williamr@2: williamr@2: { williamr@2: public: williamr@2: IMPORT_C TTmReformatParam(); williamr@2: williamr@2: TInt iStartChar; // start of changed text williamr@2: TInt iOldLength; // length of text before the change williamr@2: TInt iNewLength; // length of text after the change williamr@2: TInt iMaxExtraLines; // maximum lines in the partial paragraph after the end of the changed text williamr@2: // to format in one go; the remainder can be handled by background formatting williamr@2: TBool iParFormatChanged; // TRUE if the paragraph format of the changed text has changed williamr@2: TBool iParInvalid; // format to the end of the paragraph williamr@2: }; williamr@2: williamr@2: /** williamr@2: Information returned when reformatting. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmReformatResult williamr@2: williamr@2: { williamr@2: public: williamr@2: IMPORT_C TTmReformatResult(); williamr@2: williamr@2: TRect iRedrawRect; // rectangle to be redrawn williamr@2: TInt iHeightChange; // change in height of the reformatted text williamr@2: TInt iUnchangedTop; // y coordinate, before formatting, of the top of text needing no change, williamr@2: // including text in any section not yet formatted by this call williamr@2: TInt iUnformattedStart; // start of any unformatted section; KMaxTInt if none williamr@2: }; williamr@2: williamr@2: /** williamr@2: A structure for returning information about a line. One of these is williamr@2: returned by all hit-detection functions. Typically, after finding the position williamr@2: in the document that corresponds to given x-y coordinates, you will want some williamr@2: more information like the line's bounding rectangle. When you call, for williamr@2: example, CTmTextLayout::FindXyPos you will receive a TTmLineInfo object that williamr@2: will tell you this, and much more. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TTmLineInfo williamr@2: williamr@2: { williamr@2: public: williamr@2: // bit values for iFlags williamr@2: enum williamr@2: { williamr@2: EParStart = 1, williamr@2: EParEnd = 2, williamr@2: EParRightToLeft = 4, williamr@2: ELineEndsInForcedLineBreak = 8, williamr@2: EPictureButtsLowerEdge = 16, /**< @deprecated - no effect, present for compatibility only */ williamr@2: EPictureButtsUpperEdge = 32 /**< @deprecated - no effect, present for compatibility only */ williamr@2: }; williamr@2: williamr@2: inline TTmLineInfo(); williamr@2: williamr@2: /** Outer enclosing rectangle including margins */ williamr@2: TRect iOuterRect; williamr@2: williamr@2: /** Inner enclosing rectangle: the text only */ williamr@2: TRect iInnerRect; williamr@2: williamr@2: /** y coordinate of the baseline */ williamr@2: TInt iBaseline; williamr@2: williamr@2: /** Start document position */ williamr@2: TInt iStart; williamr@2: williamr@2: /** End document position */ williamr@2: TInt iEnd; williamr@2: williamr@2: /** Line number */ williamr@2: TInt iLineNumber; williamr@2: williamr@2: /** Paragraph number */ williamr@2: TInt iParNumber; williamr@2: williamr@2: /** Line number in the paragraph */ williamr@2: TInt iLineInPar; williamr@2: williamr@2: /** y coordinate of the top of the paragraph */ williamr@2: TInt iParTop; williamr@2: williamr@2: /** Start of paragraph, end of paragraph, etc. */ williamr@2: TUint iFlags; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A structure to hold a logical document position that can be converted to a raw williamr@2: document position or an x-y position. williamr@2: williamr@2: A document position can specify a leading or trailing edge or a text williamr@2: directionality so that bidirectional hit testing can use both these williamr@2: distinctions. williamr@2: williamr@2: The leading edge at position N is the position before character N in logical williamr@2: order, and the trailing edge is the position after character in logical order. williamr@2: williamr@2: Specification by directionality works differently. Character N in left-to-right williamr@2: text is preceded by position N (left-to-right) and followed by position N+1 williamr@2: (left-to-right). Character N in right-to-left text is preceded (in display williamr@2: order) by position N+1 (right-to-left) and followed by position N williamr@2: (right-to-left). williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TTmDocPosSpec williamr@2: williamr@2: { williamr@2: public: williamr@2: /** williamr@2: The cursor type. williamr@2: */ williamr@2: enum TType williamr@2: { williamr@2: /** trailing edge */ williamr@2: ETrailing, williamr@2: williamr@2: /** leading edge */ williamr@2: ELeading, williamr@2: williamr@2: /** left-to-right */ williamr@2: ELeftToRight, williamr@2: williamr@2: /** right-to-left */ williamr@2: ERightToLeft williamr@2: }; williamr@2: williamr@2: inline TTmDocPosSpec(); williamr@2: inline TTmDocPosSpec(TInt aPos,TType aType); williamr@2: inline TTmDocPosSpec(const TTmDocPos& aRawDocPos); williamr@2: williamr@2: /** the edge position in the document; 0 ... document length */ williamr@2: TInt iPos; williamr@2: /** the type as specified above */ williamr@2: TType iType; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A structure for holding a raw document position that can be converted to or williamr@2: from an x-y position and compared ordinally, which cannot be done with the more williamr@2: abstract TTmDocPosSpec class. Leading edges are distinguished from trailing williamr@2: edges so that bidirectional hit testing and cursor positioning can distinguish williamr@2: between 'after character N', and 'before character N + 1', which may be some williamr@2: distance apart if N and N + 1 are in runs of opposite directionality. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TTmDocPos williamr@2: williamr@2: { williamr@2: public: williamr@2: inline TTmDocPos(); williamr@2: inline TTmDocPos(TInt aPos,TBool aLeadingEdge); williamr@2: IMPORT_C TBool operator==(const TTmDocPos& aPos) const; williamr@2: inline TBool operator!=(const TTmDocPos& aPos) const; williamr@2: IMPORT_C TBool operator>(const TTmDocPos& aPos) const; williamr@2: IMPORT_C TBool operator>=(const TTmDocPos& aPos) const; williamr@2: inline TBool operator<(const TTmDocPos& aPos) const; williamr@2: inline TBool operator<=(const TTmDocPos& aPos) const; williamr@2: williamr@2: /** the edge position in the document; 0 ... document length */ williamr@2: TInt iPos; williamr@2: /** true if the position is a leading edge */ williamr@2: TBool iLeadingEdge; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Holds information about a position in a document. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TTmPosInfo2 williamr@2: williamr@2: { williamr@2: public: williamr@2: /** Document position. */ williamr@2: TTmDocPos iDocPos; williamr@2: /** True if the position is attatched to text flowing right-to-left. */ williamr@2: TBool iRightToLeft; williamr@2: /** Intersection of the character edge with the baseline. */ williamr@2: TPoint iEdge; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A structure for returning information about a position in a line. williamr@2: @deprecated 7.0s williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmPosInfo williamr@2: williamr@2: { williamr@2: public: williamr@2: TTmPosInfo() {} williamr@2: TTmPosInfo(const TTmPosInfo2& a) : iDocPos(a.iDocPos), iEdge(a.iEdge) {} williamr@2: TTmDocPos iDocPos; // the document position williamr@2: TPoint iEdge; // intersection of the character edge at iDocPos with the baseline williamr@2: }; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmHighlightExtensions williamr@2: williamr@2: { williamr@2: public: williamr@2: inline TTmHighlightExtensions(); williamr@2: inline void SetAll(TInt aExtension); williamr@2: inline void SetLeftExtension(TInt aExtension); williamr@2: inline void SetRightExtension(TInt aExtension); williamr@2: inline void SetTopExtension(TInt aExtension); williamr@2: inline void SetBottomExtension(TInt aExtension); williamr@2: inline TInt LeftExtension() const; williamr@2: inline TInt RightExtension() const; williamr@2: inline TInt TopExtension() const; williamr@2: inline TInt BottomExtension() const; williamr@2: inline TBool Extends() const; williamr@2: inline TBool Shrinks() const; williamr@2: inline void ExtendRect(TRect& aRect) const; williamr@2: inline void AdjustRect(TRect& aRect) const; williamr@2: inline TBool IsNull() const; williamr@2: inline void AbsExtendRect(TRect& aRect) const; williamr@2: public: williamr@2: TInt iLeftExtension; williamr@2: TInt iRightExtension; williamr@2: TInt iTopExtension; williamr@2: TInt iBottomExtension; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Cursor placement. Used as an argument to CTextView::SetCursorPlacement(). williamr@2: @see CTextView::SetCursorPlacement() williamr@2: @publishedAll williamr@2: */ williamr@2: enum TTmCursorPlacement williamr@2: { williamr@2: /** The text cursor is a vertical line at the insertion position, with its height williamr@2: and depth based on the metrics of the previous character in the paragraph williamr@2: or if none, the next character. */ williamr@2: ECursorVertical, williamr@2: /** The text cursor is an underline below the character logically after the insertion williamr@2: position. */ williamr@2: ECursorUnderlineNext, williamr@2: /** The text cursor is an underline below the character logically before the insertion williamr@2: position. */ williamr@2: ECursorUnderlinePrev williamr@2: }; williamr@2: williamr@2: /** williamr@2: The text layout for a single rectangular piece of text. The object does not own its text or format attributes but williamr@2: gets them from an interface class called MTmSource. williamr@2: williamr@2: There are functions for setting the text, drawing it, and converting between x-y coordinates and document positions. williamr@2: williamr@2: Ranges williamr@2: williamr@2: All ranges of character positions and pixels include the start but not the end. This means that if a line is described williamr@2: by a TTmLineInfo object as starting at document position 345 and ending at 389, character positions 345 to 388 are in williamr@2: the line; 389 is in the next line if any. williamr@2: williamr@2: Coordinates and units williamr@2: williamr@2: All coordinates used in TAGMA classes and function arguments are in pixels and are relative to the origin of the object, williamr@2: which is the top left corner of the ordinary text, not including paragraph labels. Vertical coordinates increase from williamr@2: top to bottom. williamr@2: williamr@2: Document format and positions williamr@2: williamr@2: A TAGMA document, as supplied by the MTmSource interface, has a length as returned by MTmSource::DocumentLength of williamr@2: zero or more characters. It consists of Unicode text split into paragraphs by standard Unicode paragraph delimiters williamr@2: (character value 0x2029), so the number of paragraphs in the entire document is one more than the number of williamr@2: paragraph delimiters. A document position is a value in the range 0 to one more than the document length. williamr@2: Lines contain all document positions from their start to one less than their end position. These conventions allow williamr@2: all lines to end in a delimiter; the last line contains an imaginary paragraph end, which need not be supplied by williamr@2: the MTmSource interface, at a position equal to the document length. A CTmTextLayout object formatted for an williamr@2: empty document will thus have a start position (returned by StartChar) of 0 and an end position williamr@2: (returned by EndChar) of 1. williamr@2: @internalComponent williamr@2: */ williamr@2: class CTmTextLayout: public CBase williamr@2: williamr@2: { williamr@2: public: williamr@2: williamr@2: class TTmChunkDescription williamr@2: /** williamr@2: Output from FindAdjacentChunks. Describes a chunk of text that is of a williamr@2: constant format and directionality. williamr@2: @internalComponent williamr@2: */ williamr@2: { williamr@2: public: williamr@2: /** Position of the first character in the chunk. A negative number williamr@2: indicates "no such chunk". */ williamr@2: TInt iStart; williamr@2: /** One past the position of the last character in the chunk. */ williamr@2: TInt iEnd; williamr@2: /** ETrue if the chunk is displayed right-to-left. */ williamr@2: TBool iRightToLeft; williamr@2: }; williamr@2: williamr@2: IMPORT_C CTmTextLayout(); williamr@2: IMPORT_C ~CTmTextLayout(); williamr@2: IMPORT_C void SetTextL(MTmSource& aSource,const TTmFormatParam& aParam); williamr@2: IMPORT_C void FormatL(const TTmFormatParamBase& aParam,const TTmReformatParam& aReformatParam, williamr@2: TTmReformatResult& TTmReformatResult); williamr@2: IMPORT_C TBool AddParL(const TTmFormatParamBase& aParam,TBool aAtStart,TInt& aHeightIncrease,TInt& aParagraphsIncrease); williamr@2: IMPORT_C TBool DeletePar(const TTmFormatParamBase& aParam,TBool aAtStart,TInt aMaxDeletedHeight,TInt& aHeightDecrease); williamr@2: IMPORT_C void Clear(); williamr@2: IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb* aDocBackground,TBool aDrawParBackground) const; williamr@2: IMPORT_C void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb& aBackground) const; williamr@2: IMPORT_C void InvertLayout(CGraphicsContext& aGc, const TPoint& aTopLeft, williamr@2: TInt aStartDocPos, TInt aEndDocPos) const; williamr@2: IMPORT_C void HighlightSection(CGraphicsContext& aGc, const TPoint& aTopLeft, williamr@2: TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect) const; williamr@2: IMPORT_C void DrawSection(CGraphicsContext& aGc, const TPoint& aTopLeft, williamr@2: TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect) const; williamr@2: IMPORT_C void HighlightSection(CGraphicsContext& aGc, const TPoint& aTopLeft, williamr@2: TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect, const TTmHighlightExtensions& aHighlightExtensions, williamr@2: TInt aHighlightStartDocPos, TInt aHighlightEndDocPos) const; williamr@2: IMPORT_C void InvertLayout(CGraphicsContext& aGc, williamr@2: const TPoint& aTopLeft, TInt aStartDocPos,TInt aEndDocPos, const TTmHighlightExtensions& aHighlightExtensions, williamr@2: TInt aHighlightStartDocPos, TInt aHighlightEndDocPos) const; williamr@2: IMPORT_C void DrawSection(CGraphicsContext& aGc, const TPoint& aTopLeft, williamr@2: TInt aStartDocPos, TInt aEndDocPos, const TRect& aClipRect, const TTmHighlightExtensions& aHighlightExtensions, williamr@2: TInt aHighlightStartDocPos, TInt aHighlightEndDocPos) const; williamr@2: IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool FindXyPosWithDisambiguation(const TPoint& aXyPos, williamr@2: TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight, williamr@2: TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TInt FindNextPos(TInt aStart) const; williamr@2: IMPORT_C TInt FindPreviousPos(TInt aStart) const; williamr@2: IMPORT_C TInt Lines() const; williamr@2: IMPORT_C TInt Paragraphs() const; williamr@2: IMPORT_C TBool DocPosToLine(const TTmDocPosSpec& aDocPos,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool LineNumberToLine(TInt aLineNumber,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool ParNumberToLine(TInt aParNumber,TInt aLineInPar,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool YPosToLine(TInt aYPos,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool GetDisplayedTextL(TInt aLineNumber,TDes& aText,TInt& aNeeded) const; williamr@2: IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TSize& aSize) const; williamr@2: IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize) const; williamr@2: IMPORT_C TInt WidthOfWidestLine(TInt aTop = 0,TInt aBottom = KMaxTInt) const; williamr@2: IMPORT_C void HorizontalExtremes(TInt &aLeft, TInt &aRight, williamr@2: TInt aTopY = 0, TInt aBottomY = KMaxTInt) const; williamr@2: IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aInfo,TBool aToLeft) const; williamr@2: IMPORT_C TBool GetNextPosLeftWithDisambiguation(const TTmDocPosSpec& aDocPos, williamr@2: TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; williamr@2: IMPORT_C TBool GetNextPosRightWithDisambiguation(const TTmDocPosSpec& aDocPos, williamr@2: TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; williamr@2: IMPORT_C TBool LineExtreme(const TTmDocPosSpec& aPos, TBool aToRight, williamr@2: TTmDocPos& aExtreme) const; williamr@2: IMPORT_C TBool FindAdjacentChunks(const TTmDocPosSpec& aPos, williamr@2: TTmChunkDescription& aLeft, TTmChunkDescription& aRight) const; williamr@2: IMPORT_C TBool GetCursor(const TTmDocPosSpec& aDocPos,TTmCursorPlacement aPlacement, williamr@2: TTmLineInfo& aLineInfo,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const; williamr@2: IMPORT_C TInt MemoryUsed() const; williamr@2: inline TInt StartChar() const; williamr@2: inline TInt EndChar() const; williamr@2: inline TInt LayoutWidth() const; williamr@2: inline TInt LayoutHeight() const; williamr@2: inline MTmSource* Source(); williamr@2: inline const MTmSource* Source() const; williamr@2: inline const CTmCode& Code() const; williamr@2: IMPORT_C void MakeVisible(TBool aVisible); williamr@2: TInt GetDrawingInterpFlags() const; williamr@2: IMPORT_C void DeleteFormattingFromEndL( williamr@2: const TTmFormatParamBase& aParam, TInt aMaxDeletedHeight, TInt& aHeightDecrease); williamr@2: IMPORT_C void ExtendFormattingDownwardsL(TTmFormatParam& aParam); williamr@2: williamr@2: // deprecated functions williamr@2: // deprecated 7.0 williamr@2: IMPORT_C TBool GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos, williamr@2: TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo, williamr@2: TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const; williamr@2: williamr@2: IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb* aDocBackground,TBool aDrawParBackground, williamr@2: const TCursorSelection* aHighlight, williamr@2: const TTmHighlightExtensions* aHighlightExtensions) const; williamr@2: IMPORT_C void GetUpdateBoundingRect(TInt aStartDocPos, TInt aEndDocPos, const TPoint& aTopLeft, williamr@2: TRect& aBoundingRect) const; williamr@2: williamr@2: IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo, TInt& aSubscript) const; williamr@2: private: williamr@2: TBool LastLine(TTmLineInfo& aLine); williamr@2: #ifdef _DEBUG williamr@2: void Invariant() const; williamr@2: #else williamr@2: void Invariant() const { } williamr@2: #endif williamr@2: void AdjustWidth(const TTmFormatParamBase& aParam,TInt aWidthOfNewText); williamr@2: williamr@2: MTmSource* iSource; // source of text and text attributes; not owned williamr@2: CTmCode iCode; // the layout bytecode williamr@2: TInt iWidth; // width in pixels williamr@2: TInt iHeight; // height in pixels williamr@2: TInt iStartChar; // start character position in the document williamr@2: TInt iEndChar; // end character position in the document williamr@2: TBidirectionalContext* iBdStateAtEnd; //bidirectional state at end of formatted range williamr@2: TInt iDrawingInterpFlags; // flags destined for the RTmDrawingInterpreter object williamr@2: // please try to avoid removing or adding any new members to this class. although it williamr@2: // is internal, it is included by value in CTextLayout which is published. therefore williamr@2: // a size change in this class would mean a size change in CTextLayout and a BC break. williamr@2: // if adding or removing members is unavoidable, please remember to update the dummy williamr@2: // member in CTextLayout accordingly. williamr@2: }; williamr@2: williamr@2: /** williamr@2: A mixin class to make it easy for higher-level classes that own a CTmTextLayout williamr@2: object to have enquiry functions without it being necessary to implement them williamr@2: all as forwarding functions. The owner class just implements TextLayout and williamr@2: overrides GetOrigin if necessary. williamr@2: williamr@2: Non-const CTmTextLayout functions like Clear are not included because allowing williamr@2: them to be called on owner classes would probably put the owner class into an williamr@2: inconsistent state. williamr@2: williamr@2: The word Layout is prefixed, suffixed or infixed to functions with names that williamr@2: would usually conflict with owner class names. For example, we have DrawLayout, williamr@2: not Draw, and GetMinimumLayoutSizeL, not GetMinimumSizeL. williamr@2: @internalComponent williamr@2: */ williamr@2: class MTmTextLayoutForwarder williamr@2: williamr@2: { williamr@2: public: williamr@2: IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb* aDocBackground,TBool aDrawParBackground) const; williamr@2: IMPORT_C void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb& aBackground) const; williamr@2: IMPORT_C void InvertLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,TInt aStartDocPos,TInt aEndDocPos); williamr@2: IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool FindXyPosWithDisambiguation(const TPoint& aXyPos, williamr@2: TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight, williamr@2: TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool DocPosToLine(const TTmDocPosSpec& aDocPos,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool LineNumberToLine(TInt aLineNumber,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool ParNumberToLine(TInt aParNumber,TInt aLineInPar,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TBool YPosToLine(TInt aYPos,TTmLineInfo& aLineInfo) const; williamr@2: IMPORT_C TInt WidthOfWidestLine(TInt aTop = 0,TInt aBottom = KMaxTInt) const; williamr@2: IMPORT_C void HorizontalExtremes(TInt &aLeft, TInt &aRight, williamr@2: TInt aTopY = 0, TInt aBottomY = KMaxTInt) const; williamr@2: IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aInfo,TBool aToLeft) const; williamr@2: IMPORT_C TBool GetNextPosLeftWithDisambiguation(const TTmDocPosSpec& aDocPos, williamr@2: TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; williamr@2: IMPORT_C TBool GetNextPosRightWithDisambiguation(const TTmDocPosSpec& aDocPos, williamr@2: TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const; williamr@2: IMPORT_C TBool GetCursor(const TTmDocPosSpec& aDocPos,TTmCursorPlacement aPlacement, williamr@2: TTmLineInfo& aLineInfo,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const; williamr@2: williamr@2: IMPORT_C TInt Lines() const; williamr@2: IMPORT_C TInt Paragraphs() const; williamr@2: IMPORT_C TBool GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const; williamr@2: IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TSize& aSize) const; williamr@2: IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize) const; williamr@2: IMPORT_C TInt StartChar() const; williamr@2: IMPORT_C TInt EndChar() const; williamr@2: IMPORT_C TInt LayoutWidth() const; williamr@2: IMPORT_C TInt LayoutHeight() const; williamr@2: williamr@2: // deprecated functions williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const; williamr@2: // deprecated 7.0s williamr@2: IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos, williamr@2: TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo, williamr@2: TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const; williamr@2: private: williamr@2: /** Returns a reference to the CTmTextLayoutObject this williamr@2: MTmTextLayoutForwarder forwards inquiries to. */ williamr@2: virtual const CTmTextLayout& TextLayout() const = 0; williamr@2: williamr@2: /** The origin is subtracted from coordinates passed in and added to those williamr@2: passed out. */ williamr@2: IMPORT_C virtual void GetOrigin(TPoint& aPoint) const; williamr@2: williamr@2: void FixUpLineInfo(TTmLineInfo& aInfo,const TPoint* aOrigin = NULL) const; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A character format layer. Unmasked attributes are transparent. williamr@2: @internalComponent williamr@2: */ williamr@2: class TTmCharFormatLayer williamr@2: williamr@2: { williamr@2: public: williamr@2: inline TTmCharFormatLayer(); williamr@2: IMPORT_C TTmCharFormatLayer(const CCharFormatLayer& aFormat); williamr@2: williamr@2: TTmCharFormat iFormat; williamr@2: TTmCharFormatMask iMask; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A paragraph format layer. Unmasked attributes are transparent. williamr@2: @internalComponent williamr@2: */ williamr@2: class RTmParFormatLayer williamr@2: williamr@2: { williamr@2: public: williamr@2: inline void Close(); williamr@2: IMPORT_C void CopyL(const CParaFormatLayer& aFormat); williamr@2: williamr@2: RTmParFormat iFormat; williamr@2: TTmParFormatMask iMask; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A style. williamr@2: @internalComponent williamr@2: */ williamr@2: class RTmStyle williamr@2: williamr@2: { williamr@2: public: williamr@2: enum williamr@2: { williamr@2: EMaxName = KMaxParagraphStyleName williamr@2: }; williamr@2: williamr@2: inline void Close(); williamr@2: IMPORT_C void CopyL(const RParagraphStyleInfo& aStyle); williamr@2: IMPORT_C void GetRParagraphStyleInfoL(RParagraphStyleInfo& aStyle, williamr@2: const CParaFormatLayer& aGlobalParaFormatLayer,const CCharFormatLayer& aGlobalCharFormatLayer, williamr@2: const CStyleList& aList) const; williamr@2: williamr@2: TBuf iName; williamr@2: TBuf iNextStyleName; williamr@2: TTmCharFormatLayer iCharFormat; williamr@2: RTmParFormatLayer iParFormat; williamr@2: TInt iOutlineLevel; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A self-contained text object. It owns both layout and content. It is williamr@2: intended for labels and the general display of small-to-medium-sized amounts of williamr@2: text. williamr@2: @internalComponent williamr@2: */ williamr@2: class CTmText: public CBase, public MTmTextLayoutForwarder williamr@2: williamr@2: { williamr@2: public: williamr@2: IMPORT_C static CTmText* NewL(MGraphicsDeviceMap* aDevice = NULL,const TTmFormatParamBase* aFormatParam = NULL); williamr@2: IMPORT_C static CTmText* NewL(MGraphicsDeviceMap& aDevice,const TTmFormatParamBase& aFormatParam); williamr@2: IMPORT_C static CTmText* NewL(MGraphicsDeviceMap& aDevice,TInt aWrapWidth,TInt aFlags); williamr@2: IMPORT_C ~CTmText(); williamr@2: IMPORT_C void InsertL(TInt aPos,const TDesC& aText, williamr@2: const TTmCharFormat* aCharFormat = NULL,const RTmParFormat* aParFormat = NULL, williamr@2: TRect* aRedrawRect = NULL,TInt* aScroll = NULL); williamr@2: IMPORT_C void GetFormat(TTmFormatParamBase& aFormatParam) const; williamr@2: IMPORT_C void SetWrapWidthL(TInt aWrapWidth); williamr@2: IMPORT_C void ChangeFormatL(const TTmFormatParamBase& aFormatParam); williamr@2: IMPORT_C void Clear(); williamr@2: IMPORT_C void CustomizeL(const MTmCustom* aCustom); williamr@2: IMPORT_C TInt MemoryUsed() const; williamr@2: inline void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb* aDocBackground,TBool aDrawParBackground); williamr@2: williamr@2: private: williamr@2: CTmText(); williamr@2: IMPORT_C void Spare1(); williamr@2: williamr@2: // implementations of MTmTextLayoutForwarder virtual functions williamr@2: const CTmTextLayout& TextLayout() const; williamr@2: williamr@2: CTmTextImp* iImp; // the implementation williamr@2: }; williamr@2: williamr@2: // inline functions williamr@2: /** Constructs a TTmCharFormatMask. Turns all the flags on. */ williamr@2: TTmCharFormatMask::TTmCharFormatMask(): iFlags(0xFFFFFFFF) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Clears the selected flag.*/ williamr@2: void TTmCharFormatMask::Clear(TAttrib aAttrib) williamr@2: { williamr@2: iFlags &= ~aAttrib; williamr@2: } williamr@2: williamr@2: /** Sets the selected flag. */ williamr@2: void TTmCharFormatMask::Set(TAttrib aAttrib) williamr@2: { williamr@2: iFlags |= aAttrib; williamr@2: } williamr@2: williamr@2: /** Returns true if the selected attribute is set. */ williamr@2: TBool TTmCharFormatMask::IsSet(TAttrib aAttrib) williamr@2: { williamr@2: return iFlags & aAttrib; williamr@2: } williamr@2: williamr@2: /** Constructs a TTmCharFormat by converting the information in a TCharFormat. */ williamr@2: TTmCharFormat::TTmCharFormat(const TCharFormat& aFormat) williamr@2: { williamr@2: *this = aFormat; williamr@2: } williamr@2: williamr@2: /** The inequality operator. Return TRUE if this object and aFormat differ in any way. */ williamr@2: TBool TTmCharFormat::operator!=(const TTmCharFormat& aFormat) const williamr@2: { williamr@2: return !operator==(aFormat); williamr@2: } williamr@2: williamr@2: /** Constructs a TTmTab and set it to a standard tab stop with a position of 0. */ williamr@2: TTmTab::TTmTab(): williamr@2: iPosition(0), williamr@2: iType(EStandardTab) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Constructs a TTmTab by converting the information in a TTabStop. */ williamr@2: TTmTab::TTmTab(const TTabStop& aTab) williamr@2: { williamr@2: *this = aTab; williamr@2: } williamr@2: williamr@2: /** The inequality operator. Returns TRUE if this object and aTab differ in any williamr@2: way. */ williamr@2: TBool TTmTab::operator!=(const TTmTab& aTab) const williamr@2: { williamr@2: return !operator==(aTab); williamr@2: } williamr@2: williamr@2: /** Constructs a TTmBullet by converting the information in a TBullet. */ williamr@2: TTmBullet::TTmBullet(const TBullet& aBullet) williamr@2: { williamr@2: *this = aBullet; williamr@2: } williamr@2: williamr@2: /** The inequality operator. Returns true if this object and aBullet differ in williamr@2: any way. */ williamr@2: TBool TTmBullet::operator!=(const TTmBullet& aBullet) const williamr@2: { williamr@2: return !operator==(aBullet); williamr@2: } williamr@2: williamr@2: /** Constructs a TTmParBorder by converting the information in a TParaBorder. */ williamr@2: TTmParBorder::TTmParBorder(const TParaBorder& aBorder) williamr@2: { williamr@2: *this = aBorder; williamr@2: } williamr@2: williamr@2: /** The inequality operator. Returns TRUE if this object and aBorder differ in williamr@2: any way. */ williamr@2: TBool TTmParBorder::operator!=(const TTmParBorder& aBorder) const williamr@2: { williamr@2: return !operator==(aBorder); williamr@2: } williamr@2: williamr@2: /** Constructs a TTmParFormatMask with all the flags on. */ williamr@2: TTmParFormatMask::TTmParFormatMask(): williamr@2: iFlags(0xFFFFFFFF) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Clears the selected flag. */ williamr@2: void TTmParFormatMask::Clear(TAttrib aAttrib) williamr@2: { williamr@2: iFlags &= ~aAttrib; williamr@2: } williamr@2: williamr@2: /** Sets the selected flag. */ williamr@2: void TTmParFormatMask::Set(TAttrib aAttrib) williamr@2: { williamr@2: iFlags |= aAttrib; williamr@2: } williamr@2: williamr@2: /** williamr@2: Returns true if the selected flag is Set. williamr@2: */ williamr@2: TBool TTmParFormatMask::IsSet(TAttrib aAttrib) williamr@2: { williamr@2: return iFlags & aAttrib; williamr@2: } williamr@2: williamr@2: #ifdef _DEBUG williamr@2: RTmParFormat::~RTmParFormat() williamr@2: { williamr@2: __ASSERT_DEBUG(!iTabList && !iBullet && !HaveBorders(), User::Invariant()); williamr@2: } williamr@2: #endif williamr@2: williamr@2: /** The inequality operator. Returns true if this object and aFormat differ in williamr@2: any way. williamr@2: */ williamr@2: TBool RTmParFormat::operator!=(const RTmParFormat& aFormat) const williamr@2: { williamr@2: return !operator==(aFormat); williamr@2: } williamr@2: williamr@2: /** Returns a reference to the tab selected by aIndex. */ williamr@2: const TTmTab& RTmParFormat::Tab(TInt aIndex) const williamr@2: { williamr@2: return (*iTabList)[aIndex]; williamr@2: } williamr@2: williamr@2: /** Returns a pointer to the TTmBullet object if any. Returns null if the williamr@2: RTmParFormat does not contain a TTmBullet. */ williamr@2: const TTmBullet* RTmParFormat::Bullet() const williamr@2: { williamr@2: return iBullet; williamr@2: } williamr@2: williamr@2: /** Returns a pointer to the border selected by aIndex. Returns null if the williamr@2: selected border is not present. */ williamr@2: const TTmParBorder* RTmParFormat::Border(TBorderIndex aIndex) const williamr@2: { williamr@2: return iBorder[aIndex]; williamr@2: } williamr@2: williamr@2: /** Returns true if the paragraph's base direction is right-to-left. */ williamr@2: TBool RTmParFormat::RightToLeft() const williamr@2: { williamr@2: return iFlags & ERightToLeft; williamr@2: } williamr@2: williamr@2: /** Constructs a line height parameter structure, setting all the data members williamr@2: to zero. */ williamr@2: MTmCustom::TLineHeightParam::TLineHeightParam() williamr@2: { williamr@2: Mem::FillZ(this,sizeof(*this)); williamr@2: } williamr@2: williamr@2: CTmBufSeg::CTmBufSeg(TInt aExpandSize): williamr@2: CBufSeg(aExpandSize) williamr@2: { williamr@2: } williamr@2: williamr@2: CTmCode::~CTmCode() williamr@2: { williamr@2: delete iBuffer; williamr@2: } williamr@2: williamr@2: TPtr8 CTmCode::Ptr(TInt aPos) williamr@2: { williamr@2: return iBuffer->Ptr(aPos); williamr@2: } williamr@2: williamr@2: CBufBase* CTmCode::Buffer() williamr@2: { williamr@2: return iBuffer; williamr@2: } williamr@2: williamr@2: const CBufBase* CTmCode::Buffer() const williamr@2: { williamr@2: return iBuffer; williamr@2: } williamr@2: williamr@2: /** Returns true if wrapping is turned on. */ williamr@2: TBool TTmFormatParamBase::IsWrapping() const williamr@2: { williamr@2: return iFlags & EWrap; williamr@2: } williamr@2: williamr@2: /** Returns true if truncation with ellipsis is turned on. */ williamr@2: TBool TTmFormatParamBase::IsTruncatingWithEllipsis() const williamr@2: { williamr@2: return iFlags & ETruncateWithEllipsis; williamr@2: } williamr@2: williamr@2: /** Returns true if line breaking must only occur at legal line breaks, even if williamr@2: the line cannot legally be broken at the desired wrap width. */ williamr@2: TBool TTmFormatParamBase::LegalLineBreaksOnly() const williamr@2: { williamr@2: return iFlags & ELegalLineBreaksOnly; williamr@2: } williamr@2: williamr@2: /** Constructs a TTmLineInfo object, setting all data members to 0. */ williamr@2: TTmLineInfo::TTmLineInfo() williamr@2: { williamr@2: Mem::FillZ(this,sizeof(*this)); williamr@2: } williamr@2: williamr@2: /** Constructs a TTmDocPos object, setting iPos to 0 and iLeadingEdge to false. williamr@2: This is the lowest legal value for a TTmDocPos object. A trailing edge comes williamr@2: before a leading edge because it is the trailing edge of the character before williamr@2: the position, while the leading edge is that of the character after the williamr@2: position. ('Leading' means the first to be encountered when traversing the williamr@2: document in logical order). */ williamr@2: TTmDocPos::TTmDocPos(): williamr@2: iPos(0), williamr@2: iLeadingEdge(FALSE) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Constructs a TTmDocPos object, setting iPos to aPos and iLeadingEdge to williamr@2: aLeadingEdge. williamr@2: */ williamr@2: TTmDocPos::TTmDocPos(TInt aPos,TBool aLeadingEdge): williamr@2: iPos(aPos), williamr@2: iLeadingEdge(aLeadingEdge) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Constructs a TTmDocPosSpec, setting the position to 0 and the type to williamr@2: trailing. */ williamr@2: TTmDocPosSpec::TTmDocPosSpec(): williamr@2: iPos(0), williamr@2: iType(ETrailing) williamr@2: { williamr@2: } williamr@2: williamr@2: williamr@2: /** williamr@2: The not equal operator. williamr@2: @return True if both sides have different values. williamr@2: */ williamr@2: TBool TTmDocPos::operator!=(const TTmDocPos& aPos) const { return !((*this)==aPos); } williamr@2: williamr@2: /** williamr@2: Smaller than operator. williamr@2: @return williamr@2: True if the right side of the operator is further on in the document than williamr@2: the left hand side. williamr@2: */ williamr@2: TBool TTmDocPos::operator<(const TTmDocPos& aPos) const { return !((*this)>=aPos); } williamr@2: williamr@2: /** williamr@2: Smaller than or equal to operator. williamr@2: @return williamr@2: True if the right side of the operator is further on in the document than williamr@2: the left hand side or if both sides are identical. williamr@2: */ williamr@2: TBool TTmDocPos::operator<=(const TTmDocPos& aPos) const { return !((*this)>aPos); } williamr@2: williamr@2: /** Constructs a TTmDocPosSpec, setting the position to aPos and the type to williamr@2: aType. williamr@2: */ williamr@2: TTmDocPosSpec::TTmDocPosSpec(TInt aPos,TType aType): williamr@2: iPos(aPos), williamr@2: iType(aType) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Constructs a TTmDocPosSpec from a TTmDocPos. */ williamr@2: TTmDocPosSpec::TTmDocPosSpec(const TTmDocPos& aDocPos): williamr@2: iPos(aDocPos.iPos), williamr@2: iType(aDocPos.iLeadingEdge ? ELeading : ETrailing) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Returns the first formatted character. */ williamr@2: TInt CTmTextLayout::StartChar() const williamr@2: { williamr@2: return iStartChar; williamr@2: } williamr@2: williamr@2: /** Returns the character after the last formatted character. */ williamr@2: TInt CTmTextLayout::EndChar() const williamr@2: { williamr@2: return iEndChar; williamr@2: } williamr@2: williamr@2: /** Return the width in pixels of the formatted text, not including paragraph williamr@2: labels if present. */ williamr@2: TInt CTmTextLayout::LayoutWidth() const williamr@2: { williamr@2: return iWidth; williamr@2: } williamr@2: williamr@2: /** Returns the height in pixels of the formatted text. */ williamr@2: TInt CTmTextLayout::LayoutHeight() const williamr@2: { williamr@2: return iHeight; williamr@2: } williamr@2: williamr@2: /** Returns a pointer to to the MTmSource object, if any, that provides text williamr@2: and formatting to this object. Returns null if no source object has been set. */ williamr@2: MTmSource* CTmTextLayout::Source() williamr@2: { williamr@2: return iSource; williamr@2: } williamr@2: williamr@2: const MTmSource* CTmTextLayout::Source() const williamr@2: { williamr@2: return iSource; williamr@2: } williamr@2: williamr@2: /** williamr@2: Returns a reference to the CTmCode object containing the bytecode williamr@2: representing the text layout. williamr@2: @internalComponent williamr@2: */ williamr@2: const CTmCode& CTmTextLayout::Code() const williamr@2: { williamr@2: return iCode; williamr@2: } williamr@2: williamr@2: /** Constructs a TTmCharFormatLayer object containing default TTmCharFormat and williamr@2: TTmCharFormatMask objects. */ williamr@2: TTmCharFormatLayer::TTmCharFormatLayer() williamr@2: { williamr@2: } williamr@2: williamr@2: /** Closes an RTmParFormatLayer object by freeing any objects allocated on the williamr@2: heap. */ williamr@2: void RTmParFormatLayer::Close() williamr@2: { williamr@2: iFormat.Close(); williamr@2: } williamr@2: williamr@2: /** Closes an RTmStyle object by freeing any objects allocated on the heap. williamr@2: */ williamr@2: void RTmStyle::Close() williamr@2: { williamr@2: iParFormat.Close(); williamr@2: } williamr@2: williamr@2: /** Draws the formatted text. This inline function just calls williamr@2: CTmText::DrawLayout and is identical to it. It is provided for coding williamr@2: convenience because of the expectation that a drawing function called Draw williamr@2: exists. */ williamr@2: void CTmText::Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, williamr@2: const TLogicalRgb* aDocBackground,TBool aDrawParBackground) williamr@2: { williamr@2: DrawLayout(aGc,aTopLeft,aClipRect,aDocBackground,aDrawParBackground); williamr@2: } williamr@2: williamr@2: /** Contains the extensions to character rectangle used when highlighting williamr@2: the text in reverse video williamr@2: */ williamr@2: TTmHighlightExtensions::TTmHighlightExtensions() williamr@2: { williamr@2: } williamr@2: williamr@2: void TTmHighlightExtensions::SetAll(TInt aExtension) williamr@2: { williamr@2: iLeftExtension=iRightExtension=iTopExtension=iBottomExtension=aExtension; williamr@2: } williamr@2: williamr@2: void TTmHighlightExtensions::SetLeftExtension(TInt aExtension) williamr@2: { williamr@2: iLeftExtension=aExtension; williamr@2: } williamr@2: williamr@2: void TTmHighlightExtensions::SetRightExtension(TInt aExtension) williamr@2: { williamr@2: iRightExtension=aExtension; williamr@2: } williamr@2: williamr@2: void TTmHighlightExtensions::SetTopExtension(TInt aExtension) williamr@2: { williamr@2: iTopExtension=aExtension; williamr@2: } williamr@2: williamr@2: void TTmHighlightExtensions::SetBottomExtension(TInt aExtension) williamr@2: { williamr@2: iBottomExtension=aExtension; williamr@2: } williamr@2: williamr@2: TInt TTmHighlightExtensions::LeftExtension() const williamr@2: { williamr@2: return iLeftExtension; williamr@2: } williamr@2: williamr@2: TInt TTmHighlightExtensions::RightExtension() const williamr@2: { williamr@2: return iRightExtension; williamr@2: } williamr@2: williamr@2: TInt TTmHighlightExtensions::TopExtension() const williamr@2: { williamr@2: return iTopExtension; williamr@2: } williamr@2: williamr@2: TInt TTmHighlightExtensions::BottomExtension() const williamr@2: { williamr@2: return iBottomExtension; williamr@2: } williamr@2: williamr@2: inline TBool TTmHighlightExtensions::Extends() const williamr@2: { williamr@2: return (iTopExtension > 0 || iBottomExtension > 0 || iLeftExtension > 0 || iRightExtension > 0); williamr@2: } williamr@2: williamr@2: inline TBool TTmHighlightExtensions::Shrinks() const williamr@2: { williamr@2: return (iTopExtension < 0 || iBottomExtension < 0 || iLeftExtension < 0 || iRightExtension < 0); williamr@2: } williamr@2: williamr@2: inline void TTmHighlightExtensions::ExtendRect(TRect& aRect) const williamr@2: { williamr@2: if (iLeftExtension>0) williamr@2: aRect.iTl.iX-=iLeftExtension; williamr@2: if (iRightExtension>0) williamr@2: aRect.iBr.iX+=iRightExtension; williamr@2: if (iTopExtension>0) williamr@2: aRect.iTl.iY-=iTopExtension; williamr@2: if (iBottomExtension>0) williamr@2: aRect.iBr.iY+=iBottomExtension; williamr@2: } williamr@2: williamr@2: inline void TTmHighlightExtensions::AdjustRect(TRect& aRect) const williamr@2: { williamr@2: aRect.iTl.iX-=iLeftExtension; williamr@2: aRect.iTl.iY-=iTopExtension; williamr@2: aRect.iBr.iX+=iRightExtension; williamr@2: aRect.iBr.iY+=iBottomExtension; williamr@2: } williamr@2: williamr@2: inline TBool TTmHighlightExtensions::IsNull() const williamr@2: { williamr@2: return 0 == iLeftExtension && 0 == iTopExtension && 0 == iRightExtension && 0 == iBottomExtension; williamr@2: } williamr@2: williamr@2: inline void TTmHighlightExtensions::AbsExtendRect(TRect& aRect) const williamr@2: { williamr@2: if (iLeftExtension>0) williamr@2: aRect.iTl.iX-=iLeftExtension; williamr@2: else williamr@2: aRect.iTl.iX+=iLeftExtension; williamr@2: williamr@2: if (iRightExtension>0) williamr@2: aRect.iBr.iX+=iRightExtension; williamr@2: else williamr@2: aRect.iBr.iX-=iRightExtension; williamr@2: williamr@2: if (iTopExtension>0) williamr@2: aRect.iTl.iY-=iTopExtension; williamr@2: else williamr@2: aRect.iTl.iY+=iTopExtension; williamr@2: williamr@2: if (iBottomExtension>0) williamr@2: aRect.iBr.iY+=iBottomExtension; williamr@2: else williamr@2: aRect.iBr.iY-=iBottomExtension; williamr@2: } williamr@2: williamr@2: #endif // __TAGMA_H__