OSDN Git Service

Initial checkin of a color bottom class
authorChris Mumford <cmumford@users.sourceforge.net>
Fri, 6 Sep 2002 13:39:21 +0000 (13:39 +0000)
committerChris Mumford <cmumford@users.sourceforge.net>
Fri, 6 Sep 2002 13:39:21 +0000 (13:39 +0000)
Src/ColorButton.cpp [new file with mode: 0644]
Src/ColorButton.h [new file with mode: 0644]

diff --git a/Src/ColorButton.cpp b/Src/ColorButton.cpp
new file mode 100644 (file)
index 0000000..c43aa2b
--- /dev/null
@@ -0,0 +1,55 @@
+// ColorButton.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "merge.h"
+#include "ColorButton.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CColorButton
+
+CColorButton::CColorButton( COLORREF clrFill ) : m_clrFill(clrFill)
+{
+}
+
+CColorButton::~CColorButton()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CColorButton, CButton)
+       //{{AFX_MSG_MAP(CColorButton)
+       //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CColorButton message handlers
+
+void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
+{
+       CBrush  brush;
+
+       brush.CreateSolidBrush( m_clrFill );
+
+       ::FillRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, brush );
+
+#if 0
+       ::FrameRect( lpDrawItemStruct->hDC, &lpDrawItemStruct->rcItem, 
+                       (HBRUSH)GetStockObject(BLACK_BRUSH) );
+#endif
+}
+
+
+void CColorButton::SetColor( COLORREF clrFill )
+{
+       m_clrFill = clrFill;
+       Invalidate();
+}
+
+
diff --git a/Src/ColorButton.h b/Src/ColorButton.h
new file mode 100644 (file)
index 0000000..3952b3b
--- /dev/null
@@ -0,0 +1,53 @@
+#if !defined(AFX_COLORBUTTON_H__75623C05_2D2D_4FBE_B819_661F49DEAE94__INCLUDED_)
+#define AFX_COLORBUTTON_H__75623C05_2D2D_4FBE_B819_661F49DEAE94__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+// ColorButton.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CColorButton window
+
+class CColorButton : public CButton
+{
+       COLORREF        m_clrFill;
+
+// Construction
+public:
+       CColorButton( COLORREF clrFill );
+
+// Attributes
+public:
+
+// Operations
+public:
+
+       void    SetColor( COLORREF clrFill );
+
+// Overrides
+       // ClassWizard generated virtual function overrides
+       //{{AFX_VIRTUAL(CColorButton)
+       public:
+       virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
+       //}}AFX_VIRTUAL
+
+// Implementation
+public:
+       virtual ~CColorButton();
+
+       // Generated message map functions
+protected:
+       //{{AFX_MSG(CColorButton)
+       //}}AFX_MSG
+
+       DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_COLORBUTTON_H__75623C05_2D2D_4FBE_B819_661F49DEAE94__INCLUDED_)