Скачиваний:
14
Добавлен:
01.05.2014
Размер:
1.74 Кб
Скачать
// Copyright (C) 1991 - 1999 Rational Software Corporation
//////////////////////////////////////////////////////////////////////////
#include "Text.h"

#include <ostream.h>
//////////////////////////////////////////////////////////////////////////
class ostream;
//////////////////////////////////////////////////////////////////////////

list<Text*> Text::_texts;
//////////////////////////////////////////////////////////////////////////

Text::Text( std::string content, float x, float y )
: Shape(x, y)
{
    _content = content;
    cout<<"[text] text created"<<endl;
}


Text* Text::create(std::string content, float x, float y)
{
    // проверяем, нет ли уже такого текста
    using namespace std;
    list<Text*>::iterator iter;
    for (iter = _texts.begin(); iter != _texts.end(); iter++)
    {
        Text* text = *iter;
        if (
            text->_x == x &&
            text->_y == y &&
            text->_content.compare(content) == 0
            )
        {   // такой есть
            return text;
        }
    }
    // не нашли - создаем новый
    Text* text = new Text(content, x, y);
    _texts.push_back(text);
    return text;
}


Text::~Text()
{
    _texts.remove(this);
	cout<<"[text] text destroyed"<<endl;
}


ostream& Text::speak(ostream& os) const
{
    return Shape::speak(os)
        <<"[text] text content: "
        <<_content.c_str()<<endl;
}


const std::string& Text::get__content() const
{
    return _content;
}


void Text::set__content(std::string& value)
{
    _content = value;
    return;
}


float Text::Area() const
{
    return -1;
}

//////////////////////////////////////////////////////////////////////////
Соседние файлы в папке lab_1