本文整理汇总了C++中CShape::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ CShape::Draw方法的具体用法?C++ CShape::Draw怎么用?C++ CShape::Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CShape
的用法示例。
在下文中一共展示了CShape::Draw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnDraw
void CDrawingView::OnDraw( CDC *pDC )
{
CDrawingDoc *pDoc = GetDocument();
ASSERT_VALID( pDoc );
// Enumerate through the shapes and draw each one.
POSITION position = pDoc->GetFirstShapePosition();
while( position != NULL ) {
CShape *pShape = pDoc->GetNextShape( position );
pShape->Draw( pDC );
}
}
示例2: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
cout << "도형 변호를 입력하세요. [1:사각형, 2:원]: " << endl;
int nInput = 0;
cin >> nInput;
CShape *pShape = nullptr;
if (nInput == 1)
pShape = new CRectangle;
else if (nInput == 2)
pShape = new CCircle;
else
pShape = new CShape;
// 좋은 예
pShape->Draw();
// '매우' 나쁜 예
// 가상 함수를 활용한다면 이런 코드를 작성할 이유가 없다!
CRectangle *pRect = dynamic_cast<CRectangle*>(pShape);
if (pRect != NULL)
cout << "CRectangle::Draw()" << endl;
else
{
CCircle *pCricle = dynamic_cast<CCircle*>(pShape);
if (pCricle != NULL)
cout << "CCircle::Draw()" << endl;
else
cout << "CShape::Draw()" << endl;
}
return 0;
}
示例3: Render
void CTreeWnd::Render(CDC* pDC,CRect& area)
{
//Timer t1;
//t1.start();
// Create offscreen dc & bitmap for double buffering. All
// tree m_rendering is done to this.
CRect ca;
GetClientRect(ca);
int width = mymax(m_scrollExtents.cx,ca.Width());
CRect ur;
GetUpdateRect(ur);
//CDC memdc;
//memdc.CreateCompatibleDC(pDC);
//CBitmap membm;
//membm.CreateCompatibleBitmap(pDC,width,ca.Height());
//CBitmap* pOldBM = memdc.SelectObject(&membm);
//memdc.FillSolidRect(0,0,width,ca.Height(),m_bgColour);
CDC* pDrawDC = pDC;
//pDrawDC->FillSolidRect(area,m_bgColour);
// After all the nodes have been drawn, we'll fill in the rest of the space in the
// background colour. We use this point to track where we've drawn.
CPoint bottomRight = CPoint(-1,-1);
CFont* pOldFont = (CFont*)pDrawDC->SelectStockObject(DEFAULT_GUI_FONT);
int nodesrendered=0;
bool currNodeSelected = false;
int xidx = 0;
vector<CShape*>::iterator pos;
CShape* pPrevShape = NULL;
for (pos = m_shapes.begin(); pos != m_shapes.end(); ++pos)
{
CShape *pShape = *pos;
CRect inter;
if (inter.IntersectRect(area,*pShape))
{
CTreeNode* pNode = NodeFromShape(pShape);
if (pNode && pNode->isSelected() && ( (xidx % m_pTree->numColumns()) >= m_treeColumn) )
{
// TODO: get from prefs sytem.
if (GetFocus() == this)
pShape->SetBgColour(GetSysColor(COLOR_HIGHLIGHT));
else
pShape->SetBgColour(RGB(192,192,192));
pShape->SetFgColour(RGB(255,255,255));
}
else
{
pShape->SetBgColour(m_bgColour);
}
if ( (xidx % m_pTree->numColumns()) == m_treeColumn)
{
// Fill the connecting lines area in, to make sure
// we're drawing every single pixel.
// TODO: prevent flickering here.
CRect a = *pShape;
//if (pPrevShape)
// a.left = pPrevShape->right;
//else
a.left = area.left;
pDrawDC->FillSolidRect(a,m_bgColour);
OnSetNodeDisplayProperties(pDrawDC,pNode);
SetNodeShapeIcon(pNode,pShape);
if (!pNode->isSelected())
pShape->SetFgColour(pNode->GetFgColour());
pNode->Draw(pDrawDC,*pShape);
if (pNode == m_selection.GetFocusItem())
{
pShape->Draw(pDrawDC);
// pShape->RemoveProperty(CShape::SP_FOCUS_BORDER);
}
else
pShape->Draw(pDrawDC);
}
else // non-tree columns
{
pShape->Draw(pDrawDC);
}
if (pShape->right > bottomRight.x)
bottomRight.x = pShape->right;
if (pShape->bottom > bottomRight.y)
bottomRight.y = pShape->bottom;
nodesrendered++;
}
xidx++;
//.........这里部分代码省略.........
示例4: PrintGreetingFromShape
void PrintGreetingFromShape(const CShape & shape)
{
shape.Hello();
shape.Draw(42);
}