-
Notifications
You must be signed in to change notification settings - Fork 0
/
CalendarBar.cpp
143 lines (100 loc) · 3.48 KB
/
CalendarBar.cpp
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include "stdafx.h"
#include "CalendarBar.h"
#include "Telar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const int nBorderSize = 10;
/////////////////////////////////////////////////////////////////////////////
// CCalendarBar
CCalendarBar::CCalendarBar()
{
m_nMyCalendarsY = 0;
}
CCalendarBar::~CCalendarBar()
{
}
BEGIN_MESSAGE_MAP(CCalendarBar, CWnd)
ON_WM_CREATE()
ON_WM_ERASEBKGND()
ON_WM_SIZE()
ON_WM_PAINT()
ON_WM_SETTINGCHANGE()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCalendarBar message handlers
int CCalendarBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy(0, 0, 0, 0);
m_wndCalendar.Create(WS_CHILD | WS_VISIBLE, rectDummy, this, 1);
CBitmap bmp;
bmp.LoadBitmap(IDB_PAGES_SMALL_HC);
m_Images.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 0);
m_Images.Add(&bmp, RGB(255, 0, 255));
return 0;
}
BOOL CCalendarBar::OnEraseBkgnd(CDC* /*pDC*/)
{
return TRUE;
}
void CCalendarBar::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
int nMyCalendarsHeight = 70;
if (m_wndCalendar.GetSafeHwnd() != NULL)
{
m_wndCalendar.SetWindowPos(NULL, nBorderSize, nBorderSize, cx - 2 * nBorderSize, cy - 2 * nBorderSize - nMyCalendarsHeight - 10, SWP_NOZORDER | SWP_NOACTIVATE);
}
m_nMyCalendarsY = cy - nMyCalendarsHeight;
}
BOOL CCalendarBar::Create(const RECT& rect, CWnd* pParentWnd, UINT nID)
{
return CWnd::Create(NULL, _T(""), WS_CHILD | WS_VISIBLE, rect, pParentWnd, nID);
}
void CCalendarBar::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rectClient;
GetClientRect(rectClient);
dc.FillRect(rectClient, &afxGlobalData.brWindow);
if (rectClient.bottom - m_nMyCalendarsY > 0)
{
CRect rectMyCalendarsCaption = rectClient;
rectMyCalendarsCaption.top = m_nMyCalendarsY;
rectMyCalendarsCaption.bottom = rectMyCalendarsCaption.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2;
COLORREF clrText = CMFCVisualManager::GetInstance()->OnDrawPaneCaption(&dc, NULL, FALSE, rectMyCalendarsCaption, CRect(0, 0, 0, 0));
CPen* pOldPen = dc.SelectObject(&afxGlobalData.penBarShadow);
dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.top);
dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.top);
dc.SelectStockObject(BLACK_PEN);
dc.MoveTo(rectMyCalendarsCaption.left - 1, rectMyCalendarsCaption.bottom);
dc.LineTo(rectMyCalendarsCaption.right, rectMyCalendarsCaption.bottom);
dc.SelectObject(pOldPen);
CRect rectText = rectMyCalendarsCaption;
rectText.DeflateRect(10, 0);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(clrText);
CFont* pOldFont = dc.SelectObject(&afxGlobalData.fontRegular);
BOOL bNameValid;
CString str;
bNameValid = str.LoadString(IDS_MYCALENDARS);
ASSERT(bNameValid);
dc.DrawText(str, rectText, DT_VCENTER | DT_LEFT | DT_SINGLELINE);
CRect rectCalendar = rectClient;
rectCalendar.top = rectMyCalendarsCaption.bottom + 5;
rectCalendar.bottom = rectCalendar.top + afxGlobalData.GetTextHeight(TRUE) * 3 / 2 - 5;
dc.FillSolidRect(rectCalendar, RGB(255, 255, 213));
rectCalendar.DeflateRect(20, 0);
m_Images.Draw(&dc, 3, rectCalendar.TopLeft(), 0);
rectCalendar.left += 20;
bNameValid = str.LoadString(IDS_CALENDAR);
ASSERT(bNameValid);
dc.SetTextColor(afxGlobalData.clrHotLinkNormalText);
dc.DrawText(str, rectCalendar, DT_VCENTER | DT_LEFT | DT_SINGLELINE);
dc.SelectObject(pOldFont);
}
}