void CCurThreeListBoxItem::Draw(CGraphic& aGraphic,TPoint& aPoint) const
{
	TPoint point = aPoint;

	ASSERT(iSlideText);
	TRect rect;
	if(iActive)
	{
		TSize size = iItemSize;
		size.iHeight *= 3;
		rect = size;
		rect.Move(point);

		aGraphic.SetPenColor(KTextColor);
		aGraphic.SetPenStyle(CGraphicsContext::ESolidPen);
		aGraphic.SetBrushColor(KListSelectedColor);
		aGraphic.SetBrushStyle(CGraphicsContext::ESolidBrush);
		aGraphic.DrawRect(rect);
		aGraphic.SetBrushStyle(CGraphicsContext::ENullBrush);
	}
	if(iIcon)
	{
		ASSERT(iIconMask);
		aGraphic.BitBltMasked(point,iIcon,iIconMask);
	}
	rect = iItemSize;
	if(iIcon)
	{
		rect.iTl.iX += iIcon->SizeInPixels().iWidth;
	}
	rect.Move(point);
	iSlideText->SetClientRect(rect);
	iSlideText->Draw(aGraphic);

	if(iActive)
	{	
		aGraphic.SetPenColor(iTextColor);
		rect.Move(0,iItemSize.iHeight);
		if(iSecondText)
		{
			aGraphic.DrawText(*iSecondText,rect);
		}
		rect.Move(0,iItemSize.iHeight);
		if(iThirdText)
		{
			aGraphic.DrawText(*iThirdText,rect);
		}

		aPoint.iY += iItemSize.iHeight*3;
	}
	else
	{
		aPoint.iY += iItemSize.iHeight;
	}
}
示例#2
0
void TestRRegion::TestOffset()
	{
	RRegion rgn;
	const TRect* rlist;
	TRect r;
	TUint index;

	for(index=0;index<(sizeof(rect)/sizeof(rect[0]));index++)
		{
		rgn.Clear();
		rgn.AddRect(rect[index]);
		r=rect[index];
		r.Move(1,1);
		rgn.Offset(1,1);
		if (rect[index].IsEmpty())
			test(rgn.Count()==0);
		else
			{
			test(rgn.Count()==1);
			rlist=rgn.RectangleList();
			test(rlist[0]==r);
			}
		}
	rgn.Close();
	}
示例#3
0
void CPanControl::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    TRect sourceRect = Rect();
    sourceRect.Move(iCurrentPointerPos);
    gc.DrawBitmap(aRect, iSourceBitmap, sourceRect); 
    }
EXPORT_C TRect MsgEditorCommons::MsgDataPane()
    {
    TRect msgMainPane = MsgEditorCommons::MsgMainPane();
    
#ifdef RD_SCALABLE_UI_V2
    msgMainPane.Move( -msgMainPane.iTl );
#endif // RD_SCALABLE_UI_V2

//    TAknLayoutRect msgDataLayout;
//    msgDataLayout.LayoutRect(
//        msgMainPane,
//        AknLayoutScalable_Apps::msg_data_pane().LayoutLine() );
//        
//    return msgDataLayout.Rect();
    msgMainPane.Move(0,3);
    msgMainPane.Resize(-10,-3);
    return msgMainPane;
    }
示例#5
0
/**
@see MAnimSpriteFunctions::UpdateMember
@param aFullUpdate	Not used. Wserv2 always do full back to front rendering, so there is no distinction between changes needing aFullUpdate or not 
 */
void CWsSprite::Update(TInt aMember,TRect aRect,TBool /*aFullUpdate*/) 
	{
	if (iCurIndex!=aMember)
		return;
	aRect.Move(Pos());
	aRect.Intersection(iScreen->CurrentScreenSize());
	SetDirty(ETrue);
	Screen()->SpriteManager()->Schedule(this, &aRect);
	}
示例#6
0
void CMyPicture::Draw( CGraphicsContext& aGc,
                       const TPoint& aTopLeft,
                       const TRect& aClipRect,
                       MGraphicsDeviceMap* aMap ) const
  {
  TRect bitmapRect = aMap->TwipsToPixels(TRect(TPoint(), iSizeInTwips));
  bitmapRect.Move(aTopLeft);
  aGc.Reset();
  aGc.SetClippingRect(aClipRect);
  aGc.DrawBitmap(bitmapRect, iBitmap);
  }
// CFepLayoutChoiceList::DrawItem
// Draw a choice list item.
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//
void CFepLayoutChoiceList::DrawItem(TInt aIndex, TBool aErase)
    {
    //
    if(iWndControl)
        return;
    TRect rtItem;
    rtItem.iTl.iY = aIndex * iItemRect.Height();
    rtItem.iBr.iX = iItemRect.Width();
    rtItem.iBr.iY = rtItem.iTl.iY + iItemRect.Height();
    rtItem.Move(Rect().iTl);
    DrawItem(rtItem, *iItemList[aIndex], aErase, aIndex == iCurFocusItem );
    }
/**
  Second phase constructor for CConeBackgroundTestParentWithNoBg class.\n
  Sets a container window for component control, if the container is a window-owning control.\n
  Creates two child controls, first one is placed at the top left while other is at the bottom right.\n
*/
void CConeBackgroundTestParentWithNoBg::ConstructL(const CCoeControl& aParent, const TRect& aRect)
    {
    SetContainerWindowL(aParent);
    SetRect(aRect);
	TRect tlRect = aRect;
	tlRect.iBr.iX = (aRect.iBr.iX - aRect.iTl.iX)/2 + aRect.iTl.iX;
	tlRect.iBr.iY = (aRect.iBr.iY - aRect.iTl.iY)/2 + aRect.iTl.iY;
	iChildControl1 = CConeBackgroundTestControl::NewL(*this, tlRect);
	TRect brRect = tlRect;
	brRect.Move(tlRect.Width(), tlRect.Height());
	iChildControl2 = CConeBackgroundTestControl::NewL(*this, brRect);
	}
// -----------------------------------------------------------------------------
// CFepUiLayout::SetRect
// Set layout rect
// -----------------------------------------------------------------------------
//
EXPORT_C void CFepUiLayout::SetRect(const TRect& aRect)
    {
    TRect layoutRect = Rect();
    layoutRect.Move(Position());
    if(layoutRect != aRect)
        {        
        iRootCtrl->SetRect(aRect);
        LayoutOwner()->LayoutSizeChanged( aRect.Size() );
        LayoutOwner()->SetPosition( aRect.iTl );
        iRootCtrl->GraphicDeviceSizeChanged();
        }
    }
// ---------------------------------------------------------------------------
// ReadRegionL
// ---------------------------------------------------------------------------
//
void CAlfHierarchyModel::ReadRegionL( RMemReadStream* aStream, RRegion& aRegion, TPoint aWindowPos )
    {
    aRegion.Clear();
    TRect rect;
    TInt count = aStream->ReadInt32L();
    for (TInt i = 0 ; i < count ; i++ )
        {
        ReadRectL( rect, aStream );
        rect.Move(-aWindowPos);
        aRegion.AddRect( rect );
        }
    }
// ---------------------------------------------------------------------------
// CFepUiLayout::InitL
// Initialize the layout
// ---------------------------------------------------------------------------
//
EXPORT_C TRect CFepUiLayout::Init()
    {
    //Init control    
    TRect r = iRootCtrl->InitControl();
    r.Move( Position() );
    for(TInt i = 0; i < iDragbarNum; i++)
        {
        iDragbarList[i]->AddPositionObserver(static_cast<MPositionObserver*>
                                                                (iRootCtrl)); 
        }
    //iLayoutReady = ETrue;
    return r;
    }
示例#12
0
/**
 * Sets a clipping rectangle for hiding the whole or a part of edwin's text.
 *
 * The reason for using this function is the multiline edwins. The text inside
 * an edwin can be broken to two or more lines, which must be hidden or shown
 * independently from each other. That is why it is not enough just to move
 * the whole edwin out of the screen.
 *
 * @param aClipRect The clipping rect for edwin's text. An empty rect disables
 *   hiding.
 *
 * @return How many subcontrols were hidden
 */
static TInt HideLines_Edwin(CEikEdwin *aEdwin, TRect aClipRect)
{
    aEdwin->SetTextLinesRect(aClipRect);

    // Create rects of the first and last edwin lines
    TPoint edwinTl( aEdwin->Rect().iTl );
    TPoint edwinBr( aEdwin->Rect().iBr );
    TRect textFirstLine;
    aEdwin->TextLayout()->GetLineRect(edwinTl.iY, textFirstLine);
    textFirstLine.Move( edwinTl.iX, edwinTl.iY + aEdwin->Margins().iTop );
    TRect textLastLine;
    aEdwin->TextLayout()->GetLineRect(edwinBr.iY, textLastLine);
    textLastLine.Move( edwinBr.iX, edwinBr.iY - aEdwin->Margins().iTop - textLastLine.Height() );

    // Check if at least one line fits to the clipping rect
    if( aClipRect.Contains(textFirstLine.iTl) &&
            aClipRect.iBr.iY >= textFirstLine.iBr.iY )   // The first line fits
        return 0;
    if( aClipRect.Contains(textLastLine.iTl) &&
            aClipRect.iBr.iY >= textLastLine.iBr.iY )   // The last line fits
        return 0;
    return 1;
}
void CGuideContainer::SetImage(class CImageHandler*& aImage, 
                               const TRect& aBaseRect,
                               TRect (*ptrFunc) (const class TRect& aRect, const class TSize& aSize),
                               float aXPos, float aYPos,
                               TInt aDx, TInt aDy)
{
   TRect rect = (*ptrFunc)(aBaseRect,
         TSize(WFLayoutUtils::CalculateXValue(aBaseRect.Width(), aXPos),
               WFLayoutUtils::CalculateYValue(aBaseRect.Height(), aYPos)));
   rect.Move(aDx, aDy);
   if (aImage) {
      aImage->SetImageRect(rect);
   } else {
      aImage = CImageHandler::NewL(rect);
   }
}
// ---------------------------------------------------------------------------
// CMMACameraWindow::StartViewFinder
// Starts viewfinder.
// ---------------------------------------------------------------------------
//
void CMMACameraWindow::StartViewFinder()
{
    LOG(EJavaMMAPI,EInfo," < StartViewFinder");

    ASSERT(iUICamera);
    ASSERT(iCameraPowerOn);
    ASSERT(iStarted);

    iStarterTimer->Cancel();

    // align client rect to RWindow, viewfinder
    // display co-ordinates is w.r.t to RWindow
    TRect relativeClientRect;
    relativeClientRect = iClientRect;
    relativeClientRect.Move(-iRWindowRect.iTl);

    // Set the drawing area
    TRect drawRect(iDrawRect);
    drawRect.Move(relativeClientRect.iTl);

    LOG2(EJavaMMAPI, EInfo,
         "MMA::CMMACameraWindow::StartViewFinder - Starting VF TL:%d,%d",
         drawRect.iTl.iX,
         drawRect.iTl.iY);
    LOG2(EJavaMMAPI, EInfo,
         "MMA::CMMACameraWindow::StartViewFinder - Starting VF BR:%d,%d",
         drawRect.iBr.iX,
         drawRect.iBr.iY);

    TRAPD(vfError, iUICamera->StartViewFinderDirectL(
              *iWs, *iScreenDevice, *iWindow, drawRect));

    if (vfError == KErrNone)
    {
        LOG(EJavaMMAPI,EInfo,"MMA::CMMACameraWindow::StartViewFinder - Start OK");
    }
    else
    {
        LOG1(EJavaMMAPI, EInfo,
             "MMA::CMMACameraWindow::StartViewFinder()  - \
StartViewFinderDirectL error=%d", vfError);

        TRAP_IGNORE(DrawViewFinderErrorL(vfError, drawRect));
    }

    LOG(EJavaMMAPI,EInfo," > StartViewFinder");
}
void CConeBackgroundTestParentWindowOwning::Draw(const TRect& aRect) const
	{
	CWindowGc& aGc = SystemGc();
	aGc.SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	
	TRect tlRect = aRect;
	tlRect.iBr.iX = (tlRect.iBr.iX - tlRect.iTl.iX)/2 + tlRect.iTl.iX;
	tlRect.iBr.iY = (tlRect.iBr.iY - tlRect.iTl.iY)/2 + tlRect.iTl.iY;
	
	aGc.SetBrushColor(TRgb(0xff0000)); //blue, to be changed or removed
	aGc.DrawRect(tlRect);
	
	TRect brRect = tlRect;
	brRect.Move(tlRect.Width(), tlRect.Height());
	aGc.SetBrushColor(TRgb(0xffffff)); //white , to be changed or removed
	aGc.DrawRect(brRect);
	}
/**
  Draw function of CConeBackgroundTestDrawer2 class used to draw the control.\n
  Sets the brush style to Solid Brush and Pen Style to Null Pen.\n
  Sets the brush colour to Red and paints the top left part of the control.\n
  Sets the brush colour and points the bottom right part of the control.\n
*/
void CConeBackgroundTestDrawer1::Draw(CWindowGc& aGc, const CCoeControl& /*aControl*/, const TRect& aRect) const
	{
	
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	
	TRect tlRect = aRect;
	tlRect.iBr.iX = (tlRect.iBr.iX - tlRect.iTl.iX)/2 + tlRect.iTl.iX;
	tlRect.iBr.iY = (tlRect.iBr.iY - tlRect.iTl.iY)/2 + tlRect.iTl.iY;
	
	aGc.SetBrushColor(TRgb(0xff0000));
	aGc.DrawRect(tlRect);
	
	TRect brRect = tlRect;
	brRect.Move(tlRect.Width(), tlRect.Height());
	aGc.SetBrushColor(TRgb(0x00ff00));
	aGc.DrawRect(brRect);
	}
void CWapBrowserAppView::DrawWaiting(CGraphicsContext& aGc) const
{
	if(iShowWaiting)
	{
		TRect rect = Rect();
		rect.iTl.iY = rect.iBr.iY - 20;
		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		aGc.SetBrushColor(KRgbYellow);
		aGc.SetPenStyle(CGraphicsContext::ENullPen);
		aGc.DrawRect(rect);
		rect.iTl.iX = 10*iWaitingPos;
		rect.iBr.iX = rect.iTl.iX + 10;
		aGc.SetBrushColor(KRgbGreen);
		for ( int i = 0 ; i < 20 ; i++)
		{
			aGc.DrawRect(rect);
			rect.Move(TPoint(30,0));
		}
	}
}
	void DrawProgressBarBg(CWindowGc& aGc, const TRect& aWindowRect) const
	{
		MAknsSkinInstance* skin = AknsUtils::SkinInstance();

		TRect r = aWindowRect;
		//TRect r = iProgressBar->Rect();
		TRect cr = iEikonEnv->EikAppUi()->ClientRect();
		r.Move(0, - cr.iTl.iY); 
		
		TPoint dstPosInCanvas(0,0);			
		TRect partOfBackground( r );
		TBool skinBackgroundDrawn = 
			AknsDrawUtils::DrawBackground( skin, 
										   iBackground,
										   NULL, 
										   aGc, 
										   dstPosInCanvas,
										   partOfBackground,
										   KAknsDrawParamLimitToFirstLevel);
	}
// ---------------------------------------------------------------------------
// CAknDiscreetPopupDrawer::TitleTextNeedsWrapping
// Returns ETrue if title text needs wrapping.
// ---------------------------------------------------------------------------
//
TBool CAknDiscreetPopupDrawer::TitleTextNeedsWrapping( 
        const TInt& aLayoutType )
    {
    const CFont* textFont( NULL );
    TRect textRect;
    TRect popupRect;
    TPopupLayoutData data( KPopupLayoutData[ aLayoutType ] );
    GetPopupRect( data.iWindowVariety, popupRect );
    popupRect.Move( 0, 0 );

    textFont = FontFromLayout( 
        popupRect, 
        AknLayoutScalable_Avkon::popup_discreet_window_t1( 
        data.i1stRowVariety ), textRect );
    if ( textFont->TextCount( *iTitleText, textRect.Width() ) 
            < iTitleText->Length() )
        {
        return ETrue;
        }
    return EFalse;
    }
/**
  Draw function of CConeBackgroundTestDrawer2 class used to draw the control.\n
  Sets the background style for Drawing.\n
  1. if aStyle is zero , the brush style is EVerticalHatchBrush.\n
  2. if aStyle is one , the brush style is EForwardDiagonalHatchBrush.\n
  3. if aStyle is two , the brush style is EHorizontalHatchBrush.\n
  4. if aStyle is three , the brush style is ERearwardDiagonalHatchBrush.\n
  Sets the brush colour to Red and paints the top left part of the control.\n
  Sets the brush colour and points the bottom right part of the control.\n
*/
void CConeBackgroundTestDrawer0::Draw(CWindowGc& aGc, const CCoeControl& /*aControl*/, const TRect& aRect) const
	{
	aGc.SetPenStyle(CGraphicsContext::ENullPen);
	aGc.SetBrushColor(TRgb(0xffffff));
	aGc.Clear();

	switch (iBgStyle)
		{
		case 0:
			aGc.SetBrushStyle(CGraphicsContext::EVerticalHatchBrush);
			break;
			
		case 1:
			aGc.SetBrushStyle(CGraphicsContext::EForwardDiagonalHatchBrush);
			break;
			
		case 2:
			aGc.SetBrushStyle(CGraphicsContext::EHorizontalHatchBrush);
			break;
			
		case 3:
			aGc.SetBrushStyle(CGraphicsContext::ERearwardDiagonalHatchBrush);
			break;
		}

	aGc.SetPenColor(TRgb(0xff0000));
	aGc.DrawRect(aRect);
	
	TRect tlRect = aRect;
	tlRect.iBr.iX = (tlRect.iBr.iX - tlRect.iTl.iX)/2 + tlRect.iTl.iX;
	tlRect.iBr.iY = (tlRect.iBr.iY - tlRect.iTl.iY)/2 + tlRect.iTl.iY;
	
	aGc.SetBrushColor(TRgb(0xff00ff));
	aGc.DrawRect(tlRect);
	
	TRect brRect = tlRect;
	brRect.Move(tlRect.Width(), tlRect.Height());
	aGc.SetBrushColor(TRgb(0x00ff00));
	aGc.DrawRect(brRect);
	}
void 
CPreviewPopUpContent::SetAvailableWidth(TInt aWidth, TInt aPadding, 
                                        CPreviewPopUpContent::TContentLayout aLayout,
                                        TInt aHeight)
{
   iLayout = aLayout;

   TInt numLabels = iLabelContainer.Count();
   if (numLabels == 0) {
      return;
   }
   
   // The large font header label.
   CEikLabel* labelLa = iLabelContainer[0].iLabel;
   // The small font text label.
   CEikLabel* labelSm = iLabelContainer[1].iLabel;

   // Font height in pixels
   TInt fontHeightLa = labelLa->Font()->HeightInPixels();
   // Font descent in pixels
   TInt descentLa = labelLa->Font()->DescentInPixels();
   // The height of one label
   TInt labelHeightLa = fontHeightLa + descentLa;
   // Font height in pixels
   TInt fontHeightSm = labelSm->Font()->HeightInPixels();
   // Font descent in pixels
   TInt descentSm = labelSm->Font()->DescentInPixels();
   // The height of one label
   TInt labelHeightSm = fontHeightSm + descentSm;

   // totLabelsHeight will hold the total height of all labels that 
   // will be drawn (one large font and the rest small fonts).
   // We additionaly remove a descent on the last line since that 
   // it seems otherwise we're over compensating.
   TInt totLabelsHeight = 
      labelHeightLa + labelHeightSm * (numLabels - 1); // - descentSm;

   // Calculate the image size.
   // This calc will give us the height of two label rows.
   iIconSize = fontHeightLa + fontHeightSm + descentLa;
   TInt iconSize = iIconSize;
   TInt padding = aPadding;
   if (iBitmap) {
      AknIconUtils::SetSize(iBitmap, TSize(iconSize, iconSize), 
                            EAspectRatioPreservedAndUnusedSpaceRemoved);
      iconSize = iBitmap->SizeInPixels().iWidth;
   } else {
      // We have no bitmap set so dont indent the text around the bitmap.
      iconSize = 0;
      padding = 0;
   }

   // controlRect will contain the rect for our control to draw in, 
   // including padding.
   TRect controlRect;
   if (iLayout == EFourLinesIndentedTextImageTopLeft) {
      if (aHeight > 0) {
         controlRect = TRect(TPoint(aPadding, aPadding), 
                             TSize(aWidth, aHeight));
      } else {
         controlRect = TRect(TPoint(aPadding, aPadding), 
                             TSize(aWidth, totLabelsHeight + aPadding));
      }
   } else if (iLayout == EFourLinesTextImageTopLeftAbove) {
      if (aHeight > 0) {
         controlRect = TRect(TPoint(aPadding, aPadding), 
                             TSize(aWidth, aHeight));
      } else {
         controlRect = TRect(TPoint(aPadding, aPadding), 
                             TSize(aWidth, 
                                   totLabelsHeight + iconSize + descentLa + aPadding));
      }
   }

   // iComponentRect will contain the drawing area for our controls 
   // (image and labels).
   iComponentRect = controlRect;
   iComponentRect.Shrink(aPadding, aPadding);

   // Calculate where the text should wrap and
   // calculate the positions and rects for the labels in the control.
   TRect labelRectLa;
   TRect labelRectSm;
   if (iLayout == EFourLinesIndentedTextImageTopLeft) {
      // The first line will bew positioned next to the image and 
      // therefore the width will be a bit shorter.
      iStringLengths->At(0) = (iComponentRect.Width() - (iconSize + padding));
      // The width of the last line should not be wrapped but rather set to 
      // cropped later on.
      iStringLengths->At(1) = (iComponentRect.Width() + 10000);

      // The rect for the first label in the layout mode.
      labelRectLa = TRect(TPoint(iComponentRect.iTl.iX + iconSize + padding, 
                               iComponentRect.iTl.iY),
                          TSize(iComponentRect.Width() - (iconSize + padding), 
                                labelHeightLa));
      // The rect for the labels with small font as well.
      labelRectSm = TRect(TPoint(iComponentRect.iTl.iX + iconSize + padding, 
                               iComponentRect.iTl.iY),
                          TSize(iComponentRect.Width() - (iconSize + padding), 
                                labelHeightLa));
   } else if (iLayout == EFourLinesTextImageTopLeftAbove) {
      // We can use the full length of the container.
      iStringLengths->At(0) = iComponentRect.Width();
      // The width of the last line should not be wrapped but rather set to 
      // cropped later on.
      iStringLengths->At(1) = (iComponentRect.Width() + 10000);

      // The rect for the first label in the layout mode.
      labelRectLa = TRect(TPoint(iComponentRect.iTl.iX, 
                               iComponentRect.iTl.iY + iconSize + descentLa),
                          TSize(iComponentRect.Width(), 
                                labelHeightLa));
      // The rect for the labels with small font as well.
      labelRectSm = TRect(TPoint(iComponentRect.iTl.iX, 
                               iComponentRect.iTl.iY + iconSize + descentLa),
                          TSize(iComponentRect.Width(), 
                                labelHeightLa));
   }

   iLabelContainer[0].SetRect(labelRectLa);
   
   labelRectSm.Move(0, labelHeightLa);
   iLabelContainer[1].SetRect(labelRectSm);

//    if (iLayout == EFourLinesIndentedTextImageTopLeft) {
//       // We need to move back the third label in this layout mode.
//       labelRect.iTl.iX -= (iconSize + padding);
//    }
   labelRectSm.Move(0, labelHeightSm);
   iLabelContainer[2].SetRect(labelRectSm);

   labelRectSm.Move(0, labelHeightSm);
   iLabelContainer[3].SetRect(labelRectSm);
   
   SetRect(controlRect);
}
示例#22
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;
    }