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