1 /********************************************************************
\r
3 * Copyright (c) 2002 Sven Wiegand <mail@sven-wiegand.de>
\r
5 * You can use this and modify this in any way you want,
\r
6 * BUT LEAVE THIS HEADER INTACT.
\r
8 * Redistribution is appreciated.
\r
18 *********************************************************************/
\r
21 #include "PropPageFrame.h"
\r
24 #define new DEBUG_NEW
\r
26 static char THIS_FILE[] = __FILE__;
\r
31 namespace TreePropSheet
\r
35 //-------------------------------------------------------------------
\r
36 // class CPropPageFrame
\r
37 //-------------------------------------------------------------------
\r
39 CPropPageFrame::CPropPageFrame()
\r
40 : m_bShowCaption(FALSE),
\r
41 m_nCaptionHeight(0),
\r
42 m_hCaptionIcon(NULL),
\r
43 m_dwMsgFormat(DT_CENTER|DT_VCENTER|DT_NOPREFIX|DT_SINGLELINE)
\r
48 CPropPageFrame::~CPropPageFrame()
\r
53 /////////////////////////////////////////////////////////////////////
\r
57 void CPropPageFrame::ShowCaption(BOOL bEnable)
\r
59 m_bShowCaption = bEnable;
\r
60 SafeUpdateWindow(CalcCaptionArea());
\r
64 BOOL CPropPageFrame::GetShowCaption() const
\r
66 return m_bShowCaption;
\r
70 void CPropPageFrame::SetCaption(LPCTSTR lpszCaption, HICON hIcon /*= NULL*/)
\r
72 m_strCaption = lpszCaption;
\r
73 m_hCaptionIcon = hIcon;
\r
74 SafeUpdateWindow(CalcCaptionArea());
\r
78 CString CPropPageFrame::GetCaption(HICON *pIcon /* = NULL */) const
\r
81 *pIcon = m_hCaptionIcon;
\r
82 return m_strCaption;
\r
86 void CPropPageFrame::SetCaptionHeight(int nCaptionHeight)
\r
88 m_nCaptionHeight = nCaptionHeight;
\r
89 SafeUpdateWindow(CalcCaptionArea());
\r
93 int CPropPageFrame::GetCaptionHeight() const
\r
95 return m_nCaptionHeight;
\r
99 void CPropPageFrame::SetMsgText(LPCTSTR lpszMsg)
\r
101 m_strMsg = lpszMsg;
\r
102 SafeUpdateWindow(CalcMsgArea());
\r
106 CString CPropPageFrame::GetMsgText() const
\r
112 void CPropPageFrame::SetMsgFormat(DWORD dwFormat)
\r
114 m_dwMsgFormat = dwFormat;
\r
115 SafeUpdateWindow(CalcMsgArea());
\r
119 DWORD CPropPageFrame::GetMsgFormat() const
\r
121 return m_dwMsgFormat;
\r
125 /////////////////////////////////////////////////////////////////////
\r
126 // Overridable implementation helpers
\r
128 void CPropPageFrame::Draw(CDC *pDc)
\r
130 if (GetShowCaption())
\r
131 DrawCaption(pDc, CalcCaptionArea(), m_strCaption, m_hCaptionIcon);
\r
132 DrawMsg(pDc, CalcMsgArea(), m_strMsg, m_dwMsgFormat);
\r
136 CRect CPropPageFrame::CalcMsgArea()
\r
138 ASSERT(IsWindow(GetWnd()->GetSafeHwnd()));
\r
141 GetWnd()->GetClientRect(rectMsg);
\r
142 if (GetShowCaption())
\r
143 rectMsg.top+= GetCaptionHeight();
\r
149 void CPropPageFrame::DrawMsg(CDC *pDc, CRect rect, LPCTSTR /*lpszMsg*/, DWORD /*dwFormat*/)
\r
151 CFont *pPrevFont = dynamic_cast<CFont*>(pDc->SelectStockObject(DEFAULT_GUI_FONT));
\r
152 int nPrevBkMode = pDc->SetBkMode(TRANSPARENT);
\r
154 pDc->DrawText(GetMsgText(), rect, GetMsgFormat());
\r
156 pDc->SetBkMode(nPrevBkMode);
\r
157 pDc->SelectObject(pPrevFont);
\r
161 CRect CPropPageFrame::CalcCaptionArea()
\r
163 ASSERT(IsWindow(GetWnd()->GetSafeHwnd()));
\r
166 GetWnd()->GetClientRect(rectCaption);
\r
167 if (!GetShowCaption())
\r
168 rectCaption.bottom = rectCaption.top;
\r
170 rectCaption.bottom = rectCaption.top+GetCaptionHeight();
\r
172 return rectCaption;
\r
176 void CPropPageFrame::DrawCaption(CDC * /*pDc*/, CRect /*rect*/, LPCTSTR /*lpszCaption*/, HICON /*hIcon*/)
\r
178 // should be implemented by specialized classes
\r
182 /////////////////////////////////////////////////////////////////////
\r
183 // Implementation helpers
\r
185 void CPropPageFrame::SafeUpdateWindow(LPCRECT lpRect /* = NULL */)
\r
187 if (!IsWindow(GetWnd()->GetSafeHwnd()))
\r
190 GetWnd()->InvalidateRect(lpRect, TRUE);
\r
195 } //namespace TreePropSheet
\r