コード例 #1
0
void CListBoxHighLightControl::Draw(CBitmapContext& gc) const
	{
	gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
	if (iPainter)
		gc.SetBrushColor( iPainter->GetHightLightClock() );
	
	gc.Clear(Rect());
	}
コード例 #2
0
void CBitmapAnimator::Render(CBitmapContext& aBitmapContext, TInt aFrame) const
	{
	aBitmapContext.Reset();

	const CAnimationFrame& nextFrame = *iFrameArray[aFrame];
	const TBool useMask = nextFrame.FrameInfo().iFlags&TFrameInfo::ETransparencyPossible || nextFrame.FrameInfo().iFlags&TFrameInfo::EAlphaChannel;
	
	if (useMask)
		{
		aBitmapContext.BitBltMasked(nextFrame.FrameInfo().iFrameCoordsInPixels.iTl, nextFrame.Bitmap(), nextFrame.FrameInfo().iOverallSizeInPixels, nextFrame.Mask(), EFalse);
		}
	else
		{
		aBitmapContext.BitBlt(nextFrame.FrameInfo().iFrameCoordsInPixels.iTl, nextFrame.Bitmap(), nextFrame.FrameInfo().iOverallSizeInPixels);
		}
	}
コード例 #3
0
void CTangImageManager::Draw(CBitmapContext& aGc)
	{
	if (iBackground)
		iBackground->Draw(aGc);
	//EImageNumber
	
	for(TInt i=0; i<iLayer.Count(); i++)
		{
		TInt index = iLayer[i];
		if (iElements && index<7 && iElements[index])
			//iElements[index]->Draw(aGc);
			iElements[index]->Draw(aGc,iScrollX,iScrollY);
		}
		
	
	CImageElement* element = iElements[iSelectedIndex];
	TInt x = element->GetPositionX();
	TInt y = element->GetPositionY();
	x += iScrollX;
	y += iScrollY;
	if (iSelectedState == ESelectedStateChoose)
		{
		x -= (iBitmapFocus[EBitmapFocus]->SizeInPixels().iWidth >> 1);
		y -= (iBitmapFocus[EBitmapFocus]->SizeInPixels().iHeight >> 1);
		TRect rect( TPoint( 0,0 ),iBitmapFocus[EBitmapFocus]->SizeInPixels() );
		aGc.BitBltMasked(TPoint(x,y),iBitmapFocus[EBitmapFocus],
				rect,iBitmapFocus[EBitmapFocusMask],ETrue);
		}
コード例 #4
0
void tst_NativeImageHandleProvider::bitmap()
{
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
    QPixmap tmp(10, 20);
    if (tmp.pixmapData()->classId() == QPixmapData::OpenVGClass) {
        BitmapProvider prov;

        // This should fail because of null ptr.
        QPixmap pm = pixmapFromNativeImageHandleProvider(&prov);
        QVERIFY(pm.isNull());
        pm = QPixmap();
        QCOMPARE(prov.refCount, 0);

        prov.bmp = new CFbsBitmap;
        QCOMPARE(prov.bmp->Create(TSize(prov.w, prov.h), EColor16MAP), KErrNone);
        CFbsBitmapDevice *bitmapDevice = CFbsBitmapDevice::NewL(prov.bmp);
        CBitmapContext *bitmapContext = 0;
        QCOMPARE(bitmapDevice->CreateBitmapContext(bitmapContext), KErrNone);
        TRgb symbianColor = TRgb(255, 200, 100);
        bitmapContext->SetBrushColor(symbianColor);
        bitmapContext->Clear();
        delete bitmapContext;
        delete bitmapDevice;

        pm = pixmapFromNativeImageHandleProvider(&prov);
        QVERIFY(!pm.isNull());
        QCOMPARE(pm.width(), prov.w);
        QCOMPARE(pm.height(), prov.h);
        QVERIFY(prov.refCount == 1);
        QImage img = pm.toImage();
        QVERIFY(prov.refCount == 1);
        QRgb pix = img.pixel(QPoint(1, 2));
        QCOMPARE(qRed(pix), symbianColor.Red());
        QCOMPARE(qGreen(pix), symbianColor.Green());
        QCOMPARE(qBlue(pix), symbianColor.Blue());

        pm = QPixmap(); // should result in calling release
        QCOMPARE(prov.refCount, 0);
        delete prov.bmp;
    } else {
         QSKIP("Not openvg", SkipSingle);
    }
#else
    QSKIP("Not applicable", SkipSingle);
#endif
}
コード例 #5
0
void CImageElement::Draw(CBitmapContext& aGc, TInt aScrollX, TInt aScrollY)
	{
	if (iBitmapRotate && iBitmapMask)
		{
		TInt x,y;
		x = iCenterX + iOffsetX + aScrollX;
		y = iCenterY + iOffsetY + aScrollY;
		TRect rect( TPoint( 0,0 ),iBitmapRotate->SizeInPixels() );
		aGc.BitBltMasked(TPoint(x,y),iBitmapRotate,
				rect,iBitmapMask,ETrue);
		}
	}
コード例 #6
0
void CBitmapAnimator::RenderMask(CBitmapContext& aBitmapContext, TInt aFrame) const
	{
	aBitmapContext.Reset();
	
	const CAnimationFrame& nextFrame = *iFrameArray[aFrame];

	if (aFrame == 0)
		{
		aBitmapContext.SetBrushColor(KRgbBlack);
		aBitmapContext.Clear(iMaxSize);		
		}
	else
		{
		const CAnimationFrame& currentFrame = *iFrameArray[aFrame - 1];
		if (currentFrame.FrameInfo().iFlags & TFrameInfo::ERestoreToBackground)
			{
			aBitmapContext.SetBrushColor(KRgbBlack);
			aBitmapContext.Clear(currentFrame.FrameInfo().iFrameCoordsInPixels);
			}
		}
	const TBool useMask = nextFrame.FrameInfo().iFlags&TFrameInfo::ETransparencyPossible || nextFrame.FrameInfo().iFlags&TFrameInfo::EAlphaChannel;
	if (useMask)
		{
		aBitmapContext.SetDrawMode(CGraphicsContext::EDrawModeOR);
		aBitmapContext.BitBlt(nextFrame.FrameInfo().iFrameCoordsInPixels.iTl, nextFrame.Mask(), nextFrame.FrameInfo().iOverallSizeInPixels);
		}
	else
		{
		aBitmapContext.SetBrushColor(KRgbWhite);
		if (nextFrame.FrameInfo().iOverallSizeInPixels != nextFrame.FrameInfo().iFrameSizeInPixels)
			{
			// If the frame size smaller than the overall size, the mask shall not take effect later in CBasicAnimation::Draw().
			aBitmapContext.Clear(nextFrame.FrameInfo().iOverallSizeInPixels);
			}
		else
			{
			aBitmapContext.Clear(nextFrame.FrameInfo().iFrameCoordsInPixels);
			}
		}
	}
コード例 #7
0
// -----------------------------------------------------------------------------
// Blit
//
// Blits given image to gc.
//
// -----------------------------------------------------------------------------
//
inline static TBool Blit(
    MAknsSkinInstance* aSkin, CBitmapContext& aGc, const TRect& aTrgRect,
    CAknsImageItemData* aImgData, const TAknsItemID& aIID,
    const TAknsBackground* aLayout, const TPoint& aPADelta,
    const TInt aDrawParam )
    {
    CAknsAppSkinInstance* appInstance = 
        static_cast<CAknsAppSkinInstance*>(aSkin);
        
    if ( IsBackgroundItem( aIID,appInstance ) && 
            appInstance && appInstance->AnimBackgroundState() )
        {
        if( (aDrawParam&KAknsDrawParamPrepareOnly) )
            {
            return ETrue;
            }        
        
        TRgb color = KRgbWhite;
        color.SetAlpha(0x00);
        aGc.SetPenColor(color);
        aGc.SetBrushColor(color);
        aGc.SetPenStyle(CGraphicsContext::ESolidPen);
        aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
        aGc.SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
        TRect layoutRect( aTrgRect );
        if( aLayout )
            {
            layoutRect = aLayout->iRect;
            }
        layoutRect.Move( -aPADelta );

        TRect drawRect = aTrgRect;
        drawRect.Intersection( layoutRect );

        aGc.Clear(drawRect);
        return ETrue;
        }

    TRect layoutRect( aTrgRect );

    const TAknsImageAttributeData* attr = NULL;

    if( aLayout )
        {
        layoutRect = aLayout->iRect;

        if( aLayout->iAttr.iAttributes != EAknsImageAttributeNone )
            {
            attr = &(aLayout->iAttr);
            }
        }

    layoutRect.Move( -aPADelta );

    TRect drawRect(aTrgRect);
    drawRect.Intersection( layoutRect );

    return DrawPartialCachedImage( aSkin, aGc, layoutRect, drawRect,
        aImgData, aIID, attr, aDrawParam );
    }
コード例 #8
0
ファイル: fpsview.cpp プロジェクト: jcemelanda/wormux
void CFpsView::Draw(CBitmapContext& aGc, const TRect& aTargetRect, const TSize& aSize)
    {
    ++iFps; 
    int nro = iFpsCount;
    const TSize sz = iNumbers->SizeInPixels();
    TPoint pos(iPos.iX + sz.iWidth * iDigits, iPos.iY);
    const TInt height = (sz.iHeight / 10);
    do  
        {
        const int digit = nro % 10;
        nro /= 10;
        TRect rect(0, digit * height, sz.iWidth, digit * height + height);
        aGc.BitBlt(pos, iNumbers, rect);
        pos.iX -= sz.iWidth;
        }while(nro > 0);
    }
コード例 #9
0
// -----------------------------------------------------------------------------
// BlitAndClear
//
// Blits given image to gc and draws the area that is not
// covered by the bitmap.
//
// -----------------------------------------------------------------------------
//
inline static TBool BlitAndClear(
    MAknsSkinInstance* aSkin, CBitmapContext& aGc, const TRect& aTrgRect,
    CAknsImageItemData* aImgData, const TAknsItemID& aIID,
    const TAknsBackground* aLayout, const TPoint& aPADelta,
    const TInt aDrawParam )
    {
    CAknsAppSkinInstance* appInstance = 
            static_cast<CAknsAppSkinInstance*>(aSkin);
            
    if ( IsBackgroundItem( aIID,appInstance ) && 
            appInstance && appInstance->AnimBackgroundState() )
        {
        return Blit( aSkin, aGc, aTrgRect, aImgData, aIID, aLayout, aPADelta, aDrawParam );
        }
    
    if( !(aDrawParam & KAknsDrawParamPrepareOnly) )
        {
        TAknsItemType type = aImgData->Type();
        // don't clear if the item is not a masked one
        if( AknsUtils::IsDerivedType( EAknsITMaskedBitmap, type )  
                && !(aDrawParam & KAknsDrawParamNoClearUnderImage) )
            {
            TRect layoutRect( aTrgRect );
            if( aLayout )
                {
                layoutRect = aLayout->iRect;
                }
            layoutRect.Move( -aPADelta );

            TRect drawRect(aTrgRect);
            drawRect.Intersection( layoutRect );

            aGc.DrawRect( drawRect );
            }
        }
    return Blit( aSkin, aGc, aTrgRect, aImgData, aIID, aLayout, aPADelta, aDrawParam );
    }
コード例 #10
0
void CCustomControlList::Draw(CBitmapContext& gc)
	{
	TInt x = iDrawPoint.iX + iDisplayPoint.iX;
	TInt x2 = iDrawPoint.iX + iDisplayPoint.iX + 16;
	TInt y;
	TInt dy = iDrawPoint.iY;
	for (TInt i=0; i<iList->Count(); i++)
		{
		if (dy < 0)
			{
			dy += iRowHeight;
			continue;
			}
		if (dy >= iDisplaySize.iHeight)
			{
			break;
			}
		y = dy + iDisplayPoint.iY;
		pListItemStruct item = (*iList)[i];
		CGulIcon* icon = (*iIcons)[item->iIconIndex];
		CFbsBitmap* bitmap = icon->Bitmap();
		gc.BitBlt(TPoint(x, y), bitmap);

		gc.UseFont(iFont);
		if (i!=iSelectIndex)
			{
			gc.SetPenColor(iTextColor);
			//			HBufC* text = item->iShowName;
			//			gc.DrawText(*(item->iShowName), TPoint(x2, y));
			}
		else
			{
			gc.SetPenColor(iSelectTextColor);
			//			HBufC* text = item->iShowName;
			//			gc.DrawText(*(item->iShowName), TPoint(x2, y));
			}
		y += iFontHeight;
		gc.DrawText(*(item->iShowName), TPoint(x2, y));
		gc.DiscardFont();

		dy += iRowHeight;
		}
	}
コード例 #11
0
TBool CAknAnimationData::ExecutePendingAnimationStep(CBitmapContext& aGc, TAnimMultiStep* aStep)
{
    TBool done = EFalse;
    switch (aStep->iDrawStep.Type())
    {
    case EAnimDrawLine:
    {
        TAnimLineDrawStep* step = (aStep->iDrawStep.LineDrawStep());

        if (aStep->iSubStep == step->iSteps -1)
        {
            done = ETrue;
        }
        {
            TInt diffX = step->iEndX - step->iStartX;
            TInt diffY = step->iEndY - step->iStartY;
            TInt startX = step->iStartX + (diffX * aStep->iSubStep / step->iSteps);
            TInt startY = step->iStartY + (diffY * aStep->iSubStep / step->iSteps);
            TInt endX = step->iStartX + (diffX * (aStep->iSubStep+1)/ step->iSteps);
            TInt endY = step->iStartY + (diffY * (aStep->iSubStep+1) / step->iSteps);
            aGc.SetBrushColor(iDrawColor);
            aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
            aGc.Clear(TRect(TPoint(startX,startY),TPoint(endX+1, endY+1)));
        }
    }
    break;
    case EAnimRevealPartNewViewFromLeft:
    {
        TAnimBlitStep* step = (aStep->iDrawStep.BlitStep());
        TPoint offset((step->iWidth * aStep->iSubStep) / step->iSteps, 0);
        TSize size((step->iWidth / step->iSteps)+1, step->iHeight);
        aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap,
                   TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size));
        if (aStep->iSubStep == step->iSteps-1)
            done = ETrue;
    }
    break;
    case EAnimRevealPartNewViewFromRight:
    {
        TAnimBlitStep* step = (aStep->iDrawStep.BlitStep());
        TInt thisStep = (step->iSteps - aStep->iSubStep) - 1;
        TPoint offset((step->iWidth * thisStep) / step->iSteps, 0);
        TSize size((step->iWidth / step->iSteps)+1, step->iHeight);
        aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap,
                   TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size));
        if (aStep->iSubStep == step->iSteps-1)
            done = ETrue;
    }
    break;
    case EAnimRevealPartNewViewFromTop:
    {
        TAnimBlitStep* step = (aStep->iDrawStep.BlitStep());
        TPoint offset(0,(step->iHeight * aStep->iSubStep) / step->iSteps);
        TSize size(step->iWidth,(step->iHeight / step->iSteps)+1);
        aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap,
                   TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size));
        if (aStep->iSubStep == step->iSteps-1)
            done = ETrue;
    }
    break;
    case EAnimRevealPartNewViewFromBottom:
    {
        TAnimBlitStep* step = (aStep->iDrawStep.BlitStep());
        TInt thisStep = (step->iSteps - aStep->iSubStep) - 1;
        TPoint offset(0,(step->iHeight * thisStep) / step->iSteps);
        TSize size(step->iWidth,(step->iHeight / step->iSteps)+1);
        aGc.BitBlt(TPoint(step->iDestX, step->iDestY) + offset, iViewBitmap,
                   TRect(TPoint(step->iSrcX, step->iSrcY) + offset, size));
        if (aStep->iSubStep == step->iSteps-1)
            done = ETrue;
    }
    break;
    case EAnimBlitSlideNewView:
        // Slide the bitmap between two screen positions
    {
        TAnimSlideStep* step = (aStep->iDrawStep.SlideStep());
        TSize bitmapSize(step->iWidth, step->iHeight);
        TInt slideDifferenceX = step->iSlideToX - step->iSlideFromX;
        TInt slideDifferenceY = step->iSlideToY - step->iSlideFromY;
        TInt slidePosX = step->iSlideFromX + ((slideDifferenceX * aStep->iSubStep) / step->iSteps);
        TInt slidePosY = step->iSlideFromY + ((slideDifferenceY * aStep->iSubStep) / step->iSteps);
        aGc.BitBlt(TPoint(slidePosX, slidePosY), iViewBitmap,
                   TRect(TPoint(step->iSrcX, step->iSrcY), bitmapSize));
        if (aStep->iSubStep == step->iSteps)
            done = ETrue;
    }
    break;
    case EAnimBlitSlideNewViewClearBehind:
        // Slide the bitmap between two screen positions, clearing the screen behind it
    {
        TAnimSlideStep* step = (aStep->iDrawStep.SlideStep());
        TSize bitmapSize(step->iWidth, step->iHeight);
        TInt slideDifferenceX = step->iSlideToX - step->iSlideFromX;
        TInt slideDifferenceY = step->iSlideToY - step->iSlideFromY;
        if (aStep->iSubStep > 0)
        {
            // This is not the first step, so clear over the area of the previous step
            TInt slidePosX = step->iSlideFromX + ((slideDifferenceX * (aStep->iSubStep-1)) / step->iSteps);
            TInt slidePosY = step->iSlideFromY + ((slideDifferenceY * (aStep->iSubStep-1)) / step->iSteps);
            aGc.Clear(TRect(TPoint(slidePosX, slidePosY), bitmapSize));
        }
        TInt slidePosX = step->iSlideFromX + ((slideDifferenceX * aStep->iSubStep) / step->iSteps);
        TInt slidePosY = step->iSlideFromY + ((slideDifferenceY * aStep->iSubStep) / step->iSteps);
        aGc.BitBlt(TPoint(slidePosX, slidePosY), iViewBitmap,
                   TRect(TPoint(step->iSrcX, step->iSrcY), bitmapSize));
        if (aStep->iSubStep == step->iSteps)
            done = ETrue;
    }
    break;
    default:
        done = DrawUserAnimationStep(aGc, *aStep);
        break;
    }

    aStep->iSubStep++;
    return done;
}
コード例 #12
0
EXPORT_C TBool CAknAnimationData::DrawNextAnimationStep(CBitmapContext& aGc)
{
    if (Count() == 0)
    {
        // Call the user animation step
        TAnimStep step;
        TAnimMultiStep nullStep(step);
        nullStep.iDrawStep.SetType(EAnimNullStep);
        nullStep.iSubStep = (TUint16)iCurrentDrawStep;
        TBool done = DrawUserAnimationStep(aGc, nullStep);
        iCurrentDrawStep++;
        return done;
    }

    if (iCurrentDrawStep < Count())
    {
        TInt drawSteps = (*iDrawStepsPerAnimStep)[iCurrentAnimStep];
        TInt startingDrawStep = iCurrentDrawStep;
        TBool repeatAnimStep = EFalse;

        for (TInt ii=0; ii<drawSteps; ii++)
        {
            TAnimStep* drawStep = &(At(iCurrentDrawStep));

            switch (drawStep->Type())
            {
            case EAnimBlitPreviousView:
            {
                TAnimBlitStep* step = drawStep->BlitStep();
                aGc.BitBlt(TPoint(step->iDestX, step->iDestY), iOldBitmap);
            }
            break;
            case EAnimBlitNewView:
            {
                TAnimBlitStep* step = drawStep->BlitStep();
                aGc.BitBlt(TPoint(step->iDestX, step->iDestY), iViewBitmap);
            }
            break;
            case EAnimBlitPartPreviousView:
            {
                TAnimBlitStep* step = drawStep->BlitStep();
                aGc.BitBlt(TPoint(step->iDestX, step->iDestY), iOldBitmap,
                           TRect(TPoint(step->iSrcX, step->iSrcY), TSize(step->iWidth, step->iHeight)));
            }
            break;
            case EAnimBlitPartNewView:
            {
                TAnimBlitStep* step = drawStep->BlitStep();
                aGc.BitBlt(TPoint(step->iDestX, step->iDestY), iViewBitmap,
                           TRect(TPoint(step->iSrcX, step->iSrcY), TSize(step->iWidth, step->iHeight)));
            }
            break;
            case EAnimDrawLine:
            case EAnimRevealPartNewViewFromLeft:
            case EAnimRevealPartNewViewFromRight:
            case EAnimRevealPartNewViewFromTop:
            case EAnimRevealPartNewViewFromBottom:
            case EAnimBlitSlideNewView:
            case EAnimBlitSlideNewViewClearBehind:
            {
                // Make this a pending step. Cancel the animation if the append fails
                TRAPD(err, iPendingSteps->AppendL(TAnimMultiStep(*drawStep)));
                if (err != KErrNone)
                    return ETrue;
            }
            break;
            case EAnimSetColor:
            {
                TAnimSetColorStep* step = drawStep->SetColorStep();
                iDrawColor = TRgb(step->iRed, step->iGreen, step->iBlue);
            }
            break;
            case EAnimDrawRect:
            {
                TAnimLineDrawStep* step = drawStep->LineDrawStep();
                aGc.SetPenColor(iDrawColor);
                aGc.SetPenStyle(CGraphicsContext::ESolidPen);
                aGc.DrawRect(TRect(TPoint(step->iStartX, step->iStartY),TPoint(step->iEndX, step->iEndY)));
            }
            break;
            case EAnimDrawFilledRect:
            {
                TAnimLineDrawStep* step = drawStep->LineDrawStep();
                aGc.SetBrushColor(iDrawColor);
                aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
                aGc.SetPenStyle(CGraphicsContext::ENullPen);
                aGc.DrawRect(TRect(TPoint(step->iStartX, step->iStartY),TPoint(step->iEndX, step->iEndY)));
            }
            break;
            case EAnimWait:
            {
                TAnimWaitStep* step = drawStep->WaitStep();
                repeatAnimStep = ETrue;
                if (step->iSteps > 0)
                {
                    step->iSteps--;
                    if (step->iSteps == 0)
                        repeatAnimStep = EFalse;
                }
            }
            break;
            case EAnimWaitUntilComplete:
                if (iPendingSteps->Count())
                    repeatAnimStep = ETrue;
                break;
            default:
                // Type is user-defined, so add to the pending steps
                TRAPD(err, iPendingSteps->AppendL(TAnimMultiStep(*drawStep)));
                if (err != KErrNone)
                    return ETrue;
                break;
            }
            iCurrentDrawStep++;
        }

        // If this step needs to be repeated, reset the draw step counter
        // otherwise increment the current animation step
        if (repeatAnimStep)
        {
            iCurrentDrawStep = startingDrawStep;
        }
        else
        {
            iCurrentAnimStep++;
        }
    }


    TInt done = DrawPendingAnimationSteps(aGc);

    if (iCurrentDrawStep == Count() && done)
        return ETrue;

    return EFalse;
}
コード例 #13
0
// -----------------------------------------------------------------------------
// AknsDrawUtils::DrawBackground()
// (commented in the header).
// -----------------------------------------------------------------------------
EXPORT_C TBool AknsDrawUtils::DrawBackground( MAknsSkinInstance* aInstance,
    MAknsControlContext* aContext, const CCoeControl* aControl,
    CBitmapContext& aGc, const TPoint& aDstPos,
    const TRect& aControlRect, const TInt aDrawParam )
    {
    TInt drawParam = aDrawParam;
    TInt originalParam = aDrawParam;
    TBool retVal = EFalse;
    TBool blitFailed = EFalse;
    TBool blit = EFalse;
    TBool blitAttempted = EFalse;

    if ( !&aGc )
        {
        return retVal;
        }

    MAknsControlContext* parentContext = GetParentContext( aContext );
    if( parentContext )
        {
        retVal = DrawBackground( aInstance, parentContext, aControl, aGc,
            aDstPos, aControlRect, aDrawParam );
        drawParam |= KAknsDrawParamNoClearUnderImage;
        }
    else if( drawParam & KAknsDrawParamBottomLevelRGBOnly )
        {
        drawParam |= KAknsDrawParamRGBOnly;
        }

    originalParam = drawParam;

    if( aContext )
        {
        aContext->UpdateContext();
        }

    TAknsBackground* bgLayout = RetrieveBackgroundLayout( aContext );

    TAknsItemID imgIID( KAknsIIDNone );
    CAknsImageItemData* imgData = RetrieveBackgroundImage(
        aInstance, bgLayout, imgIID );

    // chained background
    if (imgData && imgData->ParentIID() != KAknsIIDNone)
        {
        TAknsItemID parentiid = imgData->ParentIID();
        TRect parentDrawRect = imgData->DrawRect();

        imgData = RetrieveKnownBackgroundImage(
            aInstance, parentiid );
        if (imgData)
            {
            imgData->SetDrawRect(parentDrawRect);
            drawParam |= KAknsDrawParamChained ;
            }
        }

    TPoint paDelta = GetParentAbsoluteDelta( bgLayout, aControl );

    TRect drawRect = aControlRect;
    drawRect.Move( aDstPos-aControlRect.iTl );
    paDelta += aControlRect.iTl-aDstPos;

    if (!(aDrawParam & KAknsDrawParamPrepareOnly))
        {
        aGc.SetPenStyle(CGraphicsContext::ENullPen);
        aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
        }

    if ( !(aDrawParam & KAknsDrawParamIgnoreLayerMask))
        {
        if( imgData )
            {
            blitAttempted = ETrue;
            if( (drawParam&KAknsDrawParamNoClearUnderImage)==0 )
                {
                blit = BlitAndClear( aInstance, aGc, drawRect,
                    imgData, imgIID, bgLayout, paDelta, drawParam );
                }
            else
                {
                blit = Blit( aInstance, aGc, drawRect,
                    imgData, imgIID, bgLayout, paDelta, drawParam );
                }
            if ( !blit )
                {
                blitFailed = ETrue;
                }
            }
        else
            {
            if( !(drawParam&KAknsDrawParamNoClearUnderImage) &&
                !(drawParam&KAknsDrawParamPrepareOnly) )
                {
                // Clear only if permitted
                aGc.DrawRect( drawRect );
                }
            }
        }

    if( bgLayout )
        {
        if (!(aDrawParam & KAknsDrawParamIgnoreLayerMask) && aContext->IsCompatibleWithType(EAknsControlContextTypeMasked))
            {
            CAknsMaskedLayerBackgroundControlContext* layeredCxt = static_cast<CAknsMaskedLayerBackgroundControlContext*>(aContext);
            if (layeredCxt->iOffScreenBmp)
                {
                CAknsMaskedBitmapItemData* maskedImgData = NULL;
                TRAPD( err, maskedImgData = CAknsMaskedBitmapItemData::NewL() );
                if ( err != KErrNone )
                    {
                    return EFalse;
                    }
                maskedImgData->SetBitmap(layeredCxt->iOffScreenBmp);
                maskedImgData->SetMask(layeredCxt->iLayerMask);

                TAknsBackground* childLayout = bgLayout->iNext;

                blitAttempted = ETrue;
                blit = Blit( aInstance, aGc, drawRect, maskedImgData,
                    KAknsIIDNone, childLayout, paDelta, drawParam );
                if ( !blit )
                    {
                    blitFailed = ETrue;
                    }

                maskedImgData->SetBitmap(NULL);
                maskedImgData->SetMask(NULL);
                delete maskedImgData;
                if (!(aDrawParam & KAknsDrawParamPrepareOnly))
                    {
                    aGc.SetPenStyle(CGraphicsContext::ESolidPen);
                    aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
                    }
                retVal = !blitFailed;
                return retVal;
                }
            }

        if (!aContext->IsCompatibleWithType(EAknsControlContextTypeFrame))
            {
            // special handling for frames
            drawParam|=KAknsDrawParamNoClearUnderImage;
            originalParam|=KAknsDrawParamNoClearUnderImage;
            }
        TAknsBackground* nextLayout = bgLayout->iNext;
        while( nextLayout &&
            ((drawParam & KAknsDrawParamLimitToFirstLevel) == 0) )
            {
            imgData = RetrieveKnownBackgroundImage( aInstance,
                nextLayout->iImageID );
            if (imgData && imgData->ParentIID() != KAknsIIDNone)
                {
                TAknsItemID parentiid = imgData->ParentIID();
                TRect parentDrawRect = imgData->DrawRect();

                imgData = RetrieveKnownBackgroundImage(
                    aInstance, parentiid );
                if (imgData)
                    {
                    imgData->SetDrawRect(parentDrawRect);
                    drawParam |= KAknsDrawParamChained ;
                    }
                }
            else
                {
                drawParam=originalParam;
                }
            if( imgData )
                {
                blitAttempted = ETrue;
                blit = BlitAndClear( aInstance, aGc, drawRect, imgData,
                    nextLayout->iImageID, nextLayout, paDelta, drawParam );
                if ( !blit )
                    {
                    blitFailed = ETrue;
                    }
                }
            nextLayout = nextLayout->iNext;
            }
        }

    if (!(aDrawParam & KAknsDrawParamPrepareOnly))
        {
        aGc.SetPenStyle(CGraphicsContext::ESolidPen);
        aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
        }

    // If Blit failed, or was not even attempted => return EFalse
    if ( blitFailed )
        {
        retVal = EFalse;
        }
    else if ( !retVal )
        {
        retVal = blitAttempted;
        }

    return retVal;
    }
コード例 #14
0
// -----------------------------------------------------------------------------
// CheckAndDrawFrame
//
// -----------------------------------------------------------------------------
//
static TBool CheckAndDrawFrame( MAknsSkinInstance* aInstance,
    CBitmapContext& aGc, const TRect& aOuterRect, const TRect& aInnerRect,
    const TAknsItemID& aFrameID, const TAknsItemID& aCenterID,
    const TInt aDrawParam )
    {
    if( !aInstance )
        {
        return EFalse;
        }
    
    if( !(aDrawParam & KAknsDrawParamPrepareOnly) )
        {
        // Prepare before drawing
        CheckAndDrawFrame( aInstance, aGc, aOuterRect, aInnerRect,
            aFrameID, aCenterID, aDrawParam|KAknsDrawParamPrepareOnly );
        }

    CAknsImageItemData* rawData = static_cast<CAknsImageItemData*>(
        aInstance->GetCachedItemData( aFrameID, EAknsITImage ) );
    if( !rawData )
        {
        return EFalse;
        }

    if (!(aDrawParam & KAknsDrawParamPrepareOnly))
        {
        aGc.SetPenStyle(CGraphicsContext::ENullPen);
        aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
        }

    TBool retVal = EFalse;

    if( AknsUtils::IsDerivedType( EAknsITImageTable, rawData->Type() ) )
        {
        CAknsImageTableItemData* data =
            static_cast<CAknsImageTableItemData*>(rawData);
        if( data->NumberOfImages() != EAknsFrameElementsN )
            {
            return EFalse;
            }

        // Corners
        retVal |= CheckAndDrawCachedImage( aInstance, aGc,
            TRect( aOuterRect.iTl, aInnerRect.iTl ),
            data->ImageIID( EAknsFrameIndexTl ), aDrawParam );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc,
            TRect( aInnerRect.iBr.iX, aOuterRect.iTl.iY,
            aOuterRect.iBr.iX, aInnerRect.iTl.iY ),
            data->ImageIID( EAknsFrameIndexTr ), aDrawParam );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc,
            TRect( aOuterRect.iTl.iX, aInnerRect.iBr.iY,
            aInnerRect.iTl.iX, aOuterRect.iBr.iY ),
            data->ImageIID( EAknsFrameIndexBl ), aDrawParam );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc,
            TRect( aInnerRect.iBr, aOuterRect.iBr ),
            data->ImageIID( EAknsFrameIndexBr ), aDrawParam );

        // Sides
        TRect sideRect( aInnerRect.iTl.iX, aOuterRect.iTl.iY,
            aInnerRect.iBr.iX, aInnerRect.iTl.iY );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc, sideRect,
            data->ImageIID( EAknsFrameIndexT ), aDrawParam );
        sideRect.SetRect( aInnerRect.iTl.iX, aInnerRect.iBr.iY,
            aInnerRect.iBr.iX, aOuterRect.iBr.iY );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc, sideRect,
            data->ImageIID( EAknsFrameIndexB ), aDrawParam );
        sideRect.SetRect( aOuterRect.iTl.iX, aInnerRect.iTl.iY,
            aInnerRect.iTl.iX, aInnerRect.iBr.iY );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc, sideRect,
            data->ImageIID( EAknsFrameIndexL ), aDrawParam );
        sideRect.SetRect( aInnerRect.iBr.iX, aInnerRect.iTl.iY,
            aOuterRect.iBr.iX, aInnerRect.iBr.iY );
        retVal |= CheckAndDrawCachedImage( aInstance, aGc, sideRect,
            data->ImageIID( EAknsFrameIndexR ), aDrawParam );

        // Center
        //lint --e{961} Valid logic
        if( aCenterID == KAknsIIDDefault )
            {
            retVal |= CheckAndDrawCachedImage( aInstance, aGc, aInnerRect,
                data->ImageIID( EAknsFrameIndexCenter ), aDrawParam );
            }
        else if( aCenterID != KAknsIIDNone )
            {
            retVal |= CheckAndDrawCachedImage( aInstance, aGc, aInnerRect,
                aCenterID, aDrawParam );
            }
        }
    else if( AknsUtils::IsDerivedType( EAknsITBitmap, rawData->Type() ) )
        {
        // Center only
        retVal |= CheckAndDrawCachedImage( aInstance, aGc, aOuterRect,
            aFrameID, aDrawParam );
        }

    if (!(aDrawParam & KAknsDrawParamPrepareOnly))
        {
        aGc.SetPenStyle(CGraphicsContext::ESolidPen); //lint !e961 Intentional
        aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
        }
    return retVal;
    }