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