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.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef BIDITEXTIMP_H_
sl@0
    17
#define BIDITEXTIMP_H_
sl@0
    18
sl@0
    19
#include "BidiText.h"
sl@0
    20
sl@0
    21
class TRunInfoCompact;
sl@0
    22
sl@0
    23
class TBidiTextImp : public TBidiText
sl@0
    24
/** This is the implementation for the class TBidiText. It is so designed so 
sl@0
    25
that it only occupies a single heap cell. This means that it is efficient in 
sl@0
    26
memory usage, and can be placed on the cleanup stack without being a C-class.
sl@0
    27
@internalComponent */
sl@0
    28
	{
sl@0
    29
public:
sl@0
    30
	static TBidiTextImp* NewL(TInt aLength, TInt aMaxLines, TInt aBdRunArraySize);
sl@0
    31
	static TBidiTextImp* Imp(TBidiText* aSelf);
sl@0
    32
	static const TBidiTextImp* Imp(const TBidiText* aSelf);
sl@0
    33
	static TInt AlignedSizeOf();
sl@0
    34
	TText* LogicalText();
sl@0
    35
	TText* VisualText();
sl@0
    36
	TInt16* LineWidthArray();
sl@0
    37
	TRunInfoCompact* BidiRunArray();
sl@0
    38
	const TText* LogicalText() const
sl@0
    39
		{ return const_cast<TBidiTextImp*>(this)->LogicalText(); }
sl@0
    40
	const TText* VisualText() const
sl@0
    41
		{ return const_cast<TBidiTextImp*>(this)->VisualText(); }
sl@0
    42
	const TInt16* LineWidthArray() const
sl@0
    43
		{ return const_cast<TBidiTextImp*>(this)->LineWidthArray(); }
sl@0
    44
	const TRunInfoCompact* BidiRunArray() const
sl@0
    45
		{ return const_cast<TBidiTextImp*>(this)->BidiRunArray(); }
sl@0
    46
	/**
sl@0
    47
	@return Current truncation character.
sl@0
    48
	@internalComponent */
sl@0
    49
	TChar TruncationChar() const
sl@0
    50
		{ return static_cast<TInt>(iTruncationCharPlane << 16)
sl@0
    51
		+ iTruncationChar16; }
sl@0
    52
	
sl@0
    53
	inline TInt TextLength() const;
sl@0
    54
	inline void SetTextLength(TInt aLength);
sl@0
    55
	inline TBool HasRightToLeftDirectionality() const;
sl@0
    56
	inline void SetRightToLeftDirectionality(TBool aRightToLeftDirectionality);
sl@0
    57
			
sl@0
    58
	static TInt RequiredBytes(TInt aLendth, TInt aMaxLines, TInt aBdRunArraySize);
sl@0
    59
	inline TInt AllocatedTextDataBytes() const;
sl@0
    60
	
sl@0
    61
private:
sl@0
    62
	inline void SetAllocatedTextDataBytes(TInt aMaxBytes);
sl@0
    63
	enum TFlags
sl@0
    64
		{
sl@0
    65
		EFRightToLeft = 0x10000000,
sl@0
    66
		EFTruncateAtBeginning = 0x20000000
sl@0
    67
		};
sl@0
    68
sl@0
    69
	enum { ELengthMask = 0x0FFFFFFF };
sl@0
    70
	TInt iTextLengthAndFlags;
sl@0
    71
	TInt iTextDataBytes;	// Number of bytes allocated off the end of the object for text data
sl@0
    72
public:	
sl@0
    73
	TInt iVisualOrderedTextLength;
sl@0
    74
	TUint16 iWrappingWidth;
sl@0
    75
	TUint16 iBidiRunArrayLength;
sl@0
    76
	TUint8 iLines;
sl@0
    77
	TUint8 iTruncationCharPlane;
sl@0
    78
	TUint16 iTruncationChar16;
sl@0
    79
	};
sl@0
    80
sl@0
    81
TInt SizeLineBreak(const TText* aText);
sl@0
    82
const TText* FindEndOfThisLine(const TText* aStart, const TText* aEnd);
sl@0
    83
TInt NumberOfLines(const TText* aStart, const TText* aEnd);
sl@0
    84
sl@0
    85
inline TBidiTextImp* TBidiTextImp::Imp(TBidiText* aSelf)
sl@0
    86
	{ return static_cast<TBidiTextImp*>(aSelf); }
sl@0
    87
sl@0
    88
inline const TBidiTextImp* TBidiTextImp::Imp(const TBidiText* aSelf)
sl@0
    89
	{ return static_cast<const TBidiTextImp*>(aSelf); }
sl@0
    90
sl@0
    91
inline TInt TBidiTextImp::AlignedSizeOf()
sl@0
    92
	{ return ((sizeof(TBidiTextImp) + 1) & 0xFFFFFFFE); }
sl@0
    93
sl@0
    94
inline TInt TBidiTextImp::TextLength() const
sl@0
    95
	{ return iTextLengthAndFlags & TBidiTextImp::ELengthMask; }
sl@0
    96
	
sl@0
    97
inline void TBidiTextImp::SetTextLength(TInt aLength)
sl@0
    98
	{ iTextLengthAndFlags &= ~ELengthMask;					// clear old size bits
sl@0
    99
	  iTextLengthAndFlags |= (aLength&ELengthMask); }		// set new size bits
sl@0
   100
sl@0
   101
inline TBool TBidiTextImp::HasRightToLeftDirectionality() const
sl@0
   102
	{ return iTextLengthAndFlags&TBidiTextImp::EFRightToLeft; }
sl@0
   103
	
sl@0
   104
inline void TBidiTextImp::SetRightToLeftDirectionality(TBool aRightToLeftDirectionality)
sl@0
   105
	{
sl@0
   106
	if (aRightToLeftDirectionality)
sl@0
   107
		iTextLengthAndFlags |= TBidiTextImp::EFRightToLeft;
sl@0
   108
	else
sl@0
   109
		iTextLengthAndFlags &= ~TBidiTextImp::EFRightToLeft;
sl@0
   110
	}
sl@0
   111
				
sl@0
   112
inline TInt TBidiTextImp::AllocatedTextDataBytes() const
sl@0
   113
	{ return iTextDataBytes; }
sl@0
   114
sl@0
   115
inline void TBidiTextImp::SetAllocatedTextDataBytes(TInt aTextDataBytes)
sl@0
   116
	{ iTextDataBytes = aTextDataBytes; }
sl@0
   117
	
sl@0
   118
sl@0
   119
/**
sl@0
   120
Bidi panic.
sl@0
   121
@internalComponent
sl@0
   122
*/
sl@0
   123
void Panic(TInt aError);
sl@0
   124
sl@0
   125
#endif