/** * Draws the icon for the item to the graphics context aGc, in the middle of the rectangle aRect */ EXPORT_C void LafMenuPaneItem::DrawIcon(const MLafEnv& /*aLafEnv*/, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const CGulIcon* aIcon, SLafMenuPane::THighlightType aHighlightType) { if (aIcon) { if (aHighlightType == SLafMenuPane::EDrawHighlight) aGc.SetBrushStyle(CGraphicsContext::ENullBrush); // Determine the rect available for the bitmap TRect rect = aRect; // put the image in the middle of available rect const CFbsBitmap* bitmap = aIcon->Bitmap(); const TSize bmpSize(bitmap->SizeInPixels()); const TSize rectSize(aRect.Size()); const TPoint offset(((rectSize.iWidth - bmpSize.iWidth) / 2), ((rectSize.iHeight - bmpSize.iHeight) / 2)); const CFbsBitmap* mask = aIcon->Mask(); if (mask) { const TRect bmpRect(0, 0, bmpSize.iWidth, bmpSize.iHeight); aGc.BitBltMasked(rect.iTl+offset, bitmap, bmpRect, mask, ETrue); } else aGc.BitBlt(rect.iTl+offset, bitmap); if (aHighlightType == SLafMenuPane::EDrawHighlight) aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); } }
static void DrawIconL(CWindowGc& aGc, CGulIcon& aIcon, const TJuikLayoutItem& aL, TBool aDoCenter=ETrue) { CALLSTACKITEMSTATIC_N(_CL(""), _CL("DrawIconL")); CFbsBitmap* bmp = aIcon.Bitmap(); CFbsBitmap* mask = aIcon.Mask(); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); // center TInt bmpW = bmp->SizeInPixels().iWidth; TInt areaW = aL.Size().iWidth; TInt dx = 0; TInt dy = 0; if ( aDoCenter && bmpW < areaW ) { dx = (areaW - bmpW) / 2; } TPoint tl = aL.TopLeft(); tl += TPoint(dx,dy); TRect r(TPoint(0,0), bmp->SizeInPixels()); if ( mask ) { aGc.BitBltMasked( tl, bmp, r, mask, ETrue); } else { aGc.BitBlt( tl, bmp, r); } }
/** * Draws the left adornment to the graphics context aGc, in the rectangle aRect. The menu pane * flags determines the type of adornment to be drawn. */ EXPORT_C void LafMenuPane::DrawLeftAdornment(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& aItemAttributes) { // Brush the background of the rect. aGc.SetPenStyle(CGraphicsContext::ENullPen); aGc.DrawRect(aRect); aGc.SetPenStyle(CGraphicsContext::ESolidPen); const TInt itemFlags = aItemAttributes.iFlags; if (itemFlags&EEikMenuItemSymbolOn) { if (itemFlags&EEikMenuItemCheckBox) { TRect rect = aRect; rect.iTl.iY += aItemAttributes.iBaseLine; TBuf<1> buf; buf.Append(TChar(ESymFontTick)); aGc.UseFont(SymbolFont(aLafEnv)); aGc.SetPenStyle(CGraphicsContext::ESolidPen); // as the tick is big, ignore KPreLeftAdornment and steal 1 pixels from left. aGc.DrawText(buf,TPoint(rect.iTl.iX-1, rect.iTl.iY)); aGc.UseFont(NormalFont(aLafEnv)); } else if (itemFlags&KLafMenuItemRadio) { TUid bmpUid(TUid::Uid(KLafUidEikonOptiVal)); const CFbsBitmap* bitmap = aLafEnv.Bitmap(bmpUid); TSize bitsize = bitmap->SizeInPixels(); TRect butRect(TPoint(0,0), TPoint(bitsize.iWidth,bitsize.iHeight)); TInt yoffset = (aRect.Size().iHeight - bitsize.iHeight) / 2; TInt xoffset = KLafPreLeftAdornmentSpace; TPoint offset(xoffset,yoffset); if (aItemAttributes.iHighlightType == SLafMenuPane::EDrawHighlight) { bmpUid=TUid::Uid(KLafUidEikonOptihVal); bitmap = aLafEnv.Bitmap(bmpUid); } bmpUid=TUid::Uid(KLafUidEikonOptimVal); const CFbsBitmap* mask = aLafEnv.Bitmap(bmpUid); aGc.BitBltMasked((aRect.iTl+offset), bitmap, butRect, mask,ETrue); } } }