void  CHuiRasterizedTextMesh::UpdateMeshL(const TDesC8& aBuffer)
    {
    iUsingPreRasterizedMesh = ETrue;
    ResetLines();
    RDesReadStream stream(aBuffer);
    TInt count = stream.ReadInt32L();
    for (TInt i=count-1;i>=0;i--)
        {
        // lines are in reverse order
        SRasterizedLine line;
        line.iTexture = dynamic_cast<CHuiTexture*>((MHuiTexture*)stream.ReadInt32L()); //scary
        line.iGap = stream.ReadInt32L();
        iLines.InsertL(line, 0);
        }
    TSize extents;
    extents.iWidth = stream.ReadInt32L();
    extents.iHeight = stream.ReadInt32L();
    SetExtents(extents);
    stream.Close();
    
    if (RasterizedShadow()) // update shadow
        {
        for (TInt i = iLines.Count()-1; i >=0; i-- )
            {
            if (iLines[i].iTexture)
                {
                const TInt requestedBlurredSize = HUI_ROUND_FLOAT_TO_INT( 2*iVisual->DropShadowHandler()->iRadius.Now() );
                iLines[i].iTexture->CreateShadowTextureL( requestedBlurredSize, EHuiTextureShadowStyleRasterizedText );
                }
            }
        }
    }
Exemplo n.º 2
0
/* Scale the old line coordinates to the new Xmax and Ymax coordinates.
  The new Xmax and new Ymax are passed in as parameters so we can
  calculate the scaling ratios. */
void TList::ScaleTo( int NewXmax, int NewYmax )
{
  int I;
  float RatioX, RatioY;

  if ((!Xmax) || (!Ymax)) { /* at startup, Xmax and Ymax are zero */
    Xmax = NewXmax;
    Ymax = NewYmax;
    ResetLines();
  } else {
    RatioX = NewXmax / Xmax;
    RatioY = NewYmax / Ymax;
    X1 = X1 * RatioX;
    X2 = X2 * RatioX;
    Y1 = Y1 * RatioY;
    Y2 = Y2 * RatioY;
    for( I = 0; I < MaxLines; I++) {
      Line[I].LX1 = Line[I].LX1 * RatioX;
      Line[I].LX2 = Line[I].LX2 * RatioX;
      Line[I].LY1 = Line[I].LY1 * RatioY;
      Line[I].LY2 = Line[I].LY2 * RatioY;
    };
  };
  Xmax = NewXmax;
  Ymax = NewYmax;
};
CHuiRasterizedTextMesh::~CHuiRasterizedTextMesh()
    {
    ResetLines();
    iLines.Close();
    ResetPictographLines();
    iPictographLines.Close();
    delete iPictographBitmap;
    }
Exemplo n.º 4
0
 ~CAlfRasterizedTextMesh()
     {
     ResetLines(ETrue);
     iLines.Close();
     ReleaseTextures(ETrue);
     iObsoleteTextures.Close();
     delete iBuf;
     }
void CHuiRasterizedTextMesh::Reset()
    {
    if (!iUsingPreRasterizedMesh)
        {
        CHuiTextMesh::Reset();
        ResetLines();
        ResetPictographLines();
        }
    }
Exemplo n.º 6
0
    void DoBuildL(CAlfTextStyle* aTextStyle)
        {
        ResetLines();
        
        TSize extents(0, 0);
        const TDesC& text = iVisual->Text();
        
        // Retrieve the CFont object used when rasterizing this text mesh.
        CFont* font = aTextStyle->Font()->NearestFontL(1.0);

        // In wrapping mode, let the mesh know how much space there is
        // for drawing into.
        TInt maxWidth = iMaxWidth; //KMaxTInt;
        TInt lineCount = 0;

        // awkward, just to avoid warning
        CArrayFixFlat<TPtrC>* linePtrs = 0;
        HBufC* buf = 0;

        switch(iVisual->Wrapping())
            {
            case CAlfTextVisual::ELineWrapManual:
                {
                lineCount = 1;
                for (TInt i = text.Length()-2;i>=0;i--) // linebreak as last character is ignored
                    {
                    if (text[i]=='\n') // not elegant but keeps the compatibility
                        lineCount++;
                    }
                if (lineCount > 1)
                    {
                    TInt lineStart = 0;
                    TInt breakpos = 0;
                    TInt remaining = text.Length();                    
                    while(lineCount)
                        {
                        for (TInt i = lineStart; i<remaining ;i++)
                            {
                            if (text[i]=='\n') // not elegant but keeps the compatibility
                                {
                                breakpos = i;
                                break;
                                }
                            }
                            if (breakpos < lineStart) // not found
                                {
                                breakpos = remaining-1;
                                }
                                
                            HBufC* buf = text.Mid(lineStart,breakpos-lineStart).AllocLC(); // todo.. is extra space required for bidi
                            lineStart = breakpos+1;
                            TPtr ptr = buf->Des();
                            // truncate line
                            AknBidiTextUtils::ConvertToVisualAndClipL(ptr, *font, maxWidth, maxWidth);
                            // create the line entry if not already existing

                            SRasterizedLine line;
                            line.iTexture = NULL;
                            line.iGap = 0;
                            iLines.AppendL(line);
                        
                            TInt index = iLines.Count()-1;
                            // rasterize a single line (updates texture in iLines[0].iTexture)
                            RasterizeLineL(ptr, iLines[index], aTextStyle);                     

                            // Get extents from the texture we just created
                            CAlfTexture* tex = iLines[index].iTexture;
                            extents.iHeight += iLines[index].iGap;
                            if(tex)
                                {
                                extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                                extents.iHeight += tex->Size().iHeight;
                                }                   
                    
                            CleanupStack::PopAndDestroy(buf);
                            lineCount--;
                            }
                        break;
                        }
                    } // fall through with single line
            case CAlfTextVisual::ELineWrapTruncate:
                {
                lineCount = 1; // there's always one line created per logical line
                HBufC* buf = text.AllocLC(); // todo.. is extra space required for bidi
                TPtr ptr = buf->Des();
                // truncate line
                AknBidiTextUtils::ConvertToVisualAndClipL(ptr, *font, maxWidth, maxWidth);
                // create the line entry if not already existing

                SRasterizedLine line;
                line.iTexture = NULL;
                line.iGap = 0;
                iLines.AppendL(line);
                        
 	            // rasterize a single line (updates texture in iLines[0].iTexture)
        	    RasterizeLineL(ptr, iLines[0], aTextStyle);	                    

   	            // Get extents from the texture we just created
                CAlfTexture* tex = iLines[0].iTexture;
                extents.iHeight += iLines[0].iGap;
                if(tex)
                    {
                    extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                    extents.iHeight += tex->Size().iHeight;
                    }	                
                	
        	    CleanupStack::PopAndDestroy(buf);
                break;
                }

            case CAlfTextVisual::ELineWrapBreak:
                {
                // wrap lines to array
                linePtrs = new (ELeave) CArrayFixFlat<TPtrC>(KLineArrayGranularity);
                CleanupStack::PushL(linePtrs);
        
                buf = AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
                    text, maxWidth, *font, *linePtrs);
                CleanupStack::PushL(buf);

              	// Do rasterisation
                for(TInt i = 0; i < linePtrs->Count();i++)
                    {
                    SRasterizedLine line;
                    line.iTexture = NULL;
                    line.iGap = 0;
                    iLines.AppendL(line);
                        
                    // rasterize a single line (updates texture in iLines[i].iTexture)
                    RasterizeLineL(linePtrs->At(i), iLines[i], aTextStyle);
                    CAlfTexture* tex = iLines[i].iTexture;
                    extents.iHeight += iLines[i].iGap;
                            
                    if(tex)
                        {
                        extents.iWidth = Max(extents.iWidth, tex->Size().iWidth);
                        extents.iHeight += tex->Size().iHeight;
                        }    
                            	                                                         
                    if (i == iVisual->MaxLineCount()-1)
          	            {
       	                // Maximum number of lines reached.
       	                break;
       	                }
                    }
                CleanupStack::PopAndDestroy(buf);
                CleanupStack::PopAndDestroy(linePtrs);
                break;
                }
                
            default:
                break;
            }
            
        // Extents needs to be updated in order to make alignment 
        // work properly.
        iExtents = extents;

        UpdateDescriptorL();
        }