|
1 /* |
|
2 * Copyright (c) 2002-2006 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: MsgExpandableControlEditor declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CMSGEXPANDABLECONTROLEDITOR_H |
|
21 #define CMSGEXPANDABLECONTROLEDITOR_H |
|
22 |
|
23 // ========== INCLUDE FILES ================================ |
|
24 |
|
25 #include <eikrted.h> // for CEikRichTextEditor |
|
26 #include <aknenv.h> // for CAknEnv |
|
27 #include <AknUtils.h> |
|
28 |
|
29 // ========== CONSTANTS ==================================== |
|
30 |
|
31 // ========== MACROS ======================================= |
|
32 |
|
33 // ========== DATA TYPES =================================== |
|
34 |
|
35 // ========== FUNCTION PROTOTYPES ========================== |
|
36 |
|
37 // ========== FORWARD DECLARATIONS ========================= |
|
38 |
|
39 class MMsgBaseControlObserver; |
|
40 class CItemFinder; |
|
41 class CAknsFrameBackgroundControlContext; |
|
42 class MAknsControlContext; |
|
43 class TAknTextLineLayout; |
|
44 class CMsgEditorCustomDraw; |
|
45 // ========== CLASS DECLARATION ============================ |
|
46 |
|
47 /** |
|
48 * Defines a rich text editor for CMsgExpandableControl. |
|
49 */ |
|
50 class CMsgExpandableControlEditor : public CEikRichTextEditor |
|
51 { |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Constructor. |
|
56 * @param aFlags |
|
57 * @param aBaseControlObserver |
|
58 */ |
|
59 IMPORT_C CMsgExpandableControlEditor( |
|
60 TUint32& aFlags, |
|
61 MMsgBaseControlObserver* aBaseControlObserver); |
|
62 |
|
63 /** |
|
64 * Constructor. |
|
65 * @param aParent |
|
66 * @param aFlags |
|
67 * @param aBaseControlObserver |
|
68 */ |
|
69 IMPORT_C CMsgExpandableControlEditor( |
|
70 const CCoeControl* aParent, |
|
71 TUint32& aFlags, |
|
72 MMsgBaseControlObserver* aBaseControlObserver ); |
|
73 |
|
74 /** |
|
75 * Destructor. |
|
76 */ |
|
77 IMPORT_C ~CMsgExpandableControlEditor(); |
|
78 |
|
79 /** |
|
80 * 2nd phase constructor. |
|
81 */ |
|
82 IMPORT_C virtual void ConstructL(); |
|
83 |
|
84 /** |
|
85 * Creates this control from resource. |
|
86 * @param aReader |
|
87 */ |
|
88 IMPORT_C virtual void ConstructFromResourceL( TResourceReader& aReader ); |
|
89 |
|
90 /** |
|
91 * Calculates and sets the size of the control and returns new size as |
|
92 * reference aSize. |
|
93 * @param aSize |
|
94 */ |
|
95 IMPORT_C virtual void SetAndGetSizeL( TSize& aSize ); |
|
96 |
|
97 /** |
|
98 * Checks and returns control's edit permissions. |
|
99 * @return |
|
100 */ |
|
101 IMPORT_C virtual TUint32 CheckEditPermission() const; |
|
102 |
|
103 /** |
|
104 * Returns a default one line height of the editor. |
|
105 * @return |
|
106 */ |
|
107 IMPORT_C virtual TInt DefaultHeight() const; |
|
108 |
|
109 /** |
|
110 * Checks if the cursor is on the first line. |
|
111 * @return |
|
112 */ |
|
113 IMPORT_C TBool CursorInFirstLine(); |
|
114 |
|
115 /** |
|
116 * Checks if the cursor is on the last line. |
|
117 * @return |
|
118 */ |
|
119 IMPORT_C TBool CursorInLastLine(); |
|
120 |
|
121 /** |
|
122 * Returns the current control rect. |
|
123 * @return |
|
124 */ |
|
125 IMPORT_C TRect CurrentLineRectL(); |
|
126 |
|
127 /** |
|
128 * Checks if first text line is visible. |
|
129 */ |
|
130 IMPORT_C TBool IsFirstLineVisible(); |
|
131 |
|
132 /** |
|
133 * Checks if last text line is visible. |
|
134 */ |
|
135 IMPORT_C TBool IsLastLineVisible(); |
|
136 |
|
137 /** |
|
138 * Handles clipboard operation. |
|
139 * @param aClipboardFunc |
|
140 */ |
|
141 void ClipboardL( CEikEdwin::TClipboardFunc aClipboardFunc ); |
|
142 |
|
143 /** |
|
144 * Sets maximun number of characters. |
|
145 * @param aMaxNumberOfChars |
|
146 */ |
|
147 void SetMaxNumberOfChars( TInt aMaxNumberOfChars ); |
|
148 |
|
149 /** |
|
150 * Set text content for the control. |
|
151 * @param aText |
|
152 */ |
|
153 IMPORT_C void SetTextContentL( CRichText& aText ); |
|
154 |
|
155 /** |
|
156 * Returns a minimum one line height of the editor. |
|
157 * @return |
|
158 */ |
|
159 TInt MinimumDefaultHeight() const; |
|
160 |
|
161 /** |
|
162 * Resets (= clears) contents of the control. |
|
163 */ |
|
164 IMPORT_C void Reset(); |
|
165 |
|
166 /** |
|
167 * Sets base control observer. |
|
168 * @param aBaseControlObserver |
|
169 */ |
|
170 IMPORT_C void SetBaseControlObserver( |
|
171 MMsgBaseControlObserver& aBaseControlObserver ); |
|
172 |
|
173 /** |
|
174 * |
|
175 */ |
|
176 IMPORT_C void AdjustLineHeightL(); |
|
177 |
|
178 /** |
|
179 * Returns approximate height of text. |
|
180 */ |
|
181 IMPORT_C TInt VirtualHeight(); |
|
182 |
|
183 /** |
|
184 * Returns a topmost visible text position. |
|
185 */ |
|
186 IMPORT_C TInt VirtualVisibleTop(); |
|
187 |
|
188 /** |
|
189 * Sets text format. |
|
190 */ |
|
191 virtual void LayoutEdwin(); |
|
192 |
|
193 /** |
|
194 * Returns pointer to CItemFinder object. Can return NULL if automatic find is not used. |
|
195 */ |
|
196 IMPORT_C CItemFinder* ItemFinder() const; |
|
197 |
|
198 /** |
|
199 * Reads layout data from "LAF". |
|
200 */ |
|
201 virtual void ResolveLayouts(); |
|
202 |
|
203 /** |
|
204 * Resets the size of the possible frame context |
|
205 */ |
|
206 void HandleFrameSizeChangeL(); |
|
207 |
|
208 /** |
|
209 * Called by the parent control to notify editor about |
|
210 * read only state change. Includes common expandable editor |
|
211 * related functionality. Base class implementation should be called |
|
212 * by the derived class. |
|
213 * |
|
214 * @param aReadOnly ETrue if read only editor. Otherwise EFalse. |
|
215 */ |
|
216 virtual void PrepareForReadOnlyL( TBool aReadOnly ); |
|
217 |
|
218 /** |
|
219 * Sets the currently applicable text skin color ID. Default implementation |
|
220 * sets EAknsCIQsnTextColorsCG6 if editor is read-only or does not |
|
221 * have focus. Otherwise EAknsCIQsnTextColorsCG24 is set. |
|
222 * Derived class should implement this function if different |
|
223 * behaviour is wanted. This function is called when focus or read-only state |
|
224 * changes. |
|
225 */ |
|
226 virtual void SetTextSkinColorIdL(); |
|
227 |
|
228 /** |
|
229 * Returns whether cursor is currently visible. |
|
230 * |
|
231 * @return ETrue/EFalse Visible/Not visible. |
|
232 */ |
|
233 TBool IsCursorVisibleL(); |
|
234 |
|
235 /** |
|
236 * Returns pointer to MsgEditorCustomDraw object. . |
|
237 */ |
|
238 CMsgEditorCustomDraw* MsgEditorCustomDraw() const; |
|
239 |
|
240 /** |
|
241 * Sets the control type |
|
242 * |
|
243 * @return None. |
|
244 */ |
|
245 void SetControlType(TInt); |
|
246 |
|
247 public: // from CEikRichTextEditor |
|
248 |
|
249 /** |
|
250 * Handles key events. |
|
251 * @param aKeyEvent |
|
252 * @param aType |
|
253 * @return |
|
254 */ |
|
255 IMPORT_C TKeyResponse OfferKeyEventL( |
|
256 const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
257 |
|
258 /** |
|
259 * For handling dynamic layout switch. |
|
260 */ |
|
261 void HandleResourceChange( TInt aType ); |
|
262 |
|
263 public: // from MEikCcpuEditor |
|
264 |
|
265 IMPORT_C TBool CcpuCanCut() const; |
|
266 |
|
267 IMPORT_C TBool CcpuCanCopy() const; |
|
268 |
|
269 IMPORT_C TBool CcpuCanPaste() const; |
|
270 |
|
271 IMPORT_C TBool CcpuCanUndo() const; |
|
272 |
|
273 IMPORT_C void CcpuCutL(); |
|
274 |
|
275 IMPORT_C void CcpuCopyL(); |
|
276 |
|
277 IMPORT_C void CcpuPasteL(); |
|
278 |
|
279 IMPORT_C void CcpuUndoL(); |
|
280 |
|
281 protected: |
|
282 |
|
283 /** |
|
284 * Checks if the plain text mode is on and returns ETrue if it is. |
|
285 * @return |
|
286 */ |
|
287 TBool IsPlainTextMode() const; |
|
288 |
|
289 /** |
|
290 * Returns a default one line height of the editor. |
|
291 * @return |
|
292 */ |
|
293 TInt DefaultHeight( TBool aOneToOne ) const; |
|
294 |
|
295 /** |
|
296 * Returns used text font. |
|
297 * @return |
|
298 */ |
|
299 IMPORT_C virtual const CFont* TextFont() const; |
|
300 |
|
301 /** |
|
302 * Layouts the edwin correctly. |
|
303 */ |
|
304 void DoLayoutEdwin( const TRect& aEdwinParent, |
|
305 const TAknTextLineLayout& aLayout ); |
|
306 |
|
307 protected: // from CCoeControl |
|
308 |
|
309 /** |
|
310 * |
|
311 */ |
|
312 IMPORT_C void ActivateL(); |
|
313 |
|
314 /** |
|
315 * This is called when the focus of the control is changed. |
|
316 * @param aDrawNow |
|
317 */ |
|
318 IMPORT_C void FocusChanged( TDrawNow aDrawNow ); |
|
319 |
|
320 private: |
|
321 |
|
322 /** |
|
323 * Constructor (not available). |
|
324 */ |
|
325 CMsgExpandableControlEditor(); |
|
326 |
|
327 /** |
|
328 * Calculates the inner and outer rect of the focus frame |
|
329 */ |
|
330 void OuterAndInnerRects( TRect& aOuter, TRect& aInner ); |
|
331 |
|
332 /** |
|
333 * Performs focus change handling. |
|
334 */ |
|
335 void DoFocusChangedL(); |
|
336 |
|
337 protected: |
|
338 |
|
339 const CCoeControl* iParentControl; |
|
340 TUint32& iFlags; // reference to CMsgBaseControl's flags |
|
341 MMsgBaseControlObserver* iBaseControlObserver; |
|
342 TInt iMaxNumberOfChars; |
|
343 TCharFormat iActiveFormat; // not used |
|
344 TAknLayoutText iTextLayout; |
|
345 CItemFinder* iItemFinder; |
|
346 |
|
347 CAknsFrameBackgroundControlContext* iFrameBgContext; |
|
348 MAknsControlContext* iBgContext; |
|
349 |
|
350 CMsgEditorCustomDraw* iCustomDraw; |
|
351 TInt iControlType; |
|
352 TInt iEditortop; |
|
353 }; |
|
354 |
|
355 #endif // CMSGEXPANDABLECONTROLEDITOR_H |
|
356 |
|
357 // End of File |
|
358 |