Beispiel #1
0
void CTetrad_L::DrawOnScreen(const TRectanglei& rect)
{
	int XPos = (rect.GetWidth() - 3*BLOCK_WIDTH)/2 + rect.m_Left;
	int YPos = (rect.GetHeight() - 2*BLOCK_HEIGHT)/2 + rect.m_Top;
	m_pBlockImg->BlitImage(XPos,YPos);
	m_pBlockImg->BlitImage(XPos+BLOCK_WIDTH,YPos);
	m_pBlockImg->BlitImage(XPos+2*BLOCK_WIDTH,YPos);
	m_pBlockImg->BlitImage(XPos,YPos+BLOCK_HEIGHT);
}
void CTextControl::Draw()
{
    TRectanglei textSize = m_pFont->GetTextSize(m_strText);
    int yOffset = m_rectPosition.GetHeight()/2+textSize.GetHeight()/2;
    int xOffset = 0;
    switch (m_Alignement)
    {
    case TALeft:
        break;
    case TACenter:
        xOffset = (m_rectPosition.GetWidth()-textSize.GetWidth())/2;
        break;
    case TARight:
        xOffset = m_rectPosition.GetWidth()-textSize.GetWidth();
        break;
    }

    // TODO: check why we need to correct the ypos ?
    int xPos = m_rectPosition.m_Left + xOffset;
    int yPos = m_rectPosition.m_Top + yOffset - 5;
    m_pFont->DrawText(m_strText,xPos,yPos,m_fRed,m_fGreen,m_fBlue);
}