williamr@2: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@2: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #ifndef BIDITEXT_H_ williamr@2: #define BIDITEXT_H_ williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include // class TBidirectionalState::TRunInfo williamr@2: enum CGraphicsContext::TTextAlign; williamr@2: class MLineBreaker; williamr@2: class RRunInfoArray; williamr@2: class CBidiTextTls; williamr@2: williamr@2: williamr@2: /** williamr@2: This enumeration holds the possible panic codes that may be raised williamr@2: by the BidiText API on detecting an unrecoverable error. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: enum TBidiPanic williamr@2: { williamr@2: /** The call to RRunInfoArray::OpenL() has not been made prior to this call to TBidiText::SetText() williamr@2: @see TBidiText::SetText */ williamr@2: EBidiPanic_RunArrayNull = 0, williamr@2: williamr@2: /** Maximum number of lines that the text will need to be split into is invalid i.e less than zero or negative. williamr@2: @see TBidiText::NewL williamr@2: @see TBidiText::MinimumSize */ williamr@2: EBidiPanic_InvalidMaxline = 1, williamr@2: williamr@2: /** Maximum number of characters are invalid i.e less than zero or negative. williamr@2: @see TBidiText::NewL */ williamr@2: EBidiPanic_InvalidReservedMaxLength = 2, williamr@2: williamr@2: /** Maximum width of the text in pixels is invalid i.e zero or negative. williamr@2: @see TBidiText::MinimumSize */ williamr@2: EBidiPanic_InvalidWrappingWidth = 3, williamr@2: williamr@2: /** Number of empty pixels between two lines of text are invalid i.e zero or negative. williamr@2: @see TBidiText::MinimumSize */ williamr@2: EBidiPanic_InvalidLineGap = 4, williamr@2: williamr@2: /** Text length for display is invalid i.e zero or negative. williamr@2: @see TBidiText::DisplayText williamr@2: @see TBidiText::LineOfDisplayText */ williamr@2: EBidiPanic_InvalidVisualOrderedTextLength = 5, williamr@2: williamr@2: /** Line number to retrieve is invalid i.e zero or negative. williamr@2: @see TBidiText::LineOfDisplayText */ williamr@2: EBidiPanic_InvalidLineNumber = 6 williamr@2: }; williamr@2: williamr@2: /** williamr@2: This class works as a replacement for HBufC in those cases where a small williamr@2: amount of text is being formatted simply. The text must be all of one style williamr@2: and broken into lines of all the same length. The number of lines and the text williamr@2: itself is specified on construction, and the text may then be re-broken, williamr@2: re-truncated and re-drawn with non-leaving functions. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class TBidiText williamr@2: { williamr@2: public: williamr@2: /** Overall directionality of the text. */ williamr@2: enum TDirectionality williamr@2: { williamr@2: /** Text reading begins on the left. */ williamr@2: ELeftToRight = 0, williamr@2: /** Text reading begins on the right. */ williamr@2: ERightToLeft = 1 williamr@2: }; williamr@2: williamr@2: /** Class specific panic codes williamr@2: @deprecated This enum has been replaced by TBidiPanic. williamr@2: */ williamr@2: enum TPanicCodes williamr@2: { williamr@2: EPanicRunArrayNull, williamr@2: }; williamr@2: williamr@2: IMPORT_C static TDirectionality ScriptDirectionality(TLanguage aLanguage); williamr@2: IMPORT_C static TDirectionality TextDirectionality( williamr@2: const TDesC& aText, TBool* aFound = 0); williamr@2: protected: williamr@2: TBidiText(); williamr@2: public: williamr@2: IMPORT_C static TBidiText* NewL(TInt aReservedMaxLength, TInt aMaxLines); williamr@2: IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines); williamr@2: IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines, williamr@2: TDirectionality aDirectionality); williamr@2: IMPORT_C TInt SetText(const TDesC& aText, RRunInfoArray& aRunInfoArray); williamr@2: IMPORT_C TInt SetText(const TDesC& aText, TDirectionality aDirectionality, RRunInfoArray& aRunInfoArray); williamr@2: IMPORT_C void SetTruncationChar(TChar aTruncateWith); williamr@2: IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont, williamr@2: const MLineBreaker* aBreaker, TInt aMaxLines); williamr@2: IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont, williamr@2: const MLineBreaker* aBreaker = NULL); williamr@2: IMPORT_C TSize MinimumSize(TInt aWrappingWidth, const CFont& aFont, TInt aLineGap, TInt aMaxLines = -1, williamr@2: const MLineBreaker* aBreaker = NULL) const; williamr@2: IMPORT_C TPtrC Text() const; williamr@2: IMPORT_C TPtrC DisplayText() const; williamr@2: IMPORT_C TInt WrappingWidth() const; williamr@2: IMPORT_C TDirectionality Directionality() const; williamr@2: IMPORT_C TChar TruncationChar() const; williamr@2: IMPORT_C TInt NumberOfLinesInDisplayText() const; williamr@2: IMPORT_C TPtrC LineOfDisplayText(TInt aLine, TInt& aWidthInPixels) const; williamr@2: IMPORT_C void DrawText(CGraphicsContext& aGc, const TPoint& aLeft) const; williamr@2: IMPORT_C void DrawText(CGraphicsContext& aGc, williamr@2: const TPoint& aLeft, TInt aBaseLineSpacing, williamr@2: CGraphicsContext::TTextAlign aAlignment) const; williamr@2: IMPORT_C void DrawText(CGraphicsContext& aGc, williamr@2: const TPoint& aLeft, TInt aBaseLineSpacing) const; williamr@2: private: williamr@2: TInt DoWrapText(TInt aWrappingWidth, const CFont& aFont, const MLineBreaker* aBreaker, williamr@2: TInt aMaxLines, TText*& aOutputText, TInt& aNumLines, TInt16* aLineWidthArray) const; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: This class is used to keep track of the shared run info array. williamr@2: Keep it open for as long as the TBidiText object is used. The same williamr@2: RRunInfoArray object can be used with several different TBidiText objects. williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: class RRunInfoArray williamr@2: { williamr@2: friend class TBidiText; williamr@2: williamr@2: public: williamr@2: IMPORT_C RRunInfoArray(); williamr@2: IMPORT_C void OpenL(); williamr@2: IMPORT_C void Close(); williamr@2: williamr@2: private: williamr@2: TBidirectionalState::TRunInfo* RunArray() const; williamr@2: williamr@2: private: williamr@2: CBidiTextTls* iTls; williamr@2: }; williamr@2: williamr@2: #endif