|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef AKN_TEXT_CONTROL_H |
|
20 #define AKN_TEXT_CONTROL_H |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <coecntrl.h> |
|
24 #include <eiklabel.h> |
|
25 #include <AknPictographDrawerInterface.h> |
|
26 |
|
27 #include "akntext.h" |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 class CAknPictographInterface; |
|
32 |
|
33 /** |
|
34 * An avkon text control. |
|
35 * |
|
36 * Manage wrapping of text into one or more labels. |
|
37 * Support line wrapping (only wrap when a new line character is |
|
38 * found) or word wrapping (wrap when a word does not fit into a |
|
39 * specified line width). |
|
40 * |
|
41 * Text is stored in a CAknText object. |
|
42 */ |
|
43 NONSHARABLE_CLASS(CAknTextControl) : public CCoeControl, public MAknPictographAnimatorCallBack |
|
44 { |
|
45 public: |
|
46 enum TWrapMethod |
|
47 { |
|
48 ELine, |
|
49 EWord, |
|
50 ENoProcessing, |
|
51 ENoAllocation |
|
52 }; |
|
53 public: |
|
54 static CAknTextControl* NewL( |
|
55 const CAknText::TType& aTextType = CAknText::EFormatted ); |
|
56 |
|
57 ~CAknTextControl(); |
|
58 CAknTextControl& operator=(CAknTextControl& aTextControl); |
|
59 |
|
60 public: |
|
61 void ConstructFromResourceL(TResourceReader& aRes); |
|
62 TInt CountComponentControls() const; |
|
63 CCoeControl* ComponentControl(TInt anIndex) const; |
|
64 |
|
65 public: //Layout interface |
|
66 TInt NumberOfLines() const; |
|
67 CEikLabel* Line(TInt aIndex) const; |
|
68 |
|
69 TBool LineModified(TInt aIndex) const; |
|
70 void SetLineModified(TInt aIndex, TBool aValue); |
|
71 |
|
72 public: //Text interface |
|
73 void SetTextL(const TDesC& aText); |
|
74 //kept for backwards compatibility only |
|
75 void SetTextL(const TDesC& aText, TInt aLineNum,const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths); |
|
76 |
|
77 TPtr Text() const; |
|
78 void ParseTextL(const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths, const TWrapMethod& aWrapMethod = EWord); |
|
79 |
|
80 void SetTextPluralityL(TBool aIsPlural); |
|
81 void SetTextNumberL(TInt aNumber); |
|
82 |
|
83 public: //Pictograph interface |
|
84 |
|
85 /** |
|
86 * Note control invokes this callback when a redraw is required for |
|
87 * animating pictographs. Only effective if pictograph feature is |
|
88 * supported. |
|
89 */ |
|
90 void SetPictographCallBackL( TCallBack& aCallBack ); |
|
91 |
|
92 /** |
|
93 * Access to the pictograph interface owned by the text control. |
|
94 * It is NULL if pictograph feature is not supported. |
|
95 * |
|
96 * Can be used in the pictograph callback if required. It is never |
|
97 * NULL when pictograph callback is invoked. |
|
98 */ |
|
99 CAknPictographInterface* PictographInterface() const; |
|
100 |
|
101 private: // From MAknPictographAnimatorCallBack |
|
102 void DrawPictographArea(); |
|
103 |
|
104 private: |
|
105 CAknTextControl(); |
|
106 void ConstructL(const CAknText::TType& aTextType); |
|
107 |
|
108 CAknTextControl(const CAknTextControl&); //not allowed |
|
109 |
|
110 void SetWrappedTextIntoLabelsL(const CArrayFix<TPtrC>& aWrappedArray, TInt aNumLines, const CFont* aFont); |
|
111 |
|
112 void UpdateLabelsL(const TInt aNum,const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths); |
|
113 void CreateLabelsL(const TInt aNum,const CFont* aFont, CArrayFixFlat<TInt>* aLineWidths); |
|
114 CEikLabel* CreateLabelLC(TInt aLen); |
|
115 |
|
116 private: |
|
117 class CLine : public CBase |
|
118 { |
|
119 public: |
|
120 CLine(CEikLabel* aLabel) : iModified(ETrue), iLabel(aLabel) {} |
|
121 ~CLine() { delete iLabel; } |
|
122 public: |
|
123 TBool iModified; |
|
124 CEikLabel* iLabel; |
|
125 }; |
|
126 private: |
|
127 TInt iNumberOfLines; |
|
128 RPointerArray<CLine> iLines; |
|
129 CAknText* iText; |
|
130 TBool iTextIsAlreadyInLabel; |
|
131 CArrayFixFlat<TPtrC>* iWrappedArray; |
|
132 CAknPictographInterface* iPictoInterface; |
|
133 TCallBack iPictoCallBack; |
|
134 }; |
|
135 |
|
136 #endif |