aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp
blob: d0652924c5d22ba91464bba4348ba7d69ded9c0a (plain) (blame)
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
/*
 * ColourEdit.cpp
 * --------------
 * Purpose: Implementation of a coloured edit UI item.
 * Notes  : (currently none)
 * Authors: OpenMPT Devs
 * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
 */


#include "stdafx.h"
#include "ColourEdit.h"


OPENMPT_NAMESPACE_BEGIN


/////////////////////////////////////////////////////////////////////////////
// CColourEdit

CColourEdit::CColourEdit()
{
	m_crText = RGB(0, 0, 0);  //default text color
}

CColourEdit::~CColourEdit()
{
	if(m_brBackGnd.GetSafeHandle())  //delete brush
		m_brBackGnd.DeleteObject();
}


BEGIN_MESSAGE_MAP(CColourEdit, CEdit)
	ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColourEdit message handlers

HBRUSH CColourEdit::CtlColor(CDC *pDC, UINT nCtlColor)
{
	MPT_UNREFERENCED_PARAMETER(nCtlColor);
	pDC->SetTextColor(m_crText);		//set text color
	pDC->SetBkColor(m_crBackGnd);		//set the text's background color
	return m_brBackGnd;	//return the brush used for background - this sets control background
}

/////////////////////////////////////////////////////////////////////////////
// Implementation

void CColourEdit::SetBackColor(COLORREF rgb)
{
	m_crBackGnd = rgb;					//set background color ref (used for text's background)
	if(m_brBackGnd.GetSafeHandle())  //free brush
		m_brBackGnd.DeleteObject();
	m_brBackGnd.CreateSolidBrush(rgb);  //set brush to new color
	Invalidate(TRUE);					//redraw
}


void CColourEdit::SetTextColor(COLORREF rgb)
{
	m_crText = rgb;    // set text color ref
	Invalidate(TRUE);  // redraw
}


OPENMPT_NAMESPACE_END