forked from irwir/eMule
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreePropSheetPgFrame.cpp
185 lines (136 loc) · 3.6 KB
/
TreePropSheetPgFrame.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/********************************************************************
*
* Copyright (c) 2002 Sven Wiegand <mail@sven-wiegand.de>
*
* You can use this and modify this in any way you want,
* BUT LEAVE THIS HEADER INTACT.
*
* Redistribution is appreciated.
*
* $Workfile:$
* $Revision:$
* $Modtime:$
* $Author:$
*
* Revision History:
* $History:$
*
*********************************************************************/
#include "stdafx.h"
#include "TreePropSheetPgFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//-------------------------------------------------------------------
// class CPropPageFrame
//-------------------------------------------------------------------
CPropPageFrame::CPropPageFrame()
: m_bShowCaption(FALSE),
m_nCaptionHeight(0),
m_hCaptionIcon(NULL),
m_dwMsgFormat(DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE)
{
}
CPropPageFrame::~CPropPageFrame()
{
}
/////////////////////////////////////////////////////////////////////
// Operations
void CPropPageFrame::ShowCaption(BOOL bEnable)
{
m_bShowCaption = bEnable;
SafeUpdateWindow(CalcCaptionArea());
}
BOOL CPropPageFrame::GetShowCaption() const
{
return m_bShowCaption;
}
void CPropPageFrame::SetCaption(LPCTSTR lpszCaption, HICON hIcon /*= NULL*/)
{
m_strCaption = lpszCaption;
m_hCaptionIcon = hIcon;
SafeUpdateWindow(CalcCaptionArea());
}
CString CPropPageFrame::GetCaption(HICON *pIcon /* = NULL */) const
{
if (pIcon)
*pIcon = m_hCaptionIcon;
return m_strCaption;
}
void CPropPageFrame::SetCaptionHeight(int nCaptionHeight)
{
m_nCaptionHeight = nCaptionHeight;
SafeUpdateWindow(CalcCaptionArea());
}
int CPropPageFrame::GetCaptionHeight() const
{
return m_nCaptionHeight;
}
void CPropPageFrame::SetMsgText(LPCTSTR lpszMsg)
{
m_strMsg = lpszMsg;
SafeUpdateWindow(CalcMsgArea());
}
CString CPropPageFrame::GetMsgText() const
{
return m_strMsg;
}
void CPropPageFrame::SetMsgFormat(DWORD dwFormat)
{
m_dwMsgFormat = dwFormat;
SafeUpdateWindow(CalcMsgArea());
}
DWORD CPropPageFrame::GetMsgFormat() const
{
return m_dwMsgFormat;
}
/////////////////////////////////////////////////////////////////////
// Overridable implementation helpers
void CPropPageFrame::Draw(CDC *pDc)
{
if (GetShowCaption())
DrawCaption(pDc, CalcCaptionArea(), m_strCaption, m_hCaptionIcon);
DrawMsg(pDc, CalcMsgArea(), m_strMsg, m_dwMsgFormat);
}
CRect CPropPageFrame::CalcMsgArea()
{
ASSERT(IsWindow(GetWnd()->GetSafeHwnd()));
CRect rectMsg;
GetWnd()->GetClientRect(rectMsg);
if (GetShowCaption())
rectMsg.top+= GetCaptionHeight();
return rectMsg;
}
void CPropPageFrame::DrawMsg(CDC *pDc, CRect rect, LPCTSTR /*lpszMsg*/, DWORD /*dwFormat*/)
{
CFont *pPrevFont = (CFont*)pDc->SelectObject(AfxGetMainWnd()->GetFont());
int nPrevBkMode = pDc->SetBkMode(TRANSPARENT);
pDc->DrawText(GetMsgText(), rect, GetMsgFormat());
pDc->SetBkMode(nPrevBkMode);
pDc->SelectObject(pPrevFont);
}
CRect CPropPageFrame::CalcCaptionArea()
{
ASSERT(IsWindow(GetWnd()->GetSafeHwnd()));
CRect rectCaption;
GetWnd()->GetClientRect(rectCaption);
if (!GetShowCaption())
rectCaption.bottom = rectCaption.top;
else
rectCaption.bottom = rectCaption.top+GetCaptionHeight();
return rectCaption;
}
void CPropPageFrame::DrawCaption(CDC* /*pDC*/, CRect /*rect*/, LPCTSTR /*lpszCaption*/, HICON /*hIcon*/)
{
// should be implemented by specialized classes
}
/////////////////////////////////////////////////////////////////////
// Implementation helpers
void CPropPageFrame::SafeUpdateWindow(LPCRECT lpRect /* = NULL */)
{
if (!IsWindow(GetWnd()->GetSafeHwnd()))
return;
GetWnd()->InvalidateRect(lpRect, TRUE);
}