EXPORT_C void THuiFont::RasterizeLineL(const TDesC& aTextString, CFbsBitGc& aTargetContext) { // Retrieve the CFont object used when rasterizing this text mesh. CFont* font = NearestFontL(); // Draw the text aTargetContext.UseFont(font); TInt avkonMaxAscent = 0; if (CCoeEnv::Static()) { const CAknLayoutFont* layoutFont = CAknLayoutFont::AsCAknLayoutFontOrNull( font ); avkonMaxAscent = layoutFont->MaxAscent() + KHuiFontVerticalShiftInPixels; } else { avkonMaxAscent = iTextPaneHeight; } aTargetContext.DrawText(aTextString, TPoint(0, avkonMaxAscent )); aTargetContext.DiscardFont(); }
TBool CHuiRasterizedTextMesh::RasterizePictographLineL(const TDesC& aTextLine, CFont* aFont, SRasterizedLine & aLineOut) { if(iUsingPreRasterizedMesh) { return EFalse; } // Retrieve the used text style. THuiTextStyle* textStyle = CHuiStatic::Env().TextStyleManager().TextStyle(iTextStyleId); // Calculate line extents and assign it to texture size. TSize textureSize = textStyle->LineExtentsL(aTextLine); if(textureSize.iWidth == 0 || !iPictographInterface || !iPictographInterface->Interface()->ContainsPictographs(aTextLine)) { // This is an empty string or it does not contain pictographs. We will not rasterize it. // Just add a gap. aLineOut.iTexture = NULL; aLineOut.iGap = textureSize.iHeight; return !IsMaxLineCountReached(); } // store the actual size to be assigned as the textures logical size TSize actualsize(textureSize); if (aLineOut.iTexture == NULL) { // Create a texture for storing the pictographs into. aLineOut.iTexture = CHuiTexture::NewL(); HUI_DEBUG1(_L("CHuiRasterizedTextMesh::RasterizePictographLineL() - Registering self (0x%x) as a texture content observer."), this); // Register one content observer for the first texture that // is able to restore all lines in a single run if (iLines.Count()==1) { aLineOut.iTexture->iContentObservers.AppendL(*this); } aLineOut.iGap = 0; } // set a name for the texture // @todo is this needed, what names to use aLineOut.iTexture->SetImageFileNameL(_L("Pictographs")); TSize maxTextureSize = aLineOut.iTexture->MaxTextureSize(); textureSize.iWidth = Min(textureSize.iWidth, maxTextureSize.iWidth); textureSize.iHeight = Min(textureSize.iHeight, maxTextureSize.iHeight); if((textureSize.iWidth == 0) || (textureSize.iHeight == 0)) { // Cannot draw into this tiny texture, so leave. HUI_DEBUG2(_L("CHuiRasterizedTextMesh::RasterizePictographLineL() - texture size was too small to draw into (%i, %i)."), textureSize.iWidth, textureSize.iHeight); User::Leave(KErrAbort); } User::LeaveIfError( iPictographBitmap->Resize(textureSize) ); CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iPictographBitmap); CleanupStack::PushL(device); CFbsBitGc* gc = 0; User::LeaveIfError( device->CreateContext(gc) ); CleanupStack::PushL(gc); // Prepare the bitmap for drawing...set drawmode because of EColor16MA mode... gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); TRgb color = KRgbWhite; color.SetAlpha(0x00); gc->SetBrushColor(color); gc->Clear(); gc->UseFont(aFont); // Draw pictorgraphs iPictographInterface->Interface()->DrawPictographsInText( *gc, *aFont, aTextLine, TPoint(0, aFont->FontMaxAscent())); CleanupStack::PopAndDestroy(gc); CleanupStack::PopAndDestroy(device); aLineOut.iTexture->UploadL(*iPictographBitmap, NULL, EHuiTextureUploadFlagRetainResolution); aLineOut.iTexture->SetSize(actualsize); return !IsMaxLineCountReached(); }
// CFepLayoutChoiceList::DrawItem // Draw a choice list item. // (other items were commented in a header). // --------------------------------------------------------------------------- // void CFepLayoutChoiceList::DrawItem(const TRect& aRect, const CFepLayoutChoiceList::SItem& aItem, TBool aErase, TBool aFocus) { if(iWndControl) return; CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); if( aErase ) { SetBorderColor( BkColor() ); //DrawChoiceListBackground( aRect );//, EFalse); } if( aFocus ) { //draw focus bitmap TRect rtFocusRect(iItemFocusRect); TRect rtFocusInBmp(TPoint(0,0), iItemFocusRect.Size()); rtFocusRect.Move(aRect.iTl); TRect rtInnerRect( rtFocusRect ); rtInnerRect.Shrink( 5, 5 ); if( iSubItemSkinID.iMajor != EAknsMajorNone && iSubItemSkinID.iMinor != EAknsMinorNone) { gc->Activate( BitmapDevice() ); AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(), *gc, rtFocusRect, rtInnerRect, iSubItemSkinID, KAknsIIDDefault ); } else { //mask bitmaps------- gc->Activate( MaskBitmapDevice() ); if( iItemFocusBmpMask ) { DrawBitmap(rtFocusRect, rtFocusInBmp, iItemFocusBmpMask, iItemFocusBmpMask->SizeInPixels() == rtFocusInBmp.Size()); } //front bitmaps------- gc->Activate( BitmapDevice() ); if( iItemFocusBmp ) { DrawBitmap(rtFocusRect, rtFocusInBmp, iItemFocusBmp, iItemFocusBmp->SizeInPixels() == rtFocusInBmp.Size()); } } } //draw text if (iFont) { gc->UseFont(iFont); gc->SetBrushStyle( CGraphicsContext::ENullBrush ); gc->SetPenColor(iFontColor); gc->SetPenStyle(CGraphicsContext::ESolidPen); gc->DrawText(aItem.iText, aRect, iBaseline, CGraphicsContext::ELeft, iMargin); gc->DiscardFont(); } }