-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcell.cpp
More file actions
59 lines (46 loc) · 1.17 KB
/
cell.cpp
File metadata and controls
59 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "cell.h"
//
#include "figure.h"
#include <iostream>
// #include "pawn.h"
using namespace Graph_lib;
Cell::Cell(Point xy, Callback cb, Type t) : Button{xy, size, size, "", cb}, type{t} {}
void Cell::reset_color()
{
if (!pw)
error("Cell is not attached to a window");
if (is_black())
pw->color(chess_green);
else
pw->color(chess_white);
}
void Cell::attach(Graph_lib::Window& win)
{
Button::attach(win);
reset_color();
}
Figure& Cell::detach_figure()
{
Figure* ch = figure;
figure = nullptr;
ch->detach();
return *ch;
}
void Cell::attach_figure(Figure& ch)
{
ch.attach(*this);
figure = &ch;
}
//removed const and i don't know how it will turn out
/*const*/ Figure& Cell::get_figure() // обязательно нужна проверка не нулевой ли указатель checker
{
return *figure;
}
Coordinate Cell::location() const
{
int N = 8; //Couldn't find a way to properly use
//the static constant from "board.h"
char x = char((loc.x - DFTBOF)/size + a_ascii);
int y = N - (loc.y - DFTBOF)/size;
return Coordinate{x,y};
}