-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKey.cpp
More file actions
45 lines (37 loc) · 1.05 KB
/
Key.cpp
File metadata and controls
45 lines (37 loc) · 1.05 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
#include "Key.h"
Key::Key(wxPoint pos, unsigned edgelength,Symbol *symbol):_position(pos),_size(wxSize(edgelength,edgelength)),_textColor(wxColor(0,0,0)),_backColor(wxColor(255,255,255)),_symbol(symbol)
{
_center =wxPoint(_position.x + (_size.GetWidth()*0.25),_position.y + (_size.GetHeight()*0.25));
}
Key::~Key(void)
{
}
void Key::Draw(wxPaintDC *dc)
{
wxBrush brush(_backColor);
wxFont font(18, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
dc->SetBrush(brush);
dc->DrawRectangle(_position.x,_position.y,_size.GetWidth(),_size.GetHeight());
dc->SetFont(font);
dc->SetTextForeground(_textColor);
dc->SetTextBackground(_backColor);
dc->DrawText(wxString(_symbol->GetLabel()),_center.x, _center.y);
}
bool Key::HitTest(wxPoint test)
{
bool hit = false;
if((test.x < _position.x + _size.GetWidth()) && (test.x > _position.x))
{
if(test.y < _position.y + _size.GetHeight() && test.y > _position.y)
{
hit = true;
}
}
return hit;
}
void Key::ReverseColors()
{
wxColor temp = _textColor;
_textColor = _backColor;
_backColor = temp;
}