Select Git revision
field.cpp 2.29 KiB
#include "field.hpp"
#include <string>
using namespace genv;
Field::Field(Application* parent, int x, int y, int meret, int index, int ertek):
Widget(parent, x, y, meret, meret), _index(index), _ertek(ertek),
_fix(ertek), _aura(false), _helytelen(false)
{
}
void Field::rajzol() const
{
/// hatter
if (_kijelolt)
{
if (_fix)
gout << color(dark_grey);
else
gout << color(dark_purple);
}
else if (_aura)
{
if (_fix)
gout << color(mid_grey);
else
gout << color(mid_purple);
}
else
{
if (_fix)
gout << color(light_grey);
else
gout << color(light_purple);
}
gout << move_to(_x,_y) << box(_szel,_mag);
/// keret, szoveg
if (_kijelolt)
{
if (_fix)
gout << color(light_grey);
else
gout << color(light_purple);
}
else
{
if (_fix)
gout << color(dark_grey);
else
gout << color(dark_purple);
}
// keret
gout << move_to(_x,_y) << line(_szel,0) << line(0,_mag) << line(-_szel,0) << line(0,-_mag);
// vonalak
if ((_index%9) % 3 ==0) // bal
gout << move_to(_x+1, _y) << line(0,_mag);
if ((_index%9) % 3 ==2) // jobb
gout << move_to(_x+_szel-2, _y) << line(0,_mag);
if ((_index/9) % 3 ==0) // font
gout << move_to(_x, _y+1) << line(_szel,0);
if ((_index/9) % 3 ==2) // lent
gout << move_to(_x, _y+_mag-2) << line(_szel,0);
// szoveg
if (_helytelen)
gout << color(255,0,0);
gout << font("LiberationSans-Regular.ttf",_szel/3);
if (_ertek)
{
gout << move_to(_x+ (_szel-gout.twidth(std::to_string(_ertek)))/2,
_y+(_mag-gout.cascent()-gout.cdescent())/2)
<< text(std::to_string(_ertek));
//gout << text(" ") << text(std::to_string(_aura));
}
}
void Field::kezel(genv::event ev)
{
_kijelolt=!_kijelolt;
}
int Field::get_ertek()
{
return _ertek;
}
void Field::set_ertek(int uj)
{
if (!_fix)
_ertek=uj;
}
void Field::set_aura_true()
{
_aura=true;
}
void Field::set_aura_false()
{
_aura=false;
}