110 // ----------------------------------------------------------------------------- |
110 // ----------------------------------------------------------------------------- |
111 // |
111 // |
112 void CESMRResponseItem::Draw( const TRect& aRect ) const |
112 void CESMRResponseItem::Draw( const TRect& aRect ) const |
113 { |
113 { |
114 FUNC_LOG; |
114 FUNC_LOG; |
115 //switch font color to unhighlighted, leave can be ignored |
115 NMRColorManager::SetColor( *iSelectionLabel, |
116 //since it's just a color change |
116 NMRColorManager::EMRMainAreaTextColor ); |
117 TRAP_IGNORE(AknLayoutUtils::OverrideControlColorL( |
117 |
118 *iSelectionLabel, |
|
119 EColorLabelText, |
|
120 KRgbBlack )); |
|
121 if( iHighlighted ) |
118 if( iHighlighted ) |
122 { |
119 { |
123 //switch font color to highlighted, leave can be ignored |
|
124 //since it's just a color change |
|
125 TRAP_IGNORE(AknLayoutUtils::OverrideControlColorL( |
|
126 *iSelectionLabel, |
|
127 EColorLabelText, |
|
128 iLayout->ViewerListAreaHighlightedTextColor() )); |
|
129 |
|
130 CWindowGc& gc = SystemGc(); |
120 CWindowGc& gc = SystemGc(); |
131 TRect rect = aRect; |
121 TRect rect = aRect; |
132 TBool enableEdges(ETrue); |
122 TBool enableEdges(ETrue); |
133 |
123 |
134 CFbsBitmap* selector = NULL; |
124 CFbsBitmap* selector = NULL; |
300 { |
290 { |
301 TAknTextComponentLayout labelLayout = |
291 TAknTextComponentLayout labelLayout = |
302 NMRLayoutManager::GetTextComponentLayout( |
292 NMRLayoutManager::GetTextComponentLayout( |
303 NMRLayoutManager::EMRTextLayoutText ); |
293 NMRLayoutManager::EMRTextLayoutText ); |
304 AknLayoutUtils::LayoutLabel( iSelectionLabel, rect, labelLayout ); |
294 AknLayoutUtils::LayoutLabel( iSelectionLabel, rect, labelLayout ); |
305 } |
295 // SizeChange() is called when rect for ResponseItem is ready to be used. |
306 |
296 // If setting text to response topic label fails, no need to catch it. |
307 |
297 TRAP_IGNORE(SetTextToLabelL()); |
|
298 } |
308 } |
299 } |
309 |
300 |
310 // ----------------------------------------------------------------------------- |
301 // ----------------------------------------------------------------------------- |
311 // CESMRResponseItem::IconL |
302 // CESMRResponseItem::IconL |
312 // ----------------------------------------------------------------------------- |
303 // ----------------------------------------------------------------------------- |
390 iItemText = HBufC::NewL( aItemText.Length() ); |
379 iItemText = HBufC::NewL( aItemText.Length() ); |
391 *iItemText = aItemText; |
380 *iItemText = aItemText; |
392 } |
381 } |
393 else if( !iItemText && aItemText.Length() <= 0 ) |
382 else if( !iItemText && aItemText.Length() <= 0 ) |
394 { |
383 { |
395 // if there is no text yet, there is nothing to do here. |
384 // if there is no new text yet, there is nothing to do here. |
396 return; |
385 return; |
397 } |
386 } |
398 |
387 SetTextToLabelL(); |
399 TInt lineCount = 1; // Default line count. |
388 } |
400 // If this item has no icon, it may use two lines for the text |
389 |
401 if( !iIcon ) |
390 // ----------------------------------------------------------------------------- |
402 { |
391 // CESMRResponseItem::SetTextToLabelL |
403 lineCount = KMaxLinesInResponseTopicItem; |
392 // ----------------------------------------------------------------------------- |
404 } |
393 // |
405 // Text wrapping |
394 void CESMRResponseItem::SetTextToLabelL() |
406 CArrayFixFlat<TInt>* widthArray = |
395 { |
407 new (ELeave) CArrayFixFlat<TInt>( lineCount ); |
396 if( iItemText ) |
408 CleanupStack::PushL( widthArray ); |
397 { |
409 for ( TInt i(0); i < lineCount; i++ ) |
398 TInt lineCount = 1; // Default line count. |
410 { |
399 // If this item has no icon, it may use two lines for the text |
411 // If this item has no icon, all the space is for text |
400 if( !iIcon ) |
412 if( !iIcon ) |
401 { |
413 { |
402 lineCount = KMaxLinesInResponseTopicItem; |
414 TAknLayoutText layout = NMRLayoutManager::GetLayoutText( Rect(), NMRLayoutManager::EMRTextLayoutText ); |
403 } |
415 widthArray->AppendL( layout.TextRect().Width() ); |
404 |
416 } |
405 // Text wrapping |
417 else |
406 CArrayFixFlat<TInt>* widthArray = |
418 { |
407 new (ELeave) CArrayFixFlat<TInt>( lineCount ); |
419 widthArray->AppendL( iLayout->ResponseAreaAnswerTextSize().iWidth ); |
408 CleanupStack::PushL( widthArray ); |
420 } |
409 |
421 } |
410 for ( TInt i(0); i < lineCount; i++ ) |
422 |
411 { |
423 HBufC* wrappedText; |
412 // If this item has no icon, all the space is for text |
424 // Set the font for the text |
413 if( !iIcon ) |
425 const CFont* font = iSelectionLabel->Font(); |
414 { |
426 RBuf buffer; // codescanner::resourcenotoncleanupstack |
415 TAknLayoutText layout = NMRLayoutManager::GetLayoutText( |
427 buffer.CreateL( iOriginalTextLength + widthArray->Count() ); |
416 Rect(), NMRLayoutManager::EMRTextLayoutText ); |
428 buffer.CleanupClosePushL(); |
417 widthArray->AppendL( layout.TextRect().Width() ); |
429 |
418 } |
430 // Wrap the text |
419 else |
431 AknTextUtils::WrapToStringAndClipL( iItemText->Des(), *widthArray, *font, buffer ); |
420 { |
432 wrappedText = buffer.AllocLC(); |
421 // This layout leaves space for the icon to the left side |
433 |
422 TAknLayoutText layout = NMRLayoutManager::GetLayoutText( |
434 // Set the text to label |
423 Rect(), NMRLayoutManager::EMRTextLayoutTextEditor ); |
435 iSelectionLabel->SetTextL( *wrappedText ); |
424 widthArray->AppendL( layout.TextRect().Width() ); |
436 CleanupStack::PopAndDestroy(3); // widthArray, wrappedText, buffer |
425 } |
437 } |
426 } |
438 |
427 |
439 // ----------------------------------------------------------------------------- |
428 HBufC* wrappedText; |
440 // CESMRResponseItem::SetLayoutManager |
429 // Set the font for the text |
441 // ----------------------------------------------------------------------------- |
430 const CFont* font = iSelectionLabel->Font(); |
442 // |
431 RBuf buffer; // codescanner::resourcenotoncleanupstack |
443 void CESMRResponseItem::SetLayoutManager( CESMRLayoutManager* aLayout ) |
432 buffer.CreateL( iOriginalTextLength + widthArray->Count() ); |
444 { |
433 buffer.CleanupClosePushL(); |
445 FUNC_LOG; |
434 |
446 iLayout = aLayout; |
435 // Wrap the text |
447 } |
436 AknTextUtils::WrapToStringAndClipL( *iItemText, *widthArray, *font, buffer ); |
|
437 wrappedText = buffer.AllocLC(); |
|
438 |
|
439 // Set the text to label |
|
440 iSelectionLabel->SetTextL( *wrappedText ); |
|
441 CleanupStack::PopAndDestroy(3); // widthArray, wrappedText, buffer |
|
442 } |
|
443 } |
448 |
444 |
449 // ----------------------------------------------------------------------------- |
445 // ----------------------------------------------------------------------------- |
450 // CESMRResponseItem::ItemTextLineCount |
446 // CESMRResponseItem::ItemTextLineCount |
451 // ----------------------------------------------------------------------------- |
447 // ----------------------------------------------------------------------------- |
452 // |
448 // |