29 class CWindowGc; |
32 class CWindowGc; |
30 class MLayDoc; |
33 class MLayDoc; |
31 class TLayDocTextSource; |
34 class TLayDocTextSource; |
32 class TCursorPosition; |
35 class TCursorPosition; |
33 |
36 |
|
37 class TLayDocTextSource; |
|
38 class CTmTextLayout; |
|
39 class TTmHighlightExtensions; |
|
40 class MTmSource; |
|
41 class TTmFormatParamBase; |
|
42 |
|
43 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
44 #include <frmtlay_internal.h> |
|
45 #endif |
34 |
46 |
35 /** |
47 /** |
36 This interface class defines an interface for clients of Form to provided |
48 This interface class defines an interface for clients of Form to provided |
37 implementations of customisation interfaces relating to the source text |
49 implementations of customisation interfaces relating to the source text |
38 document as requried by the internals of Form and Tagma. Its use by |
50 document as requried by the internals of Form and Tagma. Its use by |
39 Form clients is optional. |
51 Form clients is optional. |
40 Derived objects of this interface are registered with the CTextLayout |
52 Derived objects of this interface are registered with the CTextLayout |
41 API and are called from the TLayDocTextSource class at present. |
53 API and are called from the TLayDocTextSource class at present. |
42 @publishedPartner |
54 @publishedAll |
43 @released |
55 @released |
44 @see MTmInlineTextSource |
56 @see MTmInlineTextSource |
45 */ |
57 */ |
46 class MFormCustomInterfaceProvider |
58 class MFormCustomInterfaceProvider |
47 { |
59 { |
311 IMPORT_C virtual void DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const; |
323 IMPORT_C virtual void DrawLineGraphics(const TParam& aParam,const TLineInfo& aLineInfo) const; |
312 IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat, |
324 IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat, |
313 const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const; |
325 const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const; |
314 IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; |
326 IMPORT_C virtual TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; |
315 |
327 |
316 IMPORT_C virtual void MFormCustomDraw_Reserved_1(); |
328 IMPORT_C virtual void DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat, |
|
329 const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const; |
317 IMPORT_C virtual void MFormCustomDraw_Reserved_2(); |
330 IMPORT_C virtual void MFormCustomDraw_Reserved_2(); |
318 }; |
331 }; |
319 |
332 |
320 |
333 |
321 /** |
334 /** |
381 Const ref to the calling CLayDocTextSource |
394 Const ref to the calling CLayDocTextSource |
382 @return |
395 @return |
383 The replacement character if remapping has taken place, else return original character |
396 The replacement character if remapping has taken place, else return original character |
384 */ |
397 */ |
385 virtual TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc) = 0; |
398 virtual TUint Remap(TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc) = 0; |
386 }; |
|
387 |
|
388 |
|
389 /** |
|
390 @internalTechnology |
|
391 Internal to Symbian |
|
392 */ |
|
393 NONSHARABLE_CLASS(TLayDocTextSource) : public MTmSource, public MFormLabelApi, public MTmTextDrawExt |
|
394 { |
|
395 public: |
|
396 |
|
397 enum |
|
398 { |
|
399 EDefaultFontHeightIncreaseFactor = 7, |
|
400 EDefaultMinimumLineDescent = 3 |
|
401 }; |
|
402 |
|
403 TLayDocTextSource(); |
|
404 |
|
405 // overrides for MTmSource pure virtual functions |
|
406 MGraphicsDeviceMap& FormatDevice() const; |
|
407 MGraphicsDeviceMap& InterpretDevice() const; |
|
408 TInt DocumentLength() const; |
|
409 void GetText(TInt aPos,TPtrC& aText,TTmCharFormat& aFormat) const; |
|
410 void GetParagraphFormatL(TInt aPos,RTmParFormat& aFormat) const; |
|
411 TInt ParagraphStart(TInt aPos) const; |
|
412 |
|
413 // overrides for other MTmSource virtual functions |
|
414 TRgb SystemColor(TUint aColorIndex,TRgb aDefaultColor) const; |
|
415 CPicture* PictureL(TInt aPos) const; |
|
416 TInt GetPictureSizeInTwipsL(TInt aPos,TSize& aSize) const; |
|
417 TBool LabelModeSelect(TLabelType aType, TInt aPos); |
|
418 void LabelModeCancel(); |
|
419 void LabelMetrics(TLabelType aType, TSize& aLabelSize, TInt& aMarginSize) const; |
|
420 TUint Map(TUint aChar) const; |
|
421 void SetLineHeight(const TLineHeightParam& aParam,TInt& aAscent,TInt& aDescent) const; |
|
422 TBool PageBreakInRange(TInt aStartPos,TInt aEndPos) const; |
|
423 void DrawBackground(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, |
|
424 const TLogicalRgb& aBackground,TRect& aRectDrawn) const; |
|
425 void DrawLineGraphics(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, |
|
426 const TTmLineInfo& aLineInfo) const; |
|
427 void DrawText(CGraphicsContext& aGc,const TPoint& aTextLayoutTopLeft,const TRect& aRect, |
|
428 const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat, |
|
429 const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const; |
|
430 virtual void DrawPicture(CGraphicsContext& aGc, |
|
431 const TPoint& aTextLayoutTopLeft, const TRect& aRect, |
|
432 MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const; |
|
433 |
|
434 // overrides for the MTmSource virtual functions which implements the MFormCustomWrap |
|
435 // if iCustomWrap is set. |
|
436 TBool LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const; |
|
437 TUint LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const; |
|
438 TBool GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos, |
|
439 TBool aForwards,TInt& aBreakPos) const; |
|
440 TBool IsHangingCharacter(TUint aChar) const; |
|
441 |
|
442 // other functions |
|
443 TBool CanMap() const; |
|
444 |
|
445 TAny* GetExtendedInterface(const TUid& aInterfaceId); |
|
446 |
|
447 //MTmTextDrawExt implementations |
|
448 virtual void DrawLine(CGraphicsContext& aGc, const TPoint& aPt1, const TPoint& aPt2) const; |
|
449 virtual void DrawText(CGraphicsContext& aGc, const TDesC& aText, const TPoint& aPt) const; |
|
450 virtual void DrawRect(CGraphicsContext& aGc, const TRect& aRc) const; |
|
451 |
|
452 //Set/reset opaque flag of aGc graphics context |
|
453 void SetOpaque(CGraphicsContext& aGc) const; |
|
454 void ResetOpaque(CGraphicsContext& aGc) const; |
|
455 |
|
456 // flags |
|
457 enum |
|
458 { |
|
459 EWrap = 1, |
|
460 ETruncateWithEllipsis = 2, |
|
461 EUseLabelsDevice = 4 |
|
462 }; |
|
463 |
|
464 MLayDoc* iLayDoc; |
|
465 TUint iFlags; // wrap, truncate, etc. |
|
466 TInt iWidth; // wrapping width |
|
467 TChar iEllipsis; // ellipsis character (or none if 0xFFFF) used if truncating |
|
468 TInt iLabelsWidth; |
|
469 TInt iLabelsGutter; |
|
470 CLayoutData::TFormatMode iFormatMode; |
|
471 MGraphicsDeviceMap* iImageDevice; // device map used for drawing text |
|
472 MGraphicsDeviceMap* iLabelsDevice; // device map used for labels |
|
473 MGraphicsDeviceMap* iFormatDevice; // device map used for formatting |
|
474 TInt iFontHeightIncreaseFactor; // percentage automatically added to font heights |
|
475 TInt iMinimumLineDescent; // minimum line descent in pixels |
|
476 TNonPrintingCharVisibility iNonPrintingCharVisibility; |
|
477 const MFormParam* iFormParam; // if non-null, points to the object that supplies system colours |
|
478 const MFormCustomDraw* iCustomDraw; // if non-null, points to custom drawing routines |
|
479 const MFormCustomWrap* iCustomWrap; // if non-null, points to custom wrapping routines |
|
480 /** Optional object able to provide a concrete customisation object for use |
|
481 internally by Form. */ |
|
482 MFormCustomInterfaceProvider* iInterfaceProvider; |
|
483 TBool iDrawOpaque; // Opaque drawing active if the flag is ETrue |
|
484 TInt iExcessHeightRequired; // delta required to position the baseline so there is enough |
|
485 // space for the highset glyph in pixels. |
|
486 MFormCustomInvisibleCharacterRemapper* iInvisibleCharacterRemapper; // Used to customize the remapping of |
|
487 // invisible characters to visible characters |
|
488 }; |
399 }; |
489 |
400 |
490 /** |
401 /** |
491 Text layout. |
402 Text layout. |
492 |
403 |
770 IMPORT_C TBool FormatNextLineL(TInt& aBotPixel); |
683 IMPORT_C TBool FormatNextLineL(TInt& aBotPixel); |
771 IMPORT_C TBool FormatLineL(CParaFormat* aParaFormat,TInt& aDocPos,TInt& aHeight,TBool& aPageBreak); |
684 IMPORT_C TBool FormatLineL(CParaFormat* aParaFormat,TInt& aDocPos,TInt& aHeight,TBool& aPageBreak); |
772 IMPORT_C TInt ScrollParagraphsL(TInt& aNumParas,TAllowDisallow aScrollBlankSpace); |
685 IMPORT_C TInt ScrollParagraphsL(TInt& aNumParas,TAllowDisallow aScrollBlankSpace); |
773 IMPORT_C TInt ScrollLinesL(TInt& aNumLines,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace); |
686 IMPORT_C TInt ScrollLinesL(TInt& aNumLines,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace); |
774 IMPORT_C TInt ChangeBandTopL(TInt& aPixels,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace); |
687 IMPORT_C TInt ChangeBandTopL(TInt& aPixels,TAllowDisallow aScrollBlankSpace = EFDisallowScrollingBlankSpace); |
|
688 IMPORT_C void ChangeBandTopNoLimitBorderL(TInt aPixels); |
775 IMPORT_C void PageUpL(TInt& aYCursorPos,TInt& aPixelsScrolled); |
689 IMPORT_C void PageUpL(TInt& aYCursorPos,TInt& aPixelsScrolled); |
776 IMPORT_C void PageDownL(TInt& aYCursorPos,TInt& aPixelsScrolled); |
690 IMPORT_C void PageDownL(TInt& aYCursorPos,TInt& aPixelsScrolled); |
777 IMPORT_C TBool HandleCharEditL(TUint aType,TInt& aCursorPos,TInt& aGood,TInt& aFormattedUpTo, |
691 IMPORT_C TBool HandleCharEditL(TUint aType,TInt& aCursorPos,TInt& aGood,TInt& aFormattedUpTo, |
778 TInt& aFormattedFrom,TInt& aScroll,TBool aFormatChanged); |
692 TInt& aFormattedFrom,TInt& aScroll,TBool aFormatChanged); |
779 IMPORT_C void HandleBlockChangeL(TCursorSelection aSelection,TInt aOldCharsChanged,TViewRectChanges& aViewChanges, |
693 IMPORT_C void HandleBlockChangeL(TCursorSelection aSelection,TInt aOldCharsChanged,TViewRectChanges& aViewChanges, |
796 const TDrawTextLayoutContext* aDrawTextLayoutContext); |
710 const TDrawTextLayoutContext* aDrawTextLayoutContext); |
797 IMPORT_C void SetCustomDraw(const MFormCustomDraw* aCustomDraw); |
711 IMPORT_C void SetCustomDraw(const MFormCustomDraw* aCustomDraw); |
798 IMPORT_C const MFormCustomDraw* CustomDraw() const; |
712 IMPORT_C const MFormCustomDraw* CustomDraw() const; |
799 IMPORT_C void SetCustomWrap(const MFormCustomWrap* aCustomWrap); |
713 IMPORT_C void SetCustomWrap(const MFormCustomWrap* aCustomWrap); |
800 IMPORT_C const MFormCustomWrap* CustomWrap() const; |
714 IMPORT_C const MFormCustomWrap* CustomWrap() const; |
|
715 /* this function should only used by Symbian internally */ |
801 IMPORT_C void ExtendFormattingToCoverYL(TInt aYPos); |
716 IMPORT_C void ExtendFormattingToCoverYL(TInt aYPos); |
802 IMPORT_C void ExtendFormattingToCoverPosL(TInt aDocPos); |
717 IMPORT_C void ExtendFormattingToCoverPosL(TInt aDocPos); |
803 |
718 |
804 IMPORT_C TInt GetLineNumber(TInt aDocPos); |
719 IMPORT_C TInt GetLineNumber(TInt aDocPos); |
805 IMPORT_C void SetHighlightExtensions(TInt aLeftExtension, TInt aRightExtension, TInt aTopExtension, TInt aBottomExtension); |
720 IMPORT_C void SetHighlightExtensions(TInt aLeftExtension, TInt aRightExtension, TInt aTopExtension, TInt aBottomExtension); |
870 |
785 |
871 private: |
786 private: |
872 IMPORT_C CTextLayout(); |
787 IMPORT_C CTextLayout(); |
873 IMPORT_C void ConstructL(MLayDoc *aDoc,TInt aWrapWidth); |
788 IMPORT_C void ConstructL(MLayDoc *aDoc,TInt aWrapWidth); |
874 void InitFormatParam(TTmFormatParamBase& aParam); |
789 void InitFormatParam(TTmFormatParamBase& aParam); |
875 TInt ScrollL(TInt aDy,TAllowDisallow aScrollBlankSpace); |
790 TInt ScrollL(TInt aDy,TAllowDisallow aScrollBlankSpace,TBool aTopNoLimitBorder=EFalse,TBool aBottomNoLimitBorder=EFalse); |
876 void FormatBandL(TInt aStartDocPos,TInt aEndDocPos); |
791 void FormatBandL(TInt aStartDocPos,TInt aEndDocPos); |
877 void PruneFormatL(TBool aFromStart); |
792 void PruneFormatL(TBool aFromStart); |
878 TInt VisibleHeightInPixels() const; |
793 TInt VisibleHeightInPixels() const; |
879 TInt BandHeightInPixels() const; |
794 TInt BandHeightInPixels() const; |
880 TInt SuggestCursorPos(TInt aCurrentCursorPos) const; |
795 TInt SuggestCursorPos(TInt aCurrentCursorPos) const; |
895 TBool iIsWndInExternalRedraw; // If ETrue, then iWnd->EndRedraw() will not be called |
811 TBool iIsWndInExternalRedraw; // If ETrue, then iWnd->EndRedraw() will not be called |
896 // from within CTextLayout::EndRedraw() as the window redraw |
812 // from within CTextLayout::EndRedraw() as the window redraw |
897 // has been initiated externally and will be ended externally as well |
813 // has been initiated externally and will be ended externally as well |
898 TBool iReadyToRedraw; // If EFalse, disables CTextLayout::BeginRedraw() and |
814 TBool iReadyToRedraw; // If EFalse, disables CTextLayout::BeginRedraw() and |
899 // CTextLayout::EndRedraw() |
815 // CTextLayout::EndRedraw() |
900 TInt iDummy[5]; // This dummy variable has been inserted to replace the original size of |
816 TInt iDummy[4]; // This dummy variable has been inserted to replace the original size of |
901 // a variable that had to be moved to avaid a BC break because it had |
817 // a variable that had to be moved to avaid a BC break because it had |
902 // increased in size. Feel free to reuse this space - just reduce the size |
818 // increased in size. Feel free to reuse this space - just reduce the size |
903 // of this variable by the size of any variable you insert in front of it. |
819 // of this variable by the size of any variable you insert in front of it. |
904 // Currently it occupies 5 words. |
820 // Currently it occupies 5 words. |
905 TInt iBandTop; // effectively, scroll position: subtract this from CTmTextLayout y position |
821 TInt iBandTop; // effectively, scroll position: subtract this from CTmTextLayout y position |
912 // if < KMaxTInt, background formatting can be used |
828 // if < KMaxTInt, background formatting can be used |
913 // (by calling FormatNextLine) to format the remainder |
829 // (by calling FormatNextLine) to format the remainder |
914 TBool iParInvalid; // if true and background formatting is happening, the remainder of the paragraph |
830 TBool iParInvalid; // if true and background formatting is happening, the remainder of the paragraph |
915 // containing iUnformattedStart is invalid and must be reformatted; |
831 // containing iUnformattedStart is invalid and must be reformatted; |
916 // otherwise, formatting stops when line ends match |
832 // otherwise, formatting stops when line ends match |
917 TTmHighlightExtensions iHighlightExtensions; |
833 TTmHighlightExtensions *iHighlightExtensions; |
918 TLayDocTextSource iSource; // the source of the text |
834 TInt iDmmyForIHighlightExtensions[3]; // It is only here to add padding for maintain compatibility |
|
835 TLayDocTextSource* iSource; // the source of the text |
919 // before adding any new member variables to the end of this class, please |
836 // before adding any new member variables to the end of this class, please |
920 // consider whether you can insert them before the iDummy member variable |
837 // consider whether you can insert them before the iDummy member variable |
921 // further up, which currently represents wasted space. |
838 // further up, which currently represents wasted space. |
|
839 TInt iDmmyForISource[23]; // It is only here to add padding for maintain compatibility |
922 }; |
840 }; |
923 |
841 |
924 /** |
842 /** |
925 Cursor position. |
843 Cursor position. |
926 |
844 |