williamr@2: // Copyright (c) 1997-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: // williamr@2: williamr@2: #ifndef __TXTFRMAT_H__ williamr@2: #define __TXTFRMAT_H__ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: williamr@2: // Classes declared in this file: williamr@2: class TTabStop; williamr@2: class TParaBorder; williamr@2: class TBullet; williamr@2: class TParaBorderArray; williamr@2: class CParaFormat; williamr@2: class TParaFormatMask; williamr@2: class TFontPresentation; williamr@2: class TCharFormat; williamr@2: class TCharFormatMask; williamr@2: williamr@2: /** williamr@2: Provides support for system colours, in addition to literal colours, in williamr@2: text formatting. williamr@2: williamr@2: The base class TRgb stores the 24-bit literal colour value using a TUint32. williamr@2: TLogicalRgb uses the MSB from iValue2 data member as an 8-bit index. The williamr@2: purpose of the index is to allow applications to use logical colours. If the williamr@2: index is zero, the value is not a logical colour; it is treated as an ordinary williamr@2: TRgb value. If the index is non zero (1-255), the colour should be translated by the williamr@2: application into a system colour. Indices 254 and 255 are reserved for the williamr@2: system foreground and background colours, respectively and should be translated williamr@2: into them. Translation from index to RGB colour occurs in the implementation of williamr@2: MFormParam::SystemColor(). williamr@2: williamr@2: All colours in the Text and Text Attributes API are stored using TLogicalRgb williamr@2: values and are initialised to either TLogicalRgb::ESystemForegroundColor or williamr@2: TLogicalRgb::ESystemBackgroundColor. williamr@2: williamr@2: This system allows an application to set its text colours once, perhaps using williamr@2: the system-wide colour scheme, rather than having to set the colours each williamr@2: time a text object is created. It is also compatible with legacy code which williamr@2: expects TRgb rather than TLogicalRgb values: for example, the logical williamr@2: foreground and background colours have their bottom three bytes filled with williamr@2: black and white respectively so that code which expects TRgb values can still williamr@2: use them. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TLogicalRgb : public TRgb williamr@2: { williamr@2: public: williamr@2: williamr@2: /* williamr@2: Reserved colour indices for default foreground and background colours, williamr@2: and colours for the selection highlight. The top 128 indices (128-255) williamr@2: are reserved for future expansion, but the first 126 non-zero indices williamr@2: (1-127) can be used by the GUI as convenient. williamr@2: */ williamr@2: enum williamr@2: { williamr@2: ESystemSelectionForegroundIndex = 252, williamr@2: ESystemSelectionBackgroundIndex = 253, williamr@2: /** Index reserved for the system foreground colour (=254). */ williamr@2: ESystemForegroundIndex = 254, williamr@2: /** Index reserved for the system background colour (=255). */ williamr@2: ESystemBackgroundIndex = 255 williamr@2: }; williamr@2: williamr@2: williamr@2: williamr@2: /** Used to construct TLogicalRgb objects which should use either the williamr@2: system foreground or background colour. */ williamr@2: enum TSystemColor williamr@2: { williamr@2: ESystemSelectionForegroundColor = ESystemSelectionForegroundIndex << 24, williamr@2: ESystemSelectionBackgroundColor = ESystemSelectionBackgroundIndex << 24, williamr@2: /** The system foreground colour. */ williamr@2: ESystemForegroundColor = ESystemForegroundIndex << 24, williamr@2: /** The system background colour. */ williamr@2: ESystemBackgroundColor = (ESystemBackgroundIndex << 24) | 0xFFFFFF williamr@2: }; williamr@2: williamr@2: /** Constructs a new TLogicalRgb object. */ williamr@2: TLogicalRgb() : williamr@2: iValue2(0) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Constructs the object with a 32-bit integer. The index is stored in the williamr@2: MSB of iValue2 data member. A TRgb value may be stored in the base TRgb class. williamr@2: @param aValue Integer holding the logical colour index. */ williamr@2: TLogicalRgb(TUint32 aValue): williamr@2: iValue2(aValue & 0xFF000000) williamr@2: { williamr@2: SetInternal((TUint32)aValue | 0xFF000000); williamr@2: } williamr@2: williamr@2: /** Constructs the object with a TSystemColor value. williamr@2: @param aValue Identifies whether the colour is the system foreground or williamr@2: system background colour. */ williamr@2: TLogicalRgb(TSystemColor aValue) : williamr@2: iValue2((TUint32)aValue & 0xFF000000) williamr@2: { williamr@2: SetInternal((TUint32)aValue | 0xFF000000); williamr@2: } williamr@2: williamr@2: /** Constructs a new TLogicalRgb object from an existing one. */ williamr@2: TLogicalRgb(const TRgb& aRgb) : williamr@2: TRgb(aRgb), williamr@2: iValue2(0) williamr@2: { williamr@2: } williamr@2: williamr@2: /** Returns the logical colour's index value. Zero indicates that the value williamr@2: is not a logical colour; it is an ordinary TRgb value. 254 and 255 indicate williamr@2: the system foreground and background colours, respectively. williamr@2: @return The index: between zero and 255 inclusive. */ williamr@2: TUint SystemColorIndex() const williamr@2: { williamr@2: return iValue2 >> 24; williamr@2: } williamr@2: williamr@2: /** Sets the logical colour's index value. williamr@2: @param aIndex The new index value (between 1 and 253 inclusive). */ williamr@2: void SetSystemColorIndex(TUint aIndex) williamr@2: { williamr@2: iValue2 = aIndex << 24; williamr@2: } williamr@2: williamr@2: private: williamr@2: TUint32 iValue2; williamr@2: williamr@2: }; williamr@2: williamr@2: /** williamr@2: Indicates which format attributes are relevant when setting or sensing text williamr@2: formatting. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TTextFormatAttribute williamr@2: { williamr@2: // Paragraph format attributes. williamr@2: /** Language of the paragraph for proofing. */ williamr@2: EAttParaLanguage, williamr@2: /** Background colour of the paragraph. */ williamr@2: EAttFillColor, williamr@2: /** Leading text margin. */ williamr@2: EAttLeftMargin, williamr@2: /** Trailing text margin. */ williamr@2: EAttRightMargin, williamr@2: /** First line leading indent. */ williamr@2: EAttIndent, williamr@2: /** Horizontal alignment of paragraph. */ williamr@2: EAttAlignment, williamr@2: /** Vertical paragraph alignment. */ williamr@2: EAttVerticalAlignment, williamr@2: /** Inter-line spacing. */ williamr@2: EAttLineSpacing, williamr@2: /** Control for EAttLineSpacing. */ williamr@2: EAttLineSpacingControl, williamr@2: /** Space above paragraph. */ williamr@2: EAttSpaceBefore, williamr@2: /** Space below paragraph. */ williamr@2: EAttSpaceAfter, williamr@2: /** Whether a page break can occur within the paragraph. */ williamr@2: EAttKeepTogether, williamr@2: /** Whether a page break can occur between this and the next paragraph. */ williamr@2: EAttKeepWithNext, williamr@2: /** Whether a page break should be inserted before this paragraph. */ williamr@2: EAttStartNewPage, williamr@2: /** Whether the last line of a paragraph can appear by itself at the top of a new williamr@2: page, (widow), or the first line of a paragraph can appear by itself at the williamr@2: bottom of the page, (orphan). */ williamr@2: EAttWidowOrphan, williamr@2: /** Whether the paragraph should line wrap at the right margin. */ williamr@2: EAttWrap, williamr@2: /** Distance between paragraph border and enclosed text. */ williamr@2: EAttBorderMargin, williamr@2: /** Top of paragraph border. */ williamr@2: EAttTopBorder, williamr@2: /** Bottom of paragraph border. */ williamr@2: EAttBottomBorder, williamr@2: /** Left-hand side of paragraph border. */ williamr@2: EAttLeftBorder, williamr@2: /** Right-hand side of paragraph border. */ williamr@2: EAttRightBorder, williamr@2: /** Bullet point associated with paragraph. */ williamr@2: EAttBullet, williamr@2: /** Spacing between default tab stops. */ williamr@2: EAttDefaultTabWidth, williamr@2: /** Tab stop. */ williamr@2: EAttTabStop, williamr@2: williamr@2: // Character format attributes. williamr@2: /** Language of individual characters within a paragraph for proofing. */ williamr@2: EAttCharLanguage, williamr@2: /** Text colour. */ williamr@2: EAttColor, williamr@2: /** Text highlight colour. */ williamr@2: EAttFontHighlightColor, williamr@2: /** Text highlight style. */ williamr@2: EAttFontHighlightStyle, williamr@2: /** Font height. */ williamr@2: EAttFontHeight, williamr@2: /** Font posture (i.e. italics). */ williamr@2: EAttFontPosture, williamr@2: /** Font stroke weight (i.e. bold). */ williamr@2: EAttFontStrokeWeight, williamr@2: /** Subscript, superscript or normal print position. */ williamr@2: EAttFontPrintPos, williamr@2: /** Underlining. */ williamr@2: EAttFontUnderline, williamr@2: /** Strikethrough. */ williamr@2: EAttFontStrikethrough, williamr@2: /** The typeface name. */ williamr@2: EAttFontTypeface, williamr@2: /** Vertical picture alignment. */ williamr@2: EAttFontPictureAlignment, williamr@2: /** Hidden text. */ williamr@2: EAttFontHiddenText, williamr@2: williamr@2: /** Used internally to indicate the count of all attributes. */ williamr@2: ETextFormatAttributeCount williamr@2: }; williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: enum {EVariableLengthValue = 0}; williamr@2: williamr@2: /** williamr@2: @internalComponent williamr@2: */ williamr@2: const TInt KMaxStyleName = 0x20; williamr@2: const TInt KMaxParaAttributes = EAttTabStop; williamr@2: const TInt KMaxCharAttributes = EAttFontHiddenText - KMaxParaAttributes; williamr@2: const TInt KTabNotFound = -1; williamr@2: williamr@2: /** williamr@2: A tab stop. williamr@2: williamr@2: This is a position on a page used to align columns of text. It has a twips williamr@2: position and an alignment. The twips position is the width in twips (1/1440th williamr@2: of an inch) of the tab stop, i.e. the number of twips from the start of the williamr@2: line at which text can be inserted. It uniquely identifies the tab stop. The williamr@2: alignment (left, right, or centre) indicates how text inserted at the tab williamr@2: stop should be aligned. williamr@2: williamr@2: Tab stops are paragraph format attributes. They are owned by the CParaFormat williamr@2: class, through which tab stops can be added and removed. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TTabStop williamr@2: { williamr@2: public: williamr@2: /** Text alignment at the tab stop. */ williamr@2: enum TTabType williamr@2: { williamr@2: /** No tab. */ williamr@2: ENullTab, williamr@2: /** Text is aligned to the tab stop's leading edge (left for williamr@2: left-to-right paragraphs, right for right-to-left paragraphs). */ williamr@2: ELeftTab, williamr@2: /** Text is aligned to the tab stop's trailing edge (right for williamr@2: left-to-right paragraphs, left for right-to-left paragraphs). */ williamr@2: ECenteredTab, williamr@2: /** Text is right aligned at the tab stop. */ williamr@2: ERightTab williamr@2: }; williamr@2: public: williamr@2: IMPORT_C TTabStop(); williamr@2: IMPORT_C TTabStop(const TTabStop& aTabStop); williamr@2: IMPORT_C TTabStop& operator=(const TTabStop& aTabStop); williamr@2: IMPORT_C TBool operator==(const TTabStop& aTabStop) const; williamr@2: inline TBool operator!=(const TTabStop& aTabStop) const; williamr@2: public: williamr@2: /** The twips position. This is the width in twips of the tab stop, i.e. williamr@2: the number of twips from the start of the line at which text can be williamr@2: inserted. */ williamr@2: TUint32 iTwipsPosition; williamr@2: /** Text alignment at the tab stop. */ williamr@2: TTabType iType; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Defines the characteristics of one of the four sides of a paragraph border. williamr@2: williamr@2: These are the line style, thickness and colour. Paragraph borders are paragraph williamr@2: format attributes. They are owned by the CParaFormat class which allows williamr@2: paragraph borders to be added and removed. The CParaFormat::TParaBorderSide williamr@2: enumeration identifies which side of the paragraph the object applies to. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TParaBorder williamr@2: { williamr@2: public: williamr@2: williamr@2: /** Line styles. */ williamr@2: enum TLineStyle williamr@2: { williamr@2: /** No line style. */ williamr@2: ENullLineStyle, williamr@2: /** Solid line. */ williamr@2: ESolid, williamr@2: /** Double solid line. */ williamr@2: EDouble, williamr@2: /** Dotted line. */ williamr@2: EDotted, williamr@2: /** Dashed line. */ williamr@2: EDashed, williamr@2: /** Alternating dots and dashes. */ williamr@2: EDotDash, williamr@2: /** Alternating sequence of two dots and a dash. */ williamr@2: EDotDotDash williamr@2: }; williamr@2: // williamr@2: IMPORT_C TParaBorder(); williamr@2: IMPORT_C TBool operator==(const TParaBorder& aParaBorder) const; williamr@2: inline TBool operator!=(const TParaBorder& aParaBorder) const; williamr@2: public: williamr@2: /** The line style. By default, ENullLineStyle. */ williamr@2: TLineStyle iLineStyle; williamr@2: /** The line thickness in twips. By default, zero. */ williamr@2: TInt iThickness; williamr@2: /** The line colour. By default, the system's default foreground colour. */ williamr@2: TLogicalRgb iColor; williamr@2: /** ETrue indicates that the line colour is set to the default or current williamr@2: text colour, overriding iColor. EFalse indicates that the iColor value is williamr@2: used. By default, ETrue. */ williamr@2: TBool iAutoColor; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Stores the four sides of a paragraph border. williamr@2: williamr@2: Paragraph borders sides are set individually using functions provided by class williamr@2: CParaFormat. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TParaBorderArray williamr@2: { williamr@2: public: williamr@2: TParaBorder iBorder[4]; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A bullet point. williamr@2: williamr@2: This is a paragraph format attribute, stored as the iBullet member of class williamr@2: CParaFormat. williamr@2: williamr@2: Bullet points have a typeface, height, colour and a character code (defines williamr@2: the symbol displayed). Single level bullets only are supported. Bullets may williamr@2: also have a hanging indent. If set, this means that the rest of the paragraph williamr@2: following the line containing the bullet point is indented. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TBullet williamr@2: { williamr@2: public: williamr@2: IMPORT_C TBullet(); williamr@2: IMPORT_C TBool operator ==(const TBullet& aBullet) const; williamr@2: inline TBool operator !=(const TBullet& aBullet) const; williamr@2: williamr@2: /** williamr@2: Identifies the bullet style. williamr@2: williamr@2: Note: Styles other than ENullStyle and EBulletStyle are not currently supported. williamr@2: They have the same effect as the EBulletStyle. williamr@2: */ williamr@2: enum TStyle williamr@2: { williamr@2: /** williamr@2: No bullet. Used for style layers that override a bullet with the absence of a bullet. williamr@2: */ williamr@2: ENullStyle, williamr@2: /** williamr@2: A bullet point. Character with code 0x2022 is used by default. 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: /** Paragraph alignment */ williamr@2: enum TAlignment williamr@2: { williamr@2: /** Paragraph left aligned. */ williamr@2: ELeftAlign, williamr@2: /** Paragraph centre aligned. */ williamr@2: ECenterAlign, williamr@2: /** Paragraph right aligned. */ williamr@2: ERightAlign williamr@2: }; williamr@2: williamr@2: /** The Unicode character used to represent the bullet point. By default williamr@2: 0x2022. */ williamr@2: TChar iCharacterCode; // the bullet or other symbol used if iStyle is EBulletStyle williamr@2: /** The height in twips of the font used for the bullet point character. williamr@2: By default, zero. */ williamr@2: TUint iHeightInTwips; williamr@2: /** The typeface used for the bullet point character. */ williamr@2: TTypeface iTypeface; williamr@2: /** ETrue to indent the rest of the paragraph from the bullet point. williamr@2: EFalse to align the bullet point character with the rest of the paragraph. */ williamr@2: TBool iHangingIndent; williamr@2: /** The colour of the bullet point character. By default, the system's williamr@2: default foreground colour. */ 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 transient container of paragraph format attributes, including tab stops, williamr@2: bullet points and paragraph borders. williamr@2: williamr@2: Rich and global text objects store paragraph formatting using paragraph format williamr@2: layers (see class CParaFormatLayer). The CParaFormat class is used to store williamr@2: the relevant attribute values when setting or sensing a CParaFormatLayer. williamr@2: It is normally used in combination with a TParaFormatMask, to specify which williamr@2: attributes are relevant to the function concerned. williamr@2: williamr@2: On construction, all CParaFormat member data is initialised. The attributes williamr@2: which are not explicitly set are assigned default values. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class CParaFormat: public CBase williamr@2: { williamr@2: public: williamr@2: /** Miscellaneous constants. */ williamr@2: enum williamr@2: { williamr@2: /** The maximum number of paragraph borders (= 4). */ williamr@2: EMaxParaBorder = 4 williamr@2: }; williamr@2: williamr@2: /** Paragraph border sides */ williamr@2: enum TParaBorderSide williamr@2: { williamr@2: /** The border at the top of the paragraph. */ williamr@2: EParaBorderTop, williamr@2: /** The border at the bottom of the paragraph. */ williamr@2: EParaBorderBottom, williamr@2: /** The border on the left hand side. */ williamr@2: EParaBorderLeft, williamr@2: /** The border on the right hand side. */ williamr@2: EParaBorderRight williamr@2: }; williamr@2: williamr@2: /** Line spacing control */ williamr@2: enum TLineSpacingControl williamr@2: { williamr@2: /** Twips line spacing must be at least as wide as the williamr@2: iLineSpacingInTwips value. */ williamr@2: ELineSpacingAtLeastInTwips, williamr@2: /** Twips line spacing must be exactly the iLineSpacingInTwips value. */ williamr@2: ELineSpacingExactlyInTwips, williamr@2: /** Pixels line spacing must be at least as wide as the line spacing williamr@2: value in pixels. */ williamr@2: ELineSpacingAtLeastInPixels, williamr@2: /** Pixels line spacing must be exactly the same as the line spacing williamr@2: value in pixels. */ williamr@2: ELineSpacingExactlyInPixels williamr@2: }; williamr@2: williamr@2: /** Paragraph alignment */ williamr@2: enum TAlignment williamr@2: { williamr@2: /** Paragraph aligned to the leading margin (left for left-to-right williamr@2: paragraphs, right for right-to-left paragraphs). */ williamr@2: ELeftAlign, williamr@2: /** Paragraph top aligned. */ williamr@2: ETopAlign = ELeftAlign, williamr@2: /** Paragraph centre aligned. */ williamr@2: ECenterAlign, williamr@2: /** Paragraph aligned to the trailing margin (right for left-to-right williamr@2: paragraphs, left for right-to-left paragraphs). */ williamr@2: ERightAlign, williamr@2: /** Paragraph bottom aligned. */ williamr@2: EBottomAlign = ERightAlign, williamr@2: /** Paragraph justified. */ williamr@2: EJustifiedAlign, williamr@2: /** Used by the spreadsheet application. Unlike ETopAlign and williamr@2: EBottomAlign, provides no default implementation. */ williamr@2: EUnspecifiedAlign, williamr@2: /** User-defined paragraph alignment. */ williamr@2: ECustomAlign, williamr@2: /** Absolute left alignment */ williamr@2: EAbsoluteLeftAlign, williamr@2: /** Absolute right alignment */ williamr@2: EAbsoluteRightAlign williamr@2: }; williamr@2: williamr@2: /** Attribute sense mode */ williamr@2: enum TParaFormatGetMode williamr@2: { williamr@2: /** Indicates that all paragraph format attributes are written to the williamr@2: result when sensing paragraph format attributes. */ williamr@2: EAllAttributes, williamr@2: /** Indicates that tabs, bullets and borders are not sensed. */ williamr@2: EFixedAttributes williamr@2: }; williamr@2: williamr@2: IMPORT_C static CParaFormat* NewL(); williamr@2: IMPORT_C static CParaFormat* NewLC(); williamr@2: IMPORT_C static CParaFormat* NewL(const CParaFormat& aFormat); williamr@2: IMPORT_C CParaFormat(); williamr@2: IMPORT_C ~CParaFormat(); williamr@2: IMPORT_C void ResetNonDestructive(); // preserves any allocated tabs, bullets or borders. williamr@2: IMPORT_C void Reset(); // full reset, deletes and nulls any allocated tabs, bullets or borders. williamr@2: IMPORT_C void CopyL(const CParaFormat& aFormat, const TParaFormatMask& aMask); williamr@2: IMPORT_C void CopyL(const CParaFormat& aFormat); williamr@2: IMPORT_C void Strip(); // Cleans up this paragraph format. williamr@2: IMPORT_C TBool IsEqual(const CParaFormat& aFormat, const TParaFormatMask& aMask) const; williamr@2: IMPORT_C TBool IsEqual(const CParaFormat& aFormat) const; williamr@2: IMPORT_C void StoreTabL(const TTabStop& aTabStop); williamr@2: IMPORT_C void RemoveTab(TInt aTabTwipsPosition); williamr@2: inline void RemoveAllTabs(); williamr@2: IMPORT_C const TTabStop TabStop(TInt aTabIndex) const; williamr@2: inline TInt TabCount() const; williamr@2: IMPORT_C TInt LocateTab(TInt aTabTwipsPosition) const; williamr@2: IMPORT_C void SetParaBorderL(TParaBorderSide aSide, const TParaBorder& aBorder); // Overwrites any existing border for that side williamr@2: IMPORT_C void RemoveAllBorders(); williamr@2: IMPORT_C const TParaBorder ParaBorder(TParaBorderSide aSide) const; williamr@2: williamr@2: /** Tests whether any paragraph borders have been set. williamr@2: williamr@2: @return ETrue if any paragraph borders have been set, EFalse if not. */ williamr@2: inline TBool BordersPresent() const { return iParaBorderArray != NULL;} williamr@2: williamr@2: inline TParaBorder* ParaBorderPtr(TParaBorderSide aSide) williamr@2: williamr@2: /** Gets a pointer to the paragraph border on the side specified. If no williamr@2: paragraph border array has been allocated, returns NULL. williamr@2: williamr@2: @param aSide The side for the paragraph border. williamr@2: @return Pointer to the paragraph border on the specified side. */ williamr@2: { return iParaBorderArray ? &iParaBorderArray->iBorder[aSide] : NULL; } williamr@2: IMPORT_C TBool AllBordersEqual(const CParaFormat& aFormat) const; williamr@2: IMPORT_C TBool IsBorderEqual(TParaBorderSide aSide, const CParaFormat& aFormat) const; williamr@2: private: williamr@2: CParaFormat(const CParaFormat& aFormat); williamr@2: void CreateTabListL(); williamr@2: enum williamr@2: { williamr@2: ETabStoreGranularity = 2 williamr@2: }; williamr@2: williamr@2: CParaFormat& operator=(const CParaFormat& aParaFormat); // intentionally unimplemented williamr@2: private: williamr@2: CArrayFixFlat* iTabList; // ordered list of tab stops; null if none williamr@2: TParaBorderArray* iParaBorderArray; // array of paragraph borders; null if none williamr@2: public: williamr@2: /** The background colour of the paragraph. By default the default system williamr@2: background colour. This colour applies to the area bounded by the paragraph williamr@2: border, if one exists. */ williamr@2: TLogicalRgb iFillColor; williamr@2: /** The language of the paragraph for proofing. By default williamr@2: KParaDefaultLanguage. Used for example when spell checking a document williamr@2: which contains text in more than one language, so that the program williamr@2: recognises the text as being in another language. */ williamr@2: TInt32 iLanguage; williamr@2: /** The width in twips of the leading margin (left for left-to-right williamr@2: paragraphs, right for right-to-left paragraphs). By default williamr@2: KParaDefaultLeftMargin (zero). */ williamr@2: TInt32 iLeftMarginInTwips; williamr@2: /** The width in twips of the trailing margin (right for left-to-right williamr@2: paragraphs, left for right-to-left paragraphs). By default williamr@2: KParaDefaultRightMargin (zero). */ williamr@2: TInt32 iRightMarginInTwips; williamr@2: /** An indent for the first line in the paragraph, relative to the leading williamr@2: margin (left for left-to-right paragraphs, right for right-to-left williamr@2: paragraphs). By default KParaDefaultIndent (zero). */ williamr@2: TInt32 iIndentInTwips; williamr@2: /** Horizontal alignment of paragraph. By default KParaDefaultHorizAlign williamr@2: (left). */ williamr@2: TAlignment iHorizontalAlignment; williamr@2: /** Vertical alignment of paragraph, (intended for use by spreadsheet williamr@2: applications). By default KParaDefaultVertAlign (unspecified). */ williamr@2: TAlignment iVerticalAlignment; williamr@2: /** Inter-line spacing within the paragraph, in twips. By default williamr@2: KParaDefaultLineSpacing (200 twips). */ williamr@2: TInt32 iLineSpacingInTwips; // distance between successive baselines williamr@2: /** Control for the iLineSpacingInTwips value. By default, williamr@2: KParaDefaultLineSpacingControl (ELineSpacingAtLeastInTwips). */ williamr@2: TLineSpacingControl iLineSpacingControl; // whether iLineSpacingInTwips means 'at least' or 'exactly' williamr@2: /** Space above paragraph. By default KParaDefaultSpaceBefore (zero). */ williamr@2: TInt32 iSpaceBeforeInTwips; williamr@2: /** Space below paragraph. By default KParaDefaultSpaceAfter (zero). */ williamr@2: TInt32 iSpaceAfterInTwips; williamr@2: /** Prevents a page break within paragraph if ETrue. By default williamr@2: KParaDefaultKeepTogether (EFalse). */ williamr@2: TBool iKeepTogether; williamr@2: /** Prevents a page break between this paragraph and the following williamr@2: paragraph if ETrue. By default, KParaDefaultKeepWithNext (EFalse). */ williamr@2: TBool iKeepWithNext; williamr@2: /** Inserts a page break immediately before this paragraph if ETrue. williamr@2: By default, KParaDefaultStartNewPage (EFalse). */ williamr@2: TBool iStartNewPage; williamr@2: /** Prevents the printing of the last line of a paragraph at the top williamr@2: of the page (referred to as a widow), or the first line of a paragraph williamr@2: at the bottom of the page, (referred to as an orphan). By default, williamr@2: KParaDefaultWidowOrphan (EFalse). */ williamr@2: TBool iWidowOrphan; williamr@2: /** Specifies whether the paragraph should line wrap at the right margin. williamr@2: By default KParaDefaultWrap (ETrue). */ williamr@2: TBool iWrap; williamr@2: /** Distance in twips between the paragraph border and the enclosed text. williamr@2: By default KParaDefaultBorderMargin (zero). */ williamr@2: TInt32 iBorderMarginInTwips; williamr@2: /** The bullet point associated with the paragraph. A NULL value indicates williamr@2: no bullet point. By default NULL. */ williamr@2: TBullet* iBullet; williamr@2: /** Specifies the default tab stop width. By default KParaDefaultTabWidth williamr@2: (360 twips). */ williamr@2: TUint32 iDefaultTabWidthInTwips; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Masks the paragraph format attributes which are involved when setting and williamr@2: sensing paragraph formatting. williamr@2: williamr@2: Used in conjunction with an object of class CParaFormat. When setting formatting, williamr@2: only the attributes which are set in the mask will participate in the relevant williamr@2: function. When sensing formatting, on return, the mask indicates which attributes williamr@2: were sensed from the format layer, and were not taken from the default values. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TParaFormatMask williamr@2: { williamr@2: public: williamr@2: inline TParaFormatMask(); williamr@2: inline void SetAttrib(TTextFormatAttribute aAttribute); williamr@2: inline void ClearAttrib(TTextFormatAttribute aAttribute); williamr@2: IMPORT_C void SetAll(); williamr@2: IMPORT_C void ClearAll(); williamr@2: inline TBool AttribIsSet(TTextFormatAttribute aAttribute) const; williamr@2: inline TBool IsNull() const; williamr@2: IMPORT_C TBool operator==(const TParaFormatMask& aMask) const; williamr@2: inline TBool operator!=(const TParaFormatMask& aMask) const; williamr@2: williamr@2: private: williamr@2: TUint32 iGuard; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Specifies the font-independent character format attributes, including bold, williamr@2: italics and underlining. williamr@2: williamr@2: An instance of this class is owned by the character formatting container (class williamr@2: TCharFormat). williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TFontPresentation williamr@2: { williamr@2: public: williamr@2: williamr@2: /** Highlight style */ williamr@2: enum TFontHighlightStyle williamr@2: { williamr@2: /** No highlighting used. */ williamr@2: EFontHighlightNone, williamr@2: /** Normal (square cornered) highlighting used. */ williamr@2: EFontHighlightNormal, williamr@2: /** Rounded corner highlighting used. */ williamr@2: EFontHighlightRounded, williamr@2: /** Text is drawn offset towards the bottom-right in the highlight williamr@2: colour, (iHighlightColor) before being drawn again in the text colour, williamr@2: (iTextColor) creating a shadow effect. */ williamr@2: EFontHighlightShadow, williamr@2: /** Placeholder for "unrecognised word" highlighting style for FEPs */ williamr@2: EFontHighlightNoMatchesIndicator, williamr@2: /** First custom highlighting style is used. williamr@2: @see MFormCustomDraw::DrawText(). */ williamr@2: EFontHighlightFirstCustomStyle = 128, williamr@2: /** Second custom highlighting style is used. williamr@2: @see MFormCustomDraw::DrawText(). */ williamr@2: EFontHighlightLastCustomStyle = 255 williamr@2: }; williamr@2: williamr@2: williamr@2: /** Vertical picture alignment */ williamr@2: enum TAlignment williamr@2: { williamr@2: /** The top of the picture is aligned flush with the top of the font's williamr@2: ascent, so that the picture may descend below the line. */ williamr@2: EAlignTop, williamr@2: /** The bottom of the picture is aligned flush with the bottom of the williamr@2: font's descent so that the picture may extend above the line. */ williamr@2: EAlignBottom, williamr@2: /** The picture is aligned so that its centre is positioned at the williamr@2: baseline of the line. */ williamr@2: EAlignCentered, williamr@2: /** The bottom of the picture is aligned with the baseline of the font. williamr@2: This is the default. */ williamr@2: EAlignBaseLine williamr@2: }; williamr@2: // williamr@2: IMPORT_C TFontPresentation(); williamr@2: // williamr@2: // Enquiry function williamr@2: IMPORT_C TBool IsEqual(const TFontPresentation& aFontPresentation, const TCharFormatMask& aMask) const; williamr@2: public: williamr@2: /** The text colour. By default, the default system foreground colour. */ williamr@2: TLogicalRgb iTextColor; williamr@2: /** The highlight colour for selected text. Only takes effect if williamr@2: iHighlightStyle is not EFontHighlightNone. By default, the default system williamr@2: foreground colour. */ williamr@2: TLogicalRgb iHighlightColor; // Background color williamr@2: /** Style for character highlighting. By default EFontHighlightNone. */ williamr@2: TFontHighlightStyle iHighlightStyle; williamr@2: /** The value of the strikethrough attribute. By default EStrikethroughOff. */ williamr@2: TFontStrikethrough iStrikethrough; williamr@2: /** The value of the underline attribute. By default EUnderlineOff. */ williamr@2: TFontUnderline iUnderline; williamr@2: /** Specifies whether or not text is hidden. Note that hidden text is not williamr@2: currently supported by the text layout engine. This attribute is provided williamr@2: to preserve information when copying from and to devices which support williamr@2: hidden text. By default EFalse. */ williamr@2: TBool iHiddenText; williamr@2: /** The vertical alignment of a picture character. By default williamr@2: EAlignBaseLine. */ williamr@2: TAlignment iPictureAlignment; williamr@2: }; williamr@2: williamr@2: /** williamr@2: A transient container of character format attributes, including williamr@2: font-dependent and font-independent attributes. williamr@2: williamr@2: The font-independent attributes are stored in a TFontPresentation object. williamr@2: Rich and global text objects store character formatting using character format williamr@2: layers (see class CCharFormatLayer). The TCharFormat class is used to store williamr@2: the relevant attribute values when setting or sensing a CCharFormatLayer. williamr@2: It is normally used in combination with a TCharFormatMask, to specify which williamr@2: attributes are relevant to the function concerned. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TCharFormat williamr@2: { williamr@2: public: williamr@2: IMPORT_C TCharFormat(); williamr@2: IMPORT_C TCharFormat(const TDesC &aTypefaceName, TInt aHeight); williamr@2: // williamr@2: // Enquiry functions williamr@2: IMPORT_C TBool IsEqual(const TCharFormat& aFormat, const TCharFormatMask& aMask) const; williamr@2: IMPORT_C TBool IsEqual(const TCharFormat& aFormat) const; williamr@2: public: williamr@2: /** Specifies the language of individual characters for proofing. Used for williamr@2: example when spell checking a document which contains text in more than one williamr@2: language, so that the program recognises the text as being in another williamr@2: language. Language is also a paragraph format attribute. If the language williamr@2: setting of a character is different from the language setting of the williamr@2: containing paragraph, the character's setting takes precedence. */ williamr@2: TInt32 iLanguage; williamr@2: /** Font independent character format attributes. */ williamr@2: TFontPresentation iFontPresentation; williamr@2: /** Device independent font specification. */ williamr@2: TFontSpec iFontSpec; williamr@2: }; williamr@2: williamr@2: /** williamr@2: Masks the character format attributes which are involved when setting and williamr@2: sensing character formatting. williamr@2: williamr@2: Used in conjunction with an object of class TCharFormat. williamr@2: williamr@2: When setting formatting, only the attributes which are set in the mask should williamr@2: participate in the relevant function. When sensing formatting, on return, williamr@2: the mask indicates which attributes were sensed from the format layer, and williamr@2: were not taken from the default values. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TCharFormatMask williamr@2: { williamr@2: public: williamr@2: inline TCharFormatMask(); williamr@2: inline void SetAttrib(TTextFormatAttribute aAttribute); williamr@2: inline void ClearAttrib(TTextFormatAttribute aAttribute); williamr@2: inline TBool AttribIsSet(TTextFormatAttribute aAttribute) const; williamr@2: IMPORT_C void SetAll(); williamr@2: IMPORT_C void ClearAll(); williamr@2: inline TBool IsNull()const; williamr@2: IMPORT_C TBool operator==(const TCharFormatMask& aMask) const; williamr@2: inline TBool operator!=(const TCharFormatMask& aMask) const; williamr@2: williamr@2: private: williamr@2: TUint32 iGuard; williamr@2: }; williamr@2: williamr@2: #include williamr@2: williamr@2: #endif