aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp')
-rw-r--r--Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp b/Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp
new file mode 100644
index 00000000..d0652924
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/mptrack/ColourEdit.cpp
@@ -0,0 +1,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