epoc32/include/txtlaydc.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #ifndef __TXTLAYDC_H__
    20 #define __TXTLAYDC_H__
    21 
    22 #include <e32std.h>
    23 
    24 class CParaFormat;
    25 class TCharFormat;
    26 class CPicture;
    27 
    28 
    29 class MLayDoc
    30 /** 
    31 Specifies the interface for providing the information needed by the text 
    32 layout engine to lay out a text object. 
    33 
    34 Examples of derived classes are CRichText and CGlobalText.
    35 
    36 At the heart of the interface are two interrogation functions; one gives the 
    37 paragraph formatting for a document position, and the other gives a pointer 
    38 descriptor to a series of contiguous characters with identical character 
    39 formatting, and their character formatting. This information is sufficient 
    40 for the layout engine to find the formatting and content of an entire document.
    41 
    42 The constructor for the layout engine (CTextLayout) is prototyped as:
    43 static CTextLayout *NewL(MLayDoc *aDoc,TInt aWrapWidth);
    44 By viewing the text object purely in terms of the MLayDoc interface, the layout 
    45 engine is insulated from any editable text implementation issues.
    46 @see static CTextLayout *NewL(MLayDoc *aDoc,TInt aWrapWidth)
    47 @publishedAll
    48 @released
    49 */
    50 	{
    51 	// Defines interface for extracting content & format information from text source.
    52 	// Designed to be 'mixed-in' with other classes.
    53 	//
    54 public:
    55 	
    56 	/** Used as a parameter to the PictureHandleL() function to control whether 
    57 	picture data should be loaded into memory or not. */
    58 	enum TForcePictureLoad 
    59 		{
    60 		/** Do not load the picture data into memory. */
    61 		EForceLoadFalse,
    62 		/** Load the picture data into memory. */
    63 		EForceLoadTrue
    64 		};
    65 public:
    66 		
    67 	/** Gets the the number of characters in the document.
    68 	
    69 	@return The number of characters contained in the document. */
    70 	virtual TInt LdDocumentLength()const=0;  // Does not include final document terminator
    71 
    72 	/** Gets the document position of the start of the paragraph containing a 
    73 	specified position.
    74 	
    75 	@param aCurrentPos A valid document position. On return contains the 
    76 	document position of the first character in the paragraph. 
    77 	@return The number of characters skipped in scanning to the start of the 
    78 	paragraph. */
    79 	virtual TInt LdToParagraphStart(TInt& aCurrentPos)const=0;
    80 		
    81 	/** Gets the effective paragraph formatting which applies to the paragraph 
    82 	which contains a specified document position. On return, aFormat is filled 
    83 	with values for all paragraph format attributes.
    84 	
    85 	@param aFormat On return, filled with the paragraph's effective paragraph 
    86 	formatting. 
    87 	@param aPos Any document position within the paragraph of interest. */
    88 	virtual void GetParagraphFormatL(CParaFormat* aFormat,TInt aPos)const=0;
    89 	
    90 	/** Gets a constant pointer descriptor to a portion of the text object with 
    91 	constant character formatting. The view starts at the document position 
    92 	specified, and ends at: 
    93 	
    94 	the last character which shares the same character formatting (rich text 
    95 	only), or
    96 	
    97 	the end of the document, or
    98 	
    99 	the end of the segment, if segmented storage is being used
   100 	
   101 	whichever occurs first. 
   102 	
   103 	Also fills a character format object with the character formatting of the 
   104 	range of characters.
   105 	
   106 	@param aView On return, a constant pointer to a portion of the text. 
   107 	@param aFormat On return, contains the character formatting of the text. 
   108 	@param aStartPos The start position for the view. Must be a valid document 
   109 	position, or a panic occurs. */
   110 	virtual void GetChars(TPtrC& aView,TCharFormat& aFormat,TInt aStartPos)const=0;	
   111 
   112 	/** Gets the size of a picture located at a specified document position.
   113 	
   114 	Note: The global text implementation of this function always returns 
   115 	KErrNotFound because global text does not support pictures.
   116 	
   117 	@param aSize On return, contains the size of the picture located at aPos.
   118 	@param aPos Document position of the picture. 
   119 	@return KErrNotFound if there is no picture at the specified document 
   120 	position, KErrNone if there is. */
   121 	virtual TInt GetPictureSizeInTwips(TSize& aSize, TInt aPos)const=0;
   122 
   123 	/** Gets a pointer to the picture located at a specified document position, 
   124 	if one exists. If the picture is not in memory, the function loads it (if 
   125 	the second argument has a value of EForceLoadTrue).
   126 	
   127 	Note: The global text implementation of this function always returns NULL 
   128 	because global text does not support pictures.
   129 	
   130 	@param aPos Document position of the picture character. 
   131 	@param aForceLoad If the picture is not loaded into memory, EForceLoadTrue 
   132 	loads it using the picture factory; EForceLoadFalse does not, and in this 
   133 	case, the function returns NULL. 
   134 	@return A pointer to the picture located at aPos. NULL if aPos does not 
   135 	specify a picture character, or if there is a picture at aPos which is not 
   136 	in memory, and the second argument is EForceLoadFalse. */
   137 	virtual CPicture* PictureHandleL(TInt aPos,TForcePictureLoad aForceLoad=EForceLoadTrue)const=0;
   138 
   139 	/** Tests whether a page break occurs within a range of characters. A page 
   140 	table should have been set up first: see CPlainText::SetPageTable().
   141 	
   142 	@param aPos The document position from which to begin searching for a page 
   143 	break.
   144 	@param aLength The number of characters to search for a page break, 
   145 	beginning at aPos. The default is zero. 
   146 	@return ETrue if a page break occurs within the specified range, otherwise 
   147 	EFalse. */
   148 	virtual TBool EnquirePageBreak(TInt aPos,TInt aLength=0)const=0;
   149 	
   150 	/** This function should be implemented by text objects which support 
   151 	paragraph labels. Each paragraph may have at most one label. By default, 
   152 	the functions provided by MLayDoc apply to the main body of text. This 
   153 	function is provided to change this so that the MLayDoc object is an 
   154 	individual paragraph label, (each of which is treated as a separate 
   155 	document). Paragraph labelling has not been implemented by global or rich 
   156 	text.
   157 	
   158 	This function should select the paragraph label associated with the 
   159 	paragraph containing document position aPos (aPos is a document position 
   160 	in the main document).
   161 	
   162 	@param aPos A document position within a paragraph. This paragraph's label 
   163 	should be set as the main MLayDoc document. 
   164 	@return Should return EFalse if the paragraph has no label, in which case 
   165 	the function has no effect, ETrue otherwise. */
   166 	virtual TBool SelectParagraphLabel(TInt aPos)=0;
   167 
   168 	/** Cancels a paragraph label selection made by a call to 
   169 	SelectParagraphLabel() so that the main document reverts back to the main 
   170 	body of text. */
   171 	virtual void CancelSelectLabel()=0;
   172 	
   173 	/** This function is reserved for future purpose.
   174 	It should not be used externally for now.
   175 	@internalAll */
   176 	IMPORT_C virtual void MLayDoc_Reserved_1();
   177 	};
   178 
   179 #endif
   180