forked from Paremo/foo_bbookmark
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader_static.cpp
More file actions
74 lines (60 loc) · 1.58 KB
/
header_static.cpp
File metadata and controls
74 lines (60 loc) · 1.58 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
#include "stdafx.h"
#include "libPPUI/PaintUtils.h"
#include "libPPUI/wtl-pp.h"
#include "header_static.h"
using PaintUtils::PaintSeparatorControl;
HeaderStatic::HeaderStatic() :
m_iLeftSpacing(8),
m_clrText(GetSysColor(COLOR_CAPTIONTEXT))
{
//..
}
void HeaderStatic::OnPaint(CDCHandle dcDummy)
{
PaintSeparatorControl(*this);
}
BOOL HeaderStatic::SubclassWindow(HWND hWnd)
{
if (!CWindowImpl<HeaderStatic, CStatic>::SubclassWindow(hWnd)) {
return FALSE;
}
SetTextColor(GetSysColor(COLOR_CAPTIONTEXT));
LOGFONTW lf;
CWindowDC dc(core_api::get_main_window());
CTheme wtheme;
HTHEME theme = wtheme.OpenThemeData(core_api::get_main_window(), L"TEXTSTYLE");
GetThemeFont(theme, dc, TEXT_BODYTEXT, 0, TMT_FONT, &lf);
if (m_headerFont) {
m_headerFont.DeleteObject();
}
m_headerFont = CreateFontIndirectW(&lf);
CLogFont newcFont(m_headerFont);
newcFont.MakeLarger(2);
newcFont.MakeBolder(2);
m_headerFont.DeleteObject();
auto hf = newcFont.CreateFontIndirect();
m_headerFont.Attach(hf);
return TRUE;
}
void HeaderStatic::PaintHeader()
{
CPaintDC dc(m_hWnd);
CRect rect;
GetClientRect(&rect);
CString strText;
GetWindowText(strText);
SetFont(m_headerFont);
DWORD dwStyle = GetStyle();
if ((dwStyle & SS_CENTER) == SS_CENTER)
dc.DrawText(strText, -1, rect, DT_SINGLELINE | DT_VCENTER | DT_CENTER);
else if((dwStyle & SS_LEFT) == SS_LEFT)
{
rect.left += m_iLeftSpacing;
dc.DrawText(strText, -1, rect, DT_SINGLELINE | DT_VCENTER | DT_LEFT);
}
else // Right
{
rect.right -= m_iLeftSpacing;
dc.DrawText(strText, -1, rect, DT_SINGLELINE | DT_VCENTER | DT_RIGHT);
}
}