textinput/peninputcommonctrls/src/peninputselectionlist/peninputscrollablelist.cpp
branchRCL_3
changeset 9 e6a39382bb9c
parent 0 eb1f2e154e89
child 11 c8fb4cf7b3ae
equal deleted inserted replaced
8:4eb1ae11334f 9:e6a39382bb9c
   119     
   119     
   120     if (bmpId != KInvalidBmp)
   120     if (bmpId != KInvalidBmp)
   121         {
   121         {
   122     	if (bmpMskId != KInvalidBmp)
   122     	if (bmpMskId != KInvalidBmp)
   123     		{
   123     		{
   124 		    AknsUtils::CreateColorIconL( AknsUtils::SkinInstance(),
   124 		    AknsUtils::CreateColorIconL( UiLayout()->SkinInstance(),
   125 						         id,
   125 						         id,
   126 						         KAknsIIDQsnIconColors,
   126 						         KAknsIIDQsnIconColors,
   127 						         EAknsCIQsnIconColorsCG30,
   127 						         EAknsCIQsnIconColorsCG30,
   128 						         iSeperationBmp,
   128 						         iSeperationBmp,
   129 						         iSeperationMaskBmp,
   129 						         iSeperationMaskBmp,
   132 						         bmpMskId,
   132 						         bmpMskId,
   133 						         AKN_LAF_COLOR( 0 ) );    		                     
   133 						         AKN_LAF_COLOR( 0 ) );    		                     
   134             }
   134             }
   135         else
   135         else
   136             {
   136             {
   137     	    AknsUtils::CreateIconL(AknsUtils::SkinInstance(),
   137     	    AknsUtils::CreateIconL(UiLayout()->SkinInstance(),
   138     	                           id,
   138     	                           id,
   139     	                           iSeperationBmp,
   139     	                           iSeperationBmp,
   140     	                           bmpFileName,
   140     	                           bmpFileName,
   141     	                           bmpId);
   141     	                           bmpId);
   142             }
   142             }
   197 
   197 
   198     // ----- draw bitmaps -----
   198     // ----- draw bitmaps -----
   199     gc->Activate(BitmapDevice());
   199     gc->Activate(BitmapDevice());
   200     gc->Clear(rect);
   200     gc->Clear(rect);
   201 
   201 
   202 	AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), 
   202 	AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), 
   203 	                         *gc, 
   203 	                         *gc, 
   204 	                         rect, 
   204 	                         rect, 
   205 	                         innerRect,
   205 	                         innerRect,
   206 	                         iBgFrId,
   206 	                         iBgFrId,
   207 	                         KAknsIIDDefault);
   207 	                         KAknsIIDDefault);
   239 	    TAknsQsnTextColorsIndex clrIndex;
   239 	    TAknsQsnTextColorsIndex clrIndex;
   240 	    clrIndex = EAknsCIQsnTextColorsCG20;
   240 	    clrIndex = EAknsCIQsnTextColorsCG20;
   241 
   241 
   242 	    if ( AknsUtils::AvkonSkinEnabled() )
   242 	    if ( AknsUtils::AvkonSkinEnabled() )
   243 	        {
   243 	        {
   244 	        AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
   244 	        AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
   245 	                               color, KAknsIIDQsnTextColors, clrIndex );
   245 	                               color, KAknsIIDQsnTextColors, clrIndex );
   246 	        }
   246 	        }
   247 
   247 
   248 	    textLayout.DrawText(*gc, iPageInfo->Des(), EFalse, color);
   248 	    textLayout.DrawText(*gc, iPageInfo->Des(), EFalse, color);
   249         }
   249         }
   344     UpdateNaviButtonStates();
   344     UpdateNaviButtonStates();
   345     }
   345     }
   346 
   346 
   347 EXPORT_C void CFepLayoutScrollableList::CalculateItemWidth()
   347 EXPORT_C void CFepLayoutScrollableList::CalculateItemWidth()
   348     {
   348     {
       
   349 	TBuf<KDisplayTextLen> buf;
       
   350 	CFont::TMeasureTextInput::TFlags flg = CFont::TMeasureTextInput::EFVisualOrder;
       
   351 	if(iAlign == CGraphicsContext::ERight)
       
   352 		flg = CFont::TMeasureTextInput::EFVisualOrderRightToLeft;
       
   353 	
       
   354 	const CFont* font = iFont;
       
   355 	if(iTextLineSet)
       
   356 		{
       
   357 		TAknLayoutText textLayout;
       
   358 		textLayout.LayoutText(TRect(0, 0, 1, 1), iTextLine);
       
   359 		font = textLayout.Font();
       
   360 		}
       
   361 	ASSERT(font);
       
   362 	
   349     iItemSize.iWidth = iInitItemWidth;
   363     iItemSize.iWidth = iInitItemWidth;
   350     const RPointerArray<SItem>& allItems = ItemArray();
   364     const RPointerArray<SItem>& allItems = ItemArray();
   351     for( TInt i = 0; i < allItems.Count() ; ++i )
   365     for(TInt i = 0; i < allItems.Count(); ++i)
   352         {
   366         {
   353         TInt itemWidth = iFont->TextWidthInPixels( allItems[i]->iText );
   367 		TInt itemWidth = AknBidiTextUtils::MeasureTextBoundsWidth(
   354         if( itemWidth > iItemSize.iWidth )
   368 				*font, allItems[i]->iText, flg);
   355             {
   369         if(itemWidth > iItemSize.iWidth)
   356             iItemSize.iWidth = itemWidth;
   370             iItemSize.iWidth = itemWidth;
   357             }
       
   358         }
   371         }
   359      
   372      
   360     TPixelsTwipsAndRotation ptScreenSize;             
   373     TPixelsTwipsAndRotation ptScreenSize;             
   361     CCoeEnv::Static()->ScreenDevice()->
   374     CCoeEnv::Static()->ScreenDevice()->
   362                             GetDefaultScreenSizeAndRotation(ptScreenSize); 
   375                             GetDefaultScreenSizeAndRotation(ptScreenSize); 
   429         
   442         
   430         // ----- draw bitmaps -----
   443         // ----- draw bitmaps -----
   431         gc->Activate(BitmapDevice());   
   444         gc->Activate(BitmapDevice());   
   432 
   445 
   433 	      // draw frame
   446 	      // draw frame
   434         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   447         MAknsSkinInstance* skin = UiLayout()->SkinInstance();
   435 	    TRect innerRect = itemRect;
   448 	    TRect innerRect = itemRect;
   436 	    innerRect.Shrink(7, 7);
   449 	    innerRect.Shrink(7, 7);
   437         AknsDrawUtils::DrawFrame(skin, 
   450         AknsDrawUtils::DrawFrame(skin, 
   438                                  *gc, 
   451                                  *gc, 
   439 	                             itemRect,
   452 	                             itemRect,
   440 	                             innerRect,
   453 	                             innerRect,
   441                                  aItemActive ? iItemActiveFrId : iItemFrId,
   454                                  aItemActive ? iItemActiveFrId : iItemFrId,
   442                                  KAknsIIDDefault); 
   455                                  KAknsIIDDefault); 
   443         }
   456         }
   444 
   457     
       
   458     CFepLayoutChoiceList::SItem* item = ItemArray()[aItemIndex];
       
   459     const CFont* font = iFont;
       
   460     TRgb color = iFontColor;
       
   461     TInt baseLine = iBaselineOffset;
       
   462     
   445     // draw text
   463     // draw text
   446     if (iTextLineSet)
   464     if (iTextLineSet)
   447         {
   465         {
   448         gc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   449         gc->SetBrushColor(KRgbBlack); 
       
   450 	    TRgb color( KRgbBlack );  // sane default for nonskinned case
       
   451                
       
   452         TAknLayoutText textLayout;
   466         TAknLayoutText textLayout;
   453         textLayout.LayoutText(itemRect, 
   467         textLayout.LayoutText(itemRect, iTextLine);
   454                               iTextLine);
   468         
   455 	    TAknsQsnTextColorsIndex clrIndex;
   469 	    TAknsQsnTextColorsIndex clrIndex;
   456 	    clrIndex = isFocus ? EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG20;
   470 	    clrIndex = isFocus ? EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG20;
   457 
   471 
   458 	    if ( AknsUtils::AvkonSkinEnabled() )
   472 	    color = KRgbBlack;
   459 	        {
   473 	    if (AknsUtils::AvkonSkinEnabled())
   460 	        AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
   474 	        AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
   461 	                               color, KAknsIIDQsnTextColors, clrIndex );
   475 	                               color, KAknsIIDQsnTextColors, clrIndex );
   462 	        }
   476 	    font = textLayout.Font();
   463 
   477 	    itemRect = textLayout.TextRect();
   464 	    textLayout.DrawText(*gc, ItemArray()[aItemIndex]->iText, ETrue, color);
   478 	    baseLine = itemRect.Height() / 2 + font->AscentInPixels() / 2;
   465         }
   479         }
   466     else if (iFont)
   480 
   467         {
   481     if(font == NULL)
   468         gc->UseFont(iFont);
   482     	return;
   469 
   483     
   470         gc->SetBrushStyle(CGraphicsContext::ENullBrush);
   484 	gc->UseFont(font);
   471         gc->SetBrushColor(KRgbBlack);
   485 	gc->SetBrushStyle(CGraphicsContext::ENullBrush);
   472         gc->SetPenColor(iFontColor);
   486 	gc->SetBrushColor(KRgbBlack);
   473         gc->SetPenStyle(CGraphicsContext::ESolidPen);
   487 	gc->SetPenColor(color);
   474         gc->SetPenSize(PenSize());
   488 	gc->SetPenStyle(CGraphicsContext::ESolidPen);
   475 
   489 	gc->SetPenSize(PenSize());
   476         if (iFont->TextWidthInPixels(ItemArray()[aItemIndex]->iText) > itemRect.Width())
   490 
   477             {
   491 	TBuf<KDisplayTextLen> buf;
   478             TBuf<KDisplayTextLen> buf;
   492 	AknBidiTextUtils::ConvertToVisualAndClip(item->iText, buf, *iFont,
   479             AknBidiTextUtils::ConvertToVisualAndClip(ItemArray()[aItemIndex]->iText,
   493 										 itemRect.Width(), itemRect.Width());
   480                                                      buf,
   494 	gc->DrawText(buf, itemRect, baseLine, iAlign);
   481                                                      *iFont,
   495 	gc->DiscardFont();
   482                                                      itemRect.Width(),
       
   483                                                      itemRect.Width());
       
   484             gc->DrawText(buf, 
       
   485                          itemRect,
       
   486                          iBaselineOffset,
       
   487                          CGraphicsContext::ELeft);  
       
   488             }
       
   489         else
       
   490             {
       
   491             gc->DrawText(ItemArray()[aItemIndex]->iText,
       
   492                          itemRect,
       
   493                          iBaselineOffset,
       
   494                          CGraphicsContext::ELeft);
       
   495             }
       
   496 
       
   497         gc->DiscardFont();
       
   498         }    
       
   499     }
   496     }
   500 
   497 
   501 EXPORT_C void CFepLayoutScrollableList::ConstructL()
   498 EXPORT_C void CFepLayoutScrollableList::ConstructL()
   502     {
   499     {
   503     CFepLayoutPopupWnd::ConstructL();
   500     CFepLayoutPopupWnd::ConstructL();
   604             {
   601             {
   605             ScrollPageDown();
   602             ScrollPageDown();
   606             }
   603             }
   607         }
   604         }
   608     }
   605     }
   609     
   606 
   610 EXPORT_C void CFepLayoutScrollableList::UpdatePageInfoL( TInt aCurrentPage, TInt aTotalPage )
   607 EXPORT_C void CFepLayoutScrollableList::UpdatePageInfoL( TInt aCurrentPage, TInt aTotalPage )
   611 	{
   608 	{
   612 	if( iPageInfoResID == 0 )
   609 	if( iPageInfoResID == 0 )
   613 		return;
   610 		return;
   614 	
   611