forked from CobaltFusion/DebugViewPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimelineDC.cpp
More file actions
82 lines (71 loc) · 2.33 KB
/
Copy pathTimelineDC.cpp
File metadata and controls
82 lines (71 loc) · 2.33 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
// (C) Copyright Gert-Jan de Vos and Jan Wilmans 2016.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "DebugViewppLib/TimelineDC.h"
#include <string>
#include <cassert>
namespace fusion {
namespace gdi {
// todo: find out how this works (DECLARE_HANDLE(HDC);
// ::GetClientRect(m_hDC, &rect); is a compiler-time error, which is pretty cool
RECT TimelineDC::GetClientArea() const
{
RECT rect;
GetClipBox(&rect);
return rect;
}
void TimelineDC::DrawTextOut(const std::wstring& str, int x, int y)
{
TextOut(x, y, str.c_str(), static_cast<int>(str.size()));
}
void TimelineDC::DrawPolygon(const std::vector<POINT>& points)
{
Polygon(points.data(), static_cast<int>(points.size()));
}
void TimelineDC::DrawTimeline(const std::wstring& name, Pixel x, Pixel y, int width, COLORREF color)
{
CPen pen(CreatePen(PS_SOLID, 1, color));
SelectPen(pen);
DrawTextOut(name, x + 15, y - 15);
Rectangle(x + s_leftTextAreaBorder, y, x + s_leftTextAreaBorder + width, y + 2);
}
void TimelineDC::DrawFlag(const std::wstring& /* tooltip */, int x, int y)
{
// tooltip not implemented, see https://www.codeproject.com/Articles/5411/CToolTipDialog-class-a-simple-WTL-class-to-enable
// and https://docs.microsoft.com/en-gb/windows/desktop/Controls/using-tooltip-contro
// and https://docs.microsoft.com/en-us/windows/desktop/controls/implement-tracking-tooltips
MoveTo(x, y);
LineTo(x, y - 20);
LineTo(x + 7, y - 16);
LineTo(x, y - 12);
}
void TimelineDC::DrawSolidFlag(const std::wstring& /* tooltip */, int x, int y)
{
DrawPolygon({{x, y - 20}, {x + 7, y - 16}, {x, y - 12}});
MoveTo(x, y);
LineTo(x, y - 20);
}
void TimelineDC::DrawSolidFlag(const std::wstring& tooltip, int x, int y, COLORREF border, COLORREF fill)
{
CPen pen(CreatePen(PS_SOLID, 1, border));
SelectPen(pen);
CBrush b(CreateSolidBrush(fill));
SelectBrush(b);
DrawSolidFlag(tooltip, x, y);
}
void TimelineDC::DrawFlag(const std::wstring& tooltip, int x, int y, COLORREF color, bool solid)
{
CPen pen(CreatePen(PS_SOLID, 1, color));
SelectPen(pen);
if (solid)
{
DrawSolidFlag(tooltip, x, y);
}
else
{
DrawFlag(tooltip, x, y);
}
}
} // namespace gdi
} // namespace fusion