/** * Draws the aHotKeys text into the graphics context aGc, in the rectangle aRect. By defalut the * text is right aligned. */ EXPORT_C void LafMenuPane::DrawHotKeyText(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TDesC& aHotKeysText, const TItemAttributes& aItemAttributes) { aGc.UseFont(AnnotationFont(aLafEnv)); // Left alignment aGc.DrawText(aHotKeysText, aRect, aItemAttributes.iBaseLine, CGraphicsContext::ELeft,KLafSpaceBetweenTextAndHotkey); aGc.UseFont(NormalFont(aLafEnv)); }
void CCalendarManagerContainer::DrawCurrentDay(CWindowGc& gc, MAknsSkinInstance* p_BgSkin, const TRgb& p_Default_Select_Color, const CFont& p_Font) const { TInt i_Col = (g_CalendarClass->g_SelectDay + g_CalendarClass->g_FirstWeek - 1) % 7 + 2; TInt i_Row = (g_CalendarClass->g_SelectDay + g_CalendarClass->g_FirstWeek - 1) / 7 + 1; TInt i_Pos_X = (i_Col - 1) * g_Space_X + i_Col - 1; TInt i_Pos_Y = (i_Row - 1) * g_Space_Y + (i_Row - 1) * 2 + g_Pos_Y; TRect i_OuterRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X + 1, i_Pos_Y + g_Space_Y + 2); i_OuterRect.Shrink(2, 2); TRect i_InnerRect(i_OuterRect); i_InnerRect.Shrink(4, 4); AknsDrawUtils::DrawFrame(p_BgSkin, gc, i_OuterRect, i_InnerRect, KAknsIIDQsnFrList, KAknsIIDQsnFrListCenter); gc.SetPenColor(p_Default_Select_Color); TBuf<5> i_Num; i_Num.AppendNum(g_CalendarClass->g_SelectDay); if (g_CalendarClass->g_SelectYear == g_CalendarClass->g_Year && g_CalendarClass->g_SelectMonth == g_CalendarClass->g_Month && g_CalendarClass->g_SelectDay == g_CalendarClass->g_Day) gc.SetUnderlineStyle(EUnderlineOn); else gc.SetUnderlineStyle(EUnderlineOff); gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0); }
/** Writes the text "aText" on the control.\n Sets the font,pen colour,brush style used for writing the text.\n Draws the text uisng Draw Text function of Graphics context.\n */ void CCtlBase::WriteName( CWindowGc& aGc, const TDesC& aText ) const { TRect rect = Rect() ; rect.Shrink( 3, 3 ) ; aGc.UseFont( iFont ) ; TInt ascent = ( rect.iBr.iY - rect.iTl.iY-iFont->HeightInPixels() ) / 2 + iFont->AscentInPixels() ; aGc.SetPenColor( KRgbBlack ) ; aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; aGc.DrawText( aText, rect, ascent, CGraphicsContext::ECenter ) ; }
void CZXingBarcodeReaderAppView::DrawTexts(CWindowGc& gc) const { if (iTitle.Length()>0) { TRect rect(Rect()); gc.SetPenColor(KRgbWhite); gc.UseFont(iTitleFont); gc.DrawText(iTitle, rect, rect.Height()/10, CGraphicsContext::ECenter ); gc.DiscardFont(); } }
void CCalendarManagerContainer::DrawSchedule(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const CFont& p_Font) const { g_Pos_Y += g_Space_Y; gc.SetPenColor(p_Default_Font_Color1); TInt i_Count = GetScheduleCount(); if (i_Count == 0) { gc.DrawText(_L("\x6CA1\x6709\x65E5\x7A0B"), TRect(0, 0, aRect.Width(), g_Pos_Y), (g_Pos_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); } else { TBuf<20> i_NUM; i_NUM.Append(_L("\x6709")); i_NUM.AppendNum(i_Count); i_NUM.Append(_L("\x4E2A\x65E5\x7A0B")); gc.DrawText(i_NUM, TRect(0, 0, aRect.Width(), g_Pos_Y), (g_Pos_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); } //gc.DrawLine(TPoint(0, g_Pos_Y), TPoint(aRect.Width(), g_Pos_Y)); }
TInt LoadsOfText(TInt aOwningGroup) { RWsSession ws; ws.Connect(); CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); device->Construct(); RWindowGroup group(ws); group.Construct(ENullWsHandle); group.SetOwningWindowGroup(aOwningGroup); TSize scrSize(device->SizeInPixels()); // RWindow window(ws); window.Construct(group,ENullWsHandle); window.SetExtent(TPoint(), scrSize); window.Activate(); // CWindowGc *gc; device->CreateContext(gc); window.BeginRedraw(); gc->Activate(window); gc->Clear(); window.EndRedraw(); TFontSpec fspec(KTestFontTypefaceName,200); CFbsFont *font; User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); gc->UseFont(font); TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba")); TInt ascent=font->AscentInPixels(); TInt fheight=font->HeightInPixels(); for(TInt nTimes=0;nTimes<10;nTimes++) { TPoint pos; // for(pos.iY=ascent;pos.iY<scrSize.iHeight;pos.iY+=font->HeightInPixels()) // gc->DrawText(loadsatext,pos); for(pos.iY=0;pos.iY<scrSize.iHeight;pos.iY+=fheight) gc->DrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent); gc->Clear(); } gc->Deactivate(); // ws.Flush(); delete gc; device->ReleaseFont(font); window.Close(); group.Close(); delete device; ws.Close(); return(KErrNone); }
void CCalendarManagerContainer::DrawWeek(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const CFont& p_Font) const { gc.SetPenColor(p_Default_Font_Color1); gc.SetUnderlineStyle(EUnderlineOff); TInt i_Pos_X = 0; TInt i_Pos_Y = g_Pos_Y; for (TInt i = 0;i < sizeof(g_CalendarClass->g_Week) / sizeof(TInt);i++) { TBuf<10> i_Num; i_Num.AppendNum(g_CalendarClass->g_Week[i]); gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0); i_Pos_Y += g_Space_Y + 2; } }
void CSpaceInvadersAppView::DrawQuitCommand(CWindowGc& aGc) const { TRgb pencolor = TRgb(255,255,255); aGc.SetPenColor(pencolor); _LIT(KQuitText, "Quit"); TBufC<4> quitText; TPtr quitPtr = quitText.Des(); quitPtr.Append(KQuitText); const CFont* menuFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL); aGc.UseFont(menuFont); TInt textLength = menuFont->TextWidthInPixels(quitPtr); TInt textHeight = menuFont->HeightInPixels(); TPoint textpoint(Rect().Width() - ( textLength + 10 ), Rect().Height() - textHeight); aGc.DrawText(quitPtr, textpoint); }
void CSpaceInvadersAppView::DrawPoints(CWindowGc& aGc) const { TRgb pencolor = TRgb(255,255,255); aGc.SetPenColor(pencolor); _LIT(KPointsText, "Points: "); TBufC<15> pointsText; TPtr pointsPtr = pointsText.Des(); pointsPtr.Append(KPointsText); pointsPtr.AppendNum(iHolder->ActivePoints()); const CFont* menuFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont, NULL); aGc.UseFont(menuFont); TInt textLength = menuFont->TextWidthInPixels(pointsPtr); TInt textHeight = menuFont->HeightInPixels(); TPoint textpoint(Rect().Width() / 2 - textLength / 2, textHeight); aGc.DrawText(pointsPtr, textpoint); }
/** * 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); } } }
/****************************************************************************\ | Function: CNumberedWindow::Draw | Purpose: Redraws the contents of CNumberedWindow within a given | rectangle. CNumberedWindow displays a number in the window. | Input: aRect Rectangle that needs redrawing | Output: None \****************************************************************************/ void CNumberedWindow::Draw(const TRect& aRect) { const TBufC<1> strings[5] = { *&KString1, *&KString2, *&KString3, *&KString4, *&KString5 }; CWindowGc* gc = SystemGc(); // get a graphics context gc->SetClippingRect(aRect); // clip outside the redraw area gc->Clear(aRect); // clear the redraw area TSize size = iWindow.Size(); TInt height = size.iHeight; // Need window height to calculate vertical text offset TInt ascent = Font()->AscentInPixels(); TInt descent = Font()->DescentInPixels(); TInt offset = (height + (ascent + descent)) / 2; // Calculate vertical text offset gc->SetPenColor(TRgb(0, 0, 0)); // Set pen to black gc->UseFont(Font()); gc->DrawText(strings[iNumber], TRect(TPoint(0, 0), size), offset, CGraphicsContext::ECenter); gc->DiscardFont(); }
/** * Draws the cascade symbol into the graphics context aGc, in the rectangle aRect and sets * the pen color depending on whether the menu item is dimmed or focused. */ EXPORT_C void LafMenuPane::DrawRightAdornment(const MLafEnv& aLafEnv, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TItemAttributes& aItemAttributes) { const TInt cascadeSize=Min(KLafRightAdornmentSpace,aItemAttributes.iHeight); // Brush the background of the rect. aGc.SetPenStyle(CGraphicsContext::ENullPen); aGc.DrawRect(aRect); aGc.SetPenStyle(CGraphicsContext::ESolidPen); if (aItemAttributes.iInternalFlags&EMenuIsRightAdornment) { //Sort out rect for cascade symbol TRect cascadeRect=TRect(TPoint(aRect.iBr.iX-cascadeSize-PostRightAdornmentSpace(),aItemAttributes.iHPosition), TSize(cascadeSize,aItemAttributes.iHeight)); cascadeRect.iTl.iY+=((aItemAttributes.iHeight-cascadeSize)/2); cascadeRect.iBr.iY-=((aItemAttributes.iHeight-cascadeSize)/2); TBuf<1> cascade; cascade.Append(TChar(ESymFontMenuCascade)); aGc.UseFont(SymbolFont(aLafEnv)); aGc.DrawText(cascade,cascadeRect,cascadeRect.Height(),CGraphicsContext::ERight); aGc.UseFont(NormalFont(aLafEnv)); } }
void CCalendarManagerContainer::DrawDay(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const TRgb& p_Default_Font_Color2, const CFont& p_Font) const { gc.SetPenColor(p_Default_Font_Color1); TInt i_Total = 0; TInt i_WeekPos = g_CalendarClass->g_FirstWeek; //TInt i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1; //TInt i_Pos_Y = g_Pos_Y; TInt i_Pos_X = g_Space_X + 1; TInt i_Pos_Y = g_Pos_Y; if (i_WeekPos != 7) { gc.SetPenColor(p_Default_Font_Color2); for (TInt i = g_CalendarClass->g_MaxDay_PreMonth - i_WeekPos + 1;i <= g_CalendarClass->g_MaxDay_PreMonth;i++) { TBuf<5> i_Num; i_Num.AppendNum(i); gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; i_Total++; } } i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1; for (TInt i = 1; i <= g_CalendarClass->g_MaxDay; i++) { TBuf<5> i_Num; i_Num.AppendNum(i); if (i_WeekPos == 0) gc.SetPenColor(KRgbRed); else gc.SetPenColor(p_Default_Font_Color1); if (g_CalendarClass->g_SelectYear == g_CalendarClass->g_Year && g_CalendarClass->g_SelectMonth == g_CalendarClass->g_Month && i == g_CalendarClass->g_Day) gc.SetUnderlineStyle(EUnderlineOn); else gc.SetUnderlineStyle(EUnderlineOff); gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0); i_WeekPos++; if (i_WeekPos >= 7) { i_WeekPos = 0; i_Pos_Y += g_Space_Y + 2; } i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1; i_Total++; } TInt j = 1; gc.SetPenColor(p_Default_Font_Color2); for (TInt i = i_Total + 1;i <= 42;i++) { TBuf<5> i_Num; i_Num.AppendNum(j); gc.DrawText(i_Num, TRect(i_Pos_X, i_Pos_Y, i_Pos_X + g_Space_X, i_Pos_Y + g_Space_Y), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels() + 1, CGraphicsContext::ECenter, 0); i_WeekPos++; if (i_WeekPos >= 7) { i_WeekPos = 0; i_Pos_Y += g_Space_Y + 2; } i_Pos_X = g_Space_X * (i_WeekPos + 1) + i_WeekPos + 1; j++; } }
void CCalendarManagerContainer::DrawWeekName(CWindowGc& gc, const TRect& aRect, const TRgb& p_Default_Font_Color1, const CFont& p_Font) const { //TInt i_Pos_X = g_Space_X + 1; TInt i_Pos_X = 0; TInt i_Width = 0; TInt i_Height = g_Pos_Y + g_Space_Y; gc.SetPenColor(p_Default_Font_Color1); i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x5468"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; for (TInt i = 0;i < 7;i++) { switch (i) { case 0: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x65E5"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; case 1: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x4E00"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; case 2: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x4E8C"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; case 3: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x4E09"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; case 4: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x56DB"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; case 5: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x4E94"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; case 6: i_Width = i_Pos_X + g_Space_X; gc.DrawText(_L("\x516D"), TRect(i_Pos_X, g_Pos_Y, i_Width, i_Height), (g_Space_Y - p_Font.HeightInPixels()) / 2 + p_Font.HeightInPixels(), CGraphicsContext::ECenter, 0); i_Pos_X += g_Space_X + 1; break; } } g_Pos_Y += g_Space_Y; //gc.DrawLine(TPoint(0, g_Pos_Y), TPoint(aRect.Width(), g_Pos_Y)); }
/** * Draws aText into the graphics context aGc, in the rectangle aRect. By default aText is * left aligned */ EXPORT_C void LafMenuPane::DrawText(const MLafEnv& /*aLafEnv*/, const CCoeControl& /*aMenuPane*/, CWindowGc& aGc, const TRect& aRect, const TDesC& aText, const TItemAttributes& aItemAttributes) { aGc.DrawText(aText, aRect, aItemAttributes.iBaseLine, CGraphicsContext::ELeft); }
/* ----------------------------------------------------------------------- ----------------------------------------------------------------------- */ void CTraceContainer::DrawMemory(const TRect& aRect, CWindowGc& gc) const { if(iMaskImg) { if(iMaskImg->Bitmap() && iMaskImg->Mask()) { if(iMaskImg->Bitmap()->Handle() && iMaskImg->Mask()->Handle()) { TSize ButtonSiz(iMaskImg->Bitmap()->SizeInPixels()); gc.DrawBitmapMasked(aRect,iMaskImg->Bitmap(),TRect(0,0,ButtonSiz.iWidth,ButtonSiz.iHeight),iMaskImg->Mask(),EFalse); } } } gc.SetPenColor(KRgbBlack); gc.DrawLine(aRect.iTl,TPoint(aRect.iTl.iX,aRect.iBr.iY)); gc.DrawLine(aRect.iTl,TPoint(aRect.iBr.iX,aRect.iTl.iY)); gc.DrawLine(aRect.iBr,TPoint(aRect.iTl.iX,aRect.iBr.iY)); gc.DrawLine(aRect.iBr,TPoint(aRect.iBr.iX,aRect.iTl.iY)); gc.SetPenColor(KRgbRed); TInt Prosentages(0); TBuf<100> FreeBuffer(_L("Free: ")); TBuf<100> TotalBuffer(_L("Total: ")); if(iArray.Count()) { if(iArray[iArray.Count() - 1]) { FreeBuffer.AppendNum(iArray[iArray.Count() - 1]->iMemory,EDecimal); TotalBuffer.AppendNum(iTotalRamInBytes,EDecimal); Prosentages = ((iArray[iArray.Count() - 1]->iMemory * 100) / iTotalRamInBytes); } } TInt SizPie = (aRect.Height() / 3); PieDrawer(gc,aRect.iTl,SizPie,Prosentages,EFalse); const CFont* MuFonr = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont); TInt TextHeight= MuFonr->HeightInPixels(); TInt StartX = (aRect.iTl.iX + SizPie); TInt StartY = (aRect.iTl.iY + 2); gc.SetPenColor(KRgbBlack); gc.UseFont(MuFonr); gc.DrawText(FreeBuffer,TRect(StartX,StartY,aRect.iBr.iX,StartY + TextHeight),MuFonr->AscentInPixels(), CGraphicsContext::ELeft, 0); gc.DrawText(TotalBuffer,TRect(StartX,(StartY + TextHeight),aRect.iBr.iX,(StartY + (TextHeight * 2))),MuFonr->AscentInPixels(), CGraphicsContext::ELeft, 0); gc.SetPenColor(KRgbRed); StartX = 0; if(iArray.Count() > aRect.Width()) { StartX = (iArray.Count() - aRect.Width()); } TPoint MePoint1(aRect.iTl.iX,aRect.iBr.iY); TPoint MePoint2(aRect.iTl); TInt Valll(0); for(TInt i = StartX; i < iArray.Count(); i++) { if(iArray[i] && iTotalRamInBytes > 0) { Valll = ((aRect.Height() * iArray[i]->iMemory) / iTotalRamInBytes); } MePoint2.iY = (aRect.iBr.iY - Valll); if(StartX != 1) { gc.DrawLine(MePoint1,MePoint2); } MePoint1 = MePoint2; MePoint2.iX = MePoint2.iX + 1; } }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CTraceContainer::PieDrawer(CWindowGc& aGc, TPoint aLeftTop, TInt aSize, TInt aProsentages, const TBool& aReverceColor) const { TBuf<50> Buffer; Buffer.Num(aProsentages); Buffer.Append(_L("%")); aGc.SetPenColor(KRgbBlack); if(aReverceColor) aGc.SetBrushColor(KRgbGreen); else aGc.SetBrushColor(KRgbRed); aGc.SetBrushStyle(CGraphicsContext::ESolidBrush); aGc.DrawEllipse(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize)); if(aProsentages < 0) { Buffer.Copy(_L("N/A")); if(aReverceColor) aGc.SetBrushColor(KRgbGreen); else aGc.SetBrushColor(KRgbRed); } else { TInt HelpPie = 0; if(aReverceColor) aGc.SetBrushColor(KRgbRed); else aGc.SetBrushColor(KRgbGreen); TInt Angle =((aProsentages * 360) / 100); if(Angle == 360) { aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),aLeftTop,aLeftTop); } else if(Angle == 45) { aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX,aLeftTop.iY)); } else if(Angle == 135) { aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX,aLeftTop.iY + aSize)); } else if(Angle == 225) { aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX + aSize,aLeftTop.iY + aSize)); } else if(Angle == 315) { aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX + aSize,aLeftTop.iY)); } else if(Angle > 45 && Angle < 135) { HelpPie = ((((Angle - 45) * aSize) / 90) + aLeftTop.iY); aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX,HelpPie)); } else if(Angle > 135 && Angle < 225) { HelpPie = ((((Angle - 135) * aSize) / 90) + aLeftTop.iX); aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(HelpPie,aLeftTop.iY + aSize)); } else if(Angle > 225 && Angle < 315) { HelpPie = (((aLeftTop.iY + aSize) - ((Angle - 225) * aSize) / 90)); aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(aLeftTop.iX + aSize,HelpPie)); } else if(Angle > 0 && Angle < 45) { HelpPie = (((aLeftTop.iX + (aSize/2)) - ((Angle) * (aSize/2)) / 45)); aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(HelpPie,aLeftTop.iY)); } else if(Angle > 315 && Angle < 360) { HelpPie = (((aLeftTop.iX + aSize) - ((Angle - 315) * (aSize/2)) / 45)); aGc.DrawPie(TRect(aLeftTop.iX,aLeftTop.iY,aLeftTop.iX + aSize,aLeftTop.iY + aSize),TPoint(aLeftTop.iX + (aSize/2),aLeftTop.iY),TPoint(HelpPie,aLeftTop.iY)); } if(aReverceColor) { if(Angle > 180) aGc.SetBrushColor(KRgbGreen); else aGc.SetBrushColor(KRgbRed); } else { if(Angle > 180) aGc.SetBrushColor(KRgbRed); else aGc.SetBrushColor(KRgbGreen); } } const CFont* MuFonr = AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont); TInt TextHeight= MuFonr->HeightInPixels(); TInt TextWidth = MuFonr->TextWidthInPixels(Buffer); TInt StartX = (aLeftTop.iX + ((aSize - TextWidth) / 2)); TInt StartY = (aLeftTop.iY + ((aSize - TextHeight) / 2)); aGc.UseFont(MuFonr); aGc.SetPenColor(KRgbBlack); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); aGc.DrawText(Buffer,TRect(StartX,StartY,StartX + TextWidth,StartY + TextHeight),MuFonr->AscentInPixels(), CGraphicsContext::ELeft, 0); aGc.SetBrushStyle(CGraphicsContext::ENullBrush); }