-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisible.cpp
More file actions
98 lines (85 loc) · 1.96 KB
/
Visible.cpp
File metadata and controls
98 lines (85 loc) · 1.96 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "stdafx.h"
#include "Visible.h"
void Visible::drawRect(HDC hdc, RECT rect, DrawStyle drawStyle) const
{
HGDIOBJ oldPen = SelectObject(hdc, getDrawStyle(drawStyle));
POINT oldPoint;
MoveToEx(hdc, rect.left, rect.top, &oldPoint);
LineTo(hdc, rect.right, rect.top);
LineTo(hdc, rect.right, rect.bottom);
LineTo(hdc, rect.left, rect.bottom);
LineTo(hdc, rect.left, rect.top);
MoveToEx(hdc, oldPoint.x, oldPoint.y, NULL);
SelectObject(hdc, oldPen);
}
HGDIOBJ Visible::getDrawStyle(DrawStyle drawStyle) const
{
if (drawStyles[drawStyle] == NULL)
{
drawStyles[drawStyle] = createDrawStyle(drawStyle);
}
return drawStyles[drawStyle];
}
HGDIOBJ Visible::createDrawStyle(DrawStyle drawStyle) const
{
return CreatePen(getPenStyle(drawStyle), getPenWidth(drawStyle), getColor(drawStyle));
}
int Visible::getPenStyle(DrawStyle drawStyle) const
{
switch(drawStyle)
{
case dsDefault:
default:
return PS_SOLID;
}
}
int Visible::getPenWidth(DrawStyle drawStyle) const
{
switch(drawStyle)
{
case dsCalculatorMarkedCell:
return 3;
case dsCalculatorVariantCell:
return 2;
default:
return 1;
}
}
COLORREF Visible::getColor(DrawStyle drawStyle) const
{
switch(drawStyle)
{
case dsBorder:
case dsInputZoneCell:
return RGB(100,100,100);
case dsCalculatorBorder:
return RGB(0,20,255);
case dsCalculatorCellBorder:
return RGB(0,200,255);
case dsCalculatorMarkedCell:
case dsInputZoneCurrent:
case dsResultBorder:
return RGB(0,255,0);
case dsCalculatorVariantCell:
case dsInputZoneNext:
return RGB(255,255,0);
case dsInputZoneInvalidCell:
return RGB(255, 100, 0);
default:
return RGB(0,0,0);
}
}
Box Visible::shiftBox(Box currentBox, RECT rect) const
{
currentBox.transfer(currentBox.width(),0);
if (currentBox.bottomRight.x > (rect.right - rect.left))
{
currentBox.transfer( - currentBox.topLeft.x, currentBox.height());
}
return currentBox;
}
Box Visible::realBox(RECT rect, Box box) const
{
box.transfer(rect.left, rect.top);
return box;
}