00001 #if !defined(AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_)
00002 #define AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_
00003
00004 #if _MSC_VER >= 1000
00005 #pragma once
00006 #endif // _MSC_VER >= 1000
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #define CPN_SELCHANGE WM_USER + 1001 // Colour Picker Selection change
00028 #define CPN_DROPDOWN WM_USER + 1002 // Colour Picker drop down
00029 #define CPN_CLOSEUP WM_USER + 1003 // Colour Picker close up
00030 #define CPN_SELENDOK WM_USER + 1004 // Colour Picker end OK
00031 #define CPN_SELENDCANCEL WM_USER + 1005 // Colour Picker end (cancelled)
00032
00033
00034 class CColourPicker;
00035
00036
00037 typedef struct {
00038 COLORREF crColour;
00039 TCHAR *szName;
00040 } ColourTableEntry;
00041
00043
00044
00045 class CColourPopup : public CWnd
00046 {
00047
00048 public:
00049 CColourPopup();
00050 CColourPopup(CPoint p, COLORREF crColour, CWnd* pParentWnd,
00051 LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL);
00052 void Initialise();
00053
00054
00055 public:
00056
00057
00058 public:
00059 BOOL Create(CPoint p, COLORREF crColour, CWnd* pParentWnd,
00060 LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL);
00061
00062
00063
00064
00065 public:
00066 virtual BOOL PreTranslateMessage(MSG* pMsg);
00067
00068
00069
00070 public:
00071 virtual ~CColourPopup();
00072
00073 protected:
00074 BOOL GetCellRect(int nIndex, const LPRECT& rect);
00075 void FindCellFromColour(COLORREF crColour);
00076 void SetWindowSize();
00077 void CreateToolTips();
00078 void ChangeSelection(int nIndex);
00079 void EndSelection(int nMessage);
00080 void DrawCell(CDC* pDC, int nIndex);
00081
00082 COLORREF GetColour(int nIndex) { return m_crColours[nIndex].crColour; }
00083 LPCTSTR GetColourName(int nIndex) { return m_crColours[nIndex].szName; }
00084 int GetIndex(int row, int col) const;
00085 int GetRow(int nIndex) const;
00086 int GetColumn(int nIndex) const;
00087
00088
00089 protected:
00090 static ColourTableEntry m_crColours[];
00091 int m_nNumColours;
00092 int m_nNumColumns, m_nNumRows;
00093 int m_nBoxSize, m_nMargin;
00094 int m_nCurrentSel;
00095 int m_nChosenColourSel;
00096 CString m_strDefaultText;
00097 CString m_strCustomText;
00098 CRect m_CustomTextRect, m_DefaultTextRect, m_WindowRect;
00099 CFont m_Font;
00100 CPalette m_Palette;
00101 COLORREF m_crInitialColour, m_crColour;
00102 CToolTipCtrl m_ToolTip;
00103 CWnd* m_pParent;
00104
00105 BOOL m_bChildWindowVisible;
00106
00107
00108 protected:
00109
00110 afx_msg void OnNcDestroy();
00111 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00112 afx_msg void OnPaint();
00113 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00114 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00115 afx_msg BOOL OnQueryNewPalette();
00116 afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
00117 afx_msg void OnKillFocus(CWnd* pNewWnd);
00118 #if _MFC_VER < 0x0700
00119 afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
00120 #else
00121 afx_msg void OnActivateApp(BOOL bActive, DWORD hTask);
00122 #endif
00123
00124 DECLARE_MESSAGE_MAP()
00125 };
00126
00128
00129
00130
00131
00132 #endif // !defined(AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_)