First public contribution.
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 "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef BIDITEXTIMP_H_
17 #define BIDITEXTIMP_H_
21 class TRunInfoCompact;
23 class TBidiTextImp : public TBidiText
24 /** This is the implementation for the class TBidiText. It is so designed so
25 that it only occupies a single heap cell. This means that it is efficient in
26 memory usage, and can be placed on the cleanup stack without being a C-class.
30 static TBidiTextImp* NewL(TInt aLength, TInt aMaxLines, TInt aBdRunArraySize);
31 static TBidiTextImp* Imp(TBidiText* aSelf);
32 static const TBidiTextImp* Imp(const TBidiText* aSelf);
33 static TInt AlignedSizeOf();
36 TInt16* LineWidthArray();
37 TRunInfoCompact* BidiRunArray();
38 const TText* LogicalText() const
39 { return const_cast<TBidiTextImp*>(this)->LogicalText(); }
40 const TText* VisualText() const
41 { return const_cast<TBidiTextImp*>(this)->VisualText(); }
42 const TInt16* LineWidthArray() const
43 { return const_cast<TBidiTextImp*>(this)->LineWidthArray(); }
44 const TRunInfoCompact* BidiRunArray() const
45 { return const_cast<TBidiTextImp*>(this)->BidiRunArray(); }
47 @return Current truncation character.
49 TChar TruncationChar() const
50 { return static_cast<TInt>(iTruncationCharPlane << 16)
51 + iTruncationChar16; }
53 inline TInt TextLength() const;
54 inline void SetTextLength(TInt aLength);
55 inline TBool HasRightToLeftDirectionality() const;
56 inline void SetRightToLeftDirectionality(TBool aRightToLeftDirectionality);
58 static TInt RequiredBytes(TInt aLendth, TInt aMaxLines, TInt aBdRunArraySize);
59 inline TInt AllocatedTextDataBytes() const;
62 inline void SetAllocatedTextDataBytes(TInt aMaxBytes);
65 EFRightToLeft = 0x10000000,
66 EFTruncateAtBeginning = 0x20000000
69 enum { ELengthMask = 0x0FFFFFFF };
70 TInt iTextLengthAndFlags;
71 TInt iTextDataBytes; // Number of bytes allocated off the end of the object for text data
73 TInt iVisualOrderedTextLength;
74 TUint16 iWrappingWidth;
75 TUint16 iBidiRunArrayLength;
77 TUint8 iTruncationCharPlane;
78 TUint16 iTruncationChar16;
81 TInt SizeLineBreak(const TText* aText);
82 const TText* FindEndOfThisLine(const TText* aStart, const TText* aEnd);
83 TInt NumberOfLines(const TText* aStart, const TText* aEnd);
85 inline TBidiTextImp* TBidiTextImp::Imp(TBidiText* aSelf)
86 { return static_cast<TBidiTextImp*>(aSelf); }
88 inline const TBidiTextImp* TBidiTextImp::Imp(const TBidiText* aSelf)
89 { return static_cast<const TBidiTextImp*>(aSelf); }
91 inline TInt TBidiTextImp::AlignedSizeOf()
92 { return ((sizeof(TBidiTextImp) + 1) & 0xFFFFFFFE); }
94 inline TInt TBidiTextImp::TextLength() const
95 { return iTextLengthAndFlags & TBidiTextImp::ELengthMask; }
97 inline void TBidiTextImp::SetTextLength(TInt aLength)
98 { iTextLengthAndFlags &= ~ELengthMask; // clear old size bits
99 iTextLengthAndFlags |= (aLength&ELengthMask); } // set new size bits
101 inline TBool TBidiTextImp::HasRightToLeftDirectionality() const
102 { return iTextLengthAndFlags&TBidiTextImp::EFRightToLeft; }
104 inline void TBidiTextImp::SetRightToLeftDirectionality(TBool aRightToLeftDirectionality)
106 if (aRightToLeftDirectionality)
107 iTextLengthAndFlags |= TBidiTextImp::EFRightToLeft;
109 iTextLengthAndFlags &= ~TBidiTextImp::EFRightToLeft;
112 inline TInt TBidiTextImp::AllocatedTextDataBytes() const
113 { return iTextDataBytes; }
115 inline void TBidiTextImp::SetAllocatedTextDataBytes(TInt aTextDataBytes)
116 { iTextDataBytes = aTextDataBytes; }
123 void Panic(TInt aError);