本文整理汇总了C++中CWindowGc::DrawText方法的典型用法代码示例。如果您正苦于以下问题:C++ CWindowGc::DrawText方法的具体用法?C++ CWindowGc::DrawText怎么用?C++ CWindowGc::DrawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWindowGc
的用法示例。
在下文中一共展示了CWindowGc::DrawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawHotKeyText
/**
* 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));
}
示例2: DrawCurrentDay
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);
}
示例3: WriteName
/**
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 ) ;
}
示例4: DrawTexts
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();
}
}
示例5: DrawSchedule
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));
}
示例6: LoadsOfText
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);
}
示例7: DrawWeek
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;
}
}
示例8: DrawQuitCommand
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);
}
示例9: DrawPoints
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);
}
示例10: DrawLeftAdornment
/**
* 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);
}
}
}
示例11: Draw
/****************************************************************************\
| 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();
}
示例12: DrawRightAdornment
/**
* 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));
}
}
示例13: DrawDay
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++;
}
}
示例14: DrawWeekName
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));
}
示例15: DrawText
/**
* 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);
}