os/graphics/graphicsdeviceinterface/gdi/sgdi/BidiTextImp.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef BIDITEXTIMP_H_
    17 #define BIDITEXTIMP_H_
    18 
    19 #include "BidiText.h"
    20 
    21 class TRunInfoCompact;
    22 
    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.
    27 @internalComponent */
    28 	{
    29 public:
    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();
    34 	TText* LogicalText();
    35 	TText* VisualText();
    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(); }
    46 	/**
    47 	@return Current truncation character.
    48 	@internalComponent */
    49 	TChar TruncationChar() const
    50 		{ return static_cast<TInt>(iTruncationCharPlane << 16)
    51 		+ iTruncationChar16; }
    52 	
    53 	inline TInt TextLength() const;
    54 	inline void SetTextLength(TInt aLength);
    55 	inline TBool HasRightToLeftDirectionality() const;
    56 	inline void SetRightToLeftDirectionality(TBool aRightToLeftDirectionality);
    57 			
    58 	static TInt RequiredBytes(TInt aLendth, TInt aMaxLines, TInt aBdRunArraySize);
    59 	inline TInt AllocatedTextDataBytes() const;
    60 	
    61 private:
    62 	inline void SetAllocatedTextDataBytes(TInt aMaxBytes);
    63 	enum TFlags
    64 		{
    65 		EFRightToLeft = 0x10000000,
    66 		EFTruncateAtBeginning = 0x20000000
    67 		};
    68 
    69 	enum { ELengthMask = 0x0FFFFFFF };
    70 	TInt iTextLengthAndFlags;
    71 	TInt iTextDataBytes;	// Number of bytes allocated off the end of the object for text data
    72 public:	
    73 	TInt iVisualOrderedTextLength;
    74 	TUint16 iWrappingWidth;
    75 	TUint16 iBidiRunArrayLength;
    76 	TUint8 iLines;
    77 	TUint8 iTruncationCharPlane;
    78 	TUint16 iTruncationChar16;
    79 	};
    80 
    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);
    84 
    85 inline TBidiTextImp* TBidiTextImp::Imp(TBidiText* aSelf)
    86 	{ return static_cast<TBidiTextImp*>(aSelf); }
    87 
    88 inline const TBidiTextImp* TBidiTextImp::Imp(const TBidiText* aSelf)
    89 	{ return static_cast<const TBidiTextImp*>(aSelf); }
    90 
    91 inline TInt TBidiTextImp::AlignedSizeOf()
    92 	{ return ((sizeof(TBidiTextImp) + 1) & 0xFFFFFFFE); }
    93 
    94 inline TInt TBidiTextImp::TextLength() const
    95 	{ return iTextLengthAndFlags & TBidiTextImp::ELengthMask; }
    96 	
    97 inline void TBidiTextImp::SetTextLength(TInt aLength)
    98 	{ iTextLengthAndFlags &= ~ELengthMask;					// clear old size bits
    99 	  iTextLengthAndFlags |= (aLength&ELengthMask); }		// set new size bits
   100 
   101 inline TBool TBidiTextImp::HasRightToLeftDirectionality() const
   102 	{ return iTextLengthAndFlags&TBidiTextImp::EFRightToLeft; }
   103 	
   104 inline void TBidiTextImp::SetRightToLeftDirectionality(TBool aRightToLeftDirectionality)
   105 	{
   106 	if (aRightToLeftDirectionality)
   107 		iTextLengthAndFlags |= TBidiTextImp::EFRightToLeft;
   108 	else
   109 		iTextLengthAndFlags &= ~TBidiTextImp::EFRightToLeft;
   110 	}
   111 				
   112 inline TInt TBidiTextImp::AllocatedTextDataBytes() const
   113 	{ return iTextDataBytes; }
   114 
   115 inline void TBidiTextImp::SetAllocatedTextDataBytes(TInt aTextDataBytes)
   116 	{ iTextDataBytes = aTextDataBytes; }
   117 	
   118 
   119 /**
   120 Bidi panic.
   121 @internalComponent
   122 */
   123 void Panic(TInt aError);
   124 
   125 #endif