本文整理汇总了C++中CContext::GetTextExtent方法的典型用法代码示例。如果您正苦于以下问题:C++ CContext::GetTextExtent方法的具体用法?C++ CContext::GetTextExtent怎么用?C++ CContext::GetTextExtent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContext
的用法示例。
在下文中一共展示了CContext::GetTextExtent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Paint
// Display the power item on the screen!
void CDrawPower::Paint(CContext &dc,paint_options options)
{
int spacing;
CDSize size;
CDPoint pa,pb,pc,pd,pos=m_point_a;
dc.SelectFont(*m_pDesign->GetOptions()->GetFont(fPIN),2);
dc.SetROP2(R2_COPYPEN);
dc.SetTextColor(m_pDesign->GetOptions()->GetUserColor().Get( CUserColor::POWER));
size=dc.GetTextExtent(str);
if (which!=0)
spacing=POWER_SIZE*2+POWER_SIZE/4;
else
spacing=POWER_SIZE+POWER_SIZE/4;
// Find out which way round the power object goes
switch (dir) {
case 0: // Top
pa=CDPoint(pos.x,pos.y-POWER_SIZE);
pb=CDPoint(pos.x-POWER_SIZE/2,pos.y-POWER_SIZE);
pc=CDPoint(pos.x+POWER_SIZE/2+1,pos.y-POWER_SIZE);
pd=CDPoint(pos.x,pos.y-POWER_SIZE*2);
TextPos = CDPoint(pos.x-size.cx/2,pos.y-spacing);
break;
case 1: // Bottom
pa=CDPoint(pos.x,pos.y+POWER_SIZE);
pb=CDPoint(pos.x-POWER_SIZE/2,pos.y+POWER_SIZE);
pc=CDPoint(pos.x+POWER_SIZE/2+1,pos.y+POWER_SIZE);
pd=CDPoint(pos.x,pos.y+POWER_SIZE*2);
TextPos = CDPoint(pos.x-size.cx/2,pos.y+spacing+size.cy);
break;
case 2: // Left
pa=CDPoint(pos.x-POWER_SIZE,pos.y);
pb=CDPoint(pos.x-POWER_SIZE,pos.y-POWER_SIZE/2);
pc=CDPoint(pos.x-POWER_SIZE,pos.y+POWER_SIZE/2+1);
pd=CDPoint(pos.x-POWER_SIZE*2,pos.y);
TextPos=CDPoint(pos.x-size.cx-spacing,pos.y+size.cy/2);
break;
case 3: // Right
pa=CDPoint(pos.x+POWER_SIZE,pos.y);
pb=CDPoint(pos.x+POWER_SIZE,pos.y-POWER_SIZE/2);
pc=CDPoint(pos.x+POWER_SIZE,pos.y+POWER_SIZE/2+1);
pd=CDPoint(pos.x+POWER_SIZE*2,pos.y);
TextPos=CDPoint(pos.x+spacing,pos.y+size.cy/2);
break;
}
dc.TextOut(str,TextPos,options);
TextEnd = CDPoint(TextPos.x + size.cx,TextPos.y - size.cy);
switch (options)
{
case draw_selected:
case draw_selectable:
dc.SelectPen(PS_SOLID,1,cSELECT);
break;
default:
dc.SelectPen(PS_SOLID,1,cLINE);
}
dc.SelectBrush();
// Draw the main line of the power item
switch (which) {
case 0: // Draw the Bar
dc.MoveTo(pb);
dc.LineTo(pc);
break;
case 1: // Draw the Circle
dc.Ellipse(CDRect(pb.x-(pa.x-pd.x),pb.y-(pa.y-pd.y),pc.x,pc.y));
break;
case 2: // Draw the Wave
// The PolyBezier function is not implemented in MFC!
// So this hack has to be used....
{
CDPoint pts[4];
pts[0]=CDPoint(pb.x+(pd.x-pa.x)/2,pb.y+(pd.y-pa.y)/2);
pts[1]=CDPoint(pd.x+(pb.x-pa.x)/2,pd.y+(pb.y-pa.y)/2);
pts[2]=CDPoint(pa.x+(pc.x-pa.x)/2,pa.y+(pc.y-pa.y)/2);
pts[3]=CDPoint(pc.x-(pa.x-pd.x)/2,pc.y-(pa.y-pd.y)/2);
dc.PolyBezier(pts,4);
}
break;
case 3: // Draw the Arrow
dc.MoveTo(pb);
dc.LineTo(pc);
dc.MoveTo(pb);
dc.LineTo(pd);
dc.LineTo(pc);
break;
case 4: // Draw the Earth
dc.MoveTo(pb);
dc.LineTo(pc);
dc.MoveTo(CDPoint(pb.x-(pb.x-pd.x)/2,pb.y-(pb.y-pd.y)/2));
dc.LineTo(CDPoint(pc.x-(pc.x-pd.x)/2,pc.y-(pc.y-pd.y)/2));
dc.MoveTo(CDPoint(pd.x-(pb.x-pa.x)/4,pd.y-(pb.y-pa.y)/4));
//.........这里部分代码省略.........