epoc32/include/biditext.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
     1.1 --- a/epoc32/include/biditext.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/biditext.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,158 @@
     1.4 -biditext.h
     1.5 +// Copyright (c) 2002-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 BIDITEXT_H_
    1.21 +#define BIDITEXT_H_
    1.22 +
    1.23 +#include <e32std.h>
    1.24 +#include <gdi.h>
    1.25 +#include <bidi.h> // class TBidirectionalState::TRunInfo
    1.26 +enum CGraphicsContext::TTextAlign;
    1.27 +class MLineBreaker;
    1.28 +class RRunInfoArray;
    1.29 +class CBidiTextTls;
    1.30 +
    1.31 +
    1.32 +/**
    1.33 +This enumeration holds the possible panic codes that may be raised 
    1.34 +by the BidiText API on detecting an unrecoverable error.
    1.35 +@publishedAll
    1.36 +@released
    1.37 +*/
    1.38 +enum TBidiPanic
    1.39 +	{
    1.40 +	/** The call to RRunInfoArray::OpenL() has not been made prior to this call to TBidiText::SetText()
    1.41 +	@see TBidiText::SetText	*/
    1.42 +	EBidiPanic_RunArrayNull						= 0,
    1.43 +	
    1.44 +	/** Maximum number of lines that the text will need to be split into is invalid i.e less than zero or negative.
    1.45 +	@see TBidiText::NewL
    1.46 +	@see TBidiText::MinimumSize	*/
    1.47 +	EBidiPanic_InvalidMaxline					= 1,
    1.48 +	
    1.49 +	/** Maximum number of characters are invalid i.e less than zero or negative.
    1.50 +	@see TBidiText::NewL */
    1.51 +	EBidiPanic_InvalidReservedMaxLength			= 2,
    1.52 +	
    1.53 +	/** Maximum width of the text in pixels is invalid i.e zero or negative.
    1.54 +	@see TBidiText::MinimumSize */
    1.55 +	EBidiPanic_InvalidWrappingWidth				= 3,
    1.56 +	
    1.57 +	/** Number of empty pixels between two lines of text are invalid i.e zero or negative.
    1.58 +	@see TBidiText::MinimumSize */
    1.59 +	EBidiPanic_InvalidLineGap					= 4,
    1.60 +	
    1.61 +	/** Text length for display is invalid i.e zero or negative.
    1.62 +	@see TBidiText::DisplayText
    1.63 +	@see TBidiText::LineOfDisplayText */
    1.64 +	EBidiPanic_InvalidVisualOrderedTextLength	= 5,
    1.65 +	
    1.66 +	/** Line number to retrieve is invalid i.e zero or negative. 
    1.67 +	@see TBidiText::LineOfDisplayText */
    1.68 +	EBidiPanic_InvalidLineNumber				= 6
    1.69 +	};
    1.70 +
    1.71 +/** 
    1.72 +This class works as a replacement for HBufC in those cases where a small 
    1.73 +amount of text is being formatted simply. The text must be all of one style 
    1.74 +and broken into lines of all the same length. The number of lines and the text 
    1.75 +itself is specified on construction, and the text may then be re-broken, 
    1.76 +re-truncated and re-drawn with non-leaving functions. 
    1.77 +@publishedAll
    1.78 +@released
    1.79 +*/
    1.80 +class TBidiText
    1.81 +	{
    1.82 +public:
    1.83 +	/** Overall directionality of the text. */
    1.84 +	enum TDirectionality
    1.85 +		{
    1.86 +		/** Text reading begins on the left. */
    1.87 +		ELeftToRight = 0,
    1.88 +		/** Text reading begins on the right. */
    1.89 +		ERightToLeft = 1
    1.90 +		};
    1.91 +
    1.92 +	/** Class specific panic codes 
    1.93 +	@deprecated This enum has been replaced by TBidiPanic.
    1.94 +    */
    1.95 +	enum TPanicCodes
    1.96 +		{
    1.97 +		EPanicRunArrayNull,
    1.98 +		};
    1.99 +
   1.100 +	IMPORT_C static TDirectionality ScriptDirectionality(TLanguage aLanguage);
   1.101 +	IMPORT_C static TDirectionality TextDirectionality(
   1.102 +		const TDesC& aText, TBool* aFound = 0);
   1.103 +protected:
   1.104 +	/** @internalComponent */
   1.105 +	TBidiText();
   1.106 +public:
   1.107 +	IMPORT_C static TBidiText* NewL(TInt aReservedMaxLength, TInt aMaxLines);
   1.108 +	IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines);
   1.109 +	IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines,
   1.110 +		TDirectionality aDirectionality);
   1.111 +	IMPORT_C TInt SetText(const TDesC& aText, RRunInfoArray& aRunInfoArray);
   1.112 +	IMPORT_C TInt SetText(const TDesC& aText, TDirectionality aDirectionality, RRunInfoArray& aRunInfoArray);
   1.113 +	IMPORT_C void SetTruncationChar(TChar aTruncateWith);
   1.114 +	IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont,
   1.115 +		const MLineBreaker* aBreaker, TInt aMaxLines);
   1.116 +	IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont,
   1.117 +		const MLineBreaker* aBreaker = NULL);
   1.118 +	IMPORT_C TSize MinimumSize(TInt aWrappingWidth, const CFont& aFont, TInt aLineGap, TInt aMaxLines = -1,
   1.119 +		const MLineBreaker* aBreaker = NULL) const;	
   1.120 +	IMPORT_C TPtrC Text() const;
   1.121 +	IMPORT_C TPtrC DisplayText() const;
   1.122 +	IMPORT_C TInt WrappingWidth() const;
   1.123 +	IMPORT_C TDirectionality Directionality() const;
   1.124 +	IMPORT_C TChar TruncationChar() const;
   1.125 +	IMPORT_C TInt NumberOfLinesInDisplayText() const;
   1.126 +	IMPORT_C TPtrC LineOfDisplayText(TInt aLine, TInt& aWidthInPixels) const;
   1.127 +	IMPORT_C void DrawText(CGraphicsContext& aGc, const TPoint& aLeft) const;
   1.128 +	IMPORT_C void DrawText(CGraphicsContext& aGc,
   1.129 +		const TPoint& aLeft, TInt aBaseLineSpacing,
   1.130 +		CGraphicsContext::TTextAlign aAlignment) const;
   1.131 +	IMPORT_C void DrawText(CGraphicsContext& aGc,
   1.132 +		const TPoint& aLeft, TInt aBaseLineSpacing) const;
   1.133 +private:
   1.134 +	TInt DoWrapText(TInt aWrappingWidth, const CFont& aFont, const MLineBreaker* aBreaker, 
   1.135 +		TInt aMaxLines, TText*& aOutputText, TInt& aNumLines, TInt16* aLineWidthArray) const;
   1.136 +	};
   1.137 +
   1.138 +
   1.139 +/**
   1.140 +This class is used to keep track of the shared run info array. 
   1.141 +Keep it open for as long as the TBidiText object is used. The same
   1.142 +RRunInfoArray object can be used with several different TBidiText objects.
   1.143 +@publishedAll
   1.144 +@released
   1.145 +*/
   1.146 +class RRunInfoArray
   1.147 +	{
   1.148 +	friend class TBidiText;
   1.149 +
   1.150 +public:	
   1.151 +	IMPORT_C RRunInfoArray();
   1.152 +	IMPORT_C void OpenL();
   1.153 +	IMPORT_C void Close();
   1.154 +
   1.155 +private:
   1.156 +	TBidirectionalState::TRunInfo* RunArray() const;
   1.157 +
   1.158 +private:
   1.159 +	CBidiTextTls* iTls;
   1.160 +	};
   1.161 +
   1.162 +#endif