35 #include "FreestyleEmailUiAppui.h" |
37 #include "FreestyleEmailUiAppui.h" |
36 #include "FreestyleEmailUiLayoutHandler.h" |
38 #include "FreestyleEmailUiLayoutHandler.h" |
37 #include "FSDelayedLoader.h" |
39 #include "FSDelayedLoader.h" |
38 #include "FreestyleEmailUiCLSItem.h" |
40 #include "FreestyleEmailUiCLSItem.h" |
39 |
41 |
|
42 const TInt KBackgroundFrameWidth = 4; |
|
43 const TInt KHighlightFrameWidth = 2; |
|
44 |
40 // ========================= MEMBER FUNCTIONS ================================== |
45 // ========================= MEMBER FUNCTIONS ================================== |
41 |
46 |
42 // ----------------------------------------------------------------------------- |
47 // ----------------------------------------------------------------------------- |
43 // CNcsPopupListBox::NewL |
48 // CNcsPopupListBox::NewL |
44 // ----------------------------------------------------------------------------- |
49 // ----------------------------------------------------------------------------- |
45 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, |
50 CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, |
46 CFSMailBox& aMailBox, |
51 CFSMailBox& aMailBox, |
47 CNcsHeaderContainer& aHeaderContainer, |
52 CNcsHeaderContainer& aHeaderContainer, |
48 TBool aRemoteLookupSupported ) |
53 TBool aRemoteLookupSupported ) |
49 { |
54 { |
50 FUNC_LOG; |
55 FUNC_LOG; |
51 CNcsPopupListBox* self = |
56 CNcsPopupListBox* self = new (ELeave) CNcsPopupListBox( aHeaderContainer, |
52 new (ELeave) CNcsPopupListBox( aHeaderContainer, aRemoteLookupSupported, aMailBox ); |
57 aRemoteLookupSupported, aMailBox ); |
53 CleanupStack::PushL( self ); |
58 CleanupStack::PushL( self ); |
54 self->ConstructL( aParent ); |
59 self->ConstructL( aParent ); |
55 CleanupStack::Pop( self ); |
60 CleanupStack::Pop( self ); |
56 return self; |
61 return self; |
57 } |
62 } |
58 |
63 |
59 // ----------------------------------------------------------------------------- |
64 // ----------------------------------------------------------------------------- |
60 // CNcsPopupListBox::CNcsPopupListBox |
65 // CNcsPopupListBox::CNcsPopupListBox |
61 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
62 CNcsPopupListBox::CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer, |
67 CNcsPopupListBox::CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer, |
73 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
74 void CNcsPopupListBox::ConstructL( const CCoeControl* aParent ) |
79 void CNcsPopupListBox::ConstructL( const CCoeControl* aParent ) |
75 { |
80 { |
76 FUNC_LOG; |
81 FUNC_LOG; |
77 CEikTextListBox::ConstructL( aParent, CEikListBox::EPopout ); |
82 CEikTextListBox::ConstructL( aParent, CEikListBox::EPopout ); |
78 CreateScrollBarFrameL(); |
83 // Create non-window-owning scrollbar to avoid flickering. |
79 |
84 CEikScrollBarFrame* frame = CreateScrollBarFrameL( EFalse, EFalse, EFalse ); |
80 CEikTextListBox::SetBorder( TGulBorder::ESingleGray ); |
85 |
81 |
86 CEikTextListBox::SetBorder( TGulBorder::ENone ); |
82 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
87 |
83 CEikTextListBox::SetItemHeightL( font->HeightInPixels() + 8 ); |
88 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
84 |
89 CEikTextListBox::SetItemHeightL( font->FontMaxHeight() + 12 ); |
85 iBaseBackroundContext = CAknsBasicBackgroundControlContext::NewL( |
90 |
86 KAknsIIDQgnFsGrafEmailContent, |
91 iBackgroundContext = CAknsFrameBackgroundControlContext::NewL( |
87 Rect(), |
92 KAknsIIDQsnFrPopup, Rect(), Rect(), EFalse ); |
88 EFalse ); |
93 UpdateTextColors(); |
89 iContactHandler = CFsDelayedLoader::InstanceL()->GetContactHandlerL(); |
94 |
90 if ( !iContactHandler->IsLanguageSupportedL() ) |
95 iContactHandler = CFsDelayedLoader::InstanceL()->GetContactHandlerL(); |
91 { |
96 if ( !iContactHandler->IsLanguageSupportedL() ) |
92 iContactHandler = NULL; |
97 { |
93 } |
98 iContactHandler = NULL; |
94 |
99 } |
95 iAppUi = static_cast<CFreestyleEmailUiAppUi*>(iEikonEnv->AppUi()); //<cmail> |
100 |
96 |
101 iAppUi = static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ); |
97 // <cmail> |
|
98 SetListBoxObserver( this ); |
102 SetListBoxObserver( this ); |
99 // </cmail> |
|
100 } |
103 } |
101 |
104 |
102 // ----------------------------------------------------------------------------- |
105 // ----------------------------------------------------------------------------- |
103 // CNcsPopupListBox::InitAndSearchL |
106 // CNcsPopupListBox::InitAndSearchL |
104 // ----------------------------------------------------------------------------- |
107 // ----------------------------------------------------------------------------- |
105 void CNcsPopupListBox::InitAndSearchL( const TDesC& aText ) |
108 void CNcsPopupListBox::InitAndSearchL( const TDesC& aText ) |
106 { |
109 { |
107 FUNC_LOG; |
110 FUNC_LOG; |
108 SetSearchTextL( aText ); |
111 SetSearchTextL( aText ); |
109 RPointerArray<CFSEmailUiClsItem> emptyArray; |
112 RPointerArray<CFSEmailUiClsItem> emptyArray; |
110 CleanupClosePushL( emptyArray ); |
113 CleanupClosePushL( emptyArray ); |
111 OperationCompleteL( ESearchContacts, emptyArray ); |
114 OperationCompleteL( ESearchContacts, emptyArray ); |
112 CleanupStack::PopAndDestroy( &emptyArray ); |
115 CleanupStack::PopAndDestroy( &emptyArray ); |
113 } |
116 } |
114 |
117 |
115 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
116 // CNcsPopupListBox::~CNcsPopupListBox |
119 // CNcsPopupListBox::~CNcsPopupListBox |
117 // --------------------------------------------------------------------------- |
120 // --------------------------------------------------------------------------- |
118 CNcsPopupListBox::~CNcsPopupListBox() |
121 CNcsPopupListBox::~CNcsPopupListBox() |
119 { |
122 { |
120 FUNC_LOG; |
123 FUNC_LOG; |
121 delete iBaseBackroundContext; |
124 delete iBackgroundContext; |
122 delete iItemTextsArray; |
125 delete iItemTextsArray; |
123 delete iCurrentSearchText; |
126 delete iCurrentSearchText; |
124 iMatchingItems.ResetAndDestroy(); |
127 iMatchingItems.ResetAndDestroy(); |
125 } |
128 } |
126 |
129 |
127 // ----------------------------------------------------------------------------- |
130 // ----------------------------------------------------------------------------- |
128 // CNcsPopupListBox::CreateItemDrawerL |
131 // CNcsPopupListBox::CreateItemDrawerL |
129 // ----------------------------------------------------------------------------- |
132 // ----------------------------------------------------------------------------- |
130 void CNcsPopupListBox::CreateItemDrawerL() |
133 void CNcsPopupListBox::CreateItemDrawerL() |
131 { |
134 { |
132 FUNC_LOG; |
135 FUNC_LOG; |
133 CNcsListItemDrawer* drawer = new (ELeave) CNcsListItemDrawer( *this ); |
136 iItemDrawer = new (ELeave) CNcsListItemDrawer( *this ); |
134 iItemDrawer = drawer; |
137 } |
135 } |
|
136 |
138 |
137 // ----------------------------------------------------------------------------- |
139 // ----------------------------------------------------------------------------- |
138 // CNcsPopupListBox::MopSupplyObject |
140 // CNcsPopupListBox::MopSupplyObject |
139 // ----------------------------------------------------------------------------- |
141 // ----------------------------------------------------------------------------- |
140 TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject(TTypeUid aId) |
142 TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject(TTypeUid aId) |
141 { |
143 { |
142 FUNC_LOG; |
144 FUNC_LOG; |
143 if ( aId.iUid == MAknsControlContext::ETypeId ) |
145 if ( aId.iUid == MAknsControlContext::ETypeId ) |
144 { |
146 { |
145 return MAknsControlContext::SupplyMopObject( aId, iBaseBackroundContext ); |
147 return MAknsControlContext::SupplyMopObject( aId, iBackgroundContext ); |
146 } |
148 } |
147 return CCoeControl::MopSupplyObject( aId ); |
149 return CCoeControl::MopSupplyObject( aId ); |
148 } |
150 } |
149 |
151 |
150 // ----------------------------------------------------------------------------- |
152 // ----------------------------------------------------------------------------- |
151 // CNcsPopupListBox::SizeChanged |
153 // CNcsPopupListBox::SizeChanged |
152 // ----------------------------------------------------------------------------- |
154 // ----------------------------------------------------------------------------- |
153 void CNcsPopupListBox::SizeChanged() |
155 void CNcsPopupListBox::SizeChanged() |
154 { |
156 { |
155 FUNC_LOG; |
157 FUNC_LOG; |
156 CEikTextListBox::SizeChanged(); |
158 TRect outerRect = Rect(); |
157 iBaseBackroundContext->SetRect( Rect() ); |
159 TRect innerRect = outerRect; |
|
160 innerRect.Shrink( KBackgroundFrameWidth, KBackgroundFrameWidth ); |
|
161 SetViewRectFromClientRect( innerRect ); |
|
162 TRAP_IGNORE( HandleViewRectSizeChangeL() ); |
|
163 iBackgroundContext->SetFrameRects( outerRect, innerRect ); |
|
164 } |
|
165 |
|
166 void CNcsPopupListBox::HandleResourceChange( TInt aType ) |
|
167 { |
|
168 FUNC_LOG; |
|
169 if ( aType == KAknsMessageSkinChange ) |
|
170 { |
|
171 UpdateTextColors(); |
|
172 } |
|
173 } |
|
174 |
|
175 void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
176 { |
|
177 // When scrollbar is non-window-owning, the pointer events should be passed |
|
178 // to it through control hierachy, but the CEikTextListBox does not seem to |
|
179 // do that, so that is handled here. |
|
180 CEikScrollBar* sb = iSBFrame->VerticalScrollBar(); |
|
181 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
182 { |
|
183 if ( sb && sb->Rect().Contains( aPointerEvent.iPosition ) ) |
|
184 { |
|
185 sb->ClaimPointerGrab( EFalse ); |
|
186 sb->HandlePointerEventL( aPointerEvent ); |
|
187 } |
|
188 else |
|
189 { |
|
190 ClaimPointerGrab( EFalse ); |
|
191 } |
|
192 } |
|
193 |
|
194 CCoeControl* pointerRecipient = GrabbingComponent(); |
|
195 if ( sb && pointerRecipient == sb ) |
|
196 { |
|
197 sb->HandlePointerEventL( aPointerEvent ); |
|
198 } |
|
199 else |
|
200 { |
|
201 CEikTextListBox::HandlePointerEventL( aPointerEvent ); |
|
202 } |
158 } |
203 } |
159 |
204 |
160 // ----------------------------------------------------------------------------- |
205 // ----------------------------------------------------------------------------- |
161 // CNcsPopupListBox::OfferKeyEventL |
206 // CNcsPopupListBox::OfferKeyEventL |
162 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
163 // |
208 // |
164 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
209 TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
210 TEventCode aType ) |
165 { |
211 { |
166 FUNC_LOG; |
212 FUNC_LOG; |
167 TKeyResponse ret( EKeyWasNotConsumed ); |
213 TKeyResponse ret( EKeyWasNotConsumed ); |
168 if( aKeyEvent.iCode == EKeyDownArrow ) |
214 if( aKeyEvent.iCode == EKeyDownArrow ) |
169 { |
215 { |
322 |
367 |
323 // ----------------------------------------------------------------------------- |
368 // ----------------------------------------------------------------------------- |
324 // CNcsPopupListBox::SetPopupMaxRect |
369 // CNcsPopupListBox::SetPopupMaxRect |
325 // ----------------------------------------------------------------------------- |
370 // ----------------------------------------------------------------------------- |
326 void CNcsPopupListBox::SetPopupMaxRect( const TRect& aPopupMaxRect ) |
371 void CNcsPopupListBox::SetPopupMaxRect( const TRect& aPopupMaxRect ) |
327 { |
372 { |
328 FUNC_LOG; |
373 FUNC_LOG; |
329 iPopupMaxRect = aPopupMaxRect; |
374 iPopupMaxRect = aPopupMaxRect; |
330 SetPopupHeight(); |
375 SetPopupHeight(); |
331 TRAP_IGNORE( UpdateScrollBarsL() ); |
376 TRAP_IGNORE( UpdateScrollBarsL() ); |
332 TRAP_IGNORE( SetScrollBarVisibilityL() ); |
377 TRAP_IGNORE( SetScrollBarVisibilityL() ); |
333 } |
378 } |
334 |
379 |
335 // ----------------------------------------------------------------------------- |
380 // ----------------------------------------------------------------------------- |
336 // CNcsPopupListBox::IsPopupEmpty |
381 // CNcsPopupListBox::IsPopupEmpty |
337 // ----------------------------------------------------------------------------- |
382 // ----------------------------------------------------------------------------- |
338 TBool CNcsPopupListBox::IsPopupEmpty() const |
383 TBool CNcsPopupListBox::IsPopupEmpty() const |
339 { |
384 { |
340 FUNC_LOG; |
385 FUNC_LOG; |
341 if( Model()->NumberOfItems() > 0 ) |
386 if ( Model()->NumberOfItems() > 0 ) |
342 return EFalse; |
387 return EFalse; |
343 else |
388 else |
344 return ETrue; |
389 return ETrue; |
345 } |
390 } |
346 |
391 |
347 // ----------------------------------------------------------------------------- |
392 // ----------------------------------------------------------------------------- |
348 // CNcsPopupListBox::IsRemoteLookupItemSelected |
393 // CNcsPopupListBox::IsRemoteLookupItemSelected |
349 // ----------------------------------------------------------------------------- |
394 // ----------------------------------------------------------------------------- |
350 TBool CNcsPopupListBox::IsRemoteLookupItemSelected() const |
395 TBool CNcsPopupListBox::IsRemoteLookupItemSelected() const |
351 { |
396 { |
352 FUNC_LOG; |
397 FUNC_LOG; |
353 if( CurrentItemIndex() == iRemoteLookupItemPos && iRemoteLookupSupported ) |
398 if ( CurrentItemIndex() == iRemoteLookupItemPos && iRemoteLookupSupported ) |
354 return ETrue; |
399 return ETrue; |
355 else |
400 else |
356 return EFalse; |
401 return EFalse; |
357 } |
402 } |
358 |
403 |
359 // ----------------------------------------------------------------------------- |
404 // ----------------------------------------------------------------------------- |
360 // CNcsPopupListBox::CurrentPopupClsItemsArray |
405 // CNcsPopupListBox::CurrentPopupClsItemsArray |
361 // ----------------------------------------------------------------------------- |
406 // ----------------------------------------------------------------------------- |
362 |
|
363 const RPointerArray<CFSEmailUiClsItem>& CNcsPopupListBox::CurrentPopupClsItemsArray() const |
407 const RPointerArray<CFSEmailUiClsItem>& CNcsPopupListBox::CurrentPopupClsItemsArray() const |
364 { |
408 { |
365 return iMatchingItems; |
409 return iMatchingItems; |
366 } |
410 } |
367 |
411 |
368 // ----------------------------------------------------------------------------- |
412 // ----------------------------------------------------------------------------- |
369 // CNcsPopupListBox::RemoteLookupItemPos |
413 // CNcsPopupListBox::RemoteLookupItemPos |
370 // ----------------------------------------------------------------------------- |
414 // ----------------------------------------------------------------------------- |
371 TInt CNcsPopupListBox::RemoteLookupItemPos() const |
415 TInt CNcsPopupListBox::RemoteLookupItemPos() const |
372 { |
416 { |
373 FUNC_LOG; |
417 FUNC_LOG; |
374 return iRemoteLookupItemPos; |
418 return iRemoteLookupItemPos; |
375 } |
419 } |
376 |
420 |
377 // ----------------------------------------------------------------------------- |
421 // ----------------------------------------------------------------------------- |
378 // CNcsPopupListBox::LayoutHandler |
422 // CNcsPopupListBox::LayoutHandler |
379 // ----------------------------------------------------------------------------- |
423 // ----------------------------------------------------------------------------- |
380 CFSEmailUiLayoutHandler& CNcsPopupListBox::LayoutHandler() const |
424 CFSEmailUiLayoutHandler& CNcsPopupListBox::LayoutHandler() const |
381 { |
425 { |
382 FUNC_LOG; |
426 FUNC_LOG; |
383 CFreestyleEmailUiAppUi* appUi = |
427 return *iAppUi->LayoutHandler(); |
384 static_cast<CFreestyleEmailUiAppUi*>( ControlEnv()->AppUi() ); |
|
385 return *appUi->LayoutHandler(); |
|
386 } |
428 } |
387 |
429 |
388 // ----------------------------------------------------------------------------- |
430 // ----------------------------------------------------------------------------- |
389 // CNcsPopupListBox::SetListItemsFromArrayL |
431 // CNcsPopupListBox::SetListItemsFromArrayL |
390 // ----------------------------------------------------------------------------- |
432 // ----------------------------------------------------------------------------- |
434 |
476 |
435 // ----------------------------------------------------------------------------- |
477 // ----------------------------------------------------------------------------- |
436 // CNcsPopupListBox::SetPopupHeight |
478 // CNcsPopupListBox::SetPopupHeight |
437 // ----------------------------------------------------------------------------- |
479 // ----------------------------------------------------------------------------- |
438 void CNcsPopupListBox::SetPopupHeight() |
480 void CNcsPopupListBox::SetPopupHeight() |
439 { |
481 { |
440 FUNC_LOG; |
482 FUNC_LOG; |
441 // This is the total height in pixels needed to show all items |
483 // This is the total height in pixels needed to show all items |
442 TInt minimumHeight = CalcHeightBasedOnNumOfItems( Model()->NumberOfItems()); |
484 TInt minimumHeight = 2 * KBackgroundFrameWidth + |
|
485 CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
443 TRect newRect = iPopupMaxRect; |
486 TRect newRect = iPopupMaxRect; |
444 TInt areaHeight = Parent()->Parent()->Rect().Height(); |
487 TInt areaHeight = Parent()->Parent()->Rect().Height(); |
445 TInt halfAreaHeight = areaHeight/2; |
488 TInt halfAreaHeight = areaHeight/2; |
446 |
489 |
447 // Get height of one line in Address field |
490 // Get height of one line in Address field |
448 CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent()); |
491 CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent()); |
449 TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height |
492 TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height |
450 if(toLineHeight == 0) |
493 if(toLineHeight == 0) |
451 { |
494 { |
452 toLineHeight = ItemHeight(); |
495 toLineHeight = ItemHeight(); |
589 |
633 |
590 // ----------------------------------------------------------------------------- |
634 // ----------------------------------------------------------------------------- |
591 // CNcsListItemDrawer::CNcsListItemDrawer |
635 // CNcsListItemDrawer::CNcsListItemDrawer |
592 // ----------------------------------------------------------------------------- |
636 // ----------------------------------------------------------------------------- |
593 CNcsListItemDrawer::CNcsListItemDrawer( const CNcsPopupListBox& aListBox ) |
637 CNcsListItemDrawer::CNcsListItemDrawer( const CNcsPopupListBox& aListBox ) |
594 :CListItemDrawer(), iListBox(aListBox) |
638 :CListItemDrawer(), iListBox( aListBox ) |
595 { |
639 { |
596 FUNC_LOG; |
640 FUNC_LOG; |
597 // Store a GC for later use |
641 // Store a GC for later use |
598 iGc = &CCoeEnv::Static()->SystemGc(); |
642 iGc = &CCoeEnv::Static()->SystemGc(); |
599 SetGc(iGc); |
643 SetGc(iGc); |
600 } |
644 } |
601 |
645 |
602 // ----------------------------------------------------------------------------- |
646 // ----------------------------------------------------------------------------- |
603 // CNcsListItemDrawer::DrawActualItem |
647 // CNcsListItemDrawer::DrawActualItem |
604 // ----------------------------------------------------------------------------- |
648 // ----------------------------------------------------------------------------- |
605 void CNcsListItemDrawer::DrawActualItem(TInt aItemIndex, |
649 void CNcsListItemDrawer::DrawActualItem(TInt aItemIndex, |
606 const TRect& aActualItemRect, TBool aItemIsCurrent, |
650 const TRect& aActualItemRect, TBool aItemIsCurrent, |
607 TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/, |
651 TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/, |
608 TBool /*aItemIsSelected*/) const |
652 TBool /*aItemIsSelected*/) const |
609 { |
653 { |
610 FUNC_LOG; |
654 FUNC_LOG; |
611 // <cmail> |
655 iGc->DiscardFont(); |
612 iGc->Reset(); |
656 |
613 // </cmail> |
657 // Get reference to curren popup cls item list. |
614 |
658 const RPointerArray<CFSEmailUiClsItem>& clsItemArray = |
615 // Get reference to curren popup cls item list. |
659 iListBox.CurrentPopupClsItemsArray(); |
616 const RPointerArray<CFSEmailUiClsItem>& clsItemArray = iListBox.CurrentPopupClsItemsArray(); |
660 TInt rmluPosition = iListBox.RemoteLookupItemPos(); |
617 TInt rmluPosition = iListBox.RemoteLookupItemPos(); |
661 |
618 |
662 // Sets all the attributes, like font, text color and background color. |
619 // Sets all the attributes, like font, text color and background color. |
663 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
620 const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
664 iGc->UseFont( font ); |
621 iGc->UseFont(font); |
665 iGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
622 |
666 iGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
623 // We have to draw the item in layered fassion in order to do the skin |
667 |
624 // First clear the backround by drawing a solid white rect. |
668 TRect itemRect = aActualItemRect; |
625 iGc->SetPenColor(iBackColor); |
669 { |
626 iGc->SetPenStyle(CGraphicsContext::ESolidPen); |
670 // temporary const_cast to get the scrollbar width |
627 iGc->SetBrushColor(iBackColor); |
671 CNcsPopupListBox& tmpListBox = const_cast<CNcsPopupListBox&>( iListBox ); |
628 iGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
672 itemRect.Resize( -tmpListBox.ScrollBarFrame()->ScrollBarBreadth( |
629 |
673 CEikScrollBar::EVertical ) + KBackgroundFrameWidth, 0 ); |
630 // draw the background |
674 } |
631 TRect backgroundRect( aActualItemRect ); |
675 |
632 |
676 TRect textRect = itemRect; |
633 if ( !aItemIndex ) |
677 textRect.Shrink( KHighlightFrameWidth, KHighlightFrameWidth ); |
634 { |
678 |
635 backgroundRect.iTl.iY = 0; |
679 // Get skin instance. |
636 } |
680 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
637 else if ( aItemIndex == iListBox.Model()->NumberOfItems() - 1 ) |
681 |
638 { |
682 // Draw background using the control context from the list box. |
639 backgroundRect.iBr.iY = iListBox.Size().iHeight; |
683 MAknsControlContext* cc = AknsDrawUtils::ControlContext( &iListBox ); |
640 } |
684 if ( cc ) |
641 |
685 { |
642 iGc->DrawRect( backgroundRect ); |
686 AknsDrawUtils::Background( skin, cc, *iGc, itemRect ); |
643 |
687 } |
644 |
688 else |
645 TRect textRect( aActualItemRect ); |
689 { |
646 { |
690 iGc->Clear( itemRect ); |
647 // temporary const_cast to get scroll width |
691 } |
648 CNcsPopupListBox& tmpListBox = const_cast<CNcsPopupListBox&>(iListBox); |
692 |
649 textRect.Resize( -tmpListBox.ScrollBarFrame()->ScrollBarBreadth(CEikScrollBar::EVertical), 0 ); |
693 // Draw the highlight, when necessary. |
650 } |
694 if ( aItemIsCurrent ) |
651 |
695 { |
652 |
696 AknsDrawUtils::DrawFrame( skin, *iGc, itemRect, textRect, |
653 // Now draw the highlight |
697 KAknsIIDQsnFrList, KAknsIIDQsnFrListCenter ); |
654 if( aItemIsCurrent ) |
698 } |
655 { |
699 |
656 TRgb highlightColor = iListBox.LayoutHandler().PcsPopupHighlightColor(); |
700 // Get text color. |
657 iGc->SetBrushColor(highlightColor); |
701 TRgb textColor = TextColor(); |
658 // AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *iGc, |
702 if ( aItemIsCurrent ) |
659 // aActualItemRect, aActualItemRect, |
703 { |
660 // KNcsIIDHighlightBackground, KNcsIIDHighlightBackground ); |
704 textColor = HighlightedTextColor(); |
661 iGc->DrawRect(textRect); |
705 } |
662 } |
706 |
663 |
707 iGc->SetPenColor( textColor ); |
664 iGc->SetPenColor(iTextColor); |
708 TInt topToBaseline = ( textRect.Height() - font->FontMaxHeight() ) / 2 |
665 iGc->SetPenStyle(CGraphicsContext::ESolidPen); |
709 + font->FontMaxAscent(); |
666 iGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
710 |
667 TInt topToBaseline = ( textRect.Height() - font->HeightInPixels() ) / 2 |
711 TPtrC itemText = iListBox.Model()->ItemText( aItemIndex ); |
668 + font->AscentInPixels(); |
|
669 |
|
670 TPtrC itemText = iListBox.Model()->ItemText( aItemIndex ); |
|
671 |
712 |
672 // Construct bidirectional text object |
713 // Construct bidirectional text object |
673 // <cmail> Removed leave from non-leaving function. |
714 // <cmail> Removed leave from non-leaving function. |
674 TBidiText* bidiText = NULL; |
715 TBidiText* bidiText = NULL; |
675 TRAPD( err, bidiText = TBidiText::NewL( itemText, 1 ) ); |
716 TRAPD( err, bidiText = TBidiText::NewL( itemText, 1 ) ); |