textrendering/textformatting/inc/TAGMA.H
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2 * Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * The main header file for TAGMA, the low-level text formatting engine for EPOC.
       
    16 * 'Tm' stands for 'TAGMA' and is the standard prefix for TAGMA classes, after
       
    17 * the C, T, or whatever.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef __TAGMA_H__
       
    23 #define __TAGMA_H__
       
    24 
       
    25 #include <e32base.h>
       
    26 #include <openfont.h>
       
    27 #include <txtfrmat.h>
       
    28 #include <txtstyle.h>
       
    29 #include <linebreak.h>
       
    30 
       
    31 // forward declarations
       
    32 class TTmLineInfo;
       
    33 class CTmTextImp;
       
    34 class RWindow;
       
    35 class RWsSession;
       
    36 class RParagraphStyleInfo;
       
    37 class CStyleList;
       
    38 class TTmDocPosSpec;
       
    39 class TTmDocPos;
       
    40 class TCursorSelection;
       
    41 class TTmHighlightExtensions;
       
    42 class TBidirectionalContext;
       
    43 class TTmLineInfo;
       
    44 class CTmTextLayout;
       
    45 
       
    46 /** 
       
    47 A character format; all dimensions are in twips. A character format object
       
    48 stores all text style attributes that can differ from any one character to the
       
    49 next. Attributes that affect an entire paragraph only are kept in RTmParFormat
       
    50 objects. 
       
    51 The class should only be used internally by FORM component.
       
    52 @internalComponent
       
    53 */
       
    54 class TTmCharFormat
       
    55 	{
       
    56 public:
       
    57 	/** Bit assignments for effects */
       
    58 	enum
       
    59 		{
       
    60 		EBackground = 1,	///< Text background is drawn in the background colour
       
    61 		ERounded = 2,		///< Text background (if any) has rounded corners
       
    62 		EUnderline = 4,	///< Text is underlined
       
    63 		EStrikethrough = 8,	///< Text is struck through with a horizontal line.
       
    64 		EShadow = 16,	///< Text has a drop shadow.
       
    65 		/** Bits 24-31 are reserved for styles defined by the custom drawer. */
       
    66 		EUserDefinedMask = 0xFF000000,
       
    67 		/** Shift TCharFormat highlight styles left by this to get the
       
    68 		TTmCharFormat effects portion. */
       
    69 		EUserDefinedShift = 24,
       
    70 		/** For custom drawers: draw whatever is wanted for "no matches" in the FEP. */
       
    71 		ENoMatchesIndicator = 0x4000000,
       
    72 		/** Reset if the effect in bits 24-30 is defined defined by Symbian,
       
    73 		set if it is defined externally. */
       
    74 		ECustomDrawEffectIsExternallyDefined = 0x80000000
       
    75 		};
       
    76 
       
    77 	/** Picture alignment */
       
    78 	enum TPictureAlignment
       
    79 		{
       
    80 		EPictureAlignBaseline,
       
    81 		EPictureAlignTop,
       
    82 		EPictureAlignBottom,
       
    83 		EPictureAlignCenter
       
    84 		};
       
    85 
       
    86 	IMPORT_C TTmCharFormat();
       
    87 	IMPORT_C TTmCharFormat(const TDesC& aFontName,TInt aFontHeight);
       
    88 	IMPORT_C void operator=(const TCharFormat& aFormat);
       
    89 	inline TTmCharFormat(const TCharFormat& aFormat);
       
    90 	IMPORT_C void GetTCharFormat(TCharFormat& aFormat) const;
       
    91 	IMPORT_C TBool operator==(const TTmCharFormat& aFormat) const;
       
    92 	inline TBool operator!=(const TTmCharFormat& aFormat) const;
       
    93 
       
    94 	TOpenFontSpec iFontSpec;
       
    95 	TLogicalRgb iTextColor;
       
    96 	TLogicalRgb iBackgroundColor;		// used only when EBackground flag is set in iEffects
       
    97 	TUint iEffects;						// bit flags as defined above;
       
    98 										// note that effects NEVER change character metrics and so can
       
    99 										// be ignored when measuring text
       
   100 	TUint iLanguage;					// language used for proofing
       
   101 	TPictureAlignment iPictureAlignment;// vertical alignment of embedded objects
       
   102 	TUint iTag;							// tag for use by URL parsers, etc.; a way of marking a range of
       
   103 										// text without using any typographic attributes
       
   104 	};
       
   105 
       
   106 /** 
       
   107 The text customization interface. You can customize the colors, word
       
   108 spacing, line breaking, line height calculation, background drawing, and text
       
   109 appearance, of a text object by supplying an implementation of the MTmCustom
       
   110 class, either directly (as in CTmText::CustomizeL, which takes a pointer to
       
   111 MTmCustom) or indirectly, making use of the fact that MTmSource is derived from
       
   112 MTmCustom (as in CTmTextLayout::SetTextL, which takes a reference to
       
   113 MTmSource).
       
   114 @publishedAll
       
   115 @released
       
   116 */
       
   117 class MTmCustom 
       
   118 				: public MLineBreaker
       
   119 	{
       
   120 public:
       
   121 	/**
       
   122     TLineHeightParam structure is used in MTmCustom::SetLineHeight() method to set 
       
   123     text line height related parameters such as max character height, max ascent and descent,
       
   124     height and depth of the tallest pictures (top-aligned, bottom-aligned or centered).
       
   125     @see MTmCustom::SetLineHeight()
       
   126 	@publishedAll
       
   127 	@released
       
   128 	*/
       
   129 	class TLineHeightParam
       
   130 		{
       
   131 	public:
       
   132 		inline TLineHeightParam();
       
   133         /** Height of the highest character in the line. */
       
   134 		TInt iMaxCharHeight;
       
   135         /** Depth of the deepest character in the line. */
       
   136 		TInt iMaxCharDepth;
       
   137         /** Height plus depth of the tallest top-aligned picture. */
       
   138 		TInt iMaxTopPictureHeight;
       
   139         /** Height plus depth of the tallest bottom-aligned picture. */
       
   140 		TInt iMaxBottomPictureHeight;
       
   141         /** Height plus depth of the tallest centred picture. */
       
   142 		TInt iMaxCenterPictureHeight;
       
   143         /** Height of the tallest character of any in the fonts in the line. */
       
   144 		TInt iFontMaxCharHeight;
       
   145         /** Depth of the deepest character of any in the fonts in the line. */
       
   146 		TInt iFontMaxCharDepth;
       
   147         /** Maximum ascent of the fonts in the line. */
       
   148 		TInt iFontMaxAscent;
       
   149         /** Maximum descent of the fonts in the line. */
       
   150 		TInt iFontMaxDescent;
       
   151         /** Desired precise or minimum line height. */
       
   152 		TInt iDesiredLineHeight;
       
   153         /** True if the line height must be precise. */
       
   154 		TBool iExactLineHeight;
       
   155 		};
       
   156 
       
   157 	/**	The Unicode line breaking classes; see Unicode Technical Report 14.
       
   158 	Not a named enumerated type, so that overriding applications can add new
       
   159 	line breaking classes freely.
       
   160 	The description of each constant gives the name of the line-breaking
       
   161 	class, an example and a brief, imprecise description of the default
       
   162 	behaviour of characters of that class.
       
   163 	*/
       
   164 	enum
       
   165 		{
       
   166 		/** Opening Punctuation (e.g. '['). Breaking after prohibited. */
       
   167 		EOpLineBreakClass,
       
   168 		/** Closing Punctuation (e.g. ']'). Breaking before prohibited. */
       
   169 		EClLineBreakClass,
       
   170 		/** Ambiguous Quotes (e.g. '"'). Breaking before and after prohibited. */
       
   171 		EQuLineBreakClass,
       
   172 		/** Glue (e.g. Non-breaking space). Breaking before and after prohibited
       
   173 		unless spaces are present. */
       
   174 		EGlLineBreakClass,
       
   175 		/** Non-Starter (e.g. small Japanese kana). Breaking before prohibited
       
   176 		if no spaces present. */
       
   177 		ENsLineBreakClass,
       
   178 		/** Exclamation or Interrogation (e.g. '?'). Like closing punctuation
       
   179 		except before Postfix or Non-starter. */
       
   180 		EExLineBreakClass,
       
   181 		/** Symbol (e.g. '/'. Like Alphabetic, but allows breaking before
       
   182 		Alphabetic. */
       
   183 		ESyLineBreakClass,
       
   184 		/** Numeric Infix Separator (e.g. ','). Forbids breaking after any and before
       
   185 		Numeric. */
       
   186 		EIsLineBreakClass,
       
   187 		/** Numeric Prefix (e.g. '$'). Forbids breaking before Numeric. */
       
   188 		EPrLineBreakClass,
       
   189 		/** Numeric Postfix (e.g. '%'). Forbids breaking after Numeric. */
       
   190 		EPoLineBreakClass,
       
   191 		/** Numeric (e.g. '1'). */
       
   192 		ENuLineBreakClass,
       
   193 		/** Alphabetic (e.g. 'a'). */
       
   194 		EAlLineBreakClass,
       
   195 		/** Ideographic (e.g. Japanese Kanji). Generally break before or after */
       
   196 		EIdLineBreakClass,
       
   197 		/** Inseparable (e.g. ellipsis). Forbid breaks between Inseparables. */
       
   198 		EInLineBreakClass,
       
   199 		/** Hyphen (e.g. '-'). Allows a break after except before Numeric. */
       
   200 		EHyLineBreakClass,
       
   201 		/** Break After. Generally allow a break after. Breaking between Break
       
   202 		Afters not separated by spaces is prohibited. */
       
   203 		EBaLineBreakClass,
       
   204 		/** Break Before. Generally allow a break before. Breaking between Break
       
   205 		Befores not separated by spaces is prohibited. */
       
   206 		EBbLineBreakClass,
       
   207 		/** Break Before and After. Generally allow a break before or after.
       
   208 		Breaking between Break Before and Afters is prohibited, even if spaces
       
   209 		are present. */
       
   210 		EB2LineBreakClass,
       
   211 		/** Zero-Width Space. Allow a break. */
       
   212 		EZwLineBreakClass,
       
   213 		/** Combining Mark. Takes on the class of its base class. */
       
   214 		ECmLineBreakClass,
       
   215 		/** Mandatory Break. */
       
   216 		EBkLineBreakClass,
       
   217 		/** Carriage Return. Break after unless part of a CRLF pair. */
       
   218 		ECrLineBreakClass,
       
   219 		/** Line Feed. Break after. */
       
   220 		ELfLineBreakClass,
       
   221 		/** Surrogate. Half of a surrogate pair. */
       
   222 		ESgLineBreakClass,
       
   223 		/** Contingent Break (e.g. embedded pictures). Uses external
       
   224 		information */
       
   225 		ECbLineBreakClass,
       
   226 
       
   227 		/** Space. Intervening characters of class Space are indicated by
       
   228 		aHaveSpaces in LineBreakPossible. */
       
   229 		ESpLineBreakClass, 
       
   230 
       
   231 		/** Complex Context (e.g. Thai). Runs of Complex Context are passed to
       
   232 		GetLineBreakInContext. */
       
   233 		ESaLineBreakClass,
       
   234 
       
   235 		/** Ambiguous. Characters of ambiguous East Asian width are treated
       
   236 		as Alphabetic, unless they are resolved as being "Wide", in which case
       
   237 		they are treated as Ideographic. */
       
   238 		EAiLineBreakClass,
       
   239 
       
   240 		/** The Xx class is used when the class is unknown; e.g.; outside the provided context. */
       
   241 		EXxLineBreakClass,
       
   242 
       
   243 		/** The number of Unicode line break classes. */
       
   244 		ELineBreakClasses
       
   245 		};
       
   246 
       
   247 	IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const;
       
   248 	IMPORT_C virtual TInt Stretch(TUint aChar) const;
       
   249 	IMPORT_C virtual TUint Map(TUint aChar) const;
       
   250 	IMPORT_C virtual void SetLineHeight(const TLineHeightParam& aParam,TInt& aAscent,TInt& aDescent) const;
       
   251 	IMPORT_C virtual void DrawBackground(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect,
       
   252 										 const TLogicalRgb& aBackground,TRect& aRectDrawn) const;
       
   253 	IMPORT_C virtual void DrawLineGraphics(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect,
       
   254 										   const TTmLineInfo& aLineInfo) const;
       
   255 	IMPORT_C virtual void DrawText(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect,
       
   256 								   const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat,
       
   257 								   const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const;
       
   258 	IMPORT_C virtual void DrawPicture(CGraphicsContext& aGc,
       
   259 		const TPoint& aTextLayoutTopLeft, const TRect& aRect,
       
   260 		MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const;
       
   261 	IMPORT_C virtual TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const;
       
   262 	IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const;
       
   263 	IMPORT_C virtual TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,
       
   264 												 TBool aForwards,TInt& aBreakPos) const;
       
   265 	IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const;
       
   266 
       
   267 	// non-virtuals
       
   268 	IMPORT_C void SetPenColor(CGraphicsContext& aGc,TLogicalRgb aColor) const;
       
   269 	IMPORT_C void SetBrushColor(CGraphicsContext& aGc,TLogicalRgb aColor) const;
       
   270 	IMPORT_C TRgb SystemColor(TLogicalRgb aColor) const;
       
   271 	};
       
   272 
       
   273 /* MTmSource extension interface****************************************************/
       
   274 
       
   275 
       
   276 const TUid KTmCustomExtensionUid = {0x10285BB5};
       
   277 
       
   278 /** MTmSource Extension Interface abstract base class to enable further customisation of the source.
       
   279 
       
   280 MTmSource derivers should also derive from this interface to enable drawing text in context
       
   281 
       
   282 This interface should be returned by the overridden
       
   283 MTmSource::GetExtendedInterface function when KUidMTmSourceExtension is
       
   284 supplied as the UID.
       
   285 
       
   286 @see MTmSource
       
   287 @see KUidMTmSourceExtension 
       
   288 @publishedAll
       
   289 @released
       
   290 */
       
   291 class MTmCustomExtension
       
   292 	{
       
   293 public:
       
   294 	IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const;
       
   295 	IMPORT_C virtual void DrawText(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect,
       
   296 								   const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat,
       
   297 								   const TDesC& aText, const TInt aStart, const TInt aEnd,const TPoint& aTextOrigin,TInt aExtraPixels) const;
       
   298 		// non-virtuals
       
   299 	IMPORT_C void SetPenColor(CGraphicsContext& aGc,TLogicalRgb aColor) const;
       
   300 	IMPORT_C void SetBrushColor(CGraphicsContext& aGc,TLogicalRgb aColor) const;
       
   301 	IMPORT_C TRgb SystemColor(TLogicalRgb aColor) const;
       
   302 	};
       
   303 
       
   304 /** 
       
   305 A structure for returning information about a line. One of these is
       
   306 returned by all hit-detection functions. Typically, after finding the position
       
   307 in the document that corresponds to given x-y coordinates, you will want some
       
   308 more information like the line's bounding rectangle. When you call, for
       
   309 example, CTmTextLayout::FindXyPos you will receive a TTmLineInfo object that
       
   310 will tell you this, and much more. 
       
   311 @publishedAll
       
   312 @released
       
   313 */
       
   314 class TTmLineInfo
       
   315 
       
   316 	{
       
   317 public:
       
   318 	// bit values for iFlags
       
   319 	enum
       
   320 		{
       
   321 		EParStart = 1,
       
   322 		EParEnd = 2,
       
   323 		EParRightToLeft = 4,
       
   324  		ELineEndsInForcedLineBreak = 8,
       
   325  		EPictureButtsLowerEdge = 16,	/**< @deprecated - no effect, present for compatibility only */
       
   326  		EPictureButtsUpperEdge = 32	/**< @deprecated - no effect, present for compatibility only */
       
   327 		};
       
   328 
       
   329 	inline TTmLineInfo();
       
   330 	
       
   331 	/** Outer enclosing rectangle including margins */
       
   332 	TRect iOuterRect;	
       
   333 	
       
   334 	/** Inner enclosing rectangle: the text only */
       
   335 	TRect iInnerRect;
       
   336 	
       
   337 	/** y coordinate of the baseline */
       
   338 	TInt iBaseline;	
       
   339 	
       
   340 	/** Start document position */
       
   341 	TInt iStart;
       
   342 	
       
   343 	/** End document position */
       
   344 	TInt iEnd;			
       
   345 	
       
   346 	/** Line number */
       
   347 	TInt iLineNumber;
       
   348 	
       
   349 	/** Paragraph number */
       
   350 	TInt iParNumber;	
       
   351 	
       
   352 	/** Line number in the paragraph */
       
   353 	TInt iLineInPar;
       
   354 	
       
   355 	/** y coordinate of the top of the paragraph */
       
   356 	TInt iParTop;
       
   357 
       
   358 	/** Start of paragraph, end of paragraph, etc. */
       
   359 	TUint iFlags;		
       
   360 	};
       
   361 
       
   362 /**
       
   363 A structure to hold a logical document position that can be converted to a raw
       
   364 document position or an x-y position.
       
   365 
       
   366 A document position can specify a leading or trailing edge or a text
       
   367 directionality so that bidirectional hit testing can use both these
       
   368 distinctions.
       
   369 
       
   370 The leading edge at position N is the position before character N in logical
       
   371 order, and the trailing edge is the position after character in logical order.
       
   372 
       
   373 Specification by directionality works differently. Character N in left-to-right
       
   374 text is preceded by position N (left-to-right) and followed by position N+1
       
   375 (left-to-right). Character N in right-to-left text is preceded (in display
       
   376 order) by position N+1 (right-to-left) and followed by position N
       
   377 (right-to-left).
       
   378 @publishedAll
       
   379 @released
       
   380 */
       
   381 class TTmDocPosSpec
       
   382 
       
   383 	{
       
   384 public:
       
   385 	/**
       
   386 	The cursor type.
       
   387 	*/
       
   388 	enum TType
       
   389 		{
       
   390 		/** trailing edge */
       
   391 		ETrailing,
       
   392 
       
   393 		/** leading edge */
       
   394 		ELeading,
       
   395 
       
   396 		/** left-to-right */
       
   397 		ELeftToRight,
       
   398 
       
   399 		/** right-to-left */
       
   400 		ERightToLeft
       
   401 		};
       
   402 
       
   403 	inline TTmDocPosSpec();
       
   404 	inline TTmDocPosSpec(TInt aPos,TType aType);
       
   405 	inline TTmDocPosSpec(const TTmDocPos& aRawDocPos);
       
   406 
       
   407 	/** the edge position in the document; 0 ... document length */
       
   408 	TInt iPos;
       
   409 	/** the type as specified above */
       
   410 	TType iType;	
       
   411 	};
       
   412 
       
   413 /** 
       
   414 A structure for holding a raw document position that can be converted to or
       
   415 from an x-y position and compared ordinally, which cannot be done with the more
       
   416 abstract TTmDocPosSpec class. Leading edges are distinguished from trailing
       
   417 edges so that bidirectional hit testing and cursor positioning can distinguish
       
   418 between 'after character N', and 'before character N + 1', which may be some
       
   419 distance apart if N and N + 1 are in runs of opposite directionality. 
       
   420 @publishedAll
       
   421 @released
       
   422 */
       
   423 class TTmDocPos
       
   424 
       
   425 	{
       
   426 public:
       
   427 	inline TTmDocPos();
       
   428 	inline TTmDocPos(TInt aPos,TBool aLeadingEdge);
       
   429 	IMPORT_C TBool operator==(const TTmDocPos& aPos) const;
       
   430 	inline TBool operator!=(const TTmDocPos& aPos) const;
       
   431 	IMPORT_C TBool operator>(const TTmDocPos& aPos) const;
       
   432 	IMPORT_C TBool operator>=(const TTmDocPos& aPos) const;
       
   433 	inline TBool operator<(const TTmDocPos& aPos) const;
       
   434 	inline TBool operator<=(const TTmDocPos& aPos) const;
       
   435 
       
   436 	/** the edge position in the document; 0 ... document length */
       
   437 	TInt iPos;
       
   438 	/** true if the position is a leading edge */
       
   439 	TBool iLeadingEdge;	
       
   440 	};
       
   441 
       
   442 /** 
       
   443 Holds information about a position in a document. 
       
   444 @publishedAll
       
   445 @released
       
   446 */	
       
   447 class TTmPosInfo2
       
   448 
       
   449 	{
       
   450 public:
       
   451 	/** Document position. */
       
   452 	TTmDocPos iDocPos;
       
   453 	/** True if the position is attatched to text flowing right-to-left. */
       
   454 	TBool iRightToLeft;
       
   455 	/** Intersection of the character edge with the baseline. */
       
   456 	TPoint iEdge;
       
   457 	};
       
   458 
       
   459 /** 
       
   460 A structure for returning information about a position in a line.
       
   461 The class should only be used internally by FORM component.
       
   462 @deprecated 7.0s 
       
   463 @internalComponent
       
   464 */
       
   465 class TTmPosInfo
       
   466 
       
   467 	{
       
   468 public:
       
   469 	TTmPosInfo() {}
       
   470 	TTmPosInfo(const TTmPosInfo2& a) : iDocPos(a.iDocPos), iEdge(a.iEdge) {}
       
   471 	TTmDocPos iDocPos;	// the document position
       
   472 	TPoint iEdge;			// intersection of the character edge at iDocPos with the baseline
       
   473 	};
       
   474 
       
   475 
       
   476 /** 
       
   477 Cursor placement. Used as an argument to CTextView::SetCursorPlacement().
       
   478 @see CTextView::SetCursorPlacement()
       
   479 @publishedAll
       
   480 @released
       
   481 */
       
   482 enum TTmCursorPlacement
       
   483 	{
       
   484 	 /** The text cursor is a vertical line at the insertion position, with its height 
       
   485 	and depth based on the metrics of the previous character in the paragraph 
       
   486 	or if none, the next character. */
       
   487 	ECursorVertical,		
       
   488 	/** The text cursor is an underline below the character logically after the insertion 
       
   489 	position. */
       
   490 	ECursorUnderlineNext,
       
   491 	/** The text cursor is an underline below the character logically before the insertion 
       
   492 	position. */
       
   493 	ECursorUnderlinePrev
       
   494 	};
       
   495 
       
   496 
       
   497 
       
   498 /**
       
   499 A mixin class to make it easy for higher-level classes that own a CTmTextLayout
       
   500 object to have enquiry functions without it being necessary to implement them
       
   501 all as forwarding functions. The owner class just implements TextLayout and
       
   502 overrides GetOrigin if necessary.
       
   503 
       
   504 Non-const CTmTextLayout functions like Clear are not included because allowing
       
   505 them to be called on owner classes would probably put the owner class into an
       
   506 inconsistent state.
       
   507 
       
   508 The word Layout is prefixed, suffixed or infixed to functions with names that
       
   509 would usually conflict with owner class names. For example, we have DrawLayout,
       
   510 not Draw, and GetMinimumLayoutSizeL, not GetMinimumSizeL.
       
   511 
       
   512 The class should only be used internally by FORM component.
       
   513 @internalComponent
       
   514 */
       
   515 class MTmTextLayoutForwarder
       
   516 
       
   517 	{
       
   518 public:
       
   519 	IMPORT_C void DrawLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,
       
   520 							 const TLogicalRgb* aDocBackground,TBool aDrawParBackground) const;
       
   521 	IMPORT_C void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,
       
   522 								 const TLogicalRgb& aBackground) const;
       
   523 	IMPORT_C void InvertLayout(CGraphicsContext& aGc,const TPoint& aTopLeft,TInt aStartDocPos,TInt aEndDocPos);
       
   524 	IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const;
       
   525 	IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo& aLineInfo) const;
       
   526 	IMPORT_C TBool FindXyPosWithDisambiguation(const TPoint& aXyPos,
       
   527 		TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight,
       
   528 		TTmLineInfo& aLineInfo) const;
       
   529 	IMPORT_C TBool DocPosToLine(const TTmDocPosSpec& aDocPos,TTmLineInfo& aLineInfo) const;
       
   530 	IMPORT_C TBool LineNumberToLine(TInt aLineNumber,TTmLineInfo& aLineInfo) const;
       
   531 	IMPORT_C TBool ParNumberToLine(TInt aParNumber,TInt aLineInPar,TTmLineInfo& aLineInfo) const;
       
   532 	IMPORT_C TBool YPosToLine(TInt aYPos,TTmLineInfo& aLineInfo) const;
       
   533 	IMPORT_C TInt WidthOfWidestLine(TInt aTop = 0,TInt aBottom = KMaxTInt) const;
       
   534 	IMPORT_C void HorizontalExtremes(TInt &aLeft, TInt &aRight,
       
   535 		TInt aTopY = 0, TInt aBottomY = KMaxTInt) const;
       
   536 	IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aInfo,TBool aToLeft) const;
       
   537 	IMPORT_C TBool GetNextPosLeftWithDisambiguation(const TTmDocPosSpec& aDocPos,
       
   538 		TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const;
       
   539 	IMPORT_C TBool GetNextPosRightWithDisambiguation(const TTmDocPosSpec& aDocPos,
       
   540 		TTmPosInfo2& aPosLeft, TTmPosInfo2& aPosRight) const;
       
   541 	IMPORT_C TBool GetCursor(const TTmDocPosSpec& aDocPos,TTmCursorPlacement aPlacement,
       
   542 							 TTmLineInfo& aLineInfo,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const;
       
   543 
       
   544 	IMPORT_C TInt Lines() const;
       
   545 	IMPORT_C TInt Paragraphs() const;
       
   546 	IMPORT_C TBool GetDisplayedText(TInt aLineNumber,TDes& aText,TInt& aNeeded) const;
       
   547 	IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TSize& aSize) const;
       
   548 	IMPORT_C void GetMinimumLayoutSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize) const;
       
   549 	IMPORT_C TInt StartChar() const;
       
   550 	IMPORT_C TInt EndChar() const;
       
   551 	IMPORT_C TInt LayoutWidth() const;
       
   552 	IMPORT_C TInt LayoutHeight() const;
       
   553 
       
   554 	// deprecated functions
       
   555 	// deprecated 7.0s
       
   556 	IMPORT_C TBool FindDocPos(const TTmDocPos& aDocPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const;
       
   557 	// deprecated 7.0s
       
   558 	IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo& aPosInfo,TTmLineInfo& aLineInfo) const;
       
   559 	// deprecated 7.0s
       
   560 	IMPORT_C TBool DocPosToLine(const TTmDocPos& aDocPos,TTmLineInfo& aLineInfo) const;
       
   561 	// deprecated 7.0s
       
   562 	IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPos& aDocPos,TTmPosInfo& aInfo,TBool aToLeft) const;
       
   563 	// deprecated 7.0s
       
   564 	IMPORT_C TBool GetCursor(const TTmDocPos& aDocPos,
       
   565 		TTmCursorPlacement aPlacement, TTmLineInfo& aLineInfo,
       
   566 		TPoint& aOrigin, TInt& aWidth, TInt& aAscent, TInt& aDescent) const;
       
   567 private:
       
   568 	/** Returns a reference to the CTmTextLayoutObject this
       
   569 	MTmTextLayoutForwarder forwards inquiries to. */
       
   570 	virtual const CTmTextLayout& TextLayout() const = 0;
       
   571 	
       
   572 	/** The origin is subtracted from coordinates passed in and added to those
       
   573 	passed out. */
       
   574 	IMPORT_C virtual void GetOrigin(TPoint& aPoint) const;
       
   575 
       
   576 	void FixUpLineInfo(TTmLineInfo& aInfo,const TPoint* aOrigin = NULL) const;
       
   577 	};
       
   578 
       
   579 /** Constructs a TTmLineInfo object, setting all data members to 0. */
       
   580 TTmLineInfo::TTmLineInfo()
       
   581 	{
       
   582 	Mem::FillZ(this,sizeof(*this));
       
   583 	}
       
   584 
       
   585 /** Constructs a TTmDocPos object, setting iPos to 0 and iLeadingEdge to false.
       
   586 This is the lowest legal value for a TTmDocPos object. A trailing edge comes
       
   587 before a leading edge because it is the trailing edge of the character before
       
   588 the position, while the leading edge is that of the character after the
       
   589 position. ('Leading' means the first to be encountered when traversing the
       
   590 document in logical order). */
       
   591 TTmDocPos::TTmDocPos():
       
   592 	iPos(0),
       
   593 	iLeadingEdge(FALSE)
       
   594 	{
       
   595 	}
       
   596 
       
   597 /** Constructs a TTmDocPos object, setting iPos to aPos and iLeadingEdge to
       
   598 aLeadingEdge.
       
   599 */
       
   600 TTmDocPos::TTmDocPos(TInt aPos,TBool aLeadingEdge):
       
   601 	iPos(aPos),
       
   602 	iLeadingEdge(aLeadingEdge)
       
   603 	{
       
   604 	}
       
   605 
       
   606 /** Constructs a TTmDocPosSpec, setting the position to 0 and the type to
       
   607 trailing. */
       
   608 TTmDocPosSpec::TTmDocPosSpec():
       
   609 	iPos(0),
       
   610 	iType(ETrailing)
       
   611 	{
       
   612 	}
       
   613 	
       
   614 
       
   615 /**
       
   616 The not equal operator.
       
   617 @return True if both sides have different values.
       
   618 */
       
   619 TBool TTmDocPos::operator!=(const TTmDocPos& aPos) const { return !((*this)==aPos); }
       
   620 
       
   621 /**
       
   622 Smaller than operator.
       
   623 @return
       
   624 	True if the right side of the operator is further on in the document than
       
   625 	the left hand side.
       
   626 */
       
   627 TBool TTmDocPos::operator<(const TTmDocPos& aPos) const { return !((*this)>=aPos); }
       
   628 
       
   629 /**
       
   630 Smaller than or equal to operator.
       
   631 @return
       
   632 	True if the right side of the operator is further on in the document than
       
   633 	the left hand side or if both sides are identical.
       
   634 */
       
   635 TBool TTmDocPos::operator<=(const TTmDocPos& aPos) const { return !((*this)>aPos); }
       
   636 
       
   637 /** Constructs a TTmDocPosSpec, setting the position to aPos and the type to
       
   638 aType.
       
   639 */
       
   640 TTmDocPosSpec::TTmDocPosSpec(TInt aPos,TType aType):
       
   641 	iPos(aPos),
       
   642 	iType(aType)
       
   643 	{
       
   644 	}
       
   645 
       
   646 /** Constructs a TTmDocPosSpec from a TTmDocPos. */
       
   647 TTmDocPosSpec::TTmDocPosSpec(const TTmDocPos& aDocPos):
       
   648 	iPos(aDocPos.iPos),
       
   649 	iType(aDocPos.iLeadingEdge ? ELeading : ETrailing)
       
   650 	{
       
   651 	}
       
   652 
       
   653 /** Constructs a TTmCharFormat by converting the information in a TCharFormat. */
       
   654 TTmCharFormat::TTmCharFormat(const TCharFormat& aFormat)
       
   655 	{
       
   656 	*this = aFormat;
       
   657 	}
       
   658 
       
   659 /** The inequality operator. Return TRUE if this object and aFormat differ in any way. */
       
   660 TBool TTmCharFormat::operator!=(const TTmCharFormat& aFormat) const
       
   661 	{
       
   662 	return !operator==(aFormat);
       
   663 	}
       
   664 
       
   665 /** Constructs a line height parameter structure, setting all the data members
       
   666 to zero. */
       
   667 MTmCustom::TLineHeightParam::TLineHeightParam()
       
   668 	{
       
   669 	Mem::FillZ(this,sizeof(*this));
       
   670 	}
       
   671 
       
   672 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
   673 #include <tagma_internal.h>
       
   674 #include <tagmalayoutandsource.h>
       
   675 #endif
       
   676 
       
   677 #endif // __TAGMA_H__