18 |
18 |
19 // INCLUDE FILES |
19 // INCLUDE FILES |
20 #include "emailtrace.h" |
20 #include "emailtrace.h" |
21 #include <eikclbd.h> |
21 #include <eikclbd.h> |
22 #include <AknsFrameBackgroundControlContext.h> |
22 #include <AknsFrameBackgroundControlContext.h> |
23 #include <FreestyleEmailUi.rsg> // R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH |
23 #include <FreestyleEmailUi.rsg> |
24 #include <StringLoader.h> // StringLoader |
24 #include <StringLoader.h> |
25 #include <CPbkContactEngine.h> |
25 #include <CPbkContactEngine.h> |
26 #include <AknsDrawUtils.h> |
26 #include <AknsDrawUtils.h> |
27 #include <AknsUtils.h> |
27 #include <AknsUtils.h> |
28 #include <aknlayoutscalable_apps.cdl.h> |
28 #include <aknlayoutscalable_apps.cdl.h> |
29 #include <aknlayoutscalable_avkon.cdl.h> |
29 #include <aknlayoutscalable_avkon.cdl.h> |
30 |
30 |
31 #include "ncspopuplistbox.h" |
31 #include "ncspopuplistbox.h" |
32 #include "ncsemailaddressobject.h" // CNcsEmailAddressObject |
32 #include "ncsemailaddressobject.h" |
33 #include "ncsconstants.h" |
33 #include "ncsconstants.h" |
34 #include "ncsheadercontainer.h" // CNcsHeaderContainer |
34 #include "ncsheadercontainer.h" |
35 #include "FreestyleEmailUiContactHandler.h" // CFSEmailUiClsListsHandler |
35 #include "FreestyleEmailUiContactHandler.h" |
36 #include "ncsutility.h" |
36 #include "ncsutility.h" |
37 #include "FreestyleEmailUiUtilities.h" |
37 #include "FreestyleEmailUiUtilities.h" |
38 #include "FreestyleEmailUiAppui.h" |
38 #include "FreestyleEmailUiAppui.h" |
39 #include "FreestyleEmailUiLayoutHandler.h" |
39 #include "FreestyleEmailUiLayoutHandler.h" |
40 #include "FSDelayedLoader.h" |
40 #include "FSDelayedLoader.h" |
47 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
48 // CNcsPopupListBox::NewL |
48 // CNcsPopupListBox::NewL |
49 // ----------------------------------------------------------------------------- |
49 // ----------------------------------------------------------------------------- |
50 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, |
50 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, |
51 CFSMailBox& aMailBox, |
51 CFSMailBox& aMailBox, |
52 CNcsHeaderContainer& aHeaderContainer, |
52 MNcsPopupListBoxObserver& aObserver, |
53 TBool aRemoteLookupSupported ) |
53 TBool aRemoteLookupSupported ) |
54 { |
54 { |
55 FUNC_LOG; |
55 FUNC_LOG; |
56 CNcsPopupListBox* self = new (ELeave) CNcsPopupListBox( aHeaderContainer, |
56 CNcsPopupListBox* self = new (ELeave) CNcsPopupListBox( aMailBox, |
57 aRemoteLookupSupported, aMailBox ); |
57 aObserver, aRemoteLookupSupported ); |
58 CleanupStack::PushL( self ); |
58 CleanupStack::PushL( self ); |
59 self->ConstructL( aParent ); |
59 self->ConstructL( aParent ); |
60 CleanupStack::Pop( self ); |
60 CleanupStack::Pop( self ); |
61 return self; |
61 return self; |
62 } |
62 } |
63 |
63 |
64 // ----------------------------------------------------------------------------- |
64 // ----------------------------------------------------------------------------- |
65 // CNcsPopupListBox::CNcsPopupListBox |
65 // CNcsPopupListBox::CNcsPopupListBox |
66 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
67 CNcsPopupListBox::CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer, |
67 CNcsPopupListBox::CNcsPopupListBox( CFSMailBox& aMailBox, |
68 TBool aRemoteLookupSupported, |
68 MNcsPopupListBoxObserver& aObserver, TBool aRemoteLookupSupported ) |
69 CFSMailBox& aMailBox) |
69 : iMailBox( aMailBox ), |
70 : iHeaderContainer( aHeaderContainer ), |
70 iObserver( aObserver ), |
71 iMailBox( aMailBox ), |
|
72 iRemoteLookupSupported( aRemoteLookupSupported ), |
71 iRemoteLookupSupported( aRemoteLookupSupported ), |
73 iCachingInProgress( EFalse ), |
72 iCachingInProgress( EFalse ), |
74 iAppUi( static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ) ) |
73 iAppUi( static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ) ) |
75 { |
74 { |
76 FUNC_LOG; |
75 FUNC_LOG; |
171 |
180 |
172 SetViewRectFromClientRect( innerRect ); |
181 SetViewRectFromClientRect( innerRect ); |
173 TRAP_IGNORE( HandleViewRectSizeChangeL() ); |
182 TRAP_IGNORE( HandleViewRectSizeChangeL() ); |
174 } |
183 } |
175 |
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CNcsPopupListBox::HandleResourceChange |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
176 void CNcsPopupListBox::HandleResourceChange( TInt aType ) |
189 void CNcsPopupListBox::HandleResourceChange( TInt aType ) |
177 { |
190 { |
178 FUNC_LOG; |
191 FUNC_LOG; |
|
192 CEikTextListBox::HandleResourceChange( aType ); |
179 if ( aType == KAknsMessageSkinChange ) |
193 if ( aType == KAknsMessageSkinChange ) |
180 { |
194 { |
181 UpdateTextColors(); |
195 UpdateTextColors(); |
182 } |
196 } |
183 } |
197 } |
184 |
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CNcsPopupListBox::HandlePointerEventL |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
185 void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
203 void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
186 { |
204 { |
187 CEikTextListBox::HandlePointerEventL( aPointerEvent ); |
205 CEikTextListBox::HandlePointerEventL( aPointerEvent ); |
188 } |
206 } |
189 |
207 |
190 // ----------------------------------------------------------------------------- |
208 // ----------------------------------------------------------------------------- |
191 // CNcsPopupListBox::OfferKeyEventL |
209 // CNcsPopupListBox::OfferKeyEventL |
192 // ----------------------------------------------------------------------------- |
210 // ----------------------------------------------------------------------------- |
193 // |
211 // |
194 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
212 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
195 TEventCode aType ) |
213 TEventCode aType ) |
196 { |
214 { |
197 FUNC_LOG; |
215 FUNC_LOG; |
198 TKeyResponse ret( EKeyWasNotConsumed ); |
216 TKeyResponse ret( EKeyWasNotConsumed ); |
199 if( aKeyEvent.iCode == EKeyDownArrow ) |
217 if( aKeyEvent.iCode == EKeyDownArrow ) |
200 { |
218 { |
201 MoveRemoteLookupItemL( ERemoteLookupItemDown ); |
219 MoveRemoteLookupItemL( ERemoteLookupItemDown ); |
202 iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection ); |
220 iView->MoveCursorL( |
|
221 CListBoxView::ECursorNextItem, CListBoxView::ENoSelection ); |
203 ret = EKeyWasConsumed; |
222 ret = EKeyWasConsumed; |
204 } |
223 } |
205 else if( aKeyEvent.iCode == EKeyUpArrow ) |
224 else if( aKeyEvent.iCode == EKeyUpArrow ) |
206 { |
225 { |
207 TBool stay = EFalse; |
226 TBool stay = EFalse; |
208 // Move cursor separator line over |
227 // Move cursor separator line over |
209 if ( CurrentItemIndex() - 1 > 0 && CurrentItemIndex() - 1 == iRemoteLookupItemPos ) |
228 if ( CurrentItemIndex() - 1 > 0 && |
|
229 CurrentItemIndex() - 1 == iRemoteLookupItemPos ) |
210 { |
230 { |
211 MoveRemoteLookupItemL( ERemoteLookupItemUp ); |
231 MoveRemoteLookupItemL( ERemoteLookupItemUp ); |
212 iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection ); |
232 iView->MoveCursorL( CListBoxView::ECursorPreviousItem, |
|
233 CListBoxView::ENoSelection ); |
213 stay = ETrue; |
234 stay = ETrue; |
214 } |
235 } |
215 |
236 |
216 MoveRemoteLookupItemL( ERemoteLookupItemUp ); |
237 MoveRemoteLookupItemL( ERemoteLookupItemUp ); |
217 iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection ); |
238 iView->MoveCursorL( CListBoxView::ECursorPreviousItem, |
|
239 CListBoxView::ENoSelection ); |
218 if( stay ) |
240 if( stay ) |
219 { |
241 { |
220 MoveRemoteLookupItemL( ERemoteLookupItemDown ); |
242 MoveRemoteLookupItemL( ERemoteLookupItemDown ); |
221 |
243 |
222 iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection ); |
244 iView->MoveCursorL( CListBoxView::ECursorNextItem, |
|
245 CListBoxView::ENoSelection ); |
223 } |
246 } |
224 |
247 |
225 |
248 |
226 ret = EKeyWasConsumed; |
249 ret = EKeyWasConsumed; |
227 } |
250 } |
228 |
251 |
229 if( ret == EKeyWasNotConsumed ) |
252 if( ret == EKeyWasNotConsumed ) |
230 { |
253 { |
231 ret = CEikListBox::OfferKeyEventL( aKeyEvent, aType ); |
254 ret = CEikListBox::OfferKeyEventL( aKeyEvent, aType ); |
232 } |
255 } |
233 // call HandleItemAdditionL just in case. There might be changes on remote lookup item place. |
256 // call HandleItemAdditionL just in case. There might be changes on remote |
234 // The call is here, because we don't want to have extra redraw events when the popuplist |
257 // lookup item place. |
235 // is not fully updated. |
258 // The call is here, because we don't want to have extra redraw events when |
|
259 // the popuplist is not fully updated. |
236 HandleItemAdditionL(); |
260 HandleItemAdditionL(); |
237 return ret; |
261 return ret; |
238 } |
262 } |
239 |
263 |
240 // --------------------------------------------------------------------------- |
264 // --------------------------------------------------------------------------- |
417 // CNcsPopupListBox::SetListItemsFromArrayL |
456 // CNcsPopupListBox::SetListItemsFromArrayL |
418 // ----------------------------------------------------------------------------- |
457 // ----------------------------------------------------------------------------- |
419 void CNcsPopupListBox::SetListItemsFromArrayL() |
458 void CNcsPopupListBox::SetListItemsFromArrayL() |
420 { |
459 { |
421 FUNC_LOG; |
460 FUNC_LOG; |
422 // reset the cursor to point to the first item |
461 |
423 //iView->MoveCursorL( CListBoxView::ECursorFirstItem, CListBoxView::ENoSelection); |
|
424 Reset(); |
462 Reset(); |
425 |
463 |
426 // Create totally new text array |
464 // Create totally new text array |
427 CreateTextArrayAndSetToTheListboxL( ETrue ); |
465 CreateTextArrayAndSetToTheListboxL( ETrue ); |
428 |
466 |
|
467 TInt matchCount = iMatchingItems.Count(); |
|
468 // Remote lookup item's index is set as last item by default |
|
469 // (in case of empty matching items list it is the only item) |
|
470 TInt rmluIndex = matchCount; |
|
471 |
429 // append texts to text array |
472 // append texts to text array |
430 for( TInt i=0; i < iMatchingItems.Count(); i++ ) |
473 for( TInt i=0; i < matchCount; i++ ) |
431 { |
474 { |
432 iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() ); |
475 iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() ); |
433 } |
476 if ( iRemoteLookupSupported && |
|
477 rmluIndex == matchCount && |
|
478 iMatchingItems[i]->EmailAddress().Compare( KNullDesC ) == 0 ) |
|
479 { |
|
480 rmluIndex = i; |
|
481 } |
|
482 } |
434 |
483 |
435 // Update rmlu item |
484 // Update rmlu item |
436 SetRemoteLookupItemFirstToTheListL(); |
485 SetRemoteLookupItemToTheListL( rmluIndex ); |
437 |
486 |
438 SetPopupRect(); |
487 SetPopupRect(); |
439 SetScrollBarVisibilityL(); |
488 SetScrollBarVisibilityL(); |
440 HandleItemAdditionL(); |
489 HandleItemAdditionL(); |
441 |
490 |
442 if ( iItemTextsArray && iItemTextsArray->Count() > 0 ) |
491 if ( iItemTextsArray && iItemTextsArray->Count() > 0 ) |
451 } |
500 } |
452 |
501 |
453 // ----------------------------------------------------------------------------- |
502 // ----------------------------------------------------------------------------- |
454 // CNcsPopupListBox::RoundToItemHeight |
503 // CNcsPopupListBox::RoundToItemHeight |
455 // ----------------------------------------------------------------------------- |
504 // ----------------------------------------------------------------------------- |
456 TInt CNcsPopupListBox::RoundToItemHeight(const TInt aPopupHeight) const |
505 TInt CNcsPopupListBox::RoundToItemHeight( const TInt aPopupHeight ) const |
457 { |
506 { |
458 TReal fullItems; // number of full visible items in window |
507 TReal fullItems; // number of full visible items in window |
459 TInt err = Math::Round(fullItems, (aPopupHeight / ItemHeight()), 0); |
508 TInt err = Math::Round( fullItems, ( aPopupHeight / ItemHeight() ), 0 ); |
460 if (err == KErrNone) |
509 if ( err == KErrNone ) |
461 { |
510 { |
462 return (TInt)(fullItems * ItemHeight()); |
511 return (TInt)( fullItems * ItemHeight() ); |
463 } |
512 } |
464 return aPopupHeight; // in case of error |
513 return aPopupHeight; // in case of error |
465 } |
514 } |
466 |
515 |
467 // ----------------------------------------------------------------------------- |
516 // ----------------------------------------------------------------------------- |
468 // CNcsPopupListBox::SetPopupRect |
517 // CNcsPopupListBox::SetPopupRect |
469 // ----------------------------------------------------------------------------- |
518 // ----------------------------------------------------------------------------- |
470 void CNcsPopupListBox::SetPopupRect() |
519 void CNcsPopupListBox::SetPopupRect() |
471 { |
520 { |
472 FUNC_LOG; |
521 FUNC_LOG; |
473 // The popup width and horizontal position is adjusted so that it |
522 |
474 // will be within the area specified in both layout data and the set |
523 // The popup height and vertical position is adjusted based on the |
475 // maximum rect. |
|
476 TAknLayoutRect editorPane; |
|
477 editorPane.LayoutRect( iAppUi->ClientRect(), |
|
478 TAknWindowComponentLayout::Compose( |
|
479 TAknWindowComponentLayout::Compose( |
|
480 AknLayoutScalable_Apps::list_cmail_pane(), |
|
481 AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0 ) ), |
|
482 AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg( 4 ) ) ); |
|
483 TRect editorPaneRect = editorPane.Rect(); |
|
484 |
|
485 TRect newRect = iPopupMaxRect; |
|
486 newRect.iTl.iX = Max( iPopupMaxRect.iTl.iX, editorPaneRect.iTl.iX ); |
|
487 newRect.iBr.iX = Min( iPopupMaxRect.iBr.iX, editorPaneRect.iBr.iX ); |
|
488 |
|
489 // Thhe popup height and vertical position is adjusted based on the |
|
490 // available space below and above the cursor and the number of items |
524 // available space below and above the cursor and the number of items |
491 // in the list. |
525 // in the list. |
492 const TRect rect = iPopupMaxRect; |
526 TRect newRect = iPopupMaxRect; |
493 TAknLayoutRect subpane; |
527 TAknLayoutRect subpane; |
494 subpane.LayoutRect( rect, AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() ); |
528 subpane.LayoutRect( newRect, |
495 const TRect subpaneRect = subpane.Rect(); |
529 AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() ); |
496 |
530 const TInt frameHeights = |
497 const TInt frameHeights = iPopupMaxRect.Height() - subpaneRect.Height(); |
531 iPopupMaxRect.Height() - subpane.Rect().Height(); |
498 |
532 |
499 // This is the total height in pixels needed to show all items |
533 // This is the total height in pixels needed to show all items |
500 TInt minimumHeight = frameHeights + |
534 const TInt minimumHeight = frameHeights + |
501 CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
535 CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
502 |
536 |
|
537 // Get height of one line in Address field |
|
538 TInt toLineHeight = |
|
539 static_cast<CNcsHeaderContainer*>( Parent() )->GetToLineHeight(); |
|
540 if ( toLineHeight == 0 ) |
|
541 { |
|
542 toLineHeight = ItemHeight(); |
|
543 } |
|
544 |
|
545 TInt newHeight = minimumHeight; // default window height |
503 CCoeControl* container = Parent()->Parent(); |
546 CCoeControl* container = Parent()->Parent(); |
504 TInt containerTop = container->PositionRelativeToScreen().iY; |
547 const TInt maxHeight = |
505 TInt containerHeight = container->Rect().Height(); |
548 container->Rect().Height() - |
506 TInt containerCenter = containerTop + containerHeight / 2; |
549 ( newRect.iTl.iY - container->PositionRelativeToScreen().iY ); |
507 |
550 newHeight = |
508 // Get height of one line in Address field |
551 RoundToItemHeight( maxHeight - frameHeights ) + frameHeights; |
509 CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent()); |
552 if ( newHeight > minimumHeight ) |
510 TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height |
553 { |
511 if ( toLineHeight == 0 ) |
554 newHeight = minimumHeight; // shrink window (if needed) |
512 { |
555 } |
513 toLineHeight = ItemHeight(); |
556 |
514 } |
557 newRect.SetHeight( newHeight ); |
515 |
|
516 TInt newHeight = minimumHeight; // default window height |
|
517 |
|
518 // latch listbox on the bottom of the editor field |
|
519 if ( newRect.iTl.iY <= containerCenter ) |
|
520 { |
|
521 TInt maxHeight = containerHeight - ( newRect.iTl.iY - containerTop ); |
|
522 newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights; |
|
523 if ( newHeight > minimumHeight ) |
|
524 { |
|
525 newHeight = minimumHeight; // shrink window (if needed) |
|
526 } |
|
527 } |
|
528 // latch listbox on the top of the editor field |
|
529 else |
|
530 { |
|
531 TInt yOffset = -minimumHeight - toLineHeight; // how much up |
|
532 TInt newTlY = newRect.iTl.iY + yOffset; // new Top Left Y coordinate |
|
533 if ( newTlY >= containerTop ) |
|
534 { |
|
535 newRect.Move( 0, yOffset ); |
|
536 } |
|
537 else |
|
538 { |
|
539 // shrink height to visible area and move |
|
540 TInt maxHeight = newRect.iTl.iY - toLineHeight - containerTop; |
|
541 newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights; |
|
542 newRect.Move( 0, -newHeight - toLineHeight ); |
|
543 } |
|
544 } |
|
545 newRect.SetHeight( newHeight ); // set new height |
|
546 SetRect( newRect ); |
558 SetRect( newRect ); |
547 } |
559 } |
548 |
560 |
549 // ----------------------------------------------------------------------------- |
561 // ----------------------------------------------------------------------------- |
550 // CNcsPopupListBox::SetScrollBarVisibilityL |
562 // CNcsPopupListBox::SetScrollBarVisibilityL |
551 // ----------------------------------------------------------------------------- |
563 // ----------------------------------------------------------------------------- |
552 void CNcsPopupListBox::SetScrollBarVisibilityL() |
564 void CNcsPopupListBox::SetScrollBarVisibilityL() |
553 { |
565 { |
554 FUNC_LOG; |
566 FUNC_LOG; |
555 // This is the total height in pixels needed to show all items |
567 // This is the total height in pixels needed to show all items |
556 TInt minimumHeight = CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
568 TInt minimumHeight = |
|
569 CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
557 |
570 |
558 // Show scroll bar if there is more items we can show at once. |
571 // Show scroll bar if there is more items we can show at once. |
559 if( iPopupMaxRect.Height() > minimumHeight ) |
572 if( iPopupMaxRect.Height() > minimumHeight ) |
560 { |
573 { |
561 ScrollBarFrame()->SetScrollBarVisibilityL( |
574 ScrollBarFrame()->SetScrollBarVisibilityL( |
562 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
575 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
563 } |
576 } |
564 else |
577 else |
568 } |
581 } |
569 } |
582 } |
570 |
583 |
571 |
584 |
572 // ----------------------------------------------------------------------------- |
585 // ----------------------------------------------------------------------------- |
573 // CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL |
586 // CNcsPopupListBox::SetRemoteLookupItemToTheListL |
574 // ----------------------------------------------------------------------------- |
587 // ----------------------------------------------------------------------------- |
575 void CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL() |
588 void CNcsPopupListBox::SetRemoteLookupItemToTheListL( TInt aIndex ) |
576 { |
589 { |
577 FUNC_LOG; |
590 FUNC_LOG; |
578 if( iRemoteLookupSupported ) |
591 if( iRemoteLookupSupported ) |
579 { |
592 { |
580 HBufC* rmluText = StringLoader::LoadLC( |
593 HBufC* rmluText = StringLoader::LoadLC( |
581 R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText ); |
594 R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, |
|
595 *iCurrentSearchText ); |
582 |
596 |
583 iItemTextsArray->InsertL( 0, *rmluText ); |
597 iItemTextsArray->InsertL( aIndex, *rmluText ); |
584 CleanupStack::PopAndDestroy( rmluText ); |
598 CleanupStack::PopAndDestroy( rmluText ); |
585 iRemoteLookupItemPos = 0; |
599 iRemoteLookupItemPos = aIndex; |
586 } |
600 } |
587 else |
601 else |
588 { |
602 { |
589 iRemoteLookupItemPos = -1; |
603 iRemoteLookupItemPos = -1; |
590 } |
604 } |
591 } |
605 } |
592 |
606 |
593 // ----------------------------------------------------------------------------- |
607 // ----------------------------------------------------------------------------- |
594 // CNcsPopupListBox::MoveRemoteLookupItemL |
608 // CNcsPopupListBox::MoveRemoteLookupItemL |
595 // ----------------------------------------------------------------------------- |
609 // ----------------------------------------------------------------------------- |
596 void CNcsPopupListBox::MoveRemoteLookupItemL( TRemoteLookupItemMoveDirection aDirection ) |
610 void CNcsPopupListBox::MoveRemoteLookupItemL( |
|
611 TRemoteLookupItemMoveDirection aDirection ) |
597 { |
612 { |
598 FUNC_LOG; |
613 FUNC_LOG; |
599 if( iRemoteLookupSupported ) |
614 if( iRemoteLookupSupported ) |
600 { |
615 { |
601 TInt newRMLUItemIndex = -1; |
616 TInt newRMLUItemIndex = -1; |
658 :CListItemDrawer(), iListBox( aListBox ) |
676 :CListItemDrawer(), iListBox( aListBox ) |
659 { |
677 { |
660 FUNC_LOG; |
678 FUNC_LOG; |
661 // Store a GC for later use |
679 // Store a GC for later use |
662 iGc = &CCoeEnv::Static()->SystemGc(); |
680 iGc = &CCoeEnv::Static()->SystemGc(); |
663 SetGc(iGc); |
681 SetGc( iGc ); |
664 } |
682 } |
665 |
683 |
666 // ----------------------------------------------------------------------------- |
684 // ----------------------------------------------------------------------------- |
667 // CNcsListItemDrawer::DrawActualItem |
685 // CNcsListItemDrawer::DrawActualItem |
668 // ----------------------------------------------------------------------------- |
686 // ----------------------------------------------------------------------------- |
669 void CNcsListItemDrawer::DrawActualItem(TInt aItemIndex, |
687 void CNcsListItemDrawer::DrawActualItem( TInt aItemIndex, |
670 const TRect& aActualItemRect, TBool aItemIsCurrent, |
688 const TRect& aActualItemRect, TBool aItemIsCurrent, |
671 TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/, |
689 TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/, |
672 TBool /*aItemIsSelected*/) const |
690 TBool /*aItemIsSelected*/ ) const |
673 { |
691 { |
674 FUNC_LOG; |
692 FUNC_LOG; |
675 iGc->DiscardFont(); |
693 iGc->DiscardFont(); |
676 |
694 |
677 // Get reference to curren popup cls item list. |
695 // Get reference to curren popup cls item list. |
678 const RPointerArray<CFSEmailUiClsItem>& clsItemArray = |
696 const RPointerArray<CFSEmailUiClsItem>& clsItemArray = |
679 iListBox.CurrentPopupClsItemsArray(); |
697 iListBox.CurrentPopupClsItemsArray(); |
680 TInt rmluPosition = iListBox.RemoteLookupItemPos(); |
698 TInt rmluPosition = iListBox.RemoteLookupItemPos(); |
681 |
699 |
682 // Sets all the attributes, like font, text color and background color. |
700 // Sets all the attributes, like font, text color and background color. |
683 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
701 const CFont* font = AknLayoutUtils::FontFromId( |
|
702 EAknLogicalFontPrimarySmallFont ); |
684 iGc->UseFont( font ); |
703 iGc->UseFont( font ); |
685 iGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
704 iGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
686 iGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
705 iGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
687 |
706 |
688 TRect itemRect = aActualItemRect; |
707 TRect itemRect = aActualItemRect; |
803 { |
824 { |
804 if ( currentTextStart < underlines[i].index ) |
825 if ( currentTextStart < underlines[i].index ) |
805 { |
826 { |
806 // draw letters to the start of the underlined part |
827 // draw letters to the start of the underlined part |
807 currentTextLength = underlines[i].index - currentTextStart; |
828 currentTextLength = underlines[i].index - currentTextStart; |
808 DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText, |
829 DrawPartOfItem( textRect, *font, currentTextStart, |
|
830 currentTextLength, itemText, |
809 EFalse, topToBaseline ); |
831 EFalse, topToBaseline ); |
810 } |
832 } |
811 else if ( currentTextStart == underlines[i].index ) |
833 else if ( currentTextStart == underlines[i].index ) |
812 { |
834 { |
813 // draw underlined letters |
835 // draw underlined letters |
814 currentTextLength = underlines[i].length; |
836 currentTextLength = underlines[i].length; |
815 |
837 |
816 DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText, |
838 DrawPartOfItem( textRect, *font, currentTextStart, |
|
839 currentTextLength, itemText, |
817 ETrue, topToBaseline ); |
840 ETrue, topToBaseline ); |
818 i++; |
841 i++; |
819 } |
842 } |
820 else |
843 else |
821 { |
844 { |
822 // This is here, because PCS Engine might give you duplicate match entries, |
845 // This is here, because PCS Engine might give you |
823 // in this case we're not advancing text but we'll skip that match |
846 // duplicate match entries, in this case we're not |
|
847 // advancing text but we'll skip that match |
824 currentTextLength = 0; |
848 currentTextLength = 0; |
825 i++; |
849 i++; |
826 } |
850 } |
827 // update text start point |
851 // update text start point |
828 currentTextStart += currentTextLength; |
852 currentTextStart += currentTextLength; |
829 |
853 |
830 if ( i >= underlines.Count() ) |
854 if ( i >= underlines.Count() ) |
831 { |
855 { |
832 partsLeft = EFalse; |
856 partsLeft = EFalse; |
833 // draw rest of the letters, if there are any after the last underlined part |
857 // draw rest of the letters, if there are any after the |
|
858 // last underlined part |
834 if ( currentTextStart < itemText.Length() ) |
859 if ( currentTextStart < itemText.Length() ) |
835 { |
860 { |
836 currentTextLength = itemText.Length() - currentTextStart; |
861 currentTextLength = |
837 DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText, |
862 itemText.Length() - currentTextStart; |
|
863 DrawPartOfItem( textRect, *font, currentTextStart, |
|
864 currentTextLength, itemText, |
838 EFalse, topToBaseline ); |
865 EFalse, topToBaseline ); |
839 } |
866 } |
840 } |
867 } |
841 |
868 |
842 } |
869 } |
874 iGc->DrawText( aDes.Mid( aStartPos, aLength ), |
902 iGc->DrawText( aDes.Mid( aStartPos, aLength ), |
875 currentTextRect, aBaselineOffsetFromTop ); |
903 currentTextRect, aBaselineOffsetFromTop ); |
876 } |
904 } |
877 |
905 |
878 |
906 |
|
907 // --------------------------------------------------------------------------- |
|
908 // Updates popup list content. |
|
909 // --------------------------------------------------------------------------- |
|
910 // |
879 void CNcsPopupListBox::UpdateListL() |
911 void CNcsPopupListBox::UpdateListL() |
880 { |
912 { |
881 FUNC_LOG; |
913 FUNC_LOG; |
882 SetListItemsFromArrayL(); |
914 SetListItemsFromArrayL(); |
883 |
915 |
884 // Close the popup if it's empty and make sure it's visible if it's not empty. |
916 // Close the popup if it's empty and make sure it's visible if it's not empty. |
885 if ( IsPopupEmpty() ) |
917 UpdateVisibilityL( !IsPopupEmpty() ); |
886 { |
918 } |
887 iHeaderContainer.ClosePopupContactListL(); |
919 |
888 } |
920 // --------------------------------------------------------------------------- |
889 else |
921 // Shows or hides popup if necessary. |
890 { |
922 // --------------------------------------------------------------------------- |
891 MakeVisible( ETrue ); |
923 // |
|
924 void CNcsPopupListBox::UpdateVisibilityL( TBool aVisible ) |
|
925 { |
|
926 if ( IsVisible() != aVisible ) |
|
927 { |
|
928 if ( iObserver.PopupVisibilityChangingL( aVisible ) ) |
|
929 { |
|
930 MakeVisible( aVisible ); |
|
931 if ( aVisible ) |
|
932 { |
|
933 UpdateScrollBarsL(); |
|
934 SetScrollBarVisibilityL(); |
|
935 // Popup is always on top (also on top of e.g. toolbar buttons) |
|
936 DrawableWindow()->SetOrdinalPosition( 0 ); |
|
937 } |
|
938 } |
|
939 } |
|
940 else if ( IsVisible() ) |
|
941 { |
892 UpdateScrollBarsL(); |
942 UpdateScrollBarsL(); |
893 iHeaderContainer.ShowPopupMenuBarL( ETrue ); |
943 SetScrollBarVisibilityL(); |
894 } |
944 } |
895 } |
945 } |
896 |
946 |
|
947 // --------------------------------------------------------------------------- |
|
948 // Updates popup text colors. |
|
949 // --------------------------------------------------------------------------- |
|
950 // |
897 void CNcsPopupListBox::UpdateTextColors() |
951 void CNcsPopupListBox::UpdateTextColors() |
898 { |
952 { |
899 if ( iItemDrawer ) |
953 if ( iItemDrawer ) |
900 { |
954 { |
901 // Get skin instance. |
955 // Get skin instance. |