1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| void CCondition::drawFig(CDC* pDC, CProgTreeView* pView, CPoint _pDepth)
{
//we're taking 10 as font width
CRect rect;
if (this->getContent().GetLength() > 2)
{
int iTmpSize = 10 * this->getContent().GetLength();
rect.SetRect(_pDepth.x - (iTmpSize / 2) , _pDepth.y, _pDepth.x + (iTmpSize / 2), _pDepth.y + 80);
}
else
rect.SetRect(_pDepth.x - 10 , _pDepth.y, _pDepth.x + 10, _pDepth.y + 80);
CFigLozenge* pLoz = new CFigLozenge(rect);
pLoz->setText(this->getContent());
pLoz->Draw(pDC);
//pLoz->putDrawer(pDC,CFigure::selected);
pLoz->pCondition = this;
CFigure* pFig = pLoz;
pView->GetDocument()->Add(pFig);
CRect rct = pView->GetDocument()->olListFigures.GetTail()->oPosition;
int y = rct.bottom + 20;
CRect cltRect;
pView->GetClientRect(&cltRect);
if (getWithElse() == TRUE)
{
pDC->MoveTo(pLoz->oPosition.left,_pDepth.y + 40);
pDC->LineTo((cltRect.Width() / 4), _pDepth.y + 40);
pDC->LineTo((cltRect.Width() / 4), _pDepth.y + 100);
pDC->ExtTextOutA((cltRect.Width() / 4),_pDepth.y + 25, ETO_CLIPPED, NULL, _T("IF"), 2 , NULL);
//arrow
pDC->LineTo((cltRect.Width() / 4) - 7, _pDepth.y + 100 - 9);
pDC->MoveTo((cltRect.Width() / 4), _pDepth.y + 100);
pDC->LineTo((cltRect.Width() / 4) + 7, _pDepth.y + 100 - 9);
//
pDC->MoveTo(pLoz->oPosition.right,_pDepth.y + 40);
pDC->LineTo(3 * (cltRect.Width() / 4), _pDepth.y + 40);
pDC->LineTo(3 * (cltRect.Width() / 4), _pDepth.y + 100);
pDC->ExtTextOutA(3 * (cltRect.Width() / 4), _pDepth.y + 25, ETO_CLIPPED, NULL, _T("ELSE"), 4 , NULL);
//arrow
pDC->LineTo((3 * (cltRect.Width() / 4)) - 7, _pDepth.y + 100 - 9);
pDC->MoveTo(3 * (cltRect.Width() / 4), _pDepth.y + 100);
pDC->LineTo((3 * (cltRect.Width() / 4)) + 7, _pDepth.y + 100 - 9);
//
this->IfBlock.setKind(IF);
this->IfBlock.setRememberLozDim(pLoz->oPosition);
this->IfBlock.drawFig(pDC, pView, CPoint((cltRect.Width() / 4),y));
this->ElseBlock.setKind(ELSE);
this->ElseBlock.setRememberLozDim(pLoz->oPosition);
this->ElseBlock.iLastDownY = pView->GetDocument()->olListFigures.GetTail()->oPosition.top;
this->ElseBlock.iLastUpY = pView->GetDocument()->olListFigures.GetTail()->oPosition.bottom;
this->ElseBlock.drawFig(pDC,pView, CPoint((cltRect.Width() / 4) * 3,y));
}
else
{
pDC->MoveTo(cltRect.Width() / 2,rct.bottom);
pDC->LineTo((cltRect.Width() / 2),rct.bottom + 20);
pDC->ExtTextOutA((cltRect.Width() / 2) + 30, rct.bottom + 3, ETO_CLIPPED, NULL, _T("IF"), 2 , NULL);
//arrow
pDC->LineTo((cltRect.Width() / 2) - 7, rct.bottom + 20 - 9 );
pDC->MoveTo((cltRect.Width() / 2),rct.bottom + 20);
pDC->LineTo((cltRect.Width() / 2) + 7, rct.bottom + 20 - 9 );
this->IfBlock.setKind(IFWITHOUTELSE);
this->IfBlock.setRememberLozDim(pLoz->oPosition);
this->IfBlock.drawFig(pDC, pView, CPoint((cltRect.Width() / 2),y));
}
} |