|
1 /* |
|
2 * Copyright (c) 2007 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 : email header container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "emailtrace.h" |
|
21 #include <StringLoader.h> |
|
22 #include <aknViewAppUi.h> |
|
23 #include <aknnotewrappers.h> //CAknInformationNote |
|
24 #include <FreestyleEmailUi.rsg> |
|
25 #include <aknphysics.h> |
|
26 |
|
27 #include "cfsmailbox.h" |
|
28 #include <FreestyleEmailUi.rsg> |
|
29 |
|
30 #include "FSEmailBuildFlags.h" |
|
31 #include "ncsheadercontainer.h" |
|
32 #include "ncscomposeviewcontainer.h" |
|
33 #include "ncsemailaddressobject.h" |
|
34 #include "ncsutility.h" |
|
35 #include "FreestyleEmailUiUtilities.h" |
|
36 #include "FreestyleEmailUiAppui.h" |
|
37 #include "FSEmail.pan" |
|
38 #include "ncsattachmentfield.h" |
|
39 #include "ncssubjectfield.h" |
|
40 #include "ncspopuplistbox.h" |
|
41 |
|
42 _LIT( KAddressDelimeterSemiColon, ";" ); |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // ToNcsControl |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 static MNcsControl* ToNcsControl( CCoeControlArray::TCursor cur ) |
|
50 { |
|
51 FUNC_LOG; |
|
52 CCoeControl* coe = cur.Control<CCoeControl>(); |
|
53 return dynamic_cast<MNcsControl*>(coe); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CNcsHeaderContainer::NewL |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CNcsHeaderContainer* CNcsHeaderContainer::NewL( CCoeControl& aParent, |
|
61 CFSMailBox& aMailBox, TInt aFlags, CAknPhysics* aPhysics ) |
|
62 { |
|
63 FUNC_LOG; |
|
64 CNcsHeaderContainer* self = |
|
65 new ( ELeave ) CNcsHeaderContainer( aParent, aMailBox, aPhysics ); |
|
66 CleanupStack::PushL( self ); |
|
67 self->ConstructL( aFlags ); |
|
68 CleanupStack::Pop( self ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CNcsHeaderContainer::CNcsHeaderContainer |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CNcsHeaderContainer::CNcsHeaderContainer( |
|
77 CCoeControl& aParent, |
|
78 CFSMailBox& aMailBox, |
|
79 CAknPhysics* aPhysics ): |
|
80 iParent( aParent ), |
|
81 iFieldSizeObserver( static_cast< CNcsComposeViewContainer& >( aParent ) ), |
|
82 iMailBox( aMailBox ), |
|
83 iLongTapEventConsumed( EFalse ), |
|
84 iPhysics( aPhysics ) |
|
85 { |
|
86 FUNC_LOG; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CNcsHeaderContainer::ConstructL |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CNcsHeaderContainer::ConstructL( TInt aFlags ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 |
|
97 SetContainerWindowL( iParent ); |
|
98 |
|
99 CFreestyleEmailUiAppUi* fsAppUi = |
|
100 static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
101 |
|
102 // Create 'To' field |
|
103 iToField = CNcsAddressInputField::NewL( |
|
104 R_NCS_TO_FIELD_TEXT, |
|
105 CNcsAddressInputField::EInputFieldTo, |
|
106 &iFieldSizeObserver, |
|
107 this, this ); |
|
108 |
|
109 // Create 'Cc' field |
|
110 iCcField = CNcsAddressInputField::NewL( |
|
111 R_NCS_CC_FIELD_TEXT, |
|
112 CNcsAddressInputField::EInputFieldCc, |
|
113 &iFieldSizeObserver, |
|
114 this, this ); |
|
115 iCcField->MakeVisible( aFlags&ECcFieldVisible ); |
|
116 |
|
117 // Create 'Bcc' field |
|
118 iBccField = CNcsAddressInputField::NewL( |
|
119 R_NCS_BCC_FIELD_TEXT, |
|
120 CNcsAddressInputField::EInputFieldBcc, |
|
121 &iFieldSizeObserver, |
|
122 this, this ); |
|
123 iBccField->MakeVisible( aFlags&EBccFieldVisible ); |
|
124 |
|
125 // Create 'subject' field |
|
126 iSubjectField = CNcsSubjectField::NewL( R_FSE_EDITOR_HEADER_SUBJECT, |
|
127 &iFieldSizeObserver, this ); |
|
128 |
|
129 iAttachmentField = CNcsAttachmentField::NewL( R_NCS_ATTACHMENT_LABEL_TEXT, |
|
130 &iFieldSizeObserver, this ); |
|
131 |
|
132 // Setup the control array |
|
133 // Add all of them now so the container and parent is set correctly |
|
134 InitComponentArrayL(); |
|
135 CCoeControlArray& controls = Components(); |
|
136 controls.SetControlsOwnedExternally( ETrue ); |
|
137 |
|
138 controls.AppendLC( iToField ); |
|
139 CleanupStack::Pop( iToField ); |
|
140 controls.AppendLC( iCcField ); |
|
141 CleanupStack::Pop( iCcField ); |
|
142 controls.AppendLC( iBccField ); |
|
143 CleanupStack::Pop( iBccField ); |
|
144 controls.AppendLC( iSubjectField ); |
|
145 CleanupStack::Pop( iSubjectField ); |
|
146 controls.AppendLC( iAttachmentField ); |
|
147 CleanupStack::Pop( iAttachmentField ); |
|
148 |
|
149 iToField->SetFocus( ETrue ); |
|
150 |
|
151 if ( !(aFlags&ECcFieldVisible) ) |
|
152 { |
|
153 controls.Remove( iCcField ); |
|
154 } |
|
155 |
|
156 if ( !(aFlags&EBccFieldVisible) ) |
|
157 { |
|
158 controls.Remove( iBccField ); |
|
159 } |
|
160 |
|
161 // initially attachments field is hidden |
|
162 iAttachmentField->MakeVisible( EFalse ); |
|
163 controls.Remove( iAttachmentField ); |
|
164 |
|
165 // test whether mailbox supports remote lookup |
|
166 TBool remoteLookupSupported = |
|
167 TFsEmailUiUtility::IsRemoteLookupSupported( iMailBox ); |
|
168 |
|
169 iAacListBox = CNcsPopupListBox::NewL( |
|
170 this, iMailBox, *this, remoteLookupSupported ); |
|
171 iAacListBox->MakeVisible( EFalse ); |
|
172 |
|
173 iRALInProgress = EFalse; |
|
174 |
|
175 iToField->EnableKineticScrollingL( iPhysics ); |
|
176 iCcField->EnableKineticScrollingL( iPhysics ); |
|
177 iBccField->EnableKineticScrollingL( iPhysics ); |
|
178 iSubjectField->EnableKineticScrollingL( iPhysics ); |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CNcsHeaderContainer::~CNcsHeaderContainer |
|
183 // --------------------------------------------------------------------------- |
|
184 CNcsHeaderContainer::~CNcsHeaderContainer() |
|
185 { |
|
186 FUNC_LOG; |
|
187 delete iToField; |
|
188 delete iCcField; |
|
189 delete iBccField; |
|
190 delete iSubjectField; |
|
191 delete iAttachmentField; |
|
192 delete iAacListBox; |
|
193 delete iLongTapDetector; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------------------------- |
|
197 // CNcsHeaderContainer::FocusChanged |
|
198 // --------------------------------------------------------------------------- |
|
199 // |
|
200 void CNcsHeaderContainer::FocusChanged( TDrawNow aDrawNow ) |
|
201 { |
|
202 FUNC_LOG; |
|
203 |
|
204 CCoeControl* focused = iFocused; |
|
205 |
|
206 if ( !focused ) |
|
207 { |
|
208 focused = FindFocused(); |
|
209 iFocused = focused; |
|
210 } |
|
211 |
|
212 if ( !IsFocused() ) |
|
213 { |
|
214 if ( focused ) |
|
215 { |
|
216 // We're loosing focus (probably going to message body) |
|
217 // Commit changes and make sure no controls are focused. |
|
218 TRAP_IGNORE( CommitFieldL( focused ) ); |
|
219 focused->SetFocus( EFalse, aDrawNow ); |
|
220 iFocused = NULL; |
|
221 } |
|
222 |
|
223 // Remove MSK label when header loses focus |
|
224 TRAP_IGNORE( SetMskL() ); |
|
225 } |
|
226 else if ( IsFocused() && !focused ) |
|
227 { |
|
228 // We're gaining focus from the message body |
|
229 // Set the focus to the last control in the control array |
|
230 // (either attachment line or subject field) |
|
231 CCoeControlArray::TCursor cur = Components().End(); |
|
232 cur.Prev(); |
|
233 cur.Control<CCoeControl>()->SetFocus( ETrue, aDrawNow ); |
|
234 iFocused = cur.Control<CCoeControl>(); |
|
235 } |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CNcsHeaderContainer::ShowCursor |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CNcsHeaderContainer::ShowCursor( TBool aShow, TDrawNow aDrawNow ) |
|
243 { |
|
244 CCoeControl* focused = FindFocused(); |
|
245 if ( focused ) |
|
246 { |
|
247 iFocused = focused; |
|
248 } |
|
249 if ( iFocused ) |
|
250 { |
|
251 iFocused->SetFocus( aShow, aDrawNow ); |
|
252 } |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CNcsHeaderContainer::Draw() const |
|
257 // Draws the display |
|
258 // ----------------------------------------------------------------------------- |
|
259 void CNcsHeaderContainer::Draw( const TRect& /*aRect*/ ) const |
|
260 { |
|
261 FUNC_LOG; |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CNcsHeaderContainer::DrawAttachmentFocusNow() const |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CNcsHeaderContainer::DrawAttachmentFocusNow() |
|
269 { |
|
270 FUNC_LOG; |
|
271 iAttachmentField->DrawDeferred(); |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CNcsHeaderContainer::HandleControlArrayEventL() |
|
276 // Handles removal or additons of controls to the header. |
|
277 // ----------------------------------------------------------------------------- |
|
278 void CNcsHeaderContainer::HandleControlArrayEventL( |
|
279 CCoeControlArray::TEvent aEvent, |
|
280 const CCoeControlArray* /*aArray*/, |
|
281 CCoeControl* aControl, |
|
282 TInt /*aControlId*/ ) |
|
283 { |
|
284 FUNC_LOG; |
|
285 if ( aEvent == CCoeControlArray::EControlAdded ) |
|
286 { |
|
287 aControl->SetContainerWindowL( iParent ); |
|
288 aControl->MakeVisible( ETrue ); |
|
289 aControl->ActivateL(); |
|
290 } |
|
291 else if ( aEvent == CCoeControlArray::EControlRemoved ) |
|
292 { |
|
293 aControl->MakeVisible( EFalse ); |
|
294 } |
|
295 // Tell the parent to recalculate everything |
|
296 iFieldSizeObserver.UpdateFieldPosition( NULL ); |
|
297 } |
|
298 |
|
299 void CNcsHeaderContainer::SetMskL() |
|
300 { |
|
301 FUNC_LOG; |
|
302 |
|
303 // msk change disabled - probably some dialog/popup is visible |
|
304 if( iSwitchChangeMskOff ) |
|
305 { |
|
306 return; |
|
307 } |
|
308 |
|
309 CCoeControl* focused = FindFocused(); |
|
310 if ( focused == iToField || focused == iCcField || focused == iBccField ) |
|
311 { |
|
312 ChangeMskCommandL( R_FSE_QTN_MSK_ADD ); |
|
313 } |
|
314 else if ( focused == iAttachmentField ) |
|
315 { |
|
316 if ( GetAttachmentCount() > 1 ) |
|
317 { |
|
318 ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENTS ); |
|
319 } |
|
320 else if ( !HasRemoteAttachments() ) |
|
321 { |
|
322 ChangeMskCommandL( R_FSE_QTN_MSK_VIEWATTACHMENT ); |
|
323 } |
|
324 else // message has single remote attachment => no MSK function |
|
325 { |
|
326 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
327 } |
|
328 } |
|
329 else if ( focused == iSubjectField ) |
|
330 { |
|
331 ChangeMskCommandL( R_FSE_QTN_MSK_EMPTY ); |
|
332 } |
|
333 else |
|
334 { |
|
335 ChangeMskCommandL( R_FSE_QTN_MSK_BODY_MENU ); |
|
336 } |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CNcsHeaderContainer::HandlePointerEventL() |
|
341 // |
|
342 // ----------------------------------------------------------------------------- |
|
343 void CNcsHeaderContainer::HandlePointerEventL( |
|
344 const TPointerEvent& aPointerEvent ) |
|
345 { |
|
346 FUNC_LOG; |
|
347 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
348 { |
|
349 CCoeControl* clicked = 0; |
|
350 for ( TInt i=0; i < Components().Count(); ++i ) |
|
351 { |
|
352 TRect rc = Components().At( i ).iControl->Rect(); |
|
353 if ( rc.Contains( aPointerEvent.iPosition ) ) |
|
354 { |
|
355 clicked = Components().At( i ).iControl; |
|
356 } |
|
357 } |
|
358 |
|
359 if ( clicked ) |
|
360 { |
|
361 CCoeControl* pOldCtrl = FindFocused(); |
|
362 CCoeControl* pNewCtrl= clicked; |
|
363 |
|
364 if ( pOldCtrl != pNewCtrl ) |
|
365 { |
|
366 // Unfocus the control |
|
367 if ( pOldCtrl ) |
|
368 { |
|
369 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
370 } |
|
371 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
372 iFocused = pNewCtrl; |
|
373 // Commit changes to previously focused field. |
|
374 if ( pOldCtrl ) |
|
375 { |
|
376 CommitFieldL( pOldCtrl ); |
|
377 } |
|
378 |
|
379 // If the attachments label has changed focus |
|
380 if ( pOldCtrl == iAttachmentField || |
|
381 pNewCtrl == iAttachmentField ) |
|
382 { |
|
383 DrawAttachmentFocusNow(); |
|
384 } |
|
385 |
|
386 CNcsComposeViewContainer* container = |
|
387 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
388 container->UpdateScrollBar(); |
|
389 } |
|
390 |
|
391 if( iLongTapEventConsumed ) |
|
392 { |
|
393 iLongTapEventConsumed = EFalse; |
|
394 return; |
|
395 } |
|
396 |
|
397 TBool physicsActionOngoing( EFalse ); |
|
398 if ( iPhysics && iPhysics->OngoingPhysicsAction() != CAknPhysics::EAknPhysicsActionNone ) |
|
399 { |
|
400 physicsActionOngoing = ETrue; |
|
401 } |
|
402 |
|
403 if( pNewCtrl == iAttachmentField && !physicsActionOngoing ) |
|
404 { |
|
405 CNcsComposeViewContainer& parent = |
|
406 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
407 parent.HandleAttachmentsOpenCommandL(); |
|
408 } |
|
409 } |
|
410 } |
|
411 |
|
412 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CNcsHeaderContainer::HandleLongTapL() |
|
417 // |
|
418 // ----------------------------------------------------------------------------- |
|
419 void CNcsHeaderContainer::HandleLongTap( const TPoint& aPenEventLocation, |
|
420 const TPoint& aPenEventScreenLocation ) |
|
421 { |
|
422 FUNC_LOG; |
|
423 iLongTapEventConsumed = EFalse; |
|
424 |
|
425 CCoeControl* control = FindFocused(); |
|
426 TRect rect = iAttachmentField->Rect(); |
|
427 if( iAttachmentField->IsVisible() && |
|
428 rect.Contains( aPenEventLocation ) ) |
|
429 { |
|
430 iLongTapEventConsumed = ETrue; |
|
431 |
|
432 CNcsComposeViewContainer& parent = |
|
433 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
434 parent.LaunchStylusPopupMenu( aPenEventScreenLocation ); |
|
435 } |
|
436 } |
|
437 |
|
438 // ----------------------------------------------------------------------------- |
|
439 // CNcsHeaderContainer::NeedsLongTapL() |
|
440 // Whether long tap detection is needed or not (depends on whether touch |
|
441 // location is within attachment field or not) |
|
442 // ----------------------------------------------------------------------------- |
|
443 TBool CNcsHeaderContainer::NeedsLongTapL( const TPoint& aPenEventLocation ) |
|
444 { |
|
445 FUNC_LOG; |
|
446 |
|
447 TRect rect = iAttachmentField->Rect(); |
|
448 TBool result( EFalse ); |
|
449 if( iAttachmentField->IsVisible() && rect.Contains( aPenEventLocation ) && |
|
450 KNoAttachmentLabelFocused != |
|
451 iAttachmentField->FocusedAttachmentLabelIndex() ) |
|
452 { |
|
453 result = ETrue; |
|
454 } |
|
455 return result; |
|
456 } |
|
457 |
|
458 // ----------------------------------------------------------------------------- |
|
459 // CNcsHeaderContainer::OfferKeyEventL() |
|
460 // Handles key events |
|
461 // ----------------------------------------------------------------------------- |
|
462 TKeyResponse CNcsHeaderContainer::OfferKeyEventL( |
|
463 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
464 { |
|
465 FUNC_LOG; |
|
466 TKeyResponse ret( EKeyWasNotConsumed ); |
|
467 |
|
468 TBool doScroll( EFalse ); |
|
469 |
|
470 if( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow ) |
|
471 { |
|
472 if ( iAacListBox && iAacListBox->IsVisible() && |
|
473 !iAacListBox->IsPopupEmpty() ) |
|
474 { |
|
475 return iAacListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
476 } |
|
477 else |
|
478 { |
|
479 ret = FindFocused()->OfferKeyEventL( aKeyEvent, aType ); |
|
480 |
|
481 doScroll = ( ret == EKeyWasConsumed ); |
|
482 } |
|
483 |
|
484 if ( ret == EKeyWasNotConsumed ) |
|
485 { |
|
486 ret = ChangeFocusL( aKeyEvent ); |
|
487 DrawDeferred(); |
|
488 } |
|
489 } |
|
490 else |
|
491 { |
|
492 if ( FindFocused() == iAttachmentField ) |
|
493 { |
|
494 if ( aType == EEventKey ) |
|
495 { |
|
496 CNcsComposeViewContainer& parent = |
|
497 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
498 |
|
499 if ( aKeyEvent.iCode == EKeyEnter || |
|
500 aKeyEvent.iScanCode == EStdKeyEnter || |
|
501 aKeyEvent.iCode == EKeyOK || |
|
502 aKeyEvent.iScanCode == EStdKeyDevice3 ) |
|
503 { |
|
504 // open list or attachment |
|
505 parent.HandleAttachmentsOpenCommandL(); |
|
506 ret = EKeyWasConsumed; |
|
507 } |
|
508 } |
|
509 } |
|
510 else if ( IsPopupActive() && aType == EEventKey ) |
|
511 { |
|
512 // select current |
|
513 if( aKeyEvent.iCode == EKeyEnter || |
|
514 aKeyEvent.iCode == EKeyDevice4 || |
|
515 aKeyEvent.iCode == EKeyOK ) |
|
516 { |
|
517 DoPopupSelectL(); |
|
518 ret = EKeyWasConsumed; |
|
519 } |
|
520 } |
|
521 else |
|
522 { |
|
523 // Don't allow line feeds in header fields. |
|
524 // Could be nice if enter committed the field and moved the focus |
|
525 // to next one |
|
526 if ( aType == EEventKey && |
|
527 ( aKeyEvent.iCode == EKeyEnter || |
|
528 aKeyEvent.iScanCode == EStdKeyEnter) ) |
|
529 { |
|
530 FindFocused()->OfferKeyEventL( aKeyEvent, aType ); |
|
531 ret = EKeyWasConsumed; |
|
532 } |
|
533 } |
|
534 } |
|
535 if ( ret == EKeyWasNotConsumed ) |
|
536 { |
|
537 CCoeControl* focused = FindFocused(); |
|
538 if ( focused ) |
|
539 { |
|
540 ret = focused->OfferKeyEventL( aKeyEvent, aType ); |
|
541 |
|
542 if(aType==EEventKeyDown) |
|
543 { |
|
544 doScroll = ETrue; |
|
545 } |
|
546 else |
|
547 { |
|
548 doScroll = (ret == EKeyWasConsumed); |
|
549 } |
|
550 } |
|
551 } |
|
552 |
|
553 if( doScroll ) |
|
554 { |
|
555 DoScroll(); |
|
556 } |
|
557 |
|
558 return ret; |
|
559 } |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // CNcsHeaderContainer::FindFocused |
|
563 // --------------------------------------------------------------------------- |
|
564 // |
|
565 CCoeControl* CNcsHeaderContainer::FindFocused() const |
|
566 { |
|
567 FUNC_LOG; |
|
568 CCoeControlArray::TCursor cur = Components().Begin(); |
|
569 do |
|
570 { |
|
571 if ( cur.Control<CCoeControl>()->IsFocused() ) |
|
572 { |
|
573 return cur.Control<CCoeControl>(); |
|
574 } |
|
575 } |
|
576 while ( cur.Next() ); |
|
577 return NULL; |
|
578 } |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // CNcsHeaderContainer::ChangeFocusL() |
|
582 // Handles key events |
|
583 // ----------------------------------------------------------------------------- |
|
584 TKeyResponse CNcsHeaderContainer::ChangeFocusL( const TKeyEvent& aKeyEvent ) |
|
585 { |
|
586 FUNC_LOG; |
|
587 ASSERT( aKeyEvent.iCode == EKeyDownArrow || |
|
588 aKeyEvent.iCode == EKeyUpArrow ); |
|
589 TKeyResponse ret( EKeyWasNotConsumed ); |
|
590 |
|
591 CCoeControl* pOldCtrl = FindFocused(); |
|
592 |
|
593 // If nothing is focused we return |
|
594 if ( !pOldCtrl ) return ret; |
|
595 |
|
596 //If this is the first control in the list, don't change focus |
|
597 CCoeControlArray::TCursor cur = Components().Find(pOldCtrl); |
|
598 if ( aKeyEvent.iCode == EKeyUpArrow && cur == Components().Begin() ) |
|
599 { |
|
600 return ret; |
|
601 } |
|
602 |
|
603 // Unfocus the control |
|
604 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
605 |
|
606 CCoeControl* pNewCtrl= NULL; |
|
607 if ( aKeyEvent.iCode == EKeyDownArrow && cur.Next() ) |
|
608 { |
|
609 pNewCtrl = cur.Control<CCoeControl>(); |
|
610 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
611 ret = EKeyWasConsumed; |
|
612 } |
|
613 else if ( aKeyEvent.iCode == EKeyUpArrow && cur.Prev() ) |
|
614 { |
|
615 pNewCtrl = cur.Control<CCoeControl>(); |
|
616 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
617 ret = EKeyWasConsumed; |
|
618 } |
|
619 |
|
620 CNcsComposeViewContainer* container = |
|
621 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
622 if ( pOldCtrl == iToField ) |
|
623 { |
|
624 container->CommitL( EToField ); |
|
625 } |
|
626 else if ( pOldCtrl == iCcField) |
|
627 { |
|
628 container->CommitL( ECcField ); |
|
629 } |
|
630 else if ( pOldCtrl == iBccField) |
|
631 { |
|
632 container->CommitL( EBccField ); |
|
633 } |
|
634 else if ( pOldCtrl == iSubjectField) |
|
635 { |
|
636 container->CommitL( ESubjectField ); |
|
637 } |
|
638 |
|
639 // If the attachments label has changed focus |
|
640 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
|
641 { |
|
642 DrawAttachmentFocusNow(); |
|
643 } |
|
644 |
|
645 // if focus was changed, update scroll bar |
|
646 if ( ret == EKeyWasConsumed ) |
|
647 { |
|
648 container->UpdateScrollBar(); |
|
649 DoScroll(); |
|
650 } |
|
651 |
|
652 // NOTE: If we're leaving the header (down was pushed on last control) |
|
653 // then we return EKeyWasNotConsumed to make sure the |
|
654 // parent moves the focus to the control below this container |
|
655 return ret; |
|
656 } |
|
657 |
|
658 // ----------------------------------------------------------------------------- |
|
659 // CNcsHeaderContainer::UpdateFieldPosition() |
|
660 // One of the controls want me to readjust myself to a new position,' |
|
661 // anchoring arround the given control |
|
662 // ----------------------------------------------------------------------------- |
|
663 void CNcsHeaderContainer::UpdateFieldPosition( CCoeControl* aAnchor ) |
|
664 { |
|
665 FUNC_LOG; |
|
666 // if the anchor is NULL just call SizeChanged |
|
667 if ( !aAnchor ) |
|
668 { |
|
669 SizeChanged(); |
|
670 return; |
|
671 } |
|
672 |
|
673 CCoeControlArray::TCursor cur = Components().Find( aAnchor ); |
|
674 // figure out the new top position of the container |
|
675 TInt top = aAnchor->Rect().iTl.iY; |
|
676 if( cur.IsValid() ) |
|
677 { |
|
678 while ( cur.Prev() ) |
|
679 { |
|
680 CCoeControl* ctrl = cur.Control<CCoeControl>(); |
|
681 top -= ctrl->Rect().Height(); |
|
682 } |
|
683 } |
|
684 // Then check we didn't move too much and composer still fills the whole |
|
685 // visible area on the screen (i.e. don't scroll below the bottom of the |
|
686 // body field) |
|
687 CNcsComposeViewContainer& parent = |
|
688 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
689 TInt composerHeight = parent.ContentTotalHeight(); |
|
690 TInt screenHeight = parent.Rect().Height(); |
|
691 if ( composerHeight <= screenHeight ) |
|
692 { // no scrolling is needed at all since everything fits on screen |
|
693 top = 0; |
|
694 } |
|
695 else |
|
696 { |
|
697 top = Max( top, screenHeight - composerHeight ); |
|
698 } |
|
699 |
|
700 // The top edge of the header should never be lower than on the top edge |
|
701 // of the screen. For some reason, the calculation above leads to such |
|
702 // situation if recipient and subject fields are scrollable. If that |
|
703 // happens, increase the top value to 0 to prevent empty space showing up |
|
704 // above the header area. |
|
705 top = Min( top, 0 ); |
|
706 |
|
707 // set the new position of the container |
|
708 SetExtent( TPoint( Rect().iTl.iX, top ), Size() ); |
|
709 } |
|
710 |
|
711 // ----------------------------------------------------------------------------- |
|
712 // CNcsHeaderContainer::SizeChanged() |
|
713 // set size |
|
714 // ----------------------------------------------------------------------------- |
|
715 void CNcsHeaderContainer::SizeChanged() |
|
716 { |
|
717 FUNC_LOG; |
|
718 |
|
719 const TRect rect( Rect() ); |
|
720 |
|
721 TInt currentLine( 0 ); |
|
722 CCoeControlArray::TCursor cur = Components().Begin(); |
|
723 do |
|
724 { |
|
725 const TInt lineCount( ToNcsControl( cur )->LayoutLineCount() ); |
|
726 if ( lineCount > 0 ) |
|
727 { |
|
728 NcsUtility::LayoutHeaderControl( cur.Control<CCoeControl>(), |
|
729 rect, currentLine, lineCount ); |
|
730 // Do not use stored value lineCount because count may change |
|
731 // during layout (e.g. when orientation is changed => edit field |
|
732 // length may change => it grows or shrinks) |
|
733 currentLine += ToNcsControl( cur )->LayoutLineCount(); |
|
734 } |
|
735 } while ( cur.Next() ); |
|
736 |
|
737 if( iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() ) |
|
738 { |
|
739 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
|
740 } |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CNcsHeaderContainer::PositionChanged() |
|
745 // set size |
|
746 // ----------------------------------------------------------------------------- |
|
747 void CNcsHeaderContainer::PositionChanged() |
|
748 { |
|
749 FUNC_LOG; |
|
750 } |
|
751 |
|
752 // ----------------------------------------------------------------------------- |
|
753 // CNcsHeaderContainer::ChangePositions() |
|
754 // set positions |
|
755 // ----------------------------------------------------------------------------- |
|
756 // |
|
757 void CNcsHeaderContainer::ChangePositions() |
|
758 { |
|
759 FUNC_LOG; |
|
760 TPoint nextPoint( Rect().iTl ); |
|
761 |
|
762 CCoeControl* ctrl; |
|
763 CCoeControlArray::TCursor cur = Components().Begin(); |
|
764 do |
|
765 { |
|
766 ctrl = cur.Control<CCoeControl>(); |
|
767 ctrl->SetPosition( nextPoint ); |
|
768 nextPoint.iY += ctrl->Size().iHeight; |
|
769 } |
|
770 while ( cur.Next() ); |
|
771 } |
|
772 |
|
773 |
|
774 // --------------------------------------------------------------------------- |
|
775 // CNcsHeaderContainer::NeedsAifMenu |
|
776 // --------------------------------------------------------------------------- |
|
777 // |
|
778 TBool CNcsHeaderContainer::NeedsAifMenu() const |
|
779 { |
|
780 FUNC_LOG; |
|
781 |
|
782 CCoeControl* focused = FindFocused(); |
|
783 |
|
784 // Has to be an AIF field |
|
785 TBool ret = EFalse; |
|
786 |
|
787 if ( IsAddressInputField( focused ) ) |
|
788 { |
|
789 CNcsAddressInputField* aifFocused = NULL; |
|
790 aifFocused = static_cast<CNcsAddressInputField*>( focused ); |
|
791 ret = ( aifFocused->TextEditor()->SelectionLength() > 1 ); |
|
792 } |
|
793 |
|
794 return ret; |
|
795 } |
|
796 |
|
797 // --------------------------------------------------------------------------- |
|
798 // CNcsHeaderContainer::GetToLineHeight |
|
799 // --------------------------------------------------------------------------- |
|
800 // |
|
801 TInt CNcsHeaderContainer::GetToLineHeight() const |
|
802 { |
|
803 FUNC_LOG; |
|
804 TInt lineHeight = 0; |
|
805 |
|
806 if(iToField) |
|
807 { |
|
808 TRect lineRect; |
|
809 TRAPD(err, iToField->GetLineRectL(lineRect) ); |
|
810 if(err == KErrNone) |
|
811 { |
|
812 lineHeight = lineRect.iBr.iY - lineRect.iTl.iY; |
|
813 } |
|
814 } |
|
815 return lineHeight; |
|
816 } |
|
817 |
|
818 // --------------------------------------------------------------------------- |
|
819 // CNcsHeaderContainer::GetTotalHeight |
|
820 // --------------------------------------------------------------------------- |
|
821 // |
|
822 TInt CNcsHeaderContainer::GetTotalHeight() const |
|
823 { |
|
824 FUNC_LOG; |
|
825 TInt ret = 0; |
|
826 CCoeControlArray::TCursor cur = Components().Begin(); |
|
827 do |
|
828 { |
|
829 CCoeControl* ctrl = cur.Control<CCoeControl>(); |
|
830 ret += ctrl->Size().iHeight; |
|
831 } |
|
832 while ( cur.Next() ); |
|
833 return ret; |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // CNcsHeaderContainer::SetAttachmentLabelTextsLD |
|
838 // |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 void CNcsHeaderContainer::SetAttachmentLabelTextsLD( |
|
842 CDesCArray* aAttachmentNames, CDesCArray* aAttachmentSizes ) |
|
843 { |
|
844 FUNC_LOG; |
|
845 iAttachmentField->SetTextsLD( aAttachmentNames, aAttachmentSizes ); |
|
846 if( aAttachmentNames ) |
|
847 { |
|
848 ShowAttachmentLabelL(); |
|
849 DrawAttachmentFocusNow(); |
|
850 } |
|
851 } |
|
852 |
|
853 // ----------------------------------------------------------------------------- |
|
854 // CNcsHeaderContainer::FocusedAttachmentLabelIndex |
|
855 // |
|
856 // ----------------------------------------------------------------------------- |
|
857 // |
|
858 TInt CNcsHeaderContainer::FocusedAttachmentLabelIndex() |
|
859 { |
|
860 FUNC_LOG; |
|
861 return iAttachmentField->FocusedAttachmentLabelIndex(); |
|
862 } |
|
863 |
|
864 // ----------------------------------------------------------------------------- |
|
865 // CNcsHeaderContainer::ShowAttachmentLabel() |
|
866 // ----------------------------------------------------------------------------- |
|
867 // |
|
868 void CNcsHeaderContainer::ShowAttachmentLabelL() |
|
869 { |
|
870 FUNC_LOG; |
|
871 if ( !iAttachmentField->IsVisible() ) |
|
872 { |
|
873 CCoeControlArray::TCursor cur = Components().End(); |
|
874 Components().InsertLC( cur, iAttachmentField ); |
|
875 CleanupStack::Pop( iAttachmentField ); |
|
876 |
|
877 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
878 |
|
879 CCoeControl* pOldCtrl = FindFocused(); |
|
880 if ( pOldCtrl ) |
|
881 { |
|
882 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
883 } |
|
884 |
|
885 iAttachmentField->SetFocus( ETrue, ENoDrawNow ); |
|
886 iFieldSizeObserver.UpdateFieldPosition( iAttachmentField ); |
|
887 } |
|
888 } |
|
889 |
|
890 // ----------------------------------------------------------------------------- |
|
891 // CNcsHeaderContainer::HideAttachmentLabel() |
|
892 // ----------------------------------------------------------------------------- |
|
893 // |
|
894 void CNcsHeaderContainer::HideAttachmentLabel() |
|
895 { |
|
896 FUNC_LOG; |
|
897 // check if we are focused and in that case |
|
898 // unfocus attachment filed and focus previous control |
|
899 CCoeControl* pOldCtrl = FindFocused(); |
|
900 CCoeControl* pNewCtrl = NULL; |
|
901 |
|
902 if ( pOldCtrl == iAttachmentField ) |
|
903 { |
|
904 CCoeControlArray::TCursor cur = Components().Find( pOldCtrl ); |
|
905 pOldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
906 |
|
907 if ( cur.Prev() ) |
|
908 { |
|
909 pNewCtrl = cur.Control<CCoeControl>(); |
|
910 pNewCtrl->SetFocus( ETrue, ENoDrawNow ); |
|
911 } |
|
912 } |
|
913 else |
|
914 { |
|
915 pNewCtrl = pOldCtrl; // no need to move focus |
|
916 } |
|
917 |
|
918 if ( pOldCtrl == iAttachmentField || pNewCtrl == iAttachmentField ) |
|
919 { |
|
920 DrawAttachmentFocusNow(); |
|
921 } |
|
922 |
|
923 iAttachmentField->MakeVisible( EFalse ); |
|
924 Components().Remove( iAttachmentField ); |
|
925 |
|
926 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
927 |
|
928 // Scroll to currently focused field |
|
929 if ( pNewCtrl ) |
|
930 { |
|
931 iFieldSizeObserver.UpdateFieldPosition( pNewCtrl ); |
|
932 } |
|
933 |
|
934 } |
|
935 |
|
936 // ----------------------------------------------------------------------------- |
|
937 // CNcsHeaderContainer::SetBccFieldVisibleL() |
|
938 // ----------------------------------------------------------------------------- |
|
939 // |
|
940 void CNcsHeaderContainer::SetBccFieldVisibleL( |
|
941 TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
|
942 { |
|
943 FUNC_LOG; |
|
944 if ( iBccField->IsVisible() == aVisible ) |
|
945 { |
|
946 return; |
|
947 } |
|
948 |
|
949 if ( aVisible ) |
|
950 { |
|
951 CCoeControlArray::TCursor cur = Components().Find( iSubjectField ); |
|
952 Components().InsertLC( cur, iBccField ); |
|
953 CleanupStack::Pop( iBccField ); |
|
954 |
|
955 if ( aFocus ) |
|
956 { |
|
957 CCoeControl* focused = FindFocused(); |
|
958 |
|
959 if ( focused ) |
|
960 { |
|
961 focused->SetFocus( EFalse ); |
|
962 } |
|
963 iBccField->SetFocus( ETrue ); |
|
964 iFocused = iBccField; |
|
965 iBccField->SelectAllTextL(); |
|
966 } |
|
967 } |
|
968 else |
|
969 { |
|
970 if ( iBccField->IsFocused() ) |
|
971 { |
|
972 CCoeControlArray::TCursor cur = Components().Find( iBccField ); |
|
973 ASSERT( cur.IsValid() ); |
|
974 |
|
975 iBccField->SetFocus( EFalse ); |
|
976 |
|
977 cur.Prev(); // Get the control before this field |
|
978 cur.Control<CCoeControl>()->SetFocus( ETrue ); |
|
979 } |
|
980 Components().Remove( iBccField ); |
|
981 iFocused = iSubjectField; |
|
982 } |
|
983 |
|
984 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
985 |
|
986 if ( aDrawNow == EDrawNow ) |
|
987 { |
|
988 DrawDeferred(); |
|
989 } |
|
990 } |
|
991 |
|
992 // ----------------------------------------------------------------------------- |
|
993 // CNcsHeaderContainer::SetCcFieldVisibleL() |
|
994 // ----------------------------------------------------------------------------- |
|
995 void CNcsHeaderContainer::SetCcFieldVisibleL( |
|
996 TBool aVisible, TDrawNow aDrawNow, TBool aFocus ) |
|
997 { |
|
998 FUNC_LOG; |
|
999 if ( iCcField->IsVisible() == aVisible ) |
|
1000 { |
|
1001 return; |
|
1002 } |
|
1003 |
|
1004 if ( aVisible ) |
|
1005 { |
|
1006 Components().InsertAfterLC( Components().Id( *iToField ), iCcField ); |
|
1007 CleanupStack::Pop( iCcField ); |
|
1008 |
|
1009 if ( aFocus ) |
|
1010 { |
|
1011 CCoeControl* focused = FindFocused(); |
|
1012 if ( focused ) |
|
1013 { |
|
1014 focused->SetFocus( EFalse ); |
|
1015 } |
|
1016 iCcField->SetFocus( ETrue ); |
|
1017 iFocused = iCcField; |
|
1018 iCcField->SelectAllTextL(); |
|
1019 } |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 if( iCcField->IsFocused() ) |
|
1024 { |
|
1025 iCcField->SetFocus( EFalse ); |
|
1026 iToField->SetFocus( ETrue ); |
|
1027 } |
|
1028 Components().Remove( iCcField ); |
|
1029 iFocused = iToField; |
|
1030 } |
|
1031 |
|
1032 TRAP_IGNORE( iFieldSizeObserver.UpdateFieldSizeL() ); |
|
1033 |
|
1034 if ( aDrawNow == EDrawNow ) |
|
1035 { |
|
1036 DrawDeferred(); |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // CNcsHeaderContainer::MopSupplyObject |
|
1042 // From CCoeControl. |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 TTypeUid::Ptr CNcsHeaderContainer::MopSupplyObject( TTypeUid aId ) |
|
1045 { |
|
1046 FUNC_LOG; |
|
1047 return CCoeControl::MopSupplyObject( aId ); |
|
1048 } |
|
1049 |
|
1050 // --------------------------------------------------------------------------- |
|
1051 // CNcsHeaderContainer::LineCount |
|
1052 // --------------------------------------------------------------------------- |
|
1053 // |
|
1054 TInt CNcsHeaderContainer::LineCount() const |
|
1055 { |
|
1056 FUNC_LOG; |
|
1057 TInt cnt = 0; |
|
1058 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1059 do |
|
1060 { |
|
1061 MNcsControl* ctrl = ToNcsControl( cur ); |
|
1062 cnt += ctrl->LineCount(); |
|
1063 } |
|
1064 while ( cur.Next() ); |
|
1065 return cnt; |
|
1066 } |
|
1067 |
|
1068 // --------------------------------------------------------------------------- |
|
1069 // CNcsHeaderContainer::ScrollableLines |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // |
|
1072 TInt CNcsHeaderContainer::ScrollableLines() const |
|
1073 { |
|
1074 FUNC_LOG; |
|
1075 TInt cnt = 0; |
|
1076 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1077 do |
|
1078 { |
|
1079 MNcsControl* ctrl = ToNcsControl( cur ); |
|
1080 cnt += ctrl->ScrollableLines(); |
|
1081 } |
|
1082 while ( cur.Next() ); |
|
1083 return cnt; |
|
1084 } |
|
1085 |
|
1086 // --------------------------------------------------------------------------- |
|
1087 // CNcsHeaderContainer::CursorPosition |
|
1088 // --------------------------------------------------------------------------- |
|
1089 // |
|
1090 TInt CNcsHeaderContainer::CursorPosition() const |
|
1091 { |
|
1092 FUNC_LOG; |
|
1093 CCoeControl* coe = FindFocused(); |
|
1094 if ( !coe ) |
|
1095 { |
|
1096 return 0; |
|
1097 } |
|
1098 |
|
1099 MNcsControl* ncsCtrl = dynamic_cast<MNcsControl*>( coe ); |
|
1100 // This will give the the position relative to the top of the control |
|
1101 TInt pos(0); // Coverity error fix ncsCtrl could be NULL |
|
1102 if(ncsCtrl) |
|
1103 { |
|
1104 pos = ncsCtrl->CursorPosition(); |
|
1105 // add the location of the top of the control relative to the top |
|
1106 // of the header. |
|
1107 pos += coe->Rect().iTl.iY - Rect().iTl.iY; |
|
1108 } |
|
1109 return pos; |
|
1110 } |
|
1111 |
|
1112 // --------------------------------------------------------------------------- |
|
1113 // CNcsHeaderContainer::CursorLineNumber |
|
1114 // --------------------------------------------------------------------------- |
|
1115 // |
|
1116 TInt CNcsHeaderContainer::CursorLineNumber() const |
|
1117 { |
|
1118 FUNC_LOG; |
|
1119 TInt cnt = 0; |
|
1120 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1121 do |
|
1122 { |
|
1123 CCoeControl* coe = cur.Control<CCoeControl>(); |
|
1124 MNcsControl* ctrl = ToNcsControl( cur ); |
|
1125 if ( !coe->IsFocused() ) |
|
1126 { |
|
1127 cnt += ctrl->LineCount(); |
|
1128 } |
|
1129 else |
|
1130 { |
|
1131 cnt += ctrl->CursorLineNumber(); |
|
1132 break; |
|
1133 } |
|
1134 } |
|
1135 while ( cur.Next() ); |
|
1136 return cnt; |
|
1137 } |
|
1138 |
|
1139 // --------------------------------------------------------------------------- |
|
1140 // CNcsHeaderContainer::GetNumChars |
|
1141 // --------------------------------------------------------------------------- |
|
1142 // |
|
1143 TInt CNcsHeaderContainer::GetNumChars() const |
|
1144 { |
|
1145 FUNC_LOG; |
|
1146 TInt cnt = iToField->GetNumChars() + |
|
1147 iCcField->GetNumChars() + |
|
1148 iBccField->GetNumChars() + |
|
1149 iSubjectField->GetNumChars(); |
|
1150 |
|
1151 return cnt; |
|
1152 } |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CNcsHeaderContainer::UpdatePopupContactListL() |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CNcsHeaderContainer::UpdatePopupContactListL( |
|
1159 const TDesC& aMatchString, TBool /*aListAll*/ ) |
|
1160 { |
|
1161 FUNC_LOG; |
|
1162 |
|
1163 // do update only for address fields |
|
1164 CCoeControl* focused = FindFocused(); |
|
1165 |
|
1166 if ( !IsAddressInputField( focused ) ) |
|
1167 { |
|
1168 return; |
|
1169 } |
|
1170 |
|
1171 if ( aMatchString.CompareC( KNullDesC ) == 0 || |
|
1172 aMatchString.Compare( KAddressDelimeterSemiColon ) == 0 ) |
|
1173 { |
|
1174 ClosePopupContactListL(); |
|
1175 return; |
|
1176 } |
|
1177 |
|
1178 if( !iAacListBox->IsVisible() ) |
|
1179 { |
|
1180 iAacListBox->SetPopupMaxRect( CalculatePopupRect() ); |
|
1181 iAacListBox->InitAndSearchL( aMatchString, 1 ); |
|
1182 iAacListBox->ActivateL(); |
|
1183 } |
|
1184 else |
|
1185 { |
|
1186 iAacListBox->SetSearchTextL( aMatchString ); |
|
1187 } |
|
1188 } |
|
1189 |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // CNcsHeaderContainer::ClosePopupContactListL() |
|
1192 // ----------------------------------------------------------------------------- |
|
1193 // |
|
1194 void CNcsHeaderContainer::ClosePopupContactListL() |
|
1195 { |
|
1196 FUNC_LOG; |
|
1197 |
|
1198 if ( iAacListBox->IsVisible() ) |
|
1199 { |
|
1200 iAacListBox->MakeVisible( EFalse ); |
|
1201 ShowPopupMenuBarL( EFalse ); |
|
1202 |
|
1203 // The focused address field should be redrawn after the popup is |
|
1204 // closed to fix the field border. |
|
1205 if ( iToField->IsFocused() ) |
|
1206 { |
|
1207 iToField->DrawDeferred(); |
|
1208 } |
|
1209 else if ( iCcField->IsFocused() ) |
|
1210 { |
|
1211 iCcField->DrawDeferred(); |
|
1212 } |
|
1213 else if ( iBccField->IsFocused() ) |
|
1214 { |
|
1215 iBccField->DrawDeferred(); |
|
1216 } |
|
1217 } |
|
1218 } |
|
1219 |
|
1220 // --------------------------------------------------------------------------- |
|
1221 // CNcsHeaderContainer::ShowPopupMenuBarL |
|
1222 // --------------------------------------------------------------------------- |
|
1223 // |
|
1224 void CNcsHeaderContainer::ShowPopupMenuBarL( TBool aShow ) |
|
1225 { |
|
1226 FUNC_LOG; |
|
1227 if ( iMenuBar ) |
|
1228 { |
|
1229 if( aShow ) |
|
1230 { |
|
1231 iMenuBar->SetCommandSetL( R_AVKON_SOFTKEYS_CANCEL ); |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 iMenuBar->SetCommandSetL( R_FSE_EDITOR_SOFTKEYS_OPTIONS_CLOSE ); |
|
1236 SetMskL(); |
|
1237 } |
|
1238 iMenuBar->DrawDeferred(); |
|
1239 } |
|
1240 } |
|
1241 |
|
1242 // --------------------------------------------------------------------------- |
|
1243 // CNcsHeaderContainer::DeleteSelectionL |
|
1244 // --------------------------------------------------------------------------- |
|
1245 // |
|
1246 void CNcsHeaderContainer::DeleteSelectionL() |
|
1247 { |
|
1248 FUNC_LOG; |
|
1249 |
|
1250 CCoeControl* focused = FindFocused(); |
|
1251 |
|
1252 if ( IsAddressInputField( focused ) ) |
|
1253 { |
|
1254 CNcsAddressInputField* field = NULL; |
|
1255 field = static_cast<CNcsAddressInputField*>( focused ); |
|
1256 TKeyEvent event; // This mimics c -button pressing |
|
1257 event.iCode = EKeyBackspace; |
|
1258 event.iScanCode = EStdKeyBackspace; |
|
1259 event.iModifiers = EModifierAutorepeatable|EModifierNumLock; |
|
1260 event.iRepeats = 0; |
|
1261 TEventCode code = EEventKey; |
|
1262 field->OfferKeyEventL( event, code ); |
|
1263 } |
|
1264 } |
|
1265 |
|
1266 // --------------------------------------------------------------------------- |
|
1267 // CNcsHeaderContainer::SelectAllToFieldTextL |
|
1268 // --------------------------------------------------------------------------- |
|
1269 // |
|
1270 void CNcsHeaderContainer::SelectAllToFieldTextL() |
|
1271 { |
|
1272 FUNC_LOG; |
|
1273 iToField->SelectAllTextL(); |
|
1274 } |
|
1275 |
|
1276 // --------------------------------------------------------------------------- |
|
1277 // CNcsHeaderContainer::SelectAllCcFieldTextL |
|
1278 // --------------------------------------------------------------------------- |
|
1279 // |
|
1280 void CNcsHeaderContainer::SelectAllCcFieldTextL() |
|
1281 { |
|
1282 FUNC_LOG; |
|
1283 iCcField->SelectAllTextL(); |
|
1284 } |
|
1285 |
|
1286 // --------------------------------------------------------------------------- |
|
1287 // CNcsHeaderContainer::SelectAllBccFieldTextL |
|
1288 // --------------------------------------------------------------------------- |
|
1289 // |
|
1290 void CNcsHeaderContainer::SelectAllBccFieldTextL() |
|
1291 { |
|
1292 FUNC_LOG; |
|
1293 iBccField->SelectAllTextL(); |
|
1294 } |
|
1295 |
|
1296 // --------------------------------------------------------------------------- |
|
1297 // CNcsHeaderContainer::SelectAllSubjectFieldTextL |
|
1298 // --------------------------------------------------------------------------- |
|
1299 // |
|
1300 void CNcsHeaderContainer::SelectAllSubjectFieldTextL() |
|
1301 { |
|
1302 FUNC_LOG; |
|
1303 iSubjectField->SelectAllTextL(); |
|
1304 } |
|
1305 |
|
1306 // ----------------------------------------------------------------------------- |
|
1307 // CNcsHeaderContainer::CalculatePopupRect |
|
1308 // ----------------------------------------------------------------------------- |
|
1309 TRect CNcsHeaderContainer::CalculatePopupRect() |
|
1310 { |
|
1311 FUNC_LOG; |
|
1312 // get focused control rect |
|
1313 TRect popupRect; |
|
1314 |
|
1315 CCoeControl* focused = FindFocused(); |
|
1316 if ( IsAddressInputField( focused ) ) |
|
1317 { |
|
1318 CNcsAddressInputField* aifEditor = |
|
1319 static_cast<CNcsAddressInputField*>( focused ); |
|
1320 |
|
1321 TPoint editorPos = aifEditor->Editor()->PositionRelativeToScreen(); |
|
1322 TRect editorRect = aifEditor->Editor()->Rect(); |
|
1323 |
|
1324 popupRect.iTl = TPoint( editorPos.iX, |
|
1325 editorPos.iY + aifEditor->CursorPosition() + 1 ); |
|
1326 |
|
1327 popupRect.iBr = TPoint( editorPos.iX + editorRect.Width(), |
|
1328 iParent.PositionRelativeToScreen().iY + iParent.Rect().Height() ); |
|
1329 } |
|
1330 |
|
1331 return popupRect; |
|
1332 } |
|
1333 |
|
1334 // ----------------------------------------------------------------------------- |
|
1335 // CNcsHeaderContainer::DoPopupSelect |
|
1336 // ----------------------------------------------------------------------------- |
|
1337 void CNcsHeaderContainer::DoPopupSelectL() |
|
1338 { |
|
1339 FUNC_LOG; |
|
1340 __ASSERT_DEBUG( iAacListBox, Panic( ENcsBasicUi ) ); |
|
1341 __ASSERT_DEBUG( &iMailBox, Panic( ENcsBasicUi ) ); |
|
1342 |
|
1343 if( iAacListBox->IsRemoteLookupItemSelected() ) |
|
1344 { |
|
1345 CCoeControl* focused = FindFocused(); |
|
1346 |
|
1347 if ( IsAddressInputField( focused ) ) |
|
1348 { |
|
1349 // Launch remote lookup |
|
1350 iRALInProgress = ETrue; |
|
1351 CNcsAddressInputField* addressField = NULL; |
|
1352 addressField = static_cast<CNcsAddressInputField*>( focused ); |
|
1353 HBufC* lookupText = addressField->GetLookupTextLC(); |
|
1354 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason ex; |
|
1355 CNcsEmailAddressObject* address = ExecuteRemoteSearchL( |
|
1356 ex, *lookupText ); |
|
1357 iRALInProgress = EFalse; |
|
1358 if ( address ) |
|
1359 { |
|
1360 CleanupStack::PushL( address ); |
|
1361 IncludeAddressL( *address ); |
|
1362 CleanupStack::PopAndDestroy( address ); |
|
1363 } |
|
1364 CleanupStack::PopAndDestroy( lookupText ); |
|
1365 CNcsComposeViewContainer& parent = |
|
1366 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1367 parent.FocusChanged( EDrawNow ); |
|
1368 } |
|
1369 } |
|
1370 else if( !iAacListBox->IsPopupEmpty() ) |
|
1371 { |
|
1372 CNcsEmailAddressObject* emailAddress = |
|
1373 iAacListBox->ReturnCurrentEmailAddressLC(); |
|
1374 if( emailAddress ) |
|
1375 { |
|
1376 if ( emailAddress->EmailAddress().Compare( KNullDesC ) != 0 ) |
|
1377 { |
|
1378 IncludeAddressL( *emailAddress ); |
|
1379 } |
|
1380 else |
|
1381 { |
|
1382 // selected contact doesn't have email address, launch remote |
|
1383 // contact lookup rcl must be usable, since otherwise there |
|
1384 // couldn't be any items without email addresses |
|
1385 iRALInProgress = ETrue; |
|
1386 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason |
|
1387 exitReason; |
|
1388 CNcsEmailAddressObject* remAddress = ExecuteRemoteSearchL( |
|
1389 exitReason, |
|
1390 emailAddress->DisplayName() ); |
|
1391 iRALInProgress = EFalse; |
|
1392 // Refresh the toolbar. It was hidden during the remote search |
|
1393 // and now it needs to be shown. FocusChanged () will do it. |
|
1394 CNcsComposeViewContainer& parent = |
|
1395 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1396 parent.FocusChanged( EDrawNow ); |
|
1397 |
|
1398 if ( remAddress ) |
|
1399 { |
|
1400 CleanupStack::PushL( remAddress ); |
|
1401 IncludeAddressL( *remAddress ); |
|
1402 CleanupStack::PopAndDestroy( remAddress ); |
|
1403 } |
|
1404 } |
|
1405 CleanupStack::PopAndDestroy( emailAddress ); |
|
1406 } |
|
1407 } |
|
1408 ClosePopupContactListL(); |
|
1409 } |
|
1410 |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 // CNcsHeaderContainer::IsPopupActive |
|
1413 // ----------------------------------------------------------------------------- |
|
1414 TBool CNcsHeaderContainer::IsPopupActive() const |
|
1415 { |
|
1416 FUNC_LOG; |
|
1417 if ( iAacListBox && iAacListBox->IsVisible() ) |
|
1418 { |
|
1419 return ETrue; |
|
1420 } |
|
1421 else |
|
1422 { |
|
1423 return EFalse; |
|
1424 } |
|
1425 } |
|
1426 |
|
1427 // --------------------------------------------------------------------------- |
|
1428 // CNcsHeaderContainer::IsToFieldEmpty |
|
1429 // --------------------------------------------------------------------------- |
|
1430 // |
|
1431 TBool CNcsHeaderContainer::IsToFieldEmpty() const |
|
1432 { |
|
1433 FUNC_LOG; |
|
1434 return ( GetToFieldLength() < 1 ); |
|
1435 } |
|
1436 |
|
1437 // --------------------------------------------------------------------------- |
|
1438 // CNcsHeaderContainer::IsCcFieldEmpty |
|
1439 // --------------------------------------------------------------------------- |
|
1440 // |
|
1441 TBool CNcsHeaderContainer::IsCcFieldEmpty() const |
|
1442 { |
|
1443 FUNC_LOG; |
|
1444 return ( !IsCcFieldVisible() || GetCcFieldLength() < 1 ); |
|
1445 } |
|
1446 |
|
1447 // --------------------------------------------------------------------------- |
|
1448 // CNcsHeaderContainer::IsBccFieldEmpty |
|
1449 // --------------------------------------------------------------------------- |
|
1450 // |
|
1451 TBool CNcsHeaderContainer::IsBccFieldEmpty() const |
|
1452 { |
|
1453 FUNC_LOG; |
|
1454 return ( !IsBccFieldVisible() || GetBccFieldLength() < 1 ); |
|
1455 } |
|
1456 |
|
1457 // --------------------------------------------------------------------------- |
|
1458 // CNcsHeaderContainer::IsSubjectFieldEmpty |
|
1459 // --------------------------------------------------------------------------- |
|
1460 // |
|
1461 TBool CNcsHeaderContainer::IsSubjectFieldEmpty() const |
|
1462 { |
|
1463 FUNC_LOG; |
|
1464 return ( GetSubjectFieldLength() < 1 ); |
|
1465 } |
|
1466 |
|
1467 // --------------------------------------------------------------------------- |
|
1468 // CNcsHeaderContainer::GetToFieldAddressesL |
|
1469 // --------------------------------------------------------------------------- |
|
1470 // |
|
1471 const RPointerArray<CNcsEmailAddressObject>& |
|
1472 CNcsHeaderContainer::GetToFieldAddressesL( TBool aParseNow ) |
|
1473 { |
|
1474 return iToField->GetAddressesL( aParseNow ); |
|
1475 } |
|
1476 |
|
1477 // --------------------------------------------------------------------------- |
|
1478 // CNcsHeaderContainer::GetCcFieldAddressesL |
|
1479 // --------------------------------------------------------------------------- |
|
1480 // |
|
1481 const RPointerArray<CNcsEmailAddressObject>& |
|
1482 CNcsHeaderContainer::GetCcFieldAddressesL( TBool aParseNow ) |
|
1483 { |
|
1484 return iCcField->GetAddressesL( aParseNow ); |
|
1485 } |
|
1486 |
|
1487 // --------------------------------------------------------------------------- |
|
1488 // CNcsHeaderContainer::GetBccFieldAddressesL |
|
1489 // --------------------------------------------------------------------------- |
|
1490 // |
|
1491 const RPointerArray<CNcsEmailAddressObject>& |
|
1492 CNcsHeaderContainer::GetBccFieldAddressesL( TBool aParseNow ) |
|
1493 { |
|
1494 return iBccField->GetAddressesL( aParseNow ); |
|
1495 } |
|
1496 |
|
1497 // --------------------------------------------------------------------------- |
|
1498 // CNcsHeaderContainer::GetSubjectLC |
|
1499 // --------------------------------------------------------------------------- |
|
1500 // |
|
1501 HBufC* CNcsHeaderContainer::GetSubjectLC() const |
|
1502 { |
|
1503 FUNC_LOG; |
|
1504 HBufC* subject = |
|
1505 HBufC::NewLC( iSubjectField->Editor()->TextLength() + 2 ); |
|
1506 TPtr des = subject->Des(); |
|
1507 iSubjectField->Editor()->GetText( des ); |
|
1508 return subject; |
|
1509 } |
|
1510 |
|
1511 // --------------------------------------------------------------------------- |
|
1512 // CNcsHeaderContainer::IsBccFieldVisible |
|
1513 // --------------------------------------------------------------------------- |
|
1514 // |
|
1515 TBool CNcsHeaderContainer::IsBccFieldVisible() const |
|
1516 { |
|
1517 FUNC_LOG; |
|
1518 return iBccField->IsVisible(); |
|
1519 } |
|
1520 |
|
1521 // --------------------------------------------------------------------------- |
|
1522 // CNcsHeaderContainer::IsCcFieldVisible |
|
1523 // --------------------------------------------------------------------------- |
|
1524 // |
|
1525 TBool CNcsHeaderContainer::IsCcFieldVisible() const |
|
1526 { |
|
1527 FUNC_LOG; |
|
1528 return iCcField->IsVisible(); |
|
1529 } |
|
1530 |
|
1531 // --------------------------------------------------------------------------- |
|
1532 // CNcsHeaderContainer::IsFocusAttachments |
|
1533 // --------------------------------------------------------------------------- |
|
1534 // |
|
1535 TBool CNcsHeaderContainer::IsFocusAttachments() const |
|
1536 { |
|
1537 FUNC_LOG; |
|
1538 return ( FindFocused() == iAttachmentField ); |
|
1539 } |
|
1540 |
|
1541 // --------------------------------------------------------------------------- |
|
1542 // CNcsHeaderContainer::IsFocusTo |
|
1543 // --------------------------------------------------------------------------- |
|
1544 // |
|
1545 TBool CNcsHeaderContainer::IsFocusTo() const |
|
1546 { |
|
1547 FUNC_LOG; |
|
1548 return ( FindFocused() == iToField ); |
|
1549 } |
|
1550 |
|
1551 // --------------------------------------------------------------------------- |
|
1552 // CNcsHeaderContainer::IsFocusCc |
|
1553 // --------------------------------------------------------------------------- |
|
1554 // |
|
1555 TBool CNcsHeaderContainer::IsFocusCc() const |
|
1556 { |
|
1557 FUNC_LOG; |
|
1558 return ( FindFocused() == iCcField ); |
|
1559 } |
|
1560 |
|
1561 // --------------------------------------------------------------------------- |
|
1562 // CNcsHeaderContainer::IsFocusBcc |
|
1563 // --------------------------------------------------------------------------- |
|
1564 // |
|
1565 TBool CNcsHeaderContainer::IsFocusBcc() const |
|
1566 { |
|
1567 FUNC_LOG; |
|
1568 return ( FindFocused() == iBccField ); |
|
1569 } |
|
1570 |
|
1571 // --------------------------------------------------------------------------- |
|
1572 // CNcsHeaderContainer::GetCcFieldLength |
|
1573 // --------------------------------------------------------------------------- |
|
1574 // |
|
1575 TInt CNcsHeaderContainer::GetCcFieldLength() const |
|
1576 { |
|
1577 FUNC_LOG; |
|
1578 return iCcField->Editor()->TrimmedTextLength(); |
|
1579 } |
|
1580 |
|
1581 // --------------------------------------------------------------------------- |
|
1582 // CNcsHeaderContainer::GetBccFieldLength |
|
1583 // --------------------------------------------------------------------------- |
|
1584 // |
|
1585 TInt CNcsHeaderContainer::GetBccFieldLength() const |
|
1586 { |
|
1587 FUNC_LOG; |
|
1588 return iBccField->Editor()->TrimmedTextLength(); |
|
1589 } |
|
1590 |
|
1591 // --------------------------------------------------------------------------- |
|
1592 // CNcsHeaderContainer::GetToFieldLength |
|
1593 // --------------------------------------------------------------------------- |
|
1594 // |
|
1595 TInt CNcsHeaderContainer::GetToFieldLength() const |
|
1596 { |
|
1597 FUNC_LOG; |
|
1598 return iToField->Editor()->TrimmedTextLength(); |
|
1599 } |
|
1600 |
|
1601 // --------------------------------------------------------------------------- |
|
1602 // CNcsHeaderContainer::GetSubjectFieldLength |
|
1603 // --------------------------------------------------------------------------- |
|
1604 // |
|
1605 TInt CNcsHeaderContainer::GetSubjectFieldLength() const |
|
1606 { |
|
1607 FUNC_LOG; |
|
1608 return iSubjectField->Editor()->TrimmedTextLength(); |
|
1609 } |
|
1610 |
|
1611 // --------------------------------------------------------------------------- |
|
1612 // CNcsHeaderContainer::GetAttachmentCount |
|
1613 // --------------------------------------------------------------------------- |
|
1614 // |
|
1615 TInt CNcsHeaderContainer::GetAttachmentCount() const |
|
1616 { |
|
1617 FUNC_LOG; |
|
1618 CNcsComposeViewContainer& parent = |
|
1619 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1620 return parent.GetAttachmentCount(); |
|
1621 } |
|
1622 |
|
1623 // --------------------------------------------------------------------------- |
|
1624 // CNcsHeaderContainer::HasRemoteAttachments |
|
1625 // --------------------------------------------------------------------------- |
|
1626 // |
|
1627 TInt CNcsHeaderContainer::HasRemoteAttachments() const |
|
1628 { |
|
1629 FUNC_LOG; |
|
1630 CNcsComposeViewContainer& parent = |
|
1631 static_cast<CNcsComposeViewContainer&>( iParent ); |
|
1632 return parent.HasRemoteAttachments(); |
|
1633 } |
|
1634 |
|
1635 // --------------------------------------------------------------------------- |
|
1636 // CNcsHeaderContainer::GetToFieldSelectionLength |
|
1637 // --------------------------------------------------------------------------- |
|
1638 // |
|
1639 TInt CNcsHeaderContainer::GetToFieldSelectionLength() const |
|
1640 { |
|
1641 FUNC_LOG; |
|
1642 return iToField->TextEditor()->SelectionLength(); |
|
1643 } |
|
1644 |
|
1645 // --------------------------------------------------------------------------- |
|
1646 // CNcsHeaderContainer::GetCcFieldSelectionLength |
|
1647 // --------------------------------------------------------------------------- |
|
1648 // |
|
1649 TInt CNcsHeaderContainer::GetCcFieldSelectionLength() const |
|
1650 { |
|
1651 FUNC_LOG; |
|
1652 return iCcField->TextEditor()->SelectionLength(); |
|
1653 } |
|
1654 |
|
1655 // --------------------------------------------------------------------------- |
|
1656 // CNcsHeaderContainer::GetBccFieldSelectionLength |
|
1657 // --------------------------------------------------------------------------- |
|
1658 // |
|
1659 TInt CNcsHeaderContainer::GetBccFieldSelectionLength() const |
|
1660 { |
|
1661 FUNC_LOG; |
|
1662 return iBccField->TextEditor()->SelectionLength(); |
|
1663 } |
|
1664 |
|
1665 // --------------------------------------------------------------------------- |
|
1666 // CNcsHeaderContainer::GetLookupTextLC |
|
1667 // --------------------------------------------------------------------------- |
|
1668 // |
|
1669 HBufC* CNcsHeaderContainer::GetLookupTextLC() const |
|
1670 { |
|
1671 FUNC_LOG; |
|
1672 CCoeControl* focused = FindFocused(); |
|
1673 if ( !focused ) return NULL; |
|
1674 |
|
1675 CNcsAddressInputField* aif = dynamic_cast<CNcsAddressInputField*>(focused); |
|
1676 if ( !aif ) return NULL; |
|
1677 return aif->GetLookupTextLC(); |
|
1678 } |
|
1679 |
|
1680 // --------------------------------------------------------------------------- |
|
1681 // CNcsHeaderContainer::SetToFieldAddressesL |
|
1682 // --------------------------------------------------------------------------- |
|
1683 // |
|
1684 void CNcsHeaderContainer::SetToFieldAddressesL( |
|
1685 const RPointerArray<CNcsEmailAddressObject>& aAddress ) |
|
1686 { |
|
1687 FUNC_LOG; |
|
1688 iToField->SetAddressesL( aAddress ); |
|
1689 } |
|
1690 |
|
1691 // --------------------------------------------------------------------------- |
|
1692 // CNcsHeaderContainer::SetCcFieldAddressesL |
|
1693 // --------------------------------------------------------------------------- |
|
1694 // |
|
1695 void CNcsHeaderContainer::SetCcFieldAddressesL( |
|
1696 const RPointerArray<CNcsEmailAddressObject>& aAddress ) |
|
1697 { |
|
1698 FUNC_LOG; |
|
1699 iCcField->SetAddressesL( aAddress ); |
|
1700 if ( !iCcField->IsEmpty() ) |
|
1701 SetCcFieldVisibleL( ETrue, ENoDrawNow ); |
|
1702 } |
|
1703 |
|
1704 // --------------------------------------------------------------------------- |
|
1705 // CNcsHeaderContainer::SetBccFieldAddressesL |
|
1706 // --------------------------------------------------------------------------- |
|
1707 // |
|
1708 void CNcsHeaderContainer::SetBccFieldAddressesL( |
|
1709 const RPointerArray<CNcsEmailAddressObject>& aAddress ) |
|
1710 { |
|
1711 FUNC_LOG; |
|
1712 iBccField->SetAddressesL( aAddress ); |
|
1713 if ( !iBccField->IsEmpty() ) |
|
1714 SetBccFieldVisibleL( ETrue, ENoDrawNow ); |
|
1715 } |
|
1716 |
|
1717 // --------------------------------------------------------------------------- |
|
1718 // CNcsHeaderContainer::AppendToFieldAddressesL |
|
1719 // --------------------------------------------------------------------------- |
|
1720 // |
|
1721 void CNcsHeaderContainer::AppendToFieldAddressesL( |
|
1722 const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
1723 { |
|
1724 FUNC_LOG; |
|
1725 iToField->AppendAddressesL( aAddresses ); |
|
1726 } |
|
1727 |
|
1728 // --------------------------------------------------------------------------- |
|
1729 // CNcsHeaderContainer::AppendCcFieldAddressesL |
|
1730 // --------------------------------------------------------------------------- |
|
1731 // |
|
1732 void CNcsHeaderContainer::AppendCcFieldAddressesL( |
|
1733 const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
1734 { |
|
1735 FUNC_LOG; |
|
1736 iCcField->AppendAddressesL( aAddresses ); |
|
1737 } |
|
1738 |
|
1739 // --------------------------------------------------------------------------- |
|
1740 // CNcsHeaderContainer::AppendBccFieldAddressesL |
|
1741 // --------------------------------------------------------------------------- |
|
1742 // |
|
1743 void CNcsHeaderContainer::AppendBccFieldAddressesL( |
|
1744 const RPointerArray<CNcsEmailAddressObject>& aAddresses ) |
|
1745 { |
|
1746 FUNC_LOG; |
|
1747 iBccField->AppendAddressesL( aAddresses ); |
|
1748 } |
|
1749 |
|
1750 // --------------------------------------------------------------------------- |
|
1751 // CNcsHeaderContainer::SetSubjectL |
|
1752 // --------------------------------------------------------------------------- |
|
1753 // |
|
1754 void CNcsHeaderContainer::SetSubjectL( const TDesC& aSubject ) |
|
1755 { |
|
1756 FUNC_LOG; |
|
1757 iSubjectField->SetSubjectL( aSubject ); |
|
1758 } |
|
1759 |
|
1760 // --------------------------------------------------------------------------- |
|
1761 // CNcsHeaderContainer::SetMenuBar |
|
1762 // --------------------------------------------------------------------------- |
|
1763 // |
|
1764 void CNcsHeaderContainer::SetMenuBar( CEikButtonGroupContainer* aMenuBar ) |
|
1765 { |
|
1766 FUNC_LOG; |
|
1767 iMenuBar = aMenuBar; |
|
1768 } |
|
1769 |
|
1770 // --------------------------------------------------------------------------- |
|
1771 // CNcsHeaderContainer::IncludeAddressL |
|
1772 // --------------------------------------------------------------------------- |
|
1773 // |
|
1774 void CNcsHeaderContainer::IncludeAddressL(const CNcsEmailAddressObject& aEml ) |
|
1775 { |
|
1776 FUNC_LOG; |
|
1777 |
|
1778 CCoeControl* focused = FindFocused(); |
|
1779 if ( IsAddressInputField( focused ) ) |
|
1780 { |
|
1781 CNcsAddressInputField* aifFocused = NULL; |
|
1782 aifFocused = static_cast<CNcsAddressInputField*>( focused ); |
|
1783 aifFocused->AddAddressL( aEml ); |
|
1784 } |
|
1785 DoScroll(); |
|
1786 } |
|
1787 |
|
1788 // --------------------------------------------------------------------------- |
|
1789 // CNcsHeaderContainer::IncludeAddressL |
|
1790 // --------------------------------------------------------------------------- |
|
1791 // |
|
1792 void CNcsHeaderContainer::IncludeAddressL() |
|
1793 { |
|
1794 FUNC_LOG; |
|
1795 } |
|
1796 |
|
1797 // --------------------------------------------------------------------------- |
|
1798 // CNcsHeaderContainer::FocusToField |
|
1799 // --------------------------------------------------------------------------- |
|
1800 // |
|
1801 void CNcsHeaderContainer::FocusToField() |
|
1802 { |
|
1803 FUNC_LOG; |
|
1804 CCoeControl* oldCtrl = FindFocused(); |
|
1805 if ( !oldCtrl ) |
|
1806 { |
|
1807 return; |
|
1808 } |
|
1809 oldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
1810 iToField->SetFocus( ETrue, ENoDrawNow ); |
|
1811 } |
|
1812 |
|
1813 // --------------------------------------------------------------------------- |
|
1814 // CNcsHeaderContainer::FocusAttachmentField |
|
1815 // --------------------------------------------------------------------------- |
|
1816 // |
|
1817 void CNcsHeaderContainer::FocusAttachmentField() |
|
1818 { |
|
1819 FUNC_LOG; |
|
1820 CCoeControl* oldCtrl = FindFocused(); |
|
1821 if ( !oldCtrl ) |
|
1822 { |
|
1823 return; |
|
1824 } |
|
1825 oldCtrl->SetFocus( EFalse, ENoDrawNow ); |
|
1826 iAttachmentField->SetFocus( ETrue, ENoDrawNow ); |
|
1827 } |
|
1828 |
|
1829 // --------------------------------------------------------------------------- |
|
1830 // CNcsHeaderContainer::AreAddressFieldsEmpty |
|
1831 // --------------------------------------------------------------------------- |
|
1832 // |
|
1833 TBool CNcsHeaderContainer::AreAddressFieldsEmpty() const |
|
1834 { |
|
1835 FUNC_LOG; |
|
1836 return ( IsToFieldEmpty() && IsCcFieldEmpty() && IsBccFieldEmpty() ) || |
|
1837 iRALInProgress; |
|
1838 } |
|
1839 |
|
1840 // --------------------------------------------------------------------------- |
|
1841 // CNcsHeaderContainer::HandleDynamicVariantSwitchL |
|
1842 // --------------------------------------------------------------------------- |
|
1843 // |
|
1844 void CNcsHeaderContainer::HandleDynamicVariantSwitchL() |
|
1845 { |
|
1846 FUNC_LOG; |
|
1847 } |
|
1848 |
|
1849 // --------------------------------------------------------------------------- |
|
1850 // CNcsHeaderContainer::HandleSkinChangeL |
|
1851 // --------------------------------------------------------------------------- |
|
1852 // |
|
1853 void CNcsHeaderContainer::HandleSkinChangeL() |
|
1854 { |
|
1855 FUNC_LOG; |
|
1856 if ( iAacListBox ) |
|
1857 { |
|
1858 iAacListBox->HandleResourceChange( KAknsMessageSkinChange ); |
|
1859 } |
|
1860 } |
|
1861 |
|
1862 // --------------------------------------------------------------------------- |
|
1863 // CNcsHeaderContainer::LayoutLineCount |
|
1864 // --------------------------------------------------------------------------- |
|
1865 // |
|
1866 TInt CNcsHeaderContainer::LayoutLineCount() const |
|
1867 { |
|
1868 FUNC_LOG; |
|
1869 TInt totalLineCount( 0 ); |
|
1870 CCoeControlArray::TCursor cur = Components().Begin(); |
|
1871 do |
|
1872 { |
|
1873 totalLineCount += ToNcsControl( cur )->LayoutLineCount(); |
|
1874 } |
|
1875 while ( cur.Next() ); |
|
1876 |
|
1877 return totalLineCount; |
|
1878 } |
|
1879 |
|
1880 |
|
1881 // --------------------------------------------------------------------------- |
|
1882 // CNcsHeaderContainer::IsAddressInputField |
|
1883 // --------------------------------------------------------------------------- |
|
1884 // |
|
1885 TBool CNcsHeaderContainer::IsAddressInputField( |
|
1886 const CCoeControl* aControl ) const |
|
1887 { |
|
1888 FUNC_LOG; |
|
1889 |
|
1890 TBool ret = EFalse; |
|
1891 |
|
1892 if ( aControl != NULL && |
|
1893 ( aControl == iToField || |
|
1894 aControl == iCcField || |
|
1895 aControl == iBccField ) ) |
|
1896 { |
|
1897 ret = ETrue; |
|
1898 } |
|
1899 |
|
1900 return ret; |
|
1901 } |
|
1902 |
|
1903 // --------------------------------------------------------------------------- |
|
1904 // CNcsHeaderContainer::ExecuteRemoteSearchL |
|
1905 // --------------------------------------------------------------------------- |
|
1906 // |
|
1907 CNcsEmailAddressObject* CNcsHeaderContainer::ExecuteRemoteSearchL( |
|
1908 CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason& /*aExitReason*/, |
|
1909 const TDesC& aSearchText ) |
|
1910 { |
|
1911 FUNC_LOG; |
|
1912 const TInt KMaxLength = 255; |
|
1913 RBuf displayname; |
|
1914 displayname.CreateL( KMaxLength ); |
|
1915 CleanupClosePushL( displayname ); |
|
1916 |
|
1917 RBuf emailAddress; |
|
1918 emailAddress.CreateL( KMaxLength ); |
|
1919 CleanupClosePushL( emailAddress ); |
|
1920 |
|
1921 TBool contactSelected = |
|
1922 CFsDelayedLoader::InstanceL()->GetContactHandlerL()-> |
|
1923 GetNameAndEmailFromRemoteLookupL( |
|
1924 iMailBox, aSearchText, displayname, emailAddress ); |
|
1925 |
|
1926 CNcsEmailAddressObject* address = NULL; |
|
1927 if ( contactSelected ) |
|
1928 { |
|
1929 if ( !displayname.Length() ) |
|
1930 { |
|
1931 address = |
|
1932 CNcsEmailAddressObject::NewL( emailAddress, emailAddress ); |
|
1933 } |
|
1934 else |
|
1935 { |
|
1936 address = |
|
1937 CNcsEmailAddressObject::NewL( displayname, emailAddress ); |
|
1938 } |
|
1939 } |
|
1940 |
|
1941 CleanupStack::PopAndDestroy( &emailAddress ); |
|
1942 CleanupStack::PopAndDestroy( &displayname ); |
|
1943 |
|
1944 return address; |
|
1945 } |
|
1946 |
|
1947 // ----------------------------------------------------------------------------- |
|
1948 // CNcsHeaderContainer::ChangeMskCommandL |
|
1949 // Utility function to change the command ID and label on the middle soft key |
|
1950 // ----------------------------------------------------------------------------- |
|
1951 void CNcsHeaderContainer::ChangeMskCommandL( TInt aLabelResourceId ) |
|
1952 { |
|
1953 FUNC_LOG; |
|
1954 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
1955 if ( cba ) |
|
1956 { |
|
1957 cba->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition, |
|
1958 aLabelResourceId ); |
|
1959 cba->DrawDeferred(); |
|
1960 } |
|
1961 } |
|
1962 |
|
1963 // ----------------------------------------------------------------------------- |
|
1964 // CNcsHeaderContainer::SwitchChangeMskOff |
|
1965 // sets up iSwitchChangeMskOff falg |
|
1966 // ----------------------------------------------------------------------------- |
|
1967 void CNcsHeaderContainer::SwitchChangeMskOff( TBool aTag ) |
|
1968 { |
|
1969 iSwitchChangeMskOff = aTag; |
|
1970 } |
|
1971 |
|
1972 // ----------------------------------------------------------------------------- |
|
1973 // CNcsHeaderContainer::OpenPhonebookL |
|
1974 // |
|
1975 // ----------------------------------------------------------------------------- |
|
1976 void CNcsHeaderContainer::OpenPhonebookL() |
|
1977 { |
|
1978 CNcsComposeViewContainer* container = |
|
1979 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
1980 container->AppendAddressesL(); |
|
1981 } |
|
1982 |
|
1983 void CNcsHeaderContainer::FixSemicolonInAddressFieldsL() |
|
1984 { |
|
1985 iToField->FixSemicolonAtTheEndL(); |
|
1986 iCcField->FixSemicolonAtTheEndL(); |
|
1987 iBccField->FixSemicolonAtTheEndL(); |
|
1988 } |
|
1989 |
|
1990 TBool CNcsHeaderContainer::IsRemoteSearchInprogress() const |
|
1991 { |
|
1992 return iRALInProgress; |
|
1993 } |
|
1994 |
|
1995 // --------------------------------------------------------------------------- |
|
1996 // Commits changes made to given input field. |
|
1997 // --------------------------------------------------------------------------- |
|
1998 // |
|
1999 void CNcsHeaderContainer::CommitFieldL( CCoeControl* aField ) |
|
2000 { |
|
2001 FUNC_LOG; |
|
2002 CNcsComposeViewContainer* container = |
|
2003 static_cast<CNcsComposeViewContainer*>( &iParent ); |
|
2004 if ( container && aField ) |
|
2005 { |
|
2006 if ( aField == iToField ) |
|
2007 { |
|
2008 container->CommitL( EToField ); |
|
2009 } |
|
2010 else if ( aField == iCcField ) |
|
2011 { |
|
2012 container->CommitL( ECcField ); |
|
2013 } |
|
2014 else if ( aField == iBccField ) |
|
2015 { |
|
2016 container->CommitL( EBccField ); |
|
2017 } |
|
2018 else if ( aField == iSubjectField ) |
|
2019 { |
|
2020 container->CommitL( ESubjectField ); |
|
2021 } |
|
2022 } |
|
2023 } |
|
2024 |
|
2025 // ----------------------------------------------------------------------------- |
|
2026 // CNcsHeaderContainer::DoScroll |
|
2027 // ----------------------------------------------------------------------------- |
|
2028 // |
|
2029 void CNcsHeaderContainer::DoScroll() |
|
2030 { |
|
2031 // scroll the screen if the cursor goes beyond the screen |
|
2032 CNcsComposeViewContainer& parent = static_cast<CNcsComposeViewContainer&>( iParent ); |
|
2033 |
|
2034 TInt screenPos( -Position().iY ); |
|
2035 TInt cursorPos( CursorPosition() ); |
|
2036 TInt lineHeight( Rect().Height() / LineCount() ); |
|
2037 TInt screenHeight( parent.Rect().Height() ); |
|
2038 |
|
2039 if ( cursorPos - lineHeight < screenPos ) |
|
2040 { |
|
2041 screenPos = cursorPos - lineHeight; |
|
2042 } |
|
2043 else if( cursorPos + lineHeight > screenPos + screenHeight ) |
|
2044 { |
|
2045 screenPos = cursorPos + lineHeight - screenHeight; |
|
2046 } |
|
2047 |
|
2048 parent.Scroll( screenPos ); |
|
2049 } |
|
2050 |
|
2051 // --------------------------------------------------------------------------- |
|
2052 // CNcsHeaderContainer::SetPhysicsEmulationOngoing |
|
2053 // --------------------------------------------------------------------------- |
|
2054 // |
|
2055 void CNcsHeaderContainer::SetPhysicsEmulationOngoing( TBool aPhysOngoing ) |
|
2056 { |
|
2057 iToField->SetPhysicsEmulationOngoing( aPhysOngoing ); |
|
2058 iCcField->SetPhysicsEmulationOngoing( aPhysOngoing ); |
|
2059 iBccField->SetPhysicsEmulationOngoing( aPhysOngoing ); |
|
2060 iSubjectField->SetPhysicsEmulationOngoing( aPhysOngoing ); |
|
2061 } |