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