|
1 /* |
|
2 * Copyright (c) 2005 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: Text viewer component |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CCATEXTVIEWCONTROL_H |
|
21 #define CCATEXTVIEWCONTROL_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <coecntrl.h> |
|
25 #include <eiksbobs.h> // MEikScrollBarObserver |
|
26 #include <eikbctrl.h> |
|
27 #include <frmtlay.h> // TCursorSelection |
|
28 #include "MCATextView.h" |
|
29 |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CTextLayout; |
|
33 class CTextView; |
|
34 class CCACustomDraw; |
|
35 class CEikScrollBarFrame; |
|
36 class CAknsBasicBackgroundControlContext; |
|
37 |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Text viewer component |
|
43 * |
|
44 * @lib chat.app |
|
45 * @since 3.0 |
|
46 */ |
|
47 class CCATextViewControl : public CCoeControl |
|
48 , public MCATextView |
|
49 , public MEikScrollBarObserver |
|
50 { |
|
51 |
|
52 public: // Constructors and destructor |
|
53 |
|
54 /** |
|
55 * Two-phased constructor. |
|
56 * @param aRect Draw area |
|
57 * @param aParent Parent control |
|
58 * @param aTextLayout Text to be viewed |
|
59 * @return Instance of this class |
|
60 */ |
|
61 static CCATextViewControl* NewL( const TRect& aRect, |
|
62 const CCoeControl& aParent, |
|
63 MLayDoc* aTextLayout ); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 virtual ~CCATextViewControl(); |
|
69 |
|
70 protected: // New functions |
|
71 |
|
72 /** |
|
73 * Updates scrollbars |
|
74 */ |
|
75 void UpdateScrollBarsL( TBool aScrollDraw = ETrue ); |
|
76 |
|
77 /** |
|
78 * Update the view |
|
79 */ |
|
80 void UpdateViewL(); |
|
81 |
|
82 /** |
|
83 * Set highlight state |
|
84 */ |
|
85 void SetHighlighted( TBool aIsHighlighted ); |
|
86 |
|
87 /** |
|
88 * Get scrollbars |
|
89 */ |
|
90 const CEikScrollBarFrame* ScrollBarFrame(); |
|
91 |
|
92 /** |
|
93 * Finds the document position which is located at aPoint |
|
94 * @param aPoint Location to find |
|
95 * @return Document position or |
|
96 * KErrNotFound if not found |
|
97 */ |
|
98 TInt FindDocPos( TPoint aPoint ); |
|
99 |
|
100 public: // from MObjectProvider |
|
101 |
|
102 TTypeUid::Ptr MopSupplyObject( TTypeUid aId ); |
|
103 |
|
104 protected: // from MEikScrollBarObserver |
|
105 |
|
106 void HandleScrollEventL( CEikScrollBar* aScrollBar, |
|
107 TEikScrollEvent aEventType ); |
|
108 |
|
109 protected: // Functions from CCoeControl |
|
110 |
|
111 /** |
|
112 * @see CCoeControl |
|
113 */ |
|
114 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
115 TEventCode aType ); |
|
116 |
|
117 /** |
|
118 * @see CCoeControl |
|
119 */ |
|
120 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
121 |
|
122 /** |
|
123 * @see CCoeControl |
|
124 */ |
|
125 void Draw( const TRect& aRect ) const; |
|
126 |
|
127 /** |
|
128 * @see CCoeControl |
|
129 */ |
|
130 void SizeChanged(); |
|
131 |
|
132 TInt CountComponentControls() const; |
|
133 CCoeControl* ComponentControl( TInt aIndex ) const; |
|
134 |
|
135 public:// Functions from MCATextView |
|
136 /** |
|
137 * @see MCATextView |
|
138 */ |
|
139 TBool IsVisible( TInt aPos ); |
|
140 |
|
141 |
|
142 protected: // Functions from MCATextView |
|
143 |
|
144 /** |
|
145 * @see MCATextView |
|
146 */ |
|
147 void HandleFormatChangedL( TCursorSelection& aChanged, |
|
148 TBool aPreserverFocus = EFalse ); |
|
149 |
|
150 /** |
|
151 * @see MCATextView |
|
152 */ |
|
153 void HandleInsertDeleteL( TCursorSelection& aChanged, |
|
154 TInt aDeletedChars ); |
|
155 |
|
156 /** |
|
157 * @see MCATextView |
|
158 */ |
|
159 void HandleAdditionL( TBool aFirst, |
|
160 TCursorSelection& aSelection, |
|
161 TBool aTop ); |
|
162 |
|
163 /** |
|
164 * @see MCATextView |
|
165 */ |
|
166 void ScrollVisibleL( TCursorSelection& aSelection, TBool aTop ); |
|
167 |
|
168 /** |
|
169 * @see MCATextView |
|
170 */ |
|
171 TCursorSelection ScrollSelection(); |
|
172 |
|
173 /** |
|
174 * @see MCATextView |
|
175 */ |
|
176 void ScrollLinesL( TInt aAmount ); |
|
177 |
|
178 |
|
179 /** |
|
180 * @see MCATextView |
|
181 */ |
|
182 TBool ParagraphFits( TInt aPos ); |
|
183 |
|
184 /** |
|
185 * @see MCATextView |
|
186 */ |
|
187 void Redraw(); |
|
188 |
|
189 /** |
|
190 * @see MCATextView |
|
191 */ |
|
192 void SetPenBehaviour( TPenBehaviour aPen ); |
|
193 |
|
194 /** |
|
195 * @see MCATextView |
|
196 */ |
|
197 MCATextView::TPenBehaviour PenBehaviour(); |
|
198 |
|
199 /** |
|
200 * @see MCATextView |
|
201 */ |
|
202 void ProcessStylusEventL( const TPointerEvent& aPointerEvent ); |
|
203 |
|
204 /** |
|
205 * @see MCATextView |
|
206 */ |
|
207 void HandleGlobalChangeNoRedrawL( |
|
208 TViewYPosQualifier aYPosQualifier = TViewYPosQualifier() ); |
|
209 |
|
210 protected: |
|
211 |
|
212 /** |
|
213 * C++ default constructor. |
|
214 */ |
|
215 CCATextViewControl(); |
|
216 |
|
217 /** |
|
218 * By default Symbian 2nd phase constructor is private. |
|
219 * @param aRect Draw area |
|
220 * @param aParent Parent control |
|
221 * @param aTextLayout Text to be viewed |
|
222 */ |
|
223 void ConstructL( const TRect& aRect, const CCoeControl& aParent, |
|
224 MLayDoc* aTextLayout ); |
|
225 |
|
226 |
|
227 private: // Data |
|
228 |
|
229 // Owns. rectangle in which to view text |
|
230 TRect iViewRect; |
|
231 |
|
232 // Owns. text layout |
|
233 CTextLayout* iLayout; |
|
234 |
|
235 // Owns. text view |
|
236 CTextView* iTextView; |
|
237 |
|
238 // Owns. custom drawer for skins |
|
239 CCACustomDraw* iCustomDraw; |
|
240 |
|
241 // Owns. scroll bar container |
|
242 CEikScrollBarFrame* iScrollBar; |
|
243 |
|
244 // Tells whether the contorl is added to Stack or not |
|
245 TBool iAddedToStack; |
|
246 |
|
247 //owns |
|
248 CAknsBasicBackgroundControlContext* iBgContext; // Skin background control context |
|
249 |
|
250 // Own. Clipping region to prevent flickering |
|
251 RRegion* iClipping; |
|
252 |
|
253 // Highlight state inside text view |
|
254 TBool iIsHighlighted; |
|
255 |
|
256 // Determines how this contol reacts to pointer events |
|
257 TPenBehaviour iPenType; |
|
258 }; |
|
259 |
|
260 #endif // CCATEXTVIEWCONTROL_H |
|
261 |
|
262 // End of File |
|
263 |