GME  13
colorbtn.h
Go to the documentation of this file.
00001 
00002 /*************************************************************************
00003 
00004 ColorBtn.h header file
00005 
00006 CColorBtn: A control panel like color picker
00007            by The Gremlin
00008 
00009 Compatibility: Visual C++ 4.0 and up.
00010 
00011 **************************************************************************/
00012 
00013 #ifndef _COLORBTN_H_
00014 #define _COLORBTN_H_
00015 
00016 // In order to ease use, these values have been hard coded in colorbtn.rc
00017 // This avoids the need for another header file.
00018 
00019 
00020 #define IDD_COLORBTN                    (5100)
00021 #define IDC_COLOR1                      (5101)
00022 #define IDC_COLOR20                     (5120)
00023 #define IDC_OTHER                       (5121)
00024 
00025 
00026 // Utility class for the dialog
00027 
00028 class CColorBtnDlg : public CDialog
00029 {
00030 // Construction
00031 public:
00032 
00033         
00034         static COLORREF colors[20];
00035     static BYTE used[20];
00036 
00037     CButton *parent;
00038     int colorindex;
00039 
00040         CColorBtnDlg(CWnd* pParent = NULL);   // standard constructor
00041 
00042      
00043 // Dialog Data
00044         //{{AFX_DATA(CColorBtnDlg)
00045         enum { IDD = IDD_COLORBTN };
00046                 // NOTE: the ClassWizard will add data members here
00047         //}}AFX_DATA
00048 
00049 
00050 // Overrides
00051         // ClassWizard generated virtual function overrides
00052         //{{AFX_VIRTUAL(CColorBtnDlg)
00053         protected:
00054         virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
00055         //}}AFX_VIRTUAL
00056 
00057 // Implementation
00058 protected:
00059 
00060         // Generated message map functions
00061         //{{AFX_MSG(CColorBtnDlg)
00062         virtual BOOL OnInitDialog();
00063         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00064         afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
00065         afx_msg void OnOther();
00066         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00067         //}}AFX_MSG
00068 
00069         void OnColor(UINT id);    
00070     void EndDialog( int nResult );
00071 
00072         DECLARE_MESSAGE_MAP()
00073 
00074 };
00075 
00076 
00077 
00078 class CColorBtn : public CButton
00079 {
00080 // Construction
00081 public:
00082 
00083     CColorBtn();
00084 
00085     // The selected color,set this variable to initialize the 
00086     // button's color and read to see the results
00087 
00088     COLORREF currentcolor;
00089 
00090     // Use Serialize to store the color table in a file. Call at the document's Serialize()
00091     
00092         void Serialize( CArchive& ar );
00093 
00094     // If using Serialize, call Reset to reinitialize the color table at OnNewDocument()
00095 
00096         static void Reset();
00097 
00098     // Use Load and Store to save/restore the color table to/from the registry
00099 
00100         static BOOL Load();
00101     static BOOL Store();
00102           
00103 
00104 
00105 // Overrides
00106         // ClassWizard generated virtual function overrides
00107         //{{AFX_VIRTUAL(CColorBtn)
00108         //}}AFX_VIRTUAL
00109 
00110 // Implementation
00111 public:
00112         virtual ~CColorBtn();
00113 
00114         // Generated message map functions
00115 protected:
00116         //{{AFX_MSG(CColorBtn)
00117         afx_msg void OnClicked();
00118         //}}AFX_MSG
00119 
00120     void DrawItem(LPDRAWITEMSTRUCT);
00121 
00122         DECLARE_MESSAGE_MAP()
00123 
00124 private:
00125 
00126     // A number of pens and brushes needed to paint the button
00127 
00128     CPen *oldpen;
00129     CBrush *oldbrush;
00130     CPen blackpen;
00131     CPen dkgray;
00132     CPen whitepen;
00133     CBrush backbrush;
00134     CBrush nullbrush;
00135     CPen nullpen;
00136     
00137 
00138 
00139    CColorBtnDlg dlg;
00140 };
00141 
00142 
00143 
00144 
00145 #endif