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