
#include "stdafx.h"
#include "CTextRecord.h"

const int TEXT_HEIGHT = 20;

C_TEXT_RECORD_0::C_TEXT_RECORD_0()
{
	_write = 1;
}

C_TEXT_RECORD_0::~C_TEXT_RECORD_0()
{

}

void C_TEXT_RECORD_0::Add(std::string text)
{
	if(!_write) return;
	_vBuffer.push_back(text);
	_Prekresli();
}

void C_TEXT_RECORD_0::Add(std::string text,int value)
{
	static std::string sMin;
	static int iMin=0;
	if(!_write) return;
	//if(text == sMin && value == iMin) return;
	sMin = text;
	iMin = value;
	std::string pridej=text;
	//pridej += (int)value;
	char hodnota[50];
	sprintf(hodnota,"%d",value);
	pridej += hodnota;
	_vBuffer.push_back(pridej);
	_Prekresli();
}

void C_TEXT_RECORD_0::Add(std::string text, float value)
{
	static std::string sMin;
	static int iMin=0;
	if(!_write) return;

	//sMin = text;
	//iMin = value;
	std::string pridej=text;
	//pridej += (int)value;
	char hodnota[50];
	sprintf(hodnota,"%f",value);
	pridej += hodnota;
	_vBuffer.push_back(pridej);
	_Prekresli();
}

void C_TEXT_RECORD_0::DrawText(HWND hWnd)
{
	if(!_write) return;
	HDC hDC;
	int zacpos = 0;
	const int MAX_HODNOT=10;

	hDC = GetDC(hWnd);
	if(_vBuffer.size() > MAX_HODNOT) zacpos = (_vBuffer.size() - MAX_HODNOT) * TEXT_HEIGHT;
	for(int i=0;i < _vBuffer.size();i++)
	{
		TextOut(hDC,10,-zacpos+i*TEXT_HEIGHT,_vBuffer[i].c_str(),_vBuffer[i].length());
	}
	ReleaseDC(hWnd,hDC);
}