sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef BIDITEXTIMP_H_ sl@0: #define BIDITEXTIMP_H_ sl@0: sl@0: #include "BidiText.h" sl@0: sl@0: class TRunInfoCompact; sl@0: sl@0: class TBidiTextImp : public TBidiText sl@0: /** This is the implementation for the class TBidiText. It is so designed so sl@0: that it only occupies a single heap cell. This means that it is efficient in sl@0: memory usage, and can be placed on the cleanup stack without being a C-class. sl@0: @internalComponent */ sl@0: { sl@0: public: sl@0: static TBidiTextImp* NewL(TInt aLength, TInt aMaxLines, TInt aBdRunArraySize); sl@0: static TBidiTextImp* Imp(TBidiText* aSelf); sl@0: static const TBidiTextImp* Imp(const TBidiText* aSelf); sl@0: static TInt AlignedSizeOf(); sl@0: TText* LogicalText(); sl@0: TText* VisualText(); sl@0: TInt16* LineWidthArray(); sl@0: TRunInfoCompact* BidiRunArray(); sl@0: const TText* LogicalText() const sl@0: { return const_cast(this)->LogicalText(); } sl@0: const TText* VisualText() const sl@0: { return const_cast(this)->VisualText(); } sl@0: const TInt16* LineWidthArray() const sl@0: { return const_cast(this)->LineWidthArray(); } sl@0: const TRunInfoCompact* BidiRunArray() const sl@0: { return const_cast(this)->BidiRunArray(); } sl@0: /** sl@0: @return Current truncation character. sl@0: @internalComponent */ sl@0: TChar TruncationChar() const sl@0: { return static_cast(iTruncationCharPlane << 16) sl@0: + iTruncationChar16; } sl@0: sl@0: inline TInt TextLength() const; sl@0: inline void SetTextLength(TInt aLength); sl@0: inline TBool HasRightToLeftDirectionality() const; sl@0: inline void SetRightToLeftDirectionality(TBool aRightToLeftDirectionality); sl@0: sl@0: static TInt RequiredBytes(TInt aLendth, TInt aMaxLines, TInt aBdRunArraySize); sl@0: inline TInt AllocatedTextDataBytes() const; sl@0: sl@0: private: sl@0: inline void SetAllocatedTextDataBytes(TInt aMaxBytes); sl@0: enum TFlags sl@0: { sl@0: EFRightToLeft = 0x10000000, sl@0: EFTruncateAtBeginning = 0x20000000 sl@0: }; sl@0: sl@0: enum { ELengthMask = 0x0FFFFFFF }; sl@0: TInt iTextLengthAndFlags; sl@0: TInt iTextDataBytes; // Number of bytes allocated off the end of the object for text data sl@0: public: sl@0: TInt iVisualOrderedTextLength; sl@0: TUint16 iWrappingWidth; sl@0: TUint16 iBidiRunArrayLength; sl@0: TUint8 iLines; sl@0: TUint8 iTruncationCharPlane; sl@0: TUint16 iTruncationChar16; sl@0: }; sl@0: sl@0: TInt SizeLineBreak(const TText* aText); sl@0: const TText* FindEndOfThisLine(const TText* aStart, const TText* aEnd); sl@0: TInt NumberOfLines(const TText* aStart, const TText* aEnd); sl@0: sl@0: inline TBidiTextImp* TBidiTextImp::Imp(TBidiText* aSelf) sl@0: { return static_cast(aSelf); } sl@0: sl@0: inline const TBidiTextImp* TBidiTextImp::Imp(const TBidiText* aSelf) sl@0: { return static_cast(aSelf); } sl@0: sl@0: inline TInt TBidiTextImp::AlignedSizeOf() sl@0: { return ((sizeof(TBidiTextImp) + 1) & 0xFFFFFFFE); } sl@0: sl@0: inline TInt TBidiTextImp::TextLength() const sl@0: { return iTextLengthAndFlags & TBidiTextImp::ELengthMask; } sl@0: sl@0: inline void TBidiTextImp::SetTextLength(TInt aLength) sl@0: { iTextLengthAndFlags &= ~ELengthMask; // clear old size bits sl@0: iTextLengthAndFlags |= (aLength&ELengthMask); } // set new size bits sl@0: sl@0: inline TBool TBidiTextImp::HasRightToLeftDirectionality() const sl@0: { return iTextLengthAndFlags&TBidiTextImp::EFRightToLeft; } sl@0: sl@0: inline void TBidiTextImp::SetRightToLeftDirectionality(TBool aRightToLeftDirectionality) sl@0: { sl@0: if (aRightToLeftDirectionality) sl@0: iTextLengthAndFlags |= TBidiTextImp::EFRightToLeft; sl@0: else sl@0: iTextLengthAndFlags &= ~TBidiTextImp::EFRightToLeft; sl@0: } sl@0: sl@0: inline TInt TBidiTextImp::AllocatedTextDataBytes() const sl@0: { return iTextDataBytes; } sl@0: sl@0: inline void TBidiTextImp::SetAllocatedTextDataBytes(TInt aTextDataBytes) sl@0: { iTextDataBytes = aTextDataBytes; } sl@0: sl@0: sl@0: /** sl@0: Bidi panic. sl@0: @internalComponent sl@0: */ sl@0: void Panic(TInt aError); sl@0: sl@0: #endif