76 : CFormattedCellListBoxItemDrawer( aTextListBoxModel,aFont,aFormattedCellData ), |
76 : CFormattedCellListBoxItemDrawer( aTextListBoxModel,aFont,aFormattedCellData ), |
77 iWmPlugin( aWmPlugin ) |
77 iWmPlugin( aWmPlugin ) |
78 { |
78 { |
79 iCellData = aFormattedCellData; |
79 iCellData = aFormattedCellData; |
80 iListBox = aListBox; |
80 iListBox = aListBox; |
81 iFont = aFont; |
|
82 } |
81 } |
83 |
82 |
84 // --------------------------------------------------------- |
83 // --------------------------------------------------------- |
85 // CWmListItemDrawer::ConstructL |
84 // CWmListItemDrawer::ConstructL |
86 // --------------------------------------------------------- |
85 // --------------------------------------------------------- |
129 // Currently forever loop in CFormattedCellListBoxData::DrawFormattedSimple |
128 // Currently forever loop in CFormattedCellListBoxData::DrawFormattedSimple |
130 // never exits if there is no iconarray and name contains tab+digit which |
129 // never exits if there is no iconarray and name contains tab+digit which |
131 // confuses listbox e.g. considering name as icon index |
130 // confuses listbox e.g. considering name as icon index |
132 CArrayPtr<CGulIcon>* dummyArray = new( ELeave ) CAknIconArray(2); |
131 CArrayPtr<CGulIcon>* dummyArray = new( ELeave ) CAknIconArray(2); |
133 CleanupStack::PushL(dummyArray); |
132 CleanupStack::PushL(dummyArray); |
134 CGulIcon* dummyIcon = CGulIcon::NewLC(); |
133 |
135 CGulIcon* dummyIcon2 = CGulIcon::NewLC(); |
134 CFbsBitmap* dummyBmp = new(ELeave) CFbsBitmap; |
|
135 CleanupStack::PushL( dummyBmp ); |
|
136 User::LeaveIfError( dummyBmp->Create( TSize(0,0), EColor256 ) ); |
|
137 CGulIcon* dummyIcon = CGulIcon::NewL( dummyBmp ); |
|
138 CleanupStack::Pop( dummyBmp ); //ownership transfered |
|
139 CleanupStack::PushL( dummyIcon ); |
|
140 |
|
141 CFbsBitmap* dummyBmp2 = new(ELeave) CFbsBitmap; |
|
142 CleanupStack::PushL( dummyBmp2 ); |
|
143 User::LeaveIfError( dummyBmp2->Create( TSize(0,0), EColor256 ) ); |
|
144 CGulIcon* dummyIcon2 = CGulIcon::NewL( dummyBmp2 ); |
|
145 CleanupStack::Pop( dummyBmp2 ); //ownership transfered |
|
146 CleanupStack::PushL( dummyIcon2 ); |
|
147 |
136 dummyArray->AppendL(dummyIcon); |
148 dummyArray->AppendL(dummyIcon); |
137 dummyArray->AppendL(dummyIcon2); |
149 dummyArray->AppendL(dummyIcon2); |
138 ColumnData()->SetIconArray(dummyArray); |
150 ColumnData()->SetIconArray(dummyArray); |
139 CleanupStack::Pop(3); |
151 CleanupStack::Pop( dummyIcon2 ); |
|
152 CleanupStack::Pop( dummyIcon ); |
|
153 CleanupStack::Pop( dummyArray ); |
140 } |
154 } |
141 |
155 |
142 // --------------------------------------------------------- |
156 // --------------------------------------------------------- |
143 // CWmListItemDrawer::~CWmListItemDrawer |
157 // CWmListItemDrawer::~CWmListItemDrawer |
144 // --------------------------------------------------------- |
158 // --------------------------------------------------------- |
194 // --------------------------------------------------------- |
208 // --------------------------------------------------------- |
195 // CWmListItemDrawer::DrawItem |
209 // CWmListItemDrawer::DrawItem |
196 // --------------------------------------------------------- |
210 // --------------------------------------------------------- |
197 // |
211 // |
198 void CWmListItemDrawer::DrawItem( TInt aItemIndex, TPoint aItemRectPos, |
212 void CWmListItemDrawer::DrawItem( TInt aItemIndex, TPoint aItemRectPos, |
199 TBool aItemIsSelected, TBool aItemIsCurrent, |
213 TBool /*aItemIsSelected*/, TBool aItemIsCurrent, |
200 TBool aViewIsEmphasized, TBool aViewIsDimmed ) const |
214 TBool /*aViewIsEmphasized*/, TBool aViewIsDimmed ) const |
201 { |
215 { |
202 TSize cellSize = ItemCellSize(); |
216 TSize cellSize = ItemCellSize(); |
203 |
217 |
204 CWmWidgetData& wData = iListBox->WidgetData( aItemIndex ); |
218 CWmWidgetData& wData = iListBox->WidgetData( aItemIndex ); |
205 // Get graphics context which is used for drawing. |
219 // Get graphics context which is used for drawing. |
206 CWindowGc& gc = *Gc(); |
220 CWindowGc& gc = *Gc(); |
207 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
221 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
208 TInt selectedIndex = iListBox->CurrentItemIndex(); |
222 TBool highlightEnabled = !( iListBox->ItemDrawer()->Flags() & |
209 TBool isInFocus = ( selectedIndex == aItemIndex ); |
223 CListItemDrawer::ESingleClickDisabledHighlight ); |
210 TBool listFocused = iListBox->IsFocused(); |
224 TBool listFocused = ((iListBox->IsFocused() && !aViewIsDimmed) ? ETrue : EFalse); |
211 TRect itemRect = TRect( aItemRectPos, cellSize ); |
225 TRect itemRect = TRect( aItemRectPos, cellSize ); |
212 |
226 |
213 if ( isInFocus && listFocused ) |
227 CFormattedCellListBoxItemDrawer::DrawEmptyItem( |
214 { |
228 aItemIndex, aItemRectPos, aViewIsDimmed ); |
215 // force baseclass to draw highlight and animation for this item |
229 |
216 CFormattedCellListBoxItemDrawer::DrawItemText( |
230 if ( aItemIsCurrent && listFocused && highlightEnabled ) |
217 aItemIndex, itemRect, |
231 { |
218 aItemIsCurrent, aViewIsEmphasized, |
232 TRect innerRect( itemRect ); |
219 ( isInFocus || aItemIsSelected ) ); |
233 const TInt highlightOffset = 2; |
|
234 innerRect.Shrink( highlightOffset, highlightOffset ); |
220 |
235 |
221 if ( iListBox->PressedDown() ) |
236 AknsDrawUtils::DrawFrame( skin, |
222 { |
237 gc, |
223 TRect innerRect( itemRect ); |
238 itemRect, |
224 const TInt highlightOffset = 3; |
239 innerRect, |
225 innerRect.Shrink( highlightOffset, highlightOffset ); |
240 KAknsIIDQsnFrList, |
226 AknsDrawUtils::DrawFrame( skin, |
241 KAknsIIDQsnFrListCenter ); |
227 gc, |
242 |
228 itemRect, |
243 } |
229 innerRect, |
|
230 KAknsIIDQsnFrListPressed, |
|
231 KAknsIIDQsnFrListCenterPressed ); |
|
232 } |
|
233 } |
|
234 else |
|
235 { |
|
236 // to prevent item staying highlighted when list isn't focused. |
|
237 CFormattedCellListBoxItemDrawer::DrawEmptyItem( |
|
238 aItemIndex, aItemRectPos, aViewIsDimmed ); |
|
239 } |
|
240 |
|
241 |
244 |
242 // DRAW LOGO |
245 // DRAW LOGO |
243 CFbsBitmap* bitmap = const_cast<CFbsBitmap*>(wData.LogoImage()); |
246 CFbsBitmap* bitmap = const_cast<CFbsBitmap*>(wData.LogoImage()); |
244 CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask()); |
247 CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask()); |
245 TAknLayoutRect logoLayout; |
248 TAknLayoutRect logoLayout; |
254 { |
257 { |
255 logoLayout.DrawImage( gc, bitmap, mask ); |
258 logoLayout.DrawImage( gc, bitmap, mask ); |
256 } |
259 } |
257 |
260 |
258 TRgb textColor; |
261 TRgb textColor; |
259 TAknsQsnTextColorsIndex index = ( isInFocus && listFocused )? |
262 TAknsQsnTextColorsIndex index = |
|
263 ( aItemIsCurrent && listFocused && highlightEnabled )? |
260 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; |
264 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; |
261 |
265 |
262 AknsUtils::GetCachedColor( |
266 AknsUtils::GetCachedColor( |
263 skin, textColor, KAknsIIDQsnTextColors, index ); |
267 skin, textColor, KAknsIIDQsnTextColors, index ); |
264 |
268 |
265 // DRAW TEXT |
269 // DRAW TEXT |
266 gc.UseFont( iFont ); |
|
267 gc.SetPenColor( textColor ); |
|
268 gc.SetPenSize( TSize(2,2) ); |
|
269 |
270 |
270 TAknTextLineLayout titleTextLayout = |
271 TAknTextLineLayout titleTextLayout = |
271 AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine(); |
272 AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine(); |
272 |
273 |
273 TAknLayoutText textLayoutTitle; |
274 TAknLayoutText textLayoutTitle; |
279 { |
280 { |
280 // DRAW ADD BUTTON |
281 // DRAW ADD BUTTON |
281 TAknLayoutRect addButtonLayout; |
282 TAknLayoutRect addButtonLayout; |
282 addButtonLayout.LayoutRect( itemRect, |
283 addButtonLayout.LayoutRect( itemRect, |
283 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine() ); |
284 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine() ); |
284 if ( isInFocus && listFocused ) |
285 if ( aItemIsCurrent && listFocused && highlightEnabled ) |
285 { |
286 { |
286 addButtonLayout.DrawImage( gc, |
287 addButtonLayout.DrawImage( gc, |
287 iAddWidgetBtnHighlightImage, iAddWidgetBtnHighlightMask ); |
288 iAddWidgetBtnHighlightImage, iAddWidgetBtnHighlightMask ); |
288 } |
289 } |
289 else |
290 else |
431 CWmListBox::CWmListBox( CWmPlugin& aWmPlugin ): |
431 CWmListBox::CWmListBox( CWmPlugin& aWmPlugin ): |
432 CAknDouble2LargeStyleListBox(), |
432 CAknDouble2LargeStyleListBox(), |
433 iWmPlugin( aWmPlugin ) |
433 iWmPlugin( aWmPlugin ) |
434 { |
434 { |
435 iFindPaneIsVisible = EFalse; |
435 iFindPaneIsVisible = EFalse; |
436 iPressedDown = EFalse; |
|
437 iLogoSize = TSize( 0, 0); |
436 iLogoSize = TSize( 0, 0); |
438 } |
437 } |
439 |
438 |
440 // --------------------------------------------------------- |
439 // --------------------------------------------------------- |
441 // CWmListBox::~CWmListBox |
440 // CWmListBox::~CWmListBox |
492 // --------------------------------------------------------- |
491 // --------------------------------------------------------- |
493 // |
492 // |
494 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData, |
493 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData, |
495 TBool aRedraw ) |
494 TBool aRedraw ) |
496 { |
495 { |
497 aWidgetData->SetObserver( this ); |
496 if ( aWidgetData ) |
498 iWidgetDatas.InsertInOrderAllowRepeatsL( aWidgetData, |
497 { |
|
498 aWidgetData->SetObserver( this ); |
|
499 iWidgetDatas.InsertInOrderAllowRepeatsL( aWidgetData, |
499 SortOrder(EStoredOrder) ); |
500 SortOrder(EStoredOrder) ); |
500 if ( aRedraw ) { HandleItemAdditionL(); } |
501 if ( aRedraw ) { HandleItemAdditionL(); } |
|
502 } |
501 } |
503 } |
502 |
504 |
503 // --------------------------------------------------------- |
505 // --------------------------------------------------------- |
504 // CWmListBox::RemoveWidgetData |
506 // CWmListBox::RemoveWidgetData |
505 // --------------------------------------------------------- |
507 // --------------------------------------------------------- |
693 // CWmListBox::HandlePointerEventL |
695 // CWmListBox::HandlePointerEventL |
694 // --------------------------------------------------------- |
696 // --------------------------------------------------------- |
695 // |
697 // |
696 void CWmListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
698 void CWmListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
697 { |
699 { |
698 CAknDouble2LargeStyleListBox::HandlePointerEventL( aPointerEvent ); |
|
699 |
|
700 // Check if pointer is down ( needed for drawing correct hightlight frame ) |
|
701 if ( Rect().Contains( aPointerEvent.iPosition ) ) |
700 if ( Rect().Contains( aPointerEvent.iPosition ) ) |
702 { |
701 { |
703 TInt itemIndex = CurrentListBoxItemIndex(); |
702 TInt itemIndex = CurrentListBoxItemIndex(); |
704 TBool itemPointed = View()->XYPosToItemIndex( |
703 TBool itemPointed = View()->XYPosToItemIndex( |
705 aPointerEvent.iPosition, |
704 aPointerEvent.iPosition, |
706 itemIndex ); |
705 itemIndex ); |
707 if ( itemIndex >= 0 && itemPointed ) |
706 if ( itemIndex >= 0 && itemPointed ) |
708 { |
707 { |
709 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
708 SetCurrentItemIndex( itemIndex ); //update index |
710 { |
|
711 iPressedDown = ETrue; |
|
712 // redraw item |
|
713 RedrawItem( itemIndex ); |
|
714 } |
|
715 else if( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
716 { |
|
717 iPressedDown = EFalse; |
|
718 // redraw item |
|
719 RedrawItem( itemIndex ); |
|
720 } |
|
721 } |
709 } |
722 } |
710 } |
|
711 CAknDouble2LargeStyleListBox::HandlePointerEventL( aPointerEvent ); |
723 } |
712 } |
724 |
713 |
725 // --------------------------------------------------------- |
714 // --------------------------------------------------------- |
726 // CWmListBox::LogoSize |
715 // CWmListBox::LogoSize |
727 // --------------------------------------------------------- |
716 // --------------------------------------------------------- |