os/textandloc/textrendering/textformatting/inc/FRMTLAY.H
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/textrendering/textformatting/inc/FRMTLAY.H	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1252 @@
     1.4 +/*
     1.5 +* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#ifndef __FRMTLAY_H__
    1.23 +#define __FRMTLAY_H__
    1.24 +
    1.25 +#include <e32std.h>
    1.26 +#include <e32base.h>
    1.27 +#include <gdi.h>
    1.28 +#include <txtfrmat.h>
    1.29 +#include <txtetext.h>
    1.30 +#include <frmlaydt.h>
    1.31 +#include <frmparam.h>
    1.32 +#include <frmvis.h>
    1.33 +#include <tagma.h>
    1.34 +
    1.35 +class CWindowGc;
    1.36 +class MLayDoc;
    1.37 +class TLayDocTextSource;
    1.38 +class TCursorPosition;
    1.39 +
    1.40 +class TLayDocTextSource;
    1.41 +class CTmTextLayout;
    1.42 +class TTmHighlightExtensions;
    1.43 +class MTmSource;
    1.44 +class TTmFormatParamBase;
    1.45 +
    1.46 +#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    1.47 +#include <frmtlay_internal.h>
    1.48 +#endif
    1.49 +
    1.50 +/**
    1.51 +This interface class defines an interface for clients of Form to provided 
    1.52 +implementations of customisation interfaces relating to the source text
    1.53 +document as requried by the internals of Form and Tagma. Its use by
    1.54 +Form clients is optional.
    1.55 +Derived objects of this interface are registered with the CTextLayout 
    1.56 +API and are called from the TLayDocTextSource class at present.
    1.57 +@publishedAll
    1.58 +@released
    1.59 +@see MTmInlineTextSource
    1.60 +*/
    1.61 +class MFormCustomInterfaceProvider
    1.62 +    {
    1.63 +    public:
    1.64 +	/**
    1.65 +	Form uses this method to request an interface implmentation for the
    1.66 +	specified interface Uid. See class description for interfaces covered
    1.67 +	by this API.
    1.68 +	@param aInterfaceId
    1.69 +		The unique identifier for the interface wanted by Form.
    1.70 +	@return 
    1.71 +		Ptr to interface instance or 0 if not supported by client
    1.72 +	*/
    1.73 +	virtual TAny* GetExtendedInterface(const TUid& aInterfaceId) = 0;
    1.74 +    };
    1.75 +
    1.76 +
    1.77 +/** Parameter used to control which part of a line (top, baseline or bottom) 
    1.78 +should be scrolled to a certain vertical position in a view rectangle. Used 
    1.79 +as a parameter in functions like CTextView::HandleGlobalChangeL() and 
    1.80 +CTextLayout::SetViewL(). The selected part of the line is called the hotspot.
    1.81 +@publishedAll
    1.82 +@released
    1.83 +*/
    1.84 +class TViewYPosQualifier
    1.85 +	{
    1.86 +friend class CTextLayout;
    1.87 +friend class CTextView;
    1.88 +public:
    1.89 +	/** Which part of a line (top, baseline or bottom) should appear at a
    1.90 +	vertical pixel position. */
    1.91 +	enum TPartOfLine
    1.92 +		{
    1.93 +		/** The top pixel is placed at the specified vertical point. */
    1.94 +		EFViewTopOfLine = 1,
    1.95 +		/** The baseline is placed at the specified vertical point. */
    1.96 +		EFViewBaseLine = 0,
    1.97 +		/** The bottom pixel is placed at the specified vertical point. */
    1.98 +		EFViewBottomOfLine = 2	
    1.99 +		};
   1.100 +
   1.101 +	/** Whether the top line in the view should be fully visible. */
   1.102 +	enum TFullyVisible
   1.103 +		{
   1.104 +		/** Force a partially visible top line to be fully visible. */
   1.105 +		EFViewForceLineFullyVisible = ETrue,
   1.106 +		/** Do not force a partially visible top line to be fully visible. */
   1.107 +		EFViewDontForceLineFullyVisible = EFalse
   1.108 +		};
   1.109 +public:
   1.110 +	inline TViewYPosQualifier();
   1.111 +	IMPORT_C void SetHotSpot(TPartOfLine aHotSpot);
   1.112 +	IMPORT_C void SetFillScreen(TBool aFillScreen = ETrue);
   1.113 +	IMPORT_C void SetMakeLineFullyVisible(TFullyVisible aMakeLineFullyVisible = EFViewForceLineFullyVisible);
   1.114 +private:
   1.115 +	TPartOfLine iHotSpot;
   1.116 +	TBool iFillScreen;
   1.117 +	TFullyVisible iFullyVisible;
   1.118 +	};
   1.119 +
   1.120 +/** 
   1.121 +A structure used to return the results of a reformatting operation.
   1.122 +@see CTextLayout::HandleBlockChangeL()
   1.123 +@publishedAll
   1.124 +@released
   1.125 +*/
   1.126 +class TViewRectChanges
   1.127 +
   1.128 +	{
   1.129 +public:
   1.130 +	inline TViewRectChanges();
   1.131 +
   1.132 +public:
   1.133 +	/** The vertical coordinate of the top of the first line of reformatted 
   1.134 +	text. */
   1.135 +	TInt iFormattedFrom;
   1.136 +	/** The vertical coordinate of the bottom of the last line of reformatted 
   1.137 +	text. */
   1.138 +	TInt iFormattedTo;
   1.139 +	/** The number of pixels by which text above the reformatted or edited 
   1.140 +	block has scrolled (positive values mean the text moved down). */
   1.141 +	TInt iScrollAtTop;
   1.142 +	/** The number of pixels by which text below the reformatted or edited 
   1.143 +	block has scrolled (positive values mean the text moved down). */
   1.144 +	TInt iScrollAtBottom;
   1.145 +	};
   1.146 +
   1.147 +/** 
   1.148 +The cursor or cursor selection within a document.
   1.149 +
   1.150 +If the cursor and anchor position differ, the selection covers the text from
   1.151 +the lower to the higher position, not including the character after the higher
   1.152 +position. If the selection is changed (by shift plus arrow keys in many UIs)
   1.153 +the cursor position changes and the anchor remains the same. 
   1.154 +@publishedAll
   1.155 +@released
   1.156 +*/
   1.157 +class TCursorSelection
   1.158 +
   1.159 +	{
   1.160 +public:
   1.161 +	inline TCursorSelection();
   1.162 +	inline TCursorSelection(TInt aCursorPos,TInt aAnchorPos);
   1.163 +	inline void SetSelection(TInt aCursorPos,TInt aAnchorPos);
   1.164 +	inline TInt LowerPos() const;
   1.165 +	inline TInt HigherPos() const;
   1.166 +	inline TInt Length() const;
   1.167 +public:
   1.168 +	/** The cursor position. */
   1.169 +	TInt iCursorPos;
   1.170 +	/** The anchor position. */
   1.171 +	TInt iAnchorPos;
   1.172 +	};
   1.173 +
   1.174 +/** 
   1.175 +Parameters used by functions that draw text.
   1.176 +
   1.177 +An object of this class is passed to CTextLayout::DrawL() and to
   1.178 +InvertRangeL(). The draw context includes the view rectangle, the graphics
   1.179 +context, the background colour and the margin widths.
   1.180 +
   1.181 +You only need to use this class directly when you are using a CTextLayout
   1.182 +object which is not owned by a CTextView object.
   1.183 +@publishedAll
   1.184 +@released
   1.185 +*/
   1.186 +class TDrawTextLayoutContext
   1.187 +
   1.188 +	{
   1.189 +private:
   1.190 +	enum TDrawMode
   1.191 +		{
   1.192 +		EFDrawText=0x001,
   1.193 +		EFDrawGraphics=0x002,
   1.194 +		EFUseClippingRect=0x004,
   1.195 +		EFUseWindowGc=0x008,
   1.196 +		EFUseGcClear=0x020,
   1.197 +		EFUseBackgroundColor=0x040,
   1.198 +		EFUseOverrideTextColor=0x080,
   1.199 +		EFParagraphFillTextOnly=0x100,
   1.200 +		EFAllFlags=0xfff
   1.201 +		};
   1.202 +public:
   1.203 +	IMPORT_C TDrawTextLayoutContext();
   1.204 +
   1.205 +	IMPORT_C void SetGc(CGraphicsContext* aGc,CGraphicsContext* aPictureGc=NULL);
   1.206 +	IMPORT_C void SetBitmapGc(CBitmapContext* aGc,CBitmapContext* aPictureGc=NULL);
   1.207 +	IMPORT_C void SetWindowGc(CWindowGc* aGc,CWindowGc* aPictureGc=NULL);
   1.208 +	IMPORT_C void SetDrawToEveryPixel(TBool aDrawToEveryPixel);
   1.209 +	IMPORT_C void SetTextColorOverride(const TRgb *aOverrideColor);
   1.210 +	IMPORT_C void SetDrawTextOnly();
   1.211 +	IMPORT_C void SetDrawGraphicsOnly();
   1.212 +	IMPORT_C void SetDrawTextAndGraphics();
   1.213 +	IMPORT_C void SetClipping(TBool aClipping);
   1.214 +	// deprecated 7.0 
   1.215 +	IMPORT_C void SetParagraphFillTextOnly(TBool aFillTextOnly);
   1.216 +
   1.217 +//Enquiry functions
   1.218 +	IMPORT_C const TRgb* TextOverrideColor() const;
   1.219 +	IMPORT_C CGraphicsContext* PrimaryGc() const;
   1.220 +	IMPORT_C CGraphicsContext* PictureGc() const;
   1.221 +	IMPORT_C TBool UseClippingRect() const;
   1.222 +	IMPORT_C TBool UseGcClear() const;
   1.223 +	IMPORT_C TBool DrawText() const;
   1.224 +	IMPORT_C TBool DrawGraphics() const;
   1.225 +	IMPORT_C TBool UseBackgroundColor() const;
   1.226 +	// deprecated 7.0
   1.227 +	IMPORT_C TBool ParagraphFillTextOnly() const;
   1.228 +
   1.229 +//Physical dimensions
   1.230 +	IMPORT_C TRect TextArea() const;
   1.231 +	IMPORT_C TInt DisplayHeight() const;
   1.232 +	IMPORT_C TPoint TopLeftTextArea() const;
   1.233 +	IMPORT_C TRect TotalMargin() const;
   1.234 +	IMPORT_C TRect LabelMargin() const;
   1.235 +	IMPORT_C TBool IsLabelMargin() const;
   1.236 +	IMPORT_C TRect GutterMargin() const;
   1.237 +	IMPORT_C TBool IsGutterMargin() const;
   1.238 +	IMPORT_C TPoint TopLeftText() const;
   1.239 +	IMPORT_C void WindowToText(TPoint& aWinPos) const;
   1.240 +	IMPORT_C void WindowToText(TRect& aRect) const;
   1.241 +	IMPORT_C void TextToWindow(TPoint& aTextAreaPos) const;
   1.242 +	IMPORT_C void TextToWindow(TRect& aRect) const;
   1.243 +
   1.244 +	TBool UseWindowGc() const;
   1.245 +	void SetDrawMode(TUint aDrawMode);
   1.246 +	TUint DrawMode() const;
   1.247 +
   1.248 +public:
   1.249 +	/** The view rectangle (specified in window coordinates). This is used to 
   1.250 +	set the	area in which text can be drawn. Text can only be drawn within the 
   1.251 +	intersection between the text area and the aDrawRect parameter passed to 
   1.252 +	CTextLayout::DrawL() or InvertRangeL(). */
   1.253 +	TRect iViewRect;
   1.254 +	/** The label margin width. By default zero. Must have the same value as 
   1.255 +	the label margin width as set in the text layout object. */
   1.256 +	TInt iLabelMarginWidth;
   1.257 +	/** The gutter margin width (also known as the line cursor margin width). 
   1.258 +	By default	zero. */
   1.259 +	TInt iGutterMarginWidth;
   1.260 +	/** The horizontal offset between window coordinates and text layout 
   1.261 +	coordinates. */
   1.262 +	TInt iTextStartX;
   1.263 +	/** The background colour for the view rectangle. The background colour is 
   1.264 +	used to fill the parts of the view rectangle in which text cannot appear, 
   1.265 +	for example, below the last line of the document and in the label, line 
   1.266 +	cursor and left	text margins. */
   1.267 +	TLogicalRgb iBackgroundColor;
   1.268 +private:
   1.269 +	CGraphicsContext* iGc;
   1.270 +	CGraphicsContext* iPictureGc;
   1.271 +	TLogicalRgb iOverrideTextColor;
   1.272 +	TUint iDrawMode;
   1.273 +	};
   1.274 +
   1.275 +/** 
   1.276 +An abstract class which specifies the protocol for customising the way text
   1.277 +and its background are drawn.
   1.278 +
   1.279 +Common uses for this are to implement custom highlighting or to draw a 
   1.280 +background bitmap. You must create an object of a class derived from this class 
   1.281 +and call CTextLayout::SetCustomDraw(), passing a pointer to the object. All of 
   1.282 +these functions have default implementations. Your class can override any of the
   1.283 +virtual functions listed below.
   1.284 +@publishedAll
   1.285 +@released
   1.286 +*/
   1.287 +class MFormCustomDraw
   1.288 +
   1.289 +	{
   1.290 +	public:
   1.291 +	
   1.292 +	class TParam
   1.293 +	/**
   1.294 +	Parameters used by several custom draw functions
   1.295 +	@publishedAll
   1.296 +	@released
   1.297 +	*/
   1.298 +			{
   1.299 +		public:
   1.300 +		TParam(CGraphicsContext& aGc,MGraphicsDeviceMap& aMap,const TPoint& aTextLayoutTopLeft,const TRect& aDrawRect):
   1.301 +			iGc(aGc), iMap(aMap), iTextLayoutTopLeft(aTextLayoutTopLeft), iDrawRect(aDrawRect) { }
   1.302 +
   1.303 +		CGraphicsContext& iGc;
   1.304 +		MGraphicsDeviceMap& iMap;
   1.305 +		const TPoint& iTextLayoutTopLeft;
   1.306 +		const TRect& iDrawRect;
   1.307 +		};
   1.308 +
   1.309 +	class TLineInfo
   1.310 +	/** 
   1.311 +	Contains the line metrics.
   1.312 +	@publishedAll
   1.313 +	@released
   1.314 +	*/
   1.315 +			{
   1.316 +		public:
   1.317 +		TLineInfo(const TRect& aOuterRect,const TRect& aInnerRect,TInt aBaseline):
   1.318 +			iOuterRect(aOuterRect), iInnerRect(aInnerRect), iBaseline(aBaseline) { }
   1.319 +
   1.320 +		const TRect& iOuterRect;
   1.321 +		const TRect& iInnerRect;
   1.322 +		TInt iBaseline;
   1.323 +		};
   1.324 +
   1.325 +	IMPORT_C virtual void DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const;
   1.326 +	IMPORT_C virtual void DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const;
   1.327 +	IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat,
   1.328 +								   const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const;
   1.329 +	IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const;
   1.330 +
   1.331 +	IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat,
   1.332 +								   const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const;
   1.333 +	IMPORT_C virtual void MFormCustomDraw_Reserved_2();
   1.334 +	};
   1.335 +
   1.336 +
   1.337 +/** 
   1.338 +An interface class that can be derived from to implement custom line breaking.
   1.339 +
   1.340 +Custom line breaking allows the Text Views line wrapping algorithm to break
   1.341 +lines in any way. For instance, it may be used to avoid the jagged white space
   1.342 +at the right edge of text windows caused by normal line wrapping on a small
   1.343 +screen.
   1.344 +
   1.345 +All of these functions have a default implementation. To change the default
   1.346 +behaviour, a pointer to an object that overrides any or all of the functions
   1.347 +in the interface needs to be passed to the function CTextLayout::SetCustomWrap().
   1.348 +@since 6.2
   1.349 +
   1.350 +@see CTextLayout::SetCustomWrap()
   1.351 +@publishedAll
   1.352 +@released
   1.353 +*/
   1.354 +class MFormCustomWrap
   1.355 +
   1.356 +	{
   1.357 +public:
   1.358 +	IMPORT_C virtual TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const;
   1.359 +	IMPORT_C virtual TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const;
   1.360 +	IMPORT_C virtual TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,
   1.361 +												 TBool aForwards,TInt& aBreakPos) const;
   1.362 +	IMPORT_C virtual TBool IsHangingCharacter(TUint aChar) const;
   1.363 +private:
   1.364 +	IMPORT_C virtual void MFormCustomWrap_Reserved_1();
   1.365 +	IMPORT_C virtual void MFormCustomWrap_Reserved_2();	
   1.366 +	};
   1.367 +
   1.368 +
   1.369 +/** 
   1.370 +Mixin class used to customize visible appearance of invisible characters 
   1.371 +such as a paragraph mark or a tab.
   1.372 +
   1.373 +@see CTextView::SetCustomInvisibleCharacterRemapper()
   1.374 +@publishedAll
   1.375 +@released
   1.376 +*/
   1.377 +class MFormCustomInvisibleCharacterRemapper
   1.378 +	{
   1.379 +public:
   1.380 +	IMPORT_C static TUint DefaultMapping(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc);
   1.381 +
   1.382 +	/** 
   1.383 +	Allows custom remapping of invisible characters.
   1.384 +
   1.385 +	Called by TLayDocTextSource::Map() if it has been created and registered 
   1.386 +	with TLayDocTextSource using CTextLayout::SetInvisibleCharacterRemapper().
   1.387 +
   1.388 +	Unless there is a specific reason for doing otherwise it is recommended 
   1.389 +	that where this function has not remapped a given character it should 
   1.390 +	pass it to DefaultMapping() to let it try.
   1.391 +
   1.392 +	@param aChar
   1.393 +		Invisible character to be remapped
   1.394 +	@param aDesiredVisibilities
   1.395 +		Current state of flags showing visibility of invisible characters
   1.396 +	@param aLayDoc
   1.397 +		Const ref to the calling CLayDocTextSource
   1.398 +	@return
   1.399 +		The replacement character if remapping has taken place, else return original character
   1.400 +	*/
   1.401 +	virtual TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc) = 0;
   1.402 +	};
   1.403 +
   1.404 +/** 
   1.405 +Text layout.
   1.406 +
   1.407 +CTextLayout is the lowest-level text formatting class in the Text Views API. It
   1.408 +obtains text and formatting attributes via the MLayDoc interface class and
   1.409 +formats the text to a certain width.
   1.410 +
   1.411 +It has functions for drawing the text and performing hit-detection that is,
   1.412 +converting x-y coordinates to document positions, and vice versa. It defines
   1.413 +many public functions that are not generally useful, but are called by the
   1.414 +higher-level CTextView class, or exist only for the convenience of closely
   1.415 +associated classes like the printing and pagination systems. These are
   1.416 +identified in the documentation by the text "not generally useful".
   1.417 +
   1.418 +When using the CTextLayout class, you must be aware of what functions have
   1.419 +previously been called. For example:
   1.420 +
   1.421 +1) Formatting and scrolling functions must not be called if a CTextView object
   1.422 +owns the CTextLayout object, because the CTextView object may be reformatting
   1.423 +the CTextLayout object asynchronously by means of an active object, or may hold
   1.424 +some state information about the CTextLayout object that would be invalidated
   1.425 +by reformatting. These functions are identified in the documentation by the
   1.426 +text "Do not use if a CTextView object owns this CTextLayout object.".
   1.427 +
   1.428 +2) Functions that raise out of memory exceptions can leave the object in an
   1.429 +inconsistent state; these functions can be identified as usual by their
   1.430 +trailing L. When this occurs, it is necessary to discard the formatting
   1.431 +information by calling DiscardFormat().
   1.432 +
   1.433 +3) Some functions change formatting parameters like the wrap width or band
   1.434 +height, but do not reformat to reflect the change. These functions are
   1.435 +identified in the documentation by the text "Reformat needed". 
   1.436 +@publishedAll
   1.437 +@released
   1.438 +*/
   1.439 +class CTextLayout: public CBase
   1.440 +
   1.441 +	{
   1.442 +friend class CTestTextLayout;
   1.443 +public:
   1.444 +
   1.445 +	/**Flags used by CTextLayout::SetViewL(). Whether to reformat and redraw.*/
   1.446 +	enum TDiscard
   1.447 +		{
   1.448 +		/** Discard all formatting; redraw. */
   1.449 +		EFViewDiscardAllFormat = TRUE,
   1.450 +		/** Do not discard all formatting; redraw. */
   1.451 +		EFViewDontDiscardFormat = FALSE
   1.452 +		};
   1.453 +
   1.454 +	/** Indicates whether blank space should scroll.
   1.455 +	Used by several CTextView and CTextLayout scrolling functions. */
   1.456 +	enum TAllowDisallow
   1.457 +		{
   1.458 +		/** Allow blank space to scroll. */
   1.459 +		EFAllowScrollingBlankSpace = TRUE,
   1.460 +		/** Disallow blank space from scrolling. */
   1.461 +		EFDisallowScrollingBlankSpace = FALSE
   1.462 +		};
   1.463 +
   1.464 +	enum									// flags for HandleCharEditL
   1.465 +		{
   1.466 +		/** Insert a character, (not a paragraph delimiter). */
   1.467 +		EFCharacterInsert,
   1.468 +		/** Insert a paragraph delimiter. */
   1.469 +		EFParagraphDelimiter,
   1.470 +		/** Delete single character to the left. */
   1.471 +		EFLeftDelete,
   1.472 +		/** Delete single character to the right. */
   1.473 +		EFRightDelete
   1.474 +		};
   1.475 +
   1.476 +	enum
   1.477 +		{
   1.478 +		/** A value greater than any possible display height indicates that the
   1.479 +		entire visible area, at least, was scrolled, and so there is no point
   1.480 +		in blitting text; a full redraw is needed.
   1.481 +		 */
   1.482 +		EFScrollRedrawWholeScreen = CLayoutData::EFLargeNumber,
   1.483 +		/** The maximum line width when wrapping is unset. */
   1.484 +		EFMaximumLineWidth = CLayoutData::EFBodyWidthForNoWrapping,
   1.485 +		};
   1.486 +
   1.487 +	enum
   1.488 +		{
   1.489 +		/** Wrapping off; overrides the paragraph format. */
   1.490 +		EFAllParagraphsNotWrapped = TRUE,
   1.491 +		/** Wrapping on, unless CParaFormat::iWrap is false. */
   1.492 +		EFParagraphsWrappedByDefault = FALSE
   1.493 +		};
   1.494 +
   1.495 +	/** Amount to format. Used by CTextLayout::SetAmountToFormat(). */
   1.496 +	enum TAmountFormatted
   1.497 +		{
   1.498 +		/** Format the whole document. */
   1.499 +		EFFormatAllText = FALSE,
   1.500 +		/** Format the visible band only. */
   1.501 +		EFFormatBand = TRUE,
   1.502 +		};
   1.503 +
   1.504 +	enum TScrollFlags
   1.505 +		{
   1.506 +		EFScrollOnlyToTopsOfLines = 1
   1.507 +		};
   1.508 +
   1.509 +	/** Formatting information. */
   1.510 +	enum TCurrentFormat
   1.511 +		{
   1.512 +		 /** Returned by some CTextLayout enquiry functions to indicate that no
   1.513 +		formatting has taken place so that the requested value cannot be
   1.514 +		calculated. */
   1.515 +		EFNoCurrentFormat = -1,
   1.516 +		/** Returned by CTextLayout::ParagraphHeight() when the paragraph is not formatted. */
   1.517 +		EFNotInCurrentFormat = 0
   1.518 +		};
   1.519 +public:
   1.520 +	class TRangeChange
   1.521 +	/** 
   1.522 +	Specifies the range of characters involved when setting or clearing a
   1.523 +	text selection.
   1.524 +
   1.525 +	This class is used in the CTextLayout::Highlight() function. The following
   1.526 +	code demonstrates how it should be used to clear an existing highlight and
   1.527 +	set a new one:
   1.528 +
   1.529 +	@code 
   1.530 +	CTextLayout::TRangeChange oldHighlight(anchorPos, old_cursorPos,
   1.531 +	CTextLayout::TRangeChange::EClear); // existing highlight
   1.532 +	CTextLayout::TRangeChange newHighlight(anchorPos, new_cursorPos,
   1.533 +	CTextLayout::TRangeChange::ESet); // new one
   1.534 +	newHighlight.OptimizeWith(oldHighlight); // doesn't matter which range is
   1.535 +	the parameter and which is the calling object
   1.536 +	layout.Highlight(oldHighlight,drawRect,context); // doesn't matter in which
   1.537 +	order this and following line occur
   1.538 +	layout.Highlight(newHighlight,drawRect,context);
   1.539 +	@endcode
   1.540 +
   1.541 +	@see CTextLayout::Highlight()
   1.542 +	@publishedAll
   1.543 +	@released
   1.544 +	*/
   1.545 +			{
   1.546 +	public:
   1.547 +		/** Enumerates the possible change types. */
   1.548 +		enum TChangeType
   1.549 +			{
   1.550 +			/** The object is being used to set a range. */
   1.551 +			ESet,
   1.552 +			/** The object is being used to clear a range. */
   1.553 +			EClear
   1.554 +			};
   1.555 +		IMPORT_C TRangeChange(TInt aStart, TInt aEnd, TChangeType aChange);
   1.556 +		IMPORT_C TRangeChange();
   1.557 +		IMPORT_C void Set(TInt aStart, TInt aEnd, TChangeType aChange);
   1.558 +		IMPORT_C TChangeType Get(TInt& aStart, TInt& aEnd) const;
   1.559 +		IMPORT_C void OptimizeWith(TRangeChange& aBuddy);
   1.560 +		IMPORT_C TBool NonNull() const;
   1.561 +		IMPORT_C TBool Clip(TInt aMin, TInt aMax);
   1.562 +
   1.563 +		TBool IsJoinedTo(const TRangeChange aRange);
   1.564 +		void Join(const TRangeChange aRange);
   1.565 +
   1.566 +	private:
   1.567 +		TInt iA;
   1.568 +		TInt iB;
   1.569 +		};
   1.570 +
   1.571 +public:
   1.572 +
   1.573 +	class TTagmaForwarder: public MTmTextLayoutForwarder
   1.574 +	/**
   1.575 +	A standard inquiry interface for the text formatting engine, built on
   1.576 +	top of a CTextView object.
   1.577 +
   1.578 +	To use it, construct a TTagmaForwarder object, then call InitL(), which
   1.579 +	finishes background formatting, then call the MTmTextLayoutForwarder
   1.580 +	functions.
   1.581 +	
   1.582 +	The class should only be used internally by FORM component.
   1.583 +	@internalComponent
   1.584 +	*/
   1.585 +		{
   1.586 +	public:
   1.587 +		inline TTagmaForwarder(const CTextLayout& aLayout);
   1.588 +
   1.589 +	private:
   1.590 +		// from MTmTextLayoutForwarder
   1.591 +		inline const CTmTextLayout& TextLayout() const;
   1.592 +		inline void GetOrigin(TPoint& aPoint) const;
   1.593 +
   1.594 +		const CTextLayout& iLayout;
   1.595 +		};
   1.596 +
   1.597 +	/**
   1.598 +	Accesses text supplied by MTmSource.
   1.599 +	@internalComponent
   1.600 +	*/
   1.601 +	class TUtf32SourceCache
   1.602 +		{
   1.603 +	public:
   1.604 +		TUtf32SourceCache(const MTmSource& aSource);
   1.605 +		TUtf32SourceCache(const CTextLayout& aLayout);
   1.606 +		TText GetUtf16(TInt aIndex);
   1.607 +		TChar GetUtf32(TInt aIndex);
   1.608 +	private:
   1.609 +		const MTmSource* iSource;
   1.610 +		TPtrC16 iCurrentView;
   1.611 +		TInt iCurrentViewIndex;
   1.612 +		};
   1.613 +	friend class TUtf32SourceCache;
   1.614 +
   1.615 +	IMPORT_C static CTextLayout *NewL(MLayDoc *aDoc,TInt aWrapWidth);
   1.616 +	IMPORT_C ~CTextLayout();
   1.617 +	IMPORT_C void DiscardFormat();
   1.618 +	IMPORT_C void SetLayDoc(MLayDoc *aDoc);
   1.619 +	IMPORT_C void SetWrapWidth(TInt aWrapWidth);
   1.620 +	IMPORT_C void SetBandHeight(TInt aHeight);
   1.621 +	IMPORT_C TInt BandHeight() const;
   1.622 +	IMPORT_C void SetImageDeviceMap(MGraphicsDeviceMap *aGd);
   1.623 +	IMPORT_C void SetLabelsDeviceMap(MGraphicsDeviceMap *aDeviceMap);
   1.624 +	IMPORT_C void SetAmountToFormat(TAmountFormatted aAmountOfFormat = EFFormatBand);
   1.625 +	IMPORT_C TBool IsFormattingBand() const;
   1.626 +	IMPORT_C void SetFormatMode(CLayoutData::TFormatMode aFormatMode,TInt aWrapWidth,MGraphicsDeviceMap* aFormatDevice);
   1.627 +	IMPORT_C void ForceNoWrapping(TBool aNoWrapping = EFAllParagraphsNotWrapped);
   1.628 +	IMPORT_C TBool IsWrapping() const;
   1.629 +	IMPORT_C void SetTruncating(TBool aOn);
   1.630 +	IMPORT_C TBool Truncating() const;
   1.631 +	IMPORT_C void SetTruncatingEllipsis(TChar aEllipsis);
   1.632 +	IMPORT_C TChar TruncatingEllipsis() const;
   1.633 +	IMPORT_C void SetLabelsMarginWidth(TInt aWidth);
   1.634 +	IMPORT_C void SetNonPrintingCharsVisibility(TNonPrintingCharVisibility aVisibility);
   1.635 +	IMPORT_C TNonPrintingCharVisibility NonPrintingCharsVisibility() const;
   1.636 +	IMPORT_C TBool IsBackgroundFormatting() const;
   1.637 +	IMPORT_C void NotifyTerminateBackgroundFormatting();
   1.638 +	// deprecated 7.0
   1.639 +	IMPORT_C void SetExcludePartialLines(TBool aExcludePartialLines = TRUE);
   1.640 +	// deprecated 7.0
   1.641 +	IMPORT_C TBool ExcludingPartialLines() const;
   1.642 +	IMPORT_C void SetFontHeightIncreaseFactor(TInt aPercentage);
   1.643 +	IMPORT_C TInt FontHeightIncreaseFactor() const;
   1.644 +	IMPORT_C void SetMinimumLineDescent(TInt aPixels);
   1.645 +	IMPORT_C TInt MinimumLineDescent() const;
   1.646 +	IMPORT_C TInt DocumentLength() const;
   1.647 +	IMPORT_C TInt ToParagraphStart(TInt& aDocPos) const;
   1.648 +	IMPORT_C TInt PixelsAboveBand() const;
   1.649 +	IMPORT_C TInt YBottomLastFormattedLine() const;
   1.650 +	IMPORT_C TInt FormattedHeightInPixels() const;
   1.651 +	IMPORT_C TInt PosRangeInBand(TInt& aDocPos) const;
   1.652 +	IMPORT_C TBool PosInBand(const TTmDocPos& aDocPos,TTmLineInfo* aLineInfo = NULL) const;
   1.653 +	IMPORT_C TBool PosInBand(TTmDocPos aDocPos,TPoint& aXyPos) const;
   1.654 +	IMPORT_C TBool PosInBand(TInt aDocPos,TPoint& aXyPos) const;
   1.655 +	IMPORT_C TBool PosIsFormatted(TInt aDocPos) const;
   1.656 +	IMPORT_C TInt FirstCharOnLine(TInt aLineNo) const;
   1.657 +	IMPORT_C TInt FormattedLength() const;
   1.658 +	IMPORT_C TInt FirstFormattedPos() const;
   1.659 +	IMPORT_C TInt NumFormattedLines() const;
   1.660 +	IMPORT_C TInt FirstLineInBand() const;
   1.661 +	IMPORT_C TInt GetLineRect(TInt aYPos,TRect& aLine) const;
   1.662 +	IMPORT_C TInt ParagraphHeight(TInt aDocPos) const;
   1.663 +	IMPORT_C TRect ParagraphRectL(TInt aDocPos) const;
   1.664 +	IMPORT_C TBool CalculateHorizontalExtremesL(TInt& aLeftX,TInt& aRightX,TBool aOnlyVisibleLines,
   1.665 +												TBool aIgnoreWrapCharacters = FALSE) const;
   1.666 +	IMPORT_C void GetCharacterHeightAndAscentL(TInt aDocPos,TInt& aHeight,TInt& aAscent) const;
   1.667 +	IMPORT_C void GetFontHeightAndAscentL(const TFontSpec& aFontSpec,TInt& aHeight,TInt& aAscent) const;
   1.668 +	IMPORT_C TInt XyPosToDocPosL(TPoint &aPos, TUint aFlags = 0) const;
   1.669 +	IMPORT_C TBool DocPosToXyPosL(TInt aDocPos, TPoint& aPos, TUint aFlags = 0) const;
   1.670 +	IMPORT_C TBool FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo = NULL) const;
   1.671 +	IMPORT_C TBool FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo = NULL) const;
   1.672 +	IMPORT_C TRect GetLineRectL(TInt aDocPos1,TInt aDocPos2) const;
   1.673 +	IMPORT_C TBool PictureRectangleL(TInt aDocPos,TRect& aPictureRect,TBool* aCanScaleOrCrop = NULL) const;
   1.674 +	IMPORT_C TBool PictureRectangleL(const TPoint& aXyPos,TRect& aPictureRect,TBool* aCanScaleOrCrop = NULL) const;
   1.675 +	IMPORT_C TInt FirstDocPosFullyInBand() const;
   1.676 +	IMPORT_C void GetMinimumSizeL(TInt aWrapWidth,TSize& aSize);
   1.677 +	IMPORT_C void GetMinimumSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize);
   1.678 +	IMPORT_C TInt MajorVersion() const;
   1.679 +	IMPORT_C TInt SetViewL(const TTmDocPos& aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier,
   1.680 +						   TDiscard aDiscardFormat = EFViewDontDiscardFormat);
   1.681 +	IMPORT_C TInt SetViewL(TInt aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier,
   1.682 +						   TDiscard aDiscardFormat = EFViewDontDiscardFormat);
   1.683 +	IMPORT_C void FormatBandL();
   1.684 +	IMPORT_C void FormatCharRangeL(TInt aStartDocPos,TInt aEndDocPos);
   1.685 +	void FormatCharRangeL(TInt aStartDocPos,TInt aEndDocPos,TInt aPixelOffset);
   1.686 +	IMPORT_C TBool FormatNextLineL(TInt& aBotPixel);
   1.687 +	IMPORT_C TBool FormatLineL(CParaFormat* aParaFormat,TInt& aDocPos,TInt& aHeight,TBool& aPageBreak);
   1.688 +	IMPORT_C TInt ScrollParagraphsL(TInt& aNumParas,TAllowDisallow aScrollBlankSpace);
   1.689 +	IMPORT_C TInt ScrollLinesL(TInt& aNumLines,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace);
   1.690 +	IMPORT_C TInt ChangeBandTopL(TInt& aPixels,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace);
   1.691 +    IMPORT_C void ChangeBandTopNoLimitBorderL(TInt aPixels);
   1.692 +	IMPORT_C void PageUpL(TInt& aYCursorPos,TInt& aPixelsScrolled);
   1.693 +	IMPORT_C void PageDownL(TInt& aYCursorPos,TInt& aPixelsScrolled);
   1.694 +	IMPORT_C TBool HandleCharEditL(TUint aType,TInt& aCursorPos,TInt& aGood,TInt& aFormattedUpTo,
   1.695 +								   TInt& aFormattedFrom,TInt& aScroll,TBool aFormatChanged);
   1.696 +	IMPORT_C void HandleBlockChangeL(TCursorSelection aSelection,TInt aOldCharsChanged,TViewRectChanges& aViewChanges,
   1.697 +									 TBool aFormatChanged);
   1.698 +	IMPORT_C void HandleAdditionalCharactersAtEndL(TInt& aFirstPixel,TInt& aLastPixel);
   1.699 +	// deprecated 6.1
   1.700 +	IMPORT_C void ReformatVerticalSpaceL();
   1.701 +	IMPORT_C void AdjustVerticalAlignment(CParaFormat::TAlignment aVerticalAlignment);
   1.702 +	IMPORT_C static void DrawBorders(const MGraphicsDeviceMap* aGd,CGraphicsContext& aGc,const TRect& aRect,
   1.703 +									 const TParaBorderArray& aBorder,const TRgb* aBackground = NULL,
   1.704 +									 TRegion* aClipRegion = NULL,const TRect* aDrawRect = NULL);
   1.705 +	IMPORT_C void DrawL(const TRect& aDrawRect,const TDrawTextLayoutContext* aDrawTextLayoutContext,
   1.706 +						const TCursorSelection* aHighlight = NULL);
   1.707 +	IMPORT_C TBool GetNextVisualCursorPos(const TTmDocPosSpec& aDocPos,
   1.708 +		TTmPosInfo2& aPosInfo, TBool aToLeft) const;
   1.709 +	// deprecated 7.0
   1.710 +	IMPORT_C void InvertRangeL(const TCursorSelection& aHighlight,const TRect& aDrawRect,
   1.711 +							   const TDrawTextLayoutContext* aDrawTextLayoutContext);
   1.712 +	IMPORT_C void Highlight(const TRangeChange& aHighlight,const TRect& aDrawRect,
   1.713 +		const TDrawTextLayoutContext* aDrawTextLayoutContext);
   1.714 +	IMPORT_C void SetCustomDraw(const MFormCustomDraw* aCustomDraw);
   1.715 +	IMPORT_C const MFormCustomDraw* CustomDraw() const;
   1.716 +	IMPORT_C void SetCustomWrap(const MFormCustomWrap* aCustomWrap);
   1.717 +	IMPORT_C const MFormCustomWrap* CustomWrap() const;
   1.718 +	/* this function should only used by Symbian internally */
   1.719 +	IMPORT_C void ExtendFormattingToCoverYL(TInt aYPos);
   1.720 +	IMPORT_C void ExtendFormattingToCoverPosL(TInt aDocPos);
   1.721 +
   1.722 +	IMPORT_C TInt GetLineNumber(TInt aDocPos);
   1.723 +	IMPORT_C void SetHighlightExtensions(TInt aLeftExtension, TInt aRightExtension, TInt aTopExtension, TInt aBottomExtension);
   1.724 +	void SetExcessHeightRequired(TInt aExcessHeightRequired);
   1.725 +    IMPORT_C void SetInterfaceProvider( MFormCustomInterfaceProvider* aProvider ); 
   1.726 +	inline const CTmTextLayout& TagmaTextLayout() const;
   1.727 +	inline void GetOrigin(TPoint& aPoint) const;
   1.728 +
   1.729 +
   1.730 +	inline void RestrictScrollToTopsOfLines(TBool aRestrict);
   1.731 +
   1.732 +
   1.733 +	// Non-exported public functions
   1.734 +	void DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,
   1.735 +						const TLogicalRgb& aBackground) const;
   1.736 +	TBool CalculateHorizontalExtremes(TInt& aLeftX,TInt& aRightX,TBool aOnlyVisibleLines) const;
   1.737 +	TBool GetCursor(const TTmDocPos& aDocPos,TTmCursorPlacement aPlacement,
   1.738 +				    TRect& aLineRect,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const;
   1.739 +	void GetParagraphRect(const TTmDocPos& aDocPos,TRect& aRect) const;
   1.740 +	TInt ScrollDocPosIntoViewL(const TTmDocPos& aDocPos);
   1.741 +	TInt PictureRectangleAndPosL(const TPoint& aXyPos, TRect& aPictureRect,
   1.742 +		TBool* aCanScaleOrCrop = 0) const;
   1.743 +	void HighlightUsingExtensions(const CTextLayout::TRangeChange& aChangeHighlight,const TRangeChange& aFullHighlight,
   1.744 +		const TRect& aDrawRect,	const TDrawTextLayoutContext* aDrawTextLayoutContext);
   1.745 +	inline const TTmHighlightExtensions& HighlightExtensions() const;
   1.746 +	void GetHighlightRemnants(const TRect& aRect, const TDrawTextLayoutContext& aDrawTextLayoutContext, TRect* aRemainderRects) const;
   1.747 +	TInt WrapWidth() const;
   1.748 +
   1.749 +	void SetOpaqueLC();
   1.750 +	
   1.751 +	IMPORT_C void SetCustomInvisibleCharacterRemapper(MFormCustomInvisibleCharacterRemapper* aInvisibleCharacterRemapper);
   1.752 +	IMPORT_C MFormCustomInvisibleCharacterRemapper* GetCustomInvisibleCharacterRemapper();
   1.753 +	void SetTextViewCursorPos(TCursorPosition* aPos); // Put in for INC092568
   1.754 +
   1.755 +	void SetWindow(RWindow* aWnd);
   1.756 +	void SetReadyToRedraw();
   1.757 +	void BeginRedraw(const TRect& aRect);
   1.758 +	void EndRedraw();
   1.759 +	void SetExternalDraw(const TRect& aRect);
   1.760 +	void ResetExternalDraw();
   1.761 +	TBool BeginRedrawCalled() const;
   1.762 +	IMPORT_C void MakeVisible(TBool aVisible);
   1.763 +
   1.764 +#ifdef _DEBUG
   1.765 +	TBool __DbgIsFormattingUpToDate() const;
   1.766 +#endif
   1.767 +
   1.768 +	enum TPanicNumber
   1.769 +		{
   1.770 +		EUnimplemented,
   1.771 +		ENoMemory,
   1.772 +		EDrawingBorderError,
   1.773 +		EFormatDeviceNotSet,
   1.774 +		EImageDeviceNotSet,
   1.775 +		EPixelNotInFormattedLine,
   1.776 +		EInvalidDocPos,
   1.777 +		ENoCharRangeToFormat,
   1.778 +		ECharacterNotFormatted,
   1.779 +		EPrintPreviewModeError,
   1.780 +		EBadCharacterEditType,
   1.781 +		EInvalidLineNumber,
   1.782 +		EPosNotFormatted,
   1.783 +		EMustFormatAllText,
   1.784 +		EPageScrollError,
   1.785 +		EInvalidRedraw
   1.786 +		};
   1.787 +	static void Panic(TPanicNumber aNumber);
   1.788 +
   1.789 +private:
   1.790 +	IMPORT_C CTextLayout();
   1.791 + 	IMPORT_C void ConstructL(MLayDoc *aDoc,TInt aWrapWidth);
   1.792 +	void InitFormatParam(TTmFormatParamBase& aParam);
   1.793 +	TInt ScrollL(TInt aDy,TAllowDisallow aScrollBlankSpace,TBool aTopNoLimitBorder=EFalse,TBool aBottomNoLimitBorder=EFalse);
   1.794 +	void FormatBandL(TInt aStartDocPos,TInt aEndDocPos);
   1.795 +	void PruneFormatL(TBool aFromStart);
   1.796 +	TInt VisibleHeightInPixels() const;
   1.797 +	TInt BandHeightInPixels() const;
   1.798 +	TInt SuggestCursorPos(TInt aCurrentCursorPos) const;
   1.799 +	TInt SetBandTop();
   1.800 +	TBool AddFormattingAtEndL(TTmFormatParamBase& aFormatParam, TInt& aHeightIncrease, TInt& aParagraphsIncrease);
   1.801 +	
   1.802 +	static void ResetOpaque(void* aThis);
   1.803 +
   1.804 +
   1.805 +	CTmTextLayout *iText;		// the TAGMA object that contains the text layout
   1.806 +	TInt iDummyForIText[10];	// It is only here to add padding for maintain compatibility 
   1.807 +	TInt iExcessHeightRequired; // The delta required to position the baseline so there is enough 
   1.808 +								// space for the highset glyph in pixels
   1.809 +	RWindow *iWnd;				// the window to be used to draw
   1.810 +	TBool iBeginRedrawCount;
   1.811 +	TRect iRedrawRect;
   1.812 +	TCursorPosition* iTextViewCursorPos; // From and owned by owning CTextView if it exists,
   1.813 +										 // Null otherwise.  Put in for INC092568
   1.814 +	TBool iIsWndInExternalRedraw;		 // If ETrue, then iWnd->EndRedraw() will not be called
   1.815 +										 // from within CTextLayout::EndRedraw() as the window redraw 
   1.816 +										 // has been initiated externally and will be ended externally as well
   1.817 +	TBool iReadyToRedraw;				// If EFalse, disables CTextLayout::BeginRedraw() and 
   1.818 +										// CTextLayout::EndRedraw()
   1.819 +	TInt iDummy[4];		// This dummy variable has been inserted to replace the original size of
   1.820 +						// a variable that had to be moved to avaid a BC break because it had
   1.821 +						// increased in size. Feel free to reuse this space - just reduce the size
   1.822 +						// of this variable by the size of any variable you insert in front of it.
   1.823 +						// Currently it occupies 5 words.
   1.824 +	TInt iBandTop;		// effectively, scroll position: subtract this from CTmTextLayout y position
   1.825 +						// to give CTextLayout y position
   1.826 +	TInt iVisibleHeight;// in pixels if iFormatMode is EFScreenMode or EFWysiwygMode, otherwise twips
   1.827 +	TInt iBandHeight;	// in pixels if iFormatMode is EFScreenMode or EFWysiwygMode, otherwise twips
   1.828 +
   1.829 +	TInt iScrollFlags;		// from CTextLayout::TScrollFlags
   1.830 +	TInt iUnformattedStart; // document position of the start of any unformatted text;
   1.831 +							// if < KMaxTInt, background formatting can be used
   1.832 +							// (by calling FormatNextLine) to format the remainder
   1.833 +	TBool iParInvalid;		// if true and background formatting is happening, the remainder of the paragraph
   1.834 +							// containing iUnformattedStart is invalid and must be reformatted;
   1.835 +							// otherwise, formatting stops when line ends match
   1.836 +	TTmHighlightExtensions *iHighlightExtensions;
   1.837 +	TInt iDmmyForIHighlightExtensions[3];	// It is only here to add padding for maintain compatibility 
   1.838 +	TLayDocTextSource* iSource;	// the source of the text
   1.839 +	// before adding any new member variables to the end of this class, please
   1.840 +	// consider whether you can insert them before the iDummy member variable
   1.841 +	// further up, which currently represents wasted space.
   1.842 +	TInt iDmmyForISource[23];	// It is only here to add padding for maintain compatibility 
   1.843 +	};
   1.844 +
   1.845 +/**
   1.846 +Cursor position.
   1.847 +
   1.848 +The TMovementType enum defined in this class is used to indicate the direction
   1.849 +of a scroll or cursor movement. The remainder of this class does not form part
   1.850 +of the API.
   1.851 +@publishedAll
   1.852 +@released
   1.853 +*/
   1.854 +class TCursorPosition
   1.855 +
   1.856 +	{
   1.857 +public:
   1.858 +
   1.859 +
   1.860 +	/** Direction of cursor movement. */
   1.861 +	enum TMovementType
   1.862 +		{
   1.863 +		/** No cursor movement */
   1.864 +		EFNoMovement,
   1.865 +		/** Single character cursor movement to the left */
   1.866 +		EFLeft,
   1.867 +		/** Single character cursor movement to the right */
   1.868 +		EFRight,
   1.869 +		/** Line up cursor movement */
   1.870 +		EFLineUp,
   1.871 +		/** Line down cursor movement */
   1.872 +		EFLineDown,
   1.873 +		/** Page up cursor movement */
   1.874 +		EFPageUp,
   1.875 +		/** Page down cursor movement */
   1.876 +		EFPageDown,
   1.877 +		/** Cursor movement to line start */
   1.878 +		EFLineBeg,
   1.879 +		/** Cursor movement to line end */
   1.880 +		EFLineEnd
   1.881 +		};
   1.882 +
   1.883 +	/** Selection of the left end or right end of a run of text. */
   1.884 +	enum TVisualEnd
   1.885 +		{
   1.886 +		/** Leftmost end. */
   1.887 +		EVisualLeft,
   1.888 +		/** Rightmost end. */
   1.889 +		EVisualRight
   1.890 +		};
   1.891 +
   1.892 +	enum TPosHint
   1.893 +		{
   1.894 +		EPosHintUndefined           = 0,
   1.895 +		/** Left to right typing expected. */
   1.896 +		EInsertStrongL2R = 1,
   1.897 +		/** Right to left typing expected. */
   1.898 +		EInsertStrongR2L = 2,
   1.899 +
   1.900 +		// Maybe several more.
   1.901 +		//...
   1.902 +		EPosHintLast
   1.903 +		};
   1.904 +		
   1.905 +	inline TCursorPosition();
   1.906 +	inline void SetLayout(CTextLayout *aLayout);
   1.907 +	inline void UpdateLatentX(TInt aX);
   1.908 +	inline void SetToPreviousHighlight();
   1.909 +	inline void SetToCurrentHighlight();
   1.910 +	inline void CancelHighlight();
   1.911 +	inline void SetDocPos(const TTmDocPos& aDocPos);
   1.912 +	void UpdateLatentPosition();
   1.913 +	TInt SetSelectionL(const TCursorSelection& aSelection);
   1.914 +	void SetPendingSelection(const TCursorSelection& aSelection);
   1.915 +	void GetOldSelection(TCursorSelection& aSelection) const;
   1.916 +	void GetSelection(TCursorSelection& aSelection) const;
   1.917 +	TInt SetDocPosL(TBool aDragSelectOn,const TTmDocPos& aDocPos);
   1.918 +	TInt SetXyPosL(TBool aDragSelectOn,TPoint aPos,TBool aAllowPictureFrame);
   1.919 +	TInt MoveL(TBool aDragSelectOn,TMovementType& aMovement,TBool aAllowPictureFrame);
   1.920 +	const TTmDocPos& VisualEndOfRunL(
   1.921 +		const TTmDocPos& aStart, const TTmDocPos& aEnd,
   1.922 +		TVisualEnd aDirection);
   1.923 +	void TextMoveVertically();
   1.924 +	inline void DontDrawOldPictureFrame();
   1.925 +
   1.926 +	// inquiry functions
   1.927 +	inline TBool IsSelection() const;
   1.928 +	inline TBool IsSelectionToDraw() const;
   1.929 +	TBool IsPictureFrame() const;
   1.930 +	TBool IsNewPictureFrame() const;
   1.931 +	inline const TTmDocPos& TmDocPos() const;
   1.932 +	inline TInt DocPos() const;
   1.933 +	inline TBool DrawHighlight() const;
   1.934 +	inline TBool DrawOldPictureFrame() const;
   1.935 +	inline TBool DrawNewPictureFrame() const;
   1.936 +	TBool GetCursor(TTmCursorPlacement aPlacement,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const;
   1.937 +	TPosHint PositioningHint() const { return iPositioningHint; }
   1.938 +	void SetPositioningHint (TPosHint aHint)
   1.939 +		{iPositioningHint = aHint;}
   1.940 +
   1.941 +	TTmPosInfo2& ChoosePosition(TTmPosInfo2& aPreferred,
   1.942 +		TTmPosInfo2& aBackup);
   1.943 +
   1.944 +private:
   1.945 +	enum
   1.946 +		{
   1.947 +		EFAbove = -1,
   1.948 +		EFInside = 0,
   1.949 +		EFBelow = 1
   1.950 +		};
   1.951 +
   1.952 +	// bit values for iFlags
   1.953 +	enum
   1.954 +		{
   1.955 +		EDrawHighlight = 1,
   1.956 +		EDrawOldPictureFrame = 2,
   1.957 +		EDrawNewPictureFrame = 4,
   1.958 +		EReturnPreviousHighlight = 8,
   1.959 +		ESelected = 16
   1.960 +		};
   1.961 +
   1.962 +	TInt ViewTopOfLineL(const TTmDocPos& aDocPos,TInt& aYPos);
   1.963 +	void CheckSelection(TBool aSelect);
   1.964 +	void CheckNullSelection();
   1.965 +	inline void UpdateLatentY(TInt aY);
   1.966 +	TInt CheckCursorOnScreenL(TInt& aY);
   1.967 +	TBool LeftRightL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove);
   1.968 +	void StartEnd(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove);
   1.969 +	void UpDownL(TTmPosInfo2& aPos, TTmLineInfo& aLine, TMovementType& aMove);
   1.970 +	TInt PageScrollL(TMovementType& aMove);
   1.971 +	TInt DoSetDocPosL(const TTmDocPos& aDocPos);
   1.972 +	TInt DoSetVisibleDocPosL(const TTmDocPos& aDocPos);
   1.973 +	void DoSetXyPos(TPoint& aXy);
   1.974 +	void SetPictureFrame(const TTmDocPos& aDocPos,TInt aAnchor,const TRect& aPictureRect);
   1.975 +	inline TBool CalculateCursorPos(TPoint& aCurPos);
   1.976 +
   1.977 +	TTmDocPos iDocPos;
   1.978 +	TInt iAnchor;
   1.979 +	TInt iOldDocPos;
   1.980 +	TInt iOldAnchor;
   1.981 +	TUint iFlags;
   1.982 +	TInt iLatentX;
   1.983 +	TInt iLatentY;
   1.984 +	CTextLayout* iLayout;
   1.985 +	TPosHint iPositioningHint;
   1.986 +	};
   1.987 +
   1.988 +// inline functions
   1.989 +inline const CTmTextLayout& CTextLayout::TagmaTextLayout() const
   1.990 +	{
   1.991 +	return *iText;
   1.992 +	}
   1.993 +
   1.994 +inline void CTextLayout::GetOrigin(TPoint& aPoint) const
   1.995 +	{
   1.996 +	aPoint.iX = 0;
   1.997 +	aPoint.iY = -iBandTop;
   1.998 +	}
   1.999 +
  1.1000 +inline CTextLayout::TTagmaForwarder::TTagmaForwarder(const CTextLayout& aLayout):
  1.1001 +	iLayout(aLayout)
  1.1002 +	{
  1.1003 +	}
  1.1004 +
  1.1005 +inline const CTmTextLayout& CTextLayout::TTagmaForwarder::TextLayout() const
  1.1006 +	{
  1.1007 +	return iLayout.TagmaTextLayout();
  1.1008 +	}
  1.1009 +
  1.1010 +inline void CTextLayout::TTagmaForwarder::GetOrigin(TPoint& aPoint) const
  1.1011 +	{
  1.1012 +	iLayout.GetOrigin(aPoint);
  1.1013 +	}
  1.1014 +
  1.1015 +inline const TTmHighlightExtensions& CTextLayout::HighlightExtensions() const
  1.1016 +	{
  1.1017 +	return *iHighlightExtensions;
  1.1018 +	}
  1.1019 +
  1.1020 +/**
  1.1021 +Dangerous function. Makes scroll operations set the top of the screen flush to
  1.1022 +the top of a line. In general this might scroll the cursor off the screen.
  1.1023 +*/
  1.1024 +void CTextLayout::RestrictScrollToTopsOfLines(TBool a)
  1.1025 +	{
  1.1026 +	if (a)
  1.1027 +		iScrollFlags |= EFScrollOnlyToTopsOfLines;
  1.1028 +	else
  1.1029 +		iScrollFlags &= ~EFScrollOnlyToTopsOfLines;
  1.1030 +	}
  1.1031 +
  1.1032 +/**Constructs a fully initialized TViewYPosQualifier object. The hotspot is
  1.1033 +initialized to be the baseline of the line, the screen is not filled, and the
  1.1034 +top line is not forced to be fully visible. */
  1.1035 +inline TViewYPosQualifier::TViewYPosQualifier():
  1.1036 +	iHotSpot(EFViewBaseLine),
  1.1037 +	iFillScreen(EFalse),
  1.1038 +	iFullyVisible(EFViewDontForceLineFullyVisible)
  1.1039 +	{
  1.1040 +	}
  1.1041 +
  1.1042 +
  1.1043 +/**Constructs a TViewRectChanges object, initializing its iScrollAtTop and
  1.1044 +iScrollAtBottom members to zero. */
  1.1045 +inline TViewRectChanges::TViewRectChanges():
  1.1046 +	iScrollAtTop(0),
  1.1047 +	iScrollAtBottom(0)
  1.1048 +	{
  1.1049 +	}
  1.1050 +
  1.1051 +/**Constructs the TCursorSelection object initialising the cursor and anchor
  1.1052 +positions to zero. */
  1.1053 +inline TCursorSelection::TCursorSelection():
  1.1054 +	iCursorPos(0),
  1.1055 +	iAnchorPos(0)
  1.1056 +	{
  1.1057 +	}
  1.1058 +
  1.1059 +/** Constructs the TCursorSelection object with a cursor and anchor position.
  1.1060 +@param aCursorPos The cursor position.
  1.1061 +@param aAnchorPos The anchor position. */
  1.1062 +inline TCursorSelection::TCursorSelection(TInt aCursorPos,TInt aAnchorPos):
  1.1063 +	iCursorPos(aCursorPos),
  1.1064 +	iAnchorPos(aAnchorPos)
  1.1065 +	{
  1.1066 +	}
  1.1067 +
  1.1068 +/** Sets the cursor and anchor positions for the selection.
  1.1069 +@param aCursorPos The new cursor position.
  1.1070 +@param aAnchorPos The new anchor position. */
  1.1071 +inline void TCursorSelection::SetSelection(TInt aCursorPos,TInt aAnchorPos)
  1.1072 +	{
  1.1073 +	iCursorPos = aCursorPos;
  1.1074 +	iAnchorPos = aAnchorPos;
  1.1075 +	}
  1.1076 +
  1.1077 +/** Gets the lesser of the cursor and anchor positions.
  1.1078 +@return The lesser of the cursor and anchor positions. */
  1.1079 +inline TInt TCursorSelection::LowerPos() const
  1.1080 +	{
  1.1081 +	return Min(iCursorPos,iAnchorPos);
  1.1082 +	}
  1.1083 +
  1.1084 +/** Gets the greater of the cursor and anchor positions.
  1.1085 +@return The greater of the cursor and anchor positions. */
  1.1086 +inline TInt TCursorSelection::HigherPos() const
  1.1087 +	{
  1.1088 +	return Max(iCursorPos,iAnchorPos);
  1.1089 +	}
  1.1090 +
  1.1091 +/** Returns the number of characters in the selected range.
  1.1092 +@return The length of the selection. */
  1.1093 +inline TInt TCursorSelection::Length() const
  1.1094 +	{
  1.1095 +	return Abs(iCursorPos - iAnchorPos);
  1.1096 +	}
  1.1097 +
  1.1098 +/** Constructs the TCursorPosition object, initializing its members
  1.1099 +	iAnchor, iOldDocPos, iOldAnchor, iFlags, iLatentX, iLatentY to 
  1.1100 +	zero, iLayout to NULL, and iPositioningHint to undefined.
  1.1101 +*/
  1.1102 +inline TCursorPosition::TCursorPosition():
  1.1103 +	iAnchor(0),
  1.1104 +	iOldDocPos(0),
  1.1105 +	iOldAnchor(0),
  1.1106 +	iFlags(0),
  1.1107 +	iLatentX(0),
  1.1108 +	iLatentY(0),
  1.1109 +	iLayout(NULL),
  1.1110 +	iPositioningHint(EPosHintUndefined)
  1.1111 +	{
  1.1112 +	}
  1.1113 +
  1.1114 +/** Sets the text layout which TCursorPosition is related.
  1.1115 +@param aLayout The text layout.
  1.1116 +*/
  1.1117 +inline void TCursorPosition::SetLayout(CTextLayout *aLayout)
  1.1118 +	{
  1.1119 +	iLayout = aLayout;
  1.1120 +	}
  1.1121 +
  1.1122 +/** Tests whether there is currently a selected region.
  1.1123 +@return True if there is a selected region. False if not. */
  1.1124 +inline TBool TCursorPosition::IsSelection() const
  1.1125 +	{
  1.1126 +	return iFlags & ESelected;
  1.1127 +	}
  1.1128 +
  1.1129 +/** Tests whether there is currently a highlighted region being drawn.
  1.1130 +@return True if there is a selected region. False if not. */
  1.1131 +inline TBool TCursorPosition::IsSelectionToDraw() const
  1.1132 +	{
  1.1133 +	return iFlags & (EDrawHighlight | EDrawOldPictureFrame | EDrawNewPictureFrame);
  1.1134 +	}
  1.1135 +
  1.1136 +/** Sets the flag which directs <code>GetSelection()</code> and 
  1.1137 +<code>IsPictureFrame()</code> to operate on the previous highlight
  1.1138 +instead of the current highlight.
  1.1139 +*/
  1.1140 +inline void TCursorPosition::SetToPreviousHighlight()
  1.1141 +	{
  1.1142 +	iFlags |= EReturnPreviousHighlight;
  1.1143 +	}
  1.1144 +
  1.1145 +/** Clears the special flag set in <code>SetToPreviousHighlight()</code>
  1.1146 +so that <code>GetSelection()</code> and <code>IsPictureFrame()</code>
  1.1147 +will operate on the current highlight.
  1.1148 +*/
  1.1149 +inline void TCursorPosition::SetToCurrentHighlight()
  1.1150 +	{
  1.1151 +	iFlags &= ~EReturnPreviousHighlight;
  1.1152 +	}
  1.1153 +
  1.1154 +/** Removes the selection, and redraws the affected part of the screen.
  1.1155 +*/
  1.1156 +inline void TCursorPosition::CancelHighlight()
  1.1157 +	{
  1.1158 +	iFlags &= ~(ESelected | EDrawHighlight | EDrawOldPictureFrame | EDrawNewPictureFrame);
  1.1159 +	}
  1.1160 +
  1.1161 +/** Sets the latent horizontal text cursor position. This is the horizontal
  1.1162 +coordinate to which the text cursor will be moved. 
  1.1163 +@param aX The horizontal coordinate to which the text cursor should be moved
  1.1164 +*/
  1.1165 +inline void TCursorPosition::UpdateLatentX(TInt aX)
  1.1166 +	{
  1.1167 +	iLatentX = aX;
  1.1168 +	}
  1.1169 +
  1.1170 +/** Sets the latent vertical text cursor position. This is the vertical 
  1.1171 +coordinate to which the text cursor will be moved. 
  1.1172 +@param aY The vertical coordinate to which the text cursor should be moved
  1.1173 +*/
  1.1174 +inline void TCursorPosition::UpdateLatentY(TInt aY)
  1.1175 +	{
  1.1176 +	iLatentY = aY;
  1.1177 +	}
  1.1178 +
  1.1179 +/** Caculate  x-y position of the cursor
  1.1180 +If ETrue is returned, places the position of the intersection of 
  1.1181 +the character edge with the baseline in aPos
  1.1182 +@param aPos On return, stores the position of the intersection of 
  1.1183 +the character edge with the baseline
  1.1184 +@return ETrue if the document is in the formatted text, otherwise EFalse.
  1.1185 +*/
  1.1186 +inline TBool TCursorPosition::CalculateCursorPos(TPoint& aPos)
  1.1187 +	{
  1.1188 +	TTmPosInfo2 pos_info;
  1.1189 +	TBool result = iLayout->FindDocPos(iDocPos,pos_info);
  1.1190 +	aPos = pos_info.iEdge;
  1.1191 +	return result;
  1.1192 +	}
  1.1193 +	
  1.1194 +/** Gets the document position, the structure for holding a raw document 
  1.1195 +position that can be converted to or from an x-y position and compared 
  1.1196 +ordinally, which cannot be done with the more abstract TTmDocPosSpec class. 
  1.1197 +@return the document position
  1.1198 +*/
  1.1199 +inline const TTmDocPos& TCursorPosition::TmDocPos() const
  1.1200 +	{
  1.1201 +	return iDocPos;
  1.1202 +	}
  1.1203 +/** Gets the edge position in the document.
  1.1204 +@return the edge position in the document.
  1.1205 +*/
  1.1206 +inline TInt TCursorPosition::DocPos() const
  1.1207 +	{
  1.1208 +	return iDocPos.iPos;
  1.1209 +	}
  1.1210 +
  1.1211 +/** Sets the document position, the structure for holding a raw document 
  1.1212 +position that can be converted to or from an x-y position and compared 
  1.1213 +ordinally, which cannot be done with the more abstract TTmDocPosSpec class. 
  1.1214 +@param aDocPos the document position
  1.1215 +*/
  1.1216 +inline void TCursorPosition::SetDocPos(const TTmDocPos& aDocPos)
  1.1217 +	{
  1.1218 +	iDocPos = aDocPos;
  1.1219 +	}
  1.1220 +
  1.1221 +/** Tests whether the highlighted region needs to be drawn.
  1.1222 +The function will be called by CTextView::UpdateHighlightL()
  1.1223 +to correct the highlight after a cursor movement
  1.1224 +@return True if the highlighted region needs to be drawn. False if not. */
  1.1225 +inline TBool TCursorPosition::DrawHighlight() const
  1.1226 +	{
  1.1227 +	return iFlags & EDrawHighlight;
  1.1228 +	}
  1.1229 +
  1.1230 +/** Tests whether there is a previous picture frame that needs to be drawn.
  1.1231 +The function will be called by CTextView::UpdateHighlightL()
  1.1232 +to correct the highlight after a cursor movement
  1.1233 +@return True if there is a previous picture frame that needs to be drawn. False if not. */	
  1.1234 +inline TBool TCursorPosition::DrawOldPictureFrame() const
  1.1235 +	{
  1.1236 +	return iFlags & EDrawOldPictureFrame;
  1.1237 +	}
  1.1238 +
  1.1239 +/** Tests whether there is a new picture frame that needs to be drawn.
  1.1240 +The function will be called by CTextView::UpdateHighlightL()
  1.1241 +to correct the highlight after a cursor movement
  1.1242 +@return True if there is a new picture frame that needs to be drawn. False if not. */		
  1.1243 +inline TBool TCursorPosition::DrawNewPictureFrame() const
  1.1244 +	{
  1.1245 +	return iFlags & EDrawNewPictureFrame;
  1.1246 +	}
  1.1247 +
  1.1248 +/** Sets to not draw the previous picture frame
  1.1249 +*/
  1.1250 +inline void TCursorPosition::DontDrawOldPictureFrame()
  1.1251 +	{
  1.1252 +	iFlags &= ~EDrawOldPictureFrame;
  1.1253 +	}
  1.1254 +
  1.1255 +#endif