epoc32/include/biditext.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
#ifndef BIDITEXT_H_
williamr@2
    17
#define BIDITEXT_H_
williamr@2
    18
williamr@2
    19
#include <e32std.h>
williamr@2
    20
#include <gdi.h>
williamr@2
    21
#include <bidi.h> // class TBidirectionalState::TRunInfo
williamr@2
    22
enum CGraphicsContext::TTextAlign;
williamr@2
    23
class MLineBreaker;
williamr@2
    24
class RRunInfoArray;
williamr@2
    25
class CBidiTextTls;
williamr@2
    26
williamr@2
    27
williamr@2
    28
/**
williamr@2
    29
This enumeration holds the possible panic codes that may be raised 
williamr@2
    30
by the BidiText API on detecting an unrecoverable error.
williamr@2
    31
@publishedAll
williamr@2
    32
@released
williamr@2
    33
*/
williamr@2
    34
enum TBidiPanic
williamr@2
    35
	{
williamr@2
    36
	/** The call to RRunInfoArray::OpenL() has not been made prior to this call to TBidiText::SetText()
williamr@2
    37
	@see TBidiText::SetText	*/
williamr@2
    38
	EBidiPanic_RunArrayNull						= 0,
williamr@2
    39
	
williamr@2
    40
	/** Maximum number of lines that the text will need to be split into is invalid i.e less than zero or negative.
williamr@2
    41
	@see TBidiText::NewL
williamr@2
    42
	@see TBidiText::MinimumSize	*/
williamr@2
    43
	EBidiPanic_InvalidMaxline					= 1,
williamr@2
    44
	
williamr@2
    45
	/** Maximum number of characters are invalid i.e less than zero or negative.
williamr@2
    46
	@see TBidiText::NewL */
williamr@2
    47
	EBidiPanic_InvalidReservedMaxLength			= 2,
williamr@2
    48
	
williamr@2
    49
	/** Maximum width of the text in pixels is invalid i.e zero or negative.
williamr@2
    50
	@see TBidiText::MinimumSize */
williamr@2
    51
	EBidiPanic_InvalidWrappingWidth				= 3,
williamr@2
    52
	
williamr@2
    53
	/** Number of empty pixels between two lines of text are invalid i.e zero or negative.
williamr@2
    54
	@see TBidiText::MinimumSize */
williamr@2
    55
	EBidiPanic_InvalidLineGap					= 4,
williamr@2
    56
	
williamr@2
    57
	/** Text length for display is invalid i.e zero or negative.
williamr@2
    58
	@see TBidiText::DisplayText
williamr@2
    59
	@see TBidiText::LineOfDisplayText */
williamr@2
    60
	EBidiPanic_InvalidVisualOrderedTextLength	= 5,
williamr@2
    61
	
williamr@2
    62
	/** Line number to retrieve is invalid i.e zero or negative. 
williamr@2
    63
	@see TBidiText::LineOfDisplayText */
williamr@2
    64
	EBidiPanic_InvalidLineNumber				= 6
williamr@2
    65
	};
williamr@2
    66
williamr@2
    67
/** 
williamr@2
    68
This class works as a replacement for HBufC in those cases where a small 
williamr@2
    69
amount of text is being formatted simply. The text must be all of one style 
williamr@2
    70
and broken into lines of all the same length. The number of lines and the text 
williamr@2
    71
itself is specified on construction, and the text may then be re-broken, 
williamr@2
    72
re-truncated and re-drawn with non-leaving functions. 
williamr@2
    73
@publishedAll
williamr@2
    74
@released
williamr@2
    75
*/
williamr@2
    76
class TBidiText
williamr@2
    77
	{
williamr@2
    78
public:
williamr@2
    79
	/** Overall directionality of the text. */
williamr@2
    80
	enum TDirectionality
williamr@2
    81
		{
williamr@2
    82
		/** Text reading begins on the left. */
williamr@2
    83
		ELeftToRight = 0,
williamr@2
    84
		/** Text reading begins on the right. */
williamr@2
    85
		ERightToLeft = 1
williamr@2
    86
		};
williamr@2
    87
williamr@2
    88
	/** Class specific panic codes 
williamr@2
    89
	@deprecated This enum has been replaced by TBidiPanic.
williamr@2
    90
    */
williamr@2
    91
	enum TPanicCodes
williamr@2
    92
		{
williamr@2
    93
		EPanicRunArrayNull,
williamr@2
    94
		};
williamr@2
    95
williamr@2
    96
	IMPORT_C static TDirectionality ScriptDirectionality(TLanguage aLanguage);
williamr@2
    97
	IMPORT_C static TDirectionality TextDirectionality(
williamr@2
    98
		const TDesC& aText, TBool* aFound = 0);
williamr@2
    99
protected:
williamr@2
   100
	TBidiText();
williamr@2
   101
public:
williamr@2
   102
	IMPORT_C static TBidiText* NewL(TInt aReservedMaxLength, TInt aMaxLines);
williamr@2
   103
	IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines);
williamr@2
   104
	IMPORT_C static TBidiText* NewL(const TDesC& aText, TInt aMaxLines,
williamr@2
   105
		TDirectionality aDirectionality);
williamr@2
   106
	IMPORT_C TInt SetText(const TDesC& aText, RRunInfoArray& aRunInfoArray);
williamr@2
   107
	IMPORT_C TInt SetText(const TDesC& aText, TDirectionality aDirectionality, RRunInfoArray& aRunInfoArray);
williamr@2
   108
	IMPORT_C void SetTruncationChar(TChar aTruncateWith);
williamr@2
   109
	IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont,
williamr@2
   110
		const MLineBreaker* aBreaker, TInt aMaxLines);
williamr@2
   111
	IMPORT_C void WrapText(TInt aWrappingWidth, const CFont& aFont,
williamr@2
   112
		const MLineBreaker* aBreaker = NULL);
williamr@2
   113
	IMPORT_C TSize MinimumSize(TInt aWrappingWidth, const CFont& aFont, TInt aLineGap, TInt aMaxLines = -1,
williamr@2
   114
		const MLineBreaker* aBreaker = NULL) const;	
williamr@2
   115
	IMPORT_C TPtrC Text() const;
williamr@2
   116
	IMPORT_C TPtrC DisplayText() const;
williamr@2
   117
	IMPORT_C TInt WrappingWidth() const;
williamr@2
   118
	IMPORT_C TDirectionality Directionality() const;
williamr@2
   119
	IMPORT_C TChar TruncationChar() const;
williamr@2
   120
	IMPORT_C TInt NumberOfLinesInDisplayText() const;
williamr@2
   121
	IMPORT_C TPtrC LineOfDisplayText(TInt aLine, TInt& aWidthInPixels) const;
williamr@2
   122
	IMPORT_C void DrawText(CGraphicsContext& aGc, const TPoint& aLeft) const;
williamr@2
   123
	IMPORT_C void DrawText(CGraphicsContext& aGc,
williamr@2
   124
		const TPoint& aLeft, TInt aBaseLineSpacing,
williamr@2
   125
		CGraphicsContext::TTextAlign aAlignment) const;
williamr@2
   126
	IMPORT_C void DrawText(CGraphicsContext& aGc,
williamr@2
   127
		const TPoint& aLeft, TInt aBaseLineSpacing) const;
williamr@2
   128
private:
williamr@2
   129
	TInt DoWrapText(TInt aWrappingWidth, const CFont& aFont, const MLineBreaker* aBreaker, 
williamr@2
   130
		TInt aMaxLines, TText*& aOutputText, TInt& aNumLines, TInt16* aLineWidthArray) const;
williamr@2
   131
	};
williamr@2
   132
williamr@2
   133
williamr@2
   134
/**
williamr@2
   135
This class is used to keep track of the shared run info array. 
williamr@2
   136
Keep it open for as long as the TBidiText object is used. The same
williamr@2
   137
RRunInfoArray object can be used with several different TBidiText objects.
williamr@2
   138
@publishedAll
williamr@2
   139
@released
williamr@2
   140
*/
williamr@2
   141
class RRunInfoArray
williamr@2
   142
	{
williamr@2
   143
	friend class TBidiText;
williamr@2
   144
williamr@2
   145
public:	
williamr@2
   146
	IMPORT_C RRunInfoArray();
williamr@2
   147
	IMPORT_C void OpenL();
williamr@2
   148
	IMPORT_C void Close();
williamr@2
   149
williamr@2
   150
private:
williamr@2
   151
	TBidirectionalState::TRunInfo* RunArray() const;
williamr@2
   152
williamr@2
   153
private:
williamr@2
   154
	CBidiTextTls* iTls;
williamr@2
   155
	};
williamr@2
   156
williamr@2
   157
#endif