|
#include "stdafx.h"
#include "CaptionBackground.h"
#include "AutoSelector.h"
//////////////////
// Helper to paint rectangle with a color.
//
CCaptionBackground::CCaptionBackground()
:m_ActiveColor(-1), m_InactiveColor(-1)
{
}
CCaptionBackground::CCaptionBackground(const CCaptionBackground& cb)
:m_ActiveColor(cb.m_ActiveColor), m_InactiveColor(cb.m_InactiveColor)
{
}
void CCaptionBackground::SetCustomColors(const CCaptionBackground& cb)
{
SetActiveColor(cb.m_ActiveColor);
SetInactiveColor(cb.m_InactiveColor);
}
void CCaptionBackground::SetCustomColors(COLORREF activeColor, COLORREF inactiveColor)
{
SetActiveColor(activeColor);
SetInactiveColor(inactiveColor);
}
void CCaptionBackground::SetActiveColor(COLORREF activeColor)
{
m_ActiveColor = activeColor;
}
void CCaptionBackground::SetInactiveColor(COLORREF inactiveColor)
{
m_InactiveColor = inactiveColor;
}
void CCaptionBackground::UseSystemColors()
{
UseSystemActiveColor();
UseSystemInactiveColor();
}
void CCaptionBackground::UseSystemActiveColor()
{
m_ActiveColor = -1;
}
void CCaptionBackground::UseSystemInactiveColor()
{
m_InactiveColor = -1;
}
boolean CCaptionBackground::IsUsingSystemColors()
{
return m_ActiveColor == -1;
}
COLORREF CCaptionBackground::GetActiveColor() const
{
return m_ActiveColor == -1 ? GetSysColor(COLOR_ACTIVECAPTION) : m_ActiveColor;
}
COLORREF CCaptionBackground::GetInactiveColor() const
{
return m_InactiveColor == -1 ? GetSysColor(COLOR_INACTIVECAPTION) : m_InactiveColor;
}
void CCaptionBackground::Paint(CDC* pDC, CSize paintArea, BOOL active)
{
PaintRect(pDC, 0, 0, paintArea.cx, paintArea.cy, active ? GetActiveColor() : GetInactiveColor());
}
// Paint the color into the rectangle dimensions on the device context
void CCaptionBackground::PaintRect(CDC* pDC, int x, int y, int w, int h, COLORREF color)
{
CBrush brush(color);
AutoSelector a(pDC, &brush);
pDC->PatBlt(x, y, w, h, PATCOPY);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.