epoc32/include/biditext.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 biditext.h
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // 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
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef BIDITEXT_H_
       
    17 #define BIDITEXT_H_
       
    18 
       
    19 #include <e32std.h>
       
    20 #include <gdi.h>
       
    21 #include <bidi.h> // class TBidirectionalState::TRunInfo
       
    22 enum CGraphicsContext::TTextAlign;
       
    23 class MLineBreaker;
       
    24 class RRunInfoArray;
       
    25 class CBidiTextTls;
       
    26 
       
    27 
       
    28 /**
       
    29 This enumeration holds the possible panic codes that may be raised 
       
    30 by the BidiText API on detecting an unrecoverable error.
       
    31 @publishedAll
       
    32 @released
       
    33 */
       
    34 enum TBidiPanic
       
    35 	{
       
    36 	/** The call to RRunInfoArray::OpenL() has not been made prior to this call to TBidiText::SetText()
       
    37 	@see TBidiText::SetText	*/
       
    38 	EBidiPanic_RunArrayNull						= 0,
       
    39 	
       
    40 	/** Maximum number of lines that the text will need to be split into is invalid i.e less than zero or negative.
       
    41 	@see TBidiText::NewL
       
    42 	@see TBidiText::MinimumSize	*/
       
    43 	EBidiPanic_InvalidMaxline					= 1,
       
    44 	
       
    45 	/** Maximum number of characters are invalid i.e less than zero or negative.
       
    46 	@see TBidiText::NewL */
       
    47 	EBidiPanic_InvalidReservedMaxLength			= 2,
       
    48 	
       
    49 	/** Maximum width of the text in pixels is invalid i.e zero or negative.
       
    50 	@see TBidiText::MinimumSize */
       
    51 	EBidiPanic_InvalidWrappingWidth				= 3,
       
    52 	
       
    53 	/** Number of empty pixels between two lines of text are invalid i.e zero or negative.
       
    54 	@see TBidiText::MinimumSize */
       
    55 	EBidiPanic_InvalidLineGap					= 4,
       
    56 	
       
    57 	/** Text length for display is invalid i.e zero or negative.
       
    58 	@see TBidiText::DisplayText
       
    59 	@see TBidiText::LineOfDisplayText */
       
    60 	EBidiPanic_InvalidVisualOrderedTextLength	= 5,
       
    61 	
       
    62 	/** Line number to retrieve is invalid i.e zero or negative. 
       
    63 	@see TBidiText::LineOfDisplayText */
       
    64 	EBidiPanic_InvalidLineNumber				= 6
       
    65 	};
       
    66 
       
    67 /** 
       
    68 This class works as a replacement for HBufC in those cases where a small 
       
    69 amount of text is being formatted simply. The text must be all of one style 
       
    70 and broken into lines of all the same length. The number of lines and the text 
       
    71 itself is specified on construction, and the text may then be re-broken, 
       
    72 re-truncated and re-drawn with non-leaving functions. 
       
    73 @publishedAll
       
    74 @released
       
    75 */
       
    76 class TBidiText
       
    77 	{
       
    78 public:
       
    79 	/** Overall directionality of the text. */
       
    80 	enum TDirectionality
       
    81 		{
       
    82 		/** Text reading begins on the left. */
       
    83 		ELeftToRight = 0,
       
    84 		/** Text reading begins on the right. */
       
    85 		ERightToLeft = 1
       
    86 		};
       
    87 
       
    88 	/** Class specific panic codes 
       
    89 	@deprecated This enum has been replaced by TBidiPanic.
       
    90     */
       
    91 	enum TPanicCodes
       
    92 		{
       
    93 		EPanicRunArrayNull,
       
    94 		};
       
    95 
       
    96 	IMPORT_C static TDirectionality ScriptDirectionality(TLanguage aLanguage);
       
    97 	IMPORT_C static TDirectionality TextDirectionality(
       
    98 		const TDesC& aText, TBool* aFound = 0);
       
    99 protected:
       
   100 	/** @internalComponent */
       
   101 	TBidiText();
       
   102 public:
       
   103 	IMPORT_C static TBidiText* NewL(TInt aReservedMaxLength, TInt aMaxLines);
       
   104 	IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines);
       
   105 	IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines,
       
   106 		TDirectionality aDirectionality);
       
   107 	IMPORT_C TInt SetText(const TDesC& aText, RRunInfoArray& aRunInfoArray);
       
   108 	IMPORT_C TInt SetText(const TDesC& aText, TDirectionality aDirectionality, RRunInfoArray& aRunInfoArray);
       
   109 	IMPORT_C void SetTruncationChar(TChar aTruncateWith);
       
   110 	IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont,
       
   111 		const MLineBreaker* aBreaker, TInt aMaxLines);
       
   112 	IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont,
       
   113 		const MLineBreaker* aBreaker = NULL);
       
   114 	IMPORT_C TSize MinimumSize(TInt aWrappingWidth, const CFont& aFont, TInt aLineGap, TInt aMaxLines = -1,
       
   115 		const MLineBreaker* aBreaker = NULL) const;	
       
   116 	IMPORT_C TPtrC Text() const;
       
   117 	IMPORT_C TPtrC DisplayText() const;
       
   118 	IMPORT_C TInt WrappingWidth() const;
       
   119 	IMPORT_C TDirectionality Directionality() const;
       
   120 	IMPORT_C TChar TruncationChar() const;
       
   121 	IMPORT_C TInt NumberOfLinesInDisplayText() const;
       
   122 	IMPORT_C TPtrC LineOfDisplayText(TInt aLine, TInt& aWidthInPixels) const;
       
   123 	IMPORT_C void DrawText(CGraphicsContext& aGc, const TPoint& aLeft) const;
       
   124 	IMPORT_C void DrawText(CGraphicsContext& aGc,
       
   125 		const TPoint& aLeft, TInt aBaseLineSpacing,
       
   126 		CGraphicsContext::TTextAlign aAlignment) const;
       
   127 	IMPORT_C void DrawText(CGraphicsContext& aGc,
       
   128 		const TPoint& aLeft, TInt aBaseLineSpacing) const;
       
   129 private:
       
   130 	TInt DoWrapText(TInt aWrappingWidth, const CFont& aFont, const MLineBreaker* aBreaker, 
       
   131 		TInt aMaxLines, TText*& aOutputText, TInt& aNumLines, TInt16* aLineWidthArray) const;
       
   132 	};
       
   133 
       
   134 
       
   135 /**
       
   136 This class is used to keep track of the shared run info array. 
       
   137 Keep it open for as long as the TBidiText object is used. The same
       
   138 RRunInfoArray object can be used with several different TBidiText objects.
       
   139 @publishedAll
       
   140 @released
       
   141 */
       
   142 class RRunInfoArray
       
   143 	{
       
   144 	friend class TBidiText;
       
   145 
       
   146 public:	
       
   147 	IMPORT_C RRunInfoArray();
       
   148 	IMPORT_C void OpenL();
       
   149 	IMPORT_C void Close();
       
   150 
       
   151 private:
       
   152 	TBidirectionalState::TRunInfo* RunArray() const;
       
   153 
       
   154 private:
       
   155 	CBidiTextTls* iTls;
       
   156 	};
       
   157 
       
   158 #endif