Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа 25 / lab22 / TextEntity
.cpp
/********************************************************************************/
#include "stdafx.h"
#include "TextEntity.h"
#include <iostream>
/********************************************************************************/
CTextEntity::CTextEntity( const CString iT,
const int iX, const int iY)
: CPointEntity(iX, iY)
{
setText( iT );
Height=8;
}
/********************************************************************************/
CTextEntity::~CTextEntity()
{
// Интересно, а надо ли как-нибудь удалять эту строку?
}
/********************************************************************************/
CString CTextEntity::getText() const
{
return mText;
}
/********************************************************************************/
void CTextEntity::setText( const CString iT )
{
mText = iT;
}
/********************************************************************************/
void CTextEntity::SetHeight(int _H)
{Height=_H;}
/********************************************************************************/
int CTextEntity::GetHeight() const
{return Height;}
/********************************************************************************/
void CTextEntity::Printfig(std::ostream& os)
{
os << "Text:" <<std::endl;
os << " X=" << mX<<std::endl;
os << " Y=" << mY<<std::endl;
os << " T=" << mText<<std::endl;
}
int CTextEntity::getNumType()
{ return 3;
}
/********************************************************************************/
void CTextEntity::Draw(CDC* pDC, Shape* figure)
{
COLORREF aColor=RGB(0,0,0);
if(this == figure)
{aColor = RGB(255,0,0);}
pDC->SetTextColor(aColor);
pDC->TextOut(getX(),getY(),getText());
Width=pDC->GetTextExtent(getText()).cx;
}
CRect CTextEntity::GetBoundRect()
{
return CRect(getX(),getY(),getX()+Width,getY()+2*GetHeight());
}
void CTextEntity::writeAr(CArchive& ar)
{ar<<getNumType();
ar<<getX();
ar<<getY();
ar<<getText();
ar<<GetHeight();
}
void CTextEntity::readAr(CArchive& ar)
{CString _str;
int _H,_X,_Y;
ar>>_X;
ar>>_Y;
ar>>_str;
ar>>_H;
setX(_X);
setY(_Y);
setText(_str);
SetHeight(_H);
}
CString CTextEntity::getName()
{return "Text";}
Соседние файлы в папке lab22