|
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: MsgAddressControlEditor declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef INC_MSGADDRESSCONTROLEDITOR_H |
|
21 #define INC_MSGADDRESSCONTROLEDITOR_H |
|
22 |
|
23 // ========== INCLUDE FILES ================================ |
|
24 #include <txtrich.h> |
|
25 #include "MsgExpandableControlEditor.h" // for CMsgExpandableControlEditor |
|
26 #include "MsgAddressControlEditorField.h" |
|
27 |
|
28 // ========== CONSTANTS ==================================== |
|
29 |
|
30 // ========== MACROS ======================================= |
|
31 #define KMaxContactLength 102 //(first name (50) + last name(50) + spaces(2)) |
|
32 |
|
33 #define iRichText ( static_cast<CRichText*>( iText ) ) |
|
34 |
|
35 // ========== DATA TYPES =================================== |
|
36 |
|
37 // ========== FUNCTION PROTOTYPES ========================== |
|
38 |
|
39 // ========== FORWARD DECLARATIONS ========================= |
|
40 |
|
41 class CMsgEditorKeyCatcher; |
|
42 class MVPbkContactLink; |
|
43 |
|
44 // ========== CLASS DECLARATION ============================ |
|
45 |
|
46 /** |
|
47 * Defines a rich text editor for CMsgAddressControl. |
|
48 * |
|
49 */ |
|
50 class CMsgAddressControlEditor : public CMsgExpandableControlEditor |
|
51 { |
|
52 public: |
|
53 |
|
54 /** |
|
55 * Constructor. |
|
56 * @param aParent |
|
57 * @param aFlags |
|
58 * @param aBaseControlObserver |
|
59 */ |
|
60 CMsgAddressControlEditor( |
|
61 const CCoeControl* aParent, |
|
62 TUint32& aFlags, |
|
63 MMsgBaseControlObserver* aBaseControlObserver); |
|
64 |
|
65 /** |
|
66 * Destructor. |
|
67 */ |
|
68 virtual ~CMsgAddressControlEditor(); |
|
69 |
|
70 // Entry handling functions |
|
71 |
|
72 /** |
|
73 * Extracts an entry according to aEntryNumber and returns it in |
|
74 * aEntryString. |
|
75 * @param aEntryString |
|
76 * @param aEntryNumber |
|
77 */ |
|
78 void ExtractEntry(TDes& aEntryString, TInt aEntryNumber); |
|
79 |
|
80 /** |
|
81 * Reads an entry aEntryNumber and returns pointer to it. If such an |
|
82 * entry does not exist, returns null string. |
|
83 * @param aEntryNumber |
|
84 * @return |
|
85 */ |
|
86 TPtrC ReadEntry(TInt aEntryNumber) const; |
|
87 |
|
88 /** |
|
89 * Returns number of entries. |
|
90 * @return |
|
91 */ |
|
92 TInt EntryCount() const; |
|
93 |
|
94 /** |
|
95 * Deletes an entry aEntryNumber. |
|
96 * @param aEntryNumber |
|
97 */ |
|
98 void DeleteEntryL(TInt aEntryNumber); |
|
99 |
|
100 /** |
|
101 * Clears a text of an entry aEntryNumber. |
|
102 * @param aEntryNumber |
|
103 * @param aUpdate |
|
104 */ |
|
105 void ClearEntryL(TInt aEntryNumber, TBool aUpdate = EFalse); |
|
106 |
|
107 /** |
|
108 * Clears the content of the editor. |
|
109 */ |
|
110 void DeleteAllL(); |
|
111 |
|
112 /** |
|
113 * Deletes characters from aStartPos to aEndPos at entry aEntryNumber. |
|
114 * @param aEntryNumber |
|
115 * @param aStartPos |
|
116 * @param aEndPos |
|
117 */ |
|
118 void DeleteEntryCharsL(TInt aEntryNumber, TInt aStartPos, TInt aEndPos); |
|
119 |
|
120 /** |
|
121 * Sets cursor position to aPos and cancels selection. |
|
122 * @param aPos |
|
123 */ |
|
124 void SetCursorPosAndCancelSelectionL(TInt aPos); |
|
125 |
|
126 /** |
|
127 * Inserts an entry to the location aEntryNumber with strings aName |
|
128 * and aAddress. Makes the entry as verified if aVerified = ETrue. |
|
129 */ |
|
130 void InsertEntryL( |
|
131 TInt aEntryNumber, |
|
132 const TDesC& aName, |
|
133 const TDesC& aAddress, |
|
134 TBool aVerified, |
|
135 TBool aValidated, |
|
136 const MVPbkContactLink* aContactLink ); |
|
137 |
|
138 /** |
|
139 * Inserts the paragraph delimiter at aPos on entry aEntryNumber. |
|
140 * @param aEntryNumber |
|
141 * @param aPos |
|
142 */ |
|
143 void InsertEntryBreakL(TInt aEntryNumber, TInt aPos); |
|
144 |
|
145 /** |
|
146 * Returns entry number where cursor is currently on. |
|
147 * @param aPos |
|
148 * @return |
|
149 */ |
|
150 TInt EntryNumber(TInt aPos) const; |
|
151 |
|
152 /** |
|
153 * Returns length of the entry aEntryNumber. |
|
154 * @param aEntryNumber |
|
155 * @return |
|
156 */ |
|
157 TInt EntryLength(TInt aEntryNumber) const; |
|
158 |
|
159 /** |
|
160 * Returns first character position on the entry aEntryNumber. |
|
161 * @param aEntryNumber |
|
162 */ |
|
163 TInt EntryStartPos(TInt aEntryNumber) const; |
|
164 |
|
165 /** |
|
166 * Return start position of field under aCursorPos. |
|
167 * @param aCursorPos |
|
168 */ |
|
169 TInt FirstFieldPos(TInt aCursorPos) const; |
|
170 |
|
171 /** |
|
172 * Moves cursor at the end of the entry aEntryNumber. |
|
173 * @param aEntryNumber |
|
174 * @param aPos |
|
175 */ |
|
176 void MoveCursorToEntryPosL(TInt aEntryNumber, TInt aPos); |
|
177 |
|
178 /** |
|
179 * Checks whether the cursor is at the beginning of the entry. |
|
180 * @param aPos |
|
181 * @return ETrue if it is, otherwise EFalse. |
|
182 */ |
|
183 TBool IsPosAtEntryBeginning(TInt aPos) const; |
|
184 |
|
185 /** |
|
186 * Checks whether an entry aEntryNumber is verified or not. |
|
187 * @param aEntryNumber |
|
188 * @return ETrue if it is, otherwise EFalse. |
|
189 */ |
|
190 TBool IsEntryVerified(TInt aEntryNumber) const; |
|
191 |
|
192 /** |
|
193 * Checks whether an entry aEntryNumber - 1 is verified. |
|
194 * @param aEntryNumber |
|
195 * @return ETrue if it is, otherwise EFalse. |
|
196 */ |
|
197 TBool IsPriorEntryVerified(TInt aEntryNumber) const; |
|
198 |
|
199 /** |
|
200 * Checks whether an entry aEntryNumber is validated or not. |
|
201 * @param aEntryNumber |
|
202 * @return ETrue if it is, otherwise EFalse. |
|
203 */ |
|
204 TBool IsEntryValidated(TInt aEntryNumber) const; |
|
205 |
|
206 /** |
|
207 * Checks if there is a text field on the left hand side of the cursor at |
|
208 * position aPos. |
|
209 * @param aPos |
|
210 * @return ETrue if it is, otherwise EFalse. |
|
211 */ |
|
212 TBool IsFieldOnLeft(TInt aPos) const; |
|
213 |
|
214 /** |
|
215 * Checks if there is a text field on the right hand side of the cursor at |
|
216 * position aPos. |
|
217 * @param aPos |
|
218 * @return ETrue if it is, otherwise EFalse. |
|
219 */ |
|
220 TBool IsFieldOnRight(TInt aPos) const; |
|
221 |
|
222 /** |
|
223 * Checks if there is a text field under the cursor at position aPos. |
|
224 * @param aPos |
|
225 * @return ETrue if it is, otherwise EFalse. |
|
226 */ |
|
227 TBool IsFieldOnPos(TInt aPos) const; |
|
228 |
|
229 /** |
|
230 * Checks whether an entry aEntryNumber is empty. |
|
231 * @param aEntryNumber |
|
232 * @return |
|
233 */ |
|
234 TBool IsEntryEmpty(TInt aEntryNumber) const; |
|
235 |
|
236 /** |
|
237 * Turns entry as highlighted if the cursor is on the top of the verified |
|
238 * entry, otherwise turns highlighting off if there were any somewhere else. |
|
239 * @param aCancelFep |
|
240 */ |
|
241 void CheckHighlightingL(TBool aCancelFep = ETrue); |
|
242 |
|
243 /** |
|
244 * Turns highlighting off if such a highlighted text field is somewhere. |
|
245 * @param aSelection |
|
246 */ |
|
247 void TurnHighlightingOffL(TCursorSelection aSelection); |
|
248 |
|
249 /** |
|
250 * Turns highlighting off if such a highlighted text field is somewhere. |
|
251 * @param aCancelFep |
|
252 */ |
|
253 void TurnHighlightingOffL(TBool aCancelFep = ETrue); |
|
254 |
|
255 /** |
|
256 * Turns highlighting off from position aPos. |
|
257 * @param aPos |
|
258 */ |
|
259 void TurnHighlightingOffFromPosL(TInt aPos); |
|
260 |
|
261 /** |
|
262 * Creates a suitable text string for the text field using strings aName |
|
263 * and aAddress and return pointer to it. If aUpdate == EFalse, this |
|
264 * function does not format the string but takes only aAddress. |
|
265 * @param aName |
|
266 * @param aAddress |
|
267 * @param aVerified |
|
268 * @return |
|
269 */ |
|
270 HBufC* CreateEntryStringLC( |
|
271 const TDesC& aName, |
|
272 const TDesC& aAddress, |
|
273 TBool aVerified = ETrue); |
|
274 |
|
275 /** |
|
276 * Re-builds all the text strings. |
|
277 */ |
|
278 void ReBuildEntryStringsL(); |
|
279 |
|
280 /** |
|
281 * Returns a field of the entry aEntryNumber. If there is no field on that |
|
282 * entry, returns NULL. |
|
283 * @param aEntryNumber |
|
284 * @return |
|
285 */ |
|
286 const CMsgAddressControlEditorField* Field(TInt aEntryNumber) const; |
|
287 |
|
288 /** |
|
289 * Returns character at position aPos. |
|
290 * @param aPos |
|
291 * @return |
|
292 */ |
|
293 TChar CharAtPos (TInt aPos) const; |
|
294 |
|
295 /** |
|
296 * Prepares control for viewing. |
|
297 */ |
|
298 void PrepareForViewing(); |
|
299 |
|
300 /** |
|
301 * Inserts ; and line feeds prior to inline edits |
|
302 */ |
|
303 void PreInsertEditorFormattingL( const TKeyEvent& aKeyEvent ); |
|
304 |
|
305 /** |
|
306 * Inserts ; and line feeds prior to inline edits |
|
307 */ |
|
308 void PostInsertEditorFormattingL( TBool aDuplicateEvent ); |
|
309 |
|
310 /** |
|
311 * Determine the overall text direction for the text for an entry |
|
312 * |
|
313 * @param aEntryNumber a valid entry number |
|
314 * @return EFalse iff the text for the given entry is not right to left text |
|
315 */ |
|
316 TBool IsEntryRightToLeft(TInt aEntryNumber) const; |
|
317 |
|
318 /** |
|
319 * Sets address highlighting for automatic find function on/off. |
|
320 * |
|
321 * @param aValidHighlightable ETrue for on / EFalse for off. |
|
322 * @return none |
|
323 */ |
|
324 void SetAddressFieldAutoHighlight( TBool aValidHighlightable = EFalse ); |
|
325 |
|
326 /** |
|
327 * Returns address highlighting value for automatic find function. |
|
328 * |
|
329 * @param |
|
330 * @return aValidHighlightable ETrue for on / EFalse for off. |
|
331 */ |
|
332 inline TBool AddressFieldAutoHighlight(); |
|
333 |
|
334 public: // from CMsgExpandableControlEditor |
|
335 |
|
336 /** |
|
337 * Checks and returns control's edit permissions. |
|
338 * @return |
|
339 */ |
|
340 TUint32 CheckEditPermission() const; |
|
341 |
|
342 /** |
|
343 * Creates this control from resource. |
|
344 * @param aReader |
|
345 */ |
|
346 void ConstructFromResourceL(TResourceReader& aReader); |
|
347 |
|
348 /** |
|
349 * Calculates and sets the size of the control and returns new size as |
|
350 * reference aSize. |
|
351 * @param aSize |
|
352 */ |
|
353 void SetAndGetSizeL(TSize& aSize); |
|
354 |
|
355 /** |
|
356 * |
|
357 */ |
|
358 TBool IsHandleEditEvent() const { return iHandleEditEvent; } |
|
359 |
|
360 /** |
|
361 * Called by the parent control to notify editor about |
|
362 * read only state change. Includes address field and |
|
363 * expandable control specific behaviours. |
|
364 * Base class implementation should be called by the derived class. |
|
365 * |
|
366 * @param aReadOnly ETrue if read only editor. Otherwise EFalse. |
|
367 */ |
|
368 void PrepareForReadOnlyL( TBool aReadOnly ); |
|
369 |
|
370 /** |
|
371 * returns the current cursor position |
|
372 */ |
|
373 TInt GetCursorpos() const; |
|
374 public: // from CEikRichTextEditor |
|
375 |
|
376 /** |
|
377 * Handles key events. |
|
378 * @param aKeyEvent |
|
379 * @param aType |
|
380 * @return |
|
381 */ |
|
382 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
383 |
|
384 /** |
|
385 * From CCoeControl. See coecntrl.h |
|
386 */ |
|
387 void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
388 |
|
389 /** |
|
390 * From CCoeControl. See coecntrl.h |
|
391 */ |
|
392 void HandleResourceChange( TInt aType ); |
|
393 |
|
394 public: // from MEikCcpuEditor |
|
395 |
|
396 /** |
|
397 * |
|
398 */ |
|
399 void CcpuPasteL(); |
|
400 |
|
401 private: |
|
402 |
|
403 /** |
|
404 * Constructor (not available). |
|
405 */ |
|
406 CMsgAddressControlEditor(); |
|
407 |
|
408 /** |
|
409 * 2nd phase constructor. |
|
410 */ |
|
411 void ConstructL(); |
|
412 |
|
413 /** |
|
414 * Insert a semicolon at the specified position. |
|
415 * |
|
416 * @param aPos intertion point |
|
417 */ |
|
418 void InsertSemicolonL(TInt aPos); |
|
419 |
|
420 /** |
|
421 * Insert a paragraph delimiter at the specified position. |
|
422 * |
|
423 * @param aPos intertion point |
|
424 */ |
|
425 void InsertParagraphL(TInt aPos); |
|
426 |
|
427 /** |
|
428 * Check that contact underlining is correct. |
|
429 */ |
|
430 void CheckUnderliningL(); |
|
431 |
|
432 /** |
|
433 * Returns field from given position. |
|
434 */ |
|
435 inline const CMsgAddressControlEditorField* FieldFromPos( TInt aPos ) const; |
|
436 |
|
437 private: |
|
438 |
|
439 TMsgAddressControlEditorFieldFactory* iAddressControlEditorFieldFactory; |
|
440 |
|
441 // this is used to indicate where higlighting starts. |
|
442 TInt iHighLightedFieldPos; |
|
443 |
|
444 // Indicates current entry number if length of the text has been changed |
|
445 // due to RebuildEntryString. |
|
446 TInt iCurrentEntry; |
|
447 |
|
448 TBool iHandleEditEvent; |
|
449 TBool iValidHighlightable; // for automatic highlight |
|
450 |
|
451 CMsgEditorKeyCatcher* iKeyCatcher; |
|
452 TBool iHandlingPointerEvent; |
|
453 |
|
454 const CMsgAddressControlEditorField* iPreviousField; |
|
455 TInt iCusPos; |
|
456 }; |
|
457 |
|
458 inline TBool CMsgAddressControlEditor::AddressFieldAutoHighlight( ) |
|
459 { |
|
460 return iValidHighlightable; |
|
461 } |
|
462 |
|
463 inline const CMsgAddressControlEditorField* CMsgAddressControlEditor::FieldFromPos( TInt aPos ) const |
|
464 { |
|
465 return static_cast<const CMsgAddressControlEditorField*>( iRichText->TextField( aPos ) ); |
|
466 } |
|
467 |
|
468 #endif |
|
469 |
|
470 // End of File |