GME
13
|
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 // ColourPopup.h : header file 00009 // 00010 // Written by Chris Maunder (chrismaunder@codeguru.com) 00011 // Extended by Alexander Bischofberger (bischofb@informatik.tu-muenchen.de) 00012 // Copyright (c) 1998. 00013 // 00014 // This code may be used in compiled form in any way you desire. This 00015 // file may be redistributed unmodified by any means PROVIDING it is 00016 // not sold for profit without the authors written consent, and 00017 // providing that this notice and the authors name is included. If 00018 // the source code in this file is used in any commercial application 00019 // then a simple email would be nice. 00020 // 00021 // This file is provided "as is" with no expressed or implied warranty. 00022 // The author accepts no liability if it causes any damage whatsoever. 00023 // It's free - so you get what you pay for. 00024 00025 #include "resource.h" 00026 00027 #define DEFAULT_BOX_VALUE -3 00028 00029 // To hold the colours and their names 00030 typedef struct { 00031 COLORREF crColour; 00032 TCHAR *szName; 00033 } ColourTableEntry; 00034 00036 // CColourPopup window 00037 00038 class CColourPopup : public CDialog 00039 { 00040 DECLARE_DYNAMIC(CColourPopup) 00041 00042 // Construction 00043 public: 00044 CColourPopup(CWnd* pParent = NULL); 00045 virtual ~CColourPopup(); 00046 00047 // Dialog Data 00048 //{{AFX_DATA(CColourPopup) 00049 enum { IDD = IDD_COLORPICKER_DIALOG }; 00050 //}}AFX_DATA 00051 00052 static ColourTableEntry m_crColours[]; 00053 CRect m_RectBound; 00054 int m_nNumColours; 00055 int m_nNumColumns, m_nNumRows; 00056 int m_nBoxSize, m_nMargin; 00057 int m_nCurrentSel; 00058 int m_nChosenColourSel; 00059 CString m_strDefaultText; 00060 CString m_strCustomText; 00061 CRect m_CustomTextRect, m_DefaultTextRect, m_WindowRect; 00062 CFont m_Font; 00063 CPalette m_Palette; 00064 COLORREF m_crInitialColour, m_crColour; 00065 CToolTipCtrl m_ToolTip; 00066 00067 BOOL m_bChildWindowVisible; 00068 bool m_bRightSideClick; 00069 bool m_bFirstMouseMsgReceived; 00070 00071 // Implementation 00072 public: 00073 void SetWindowSize(void); 00074 void SetParameters(CRect rectBound, COLORREF crColour, bool rightSideClick, 00075 LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL); 00076 COLORREF GetSelectedColor(void) const { return m_crColour; }; 00077 00078 protected: 00079 void Initialize(void); 00080 int GetIndex(int row, int col) const; 00081 int GetRow(int nIndex) const; 00082 int GetColumn(int nIndex) const; 00083 void FindCellFromColour(COLORREF crColour); 00084 BOOL GetCellRect(int nIndex, const LPRECT& rect); 00085 void CreateToolTips(void); 00086 void ChangeSelection(int nIndex); 00087 void EndSelection(int nMessage); 00088 void DrawCell(CDC* pDC, int nIndex); 00089 00090 COLORREF GetColour(int nIndex) { return m_crColours[nIndex].crColour; } 00091 LPCTSTR GetColourName(int nIndex) { return m_crColours[nIndex].szName; } 00092 00093 // Generated message map functions 00094 protected: 00095 //{{AFX_MSG(CColourPopup) 00096 virtual BOOL OnInitDialog(); 00097 afx_msg void OnDestroy(); 00098 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); 00099 afx_msg void OnPaint(); 00100 afx_msg void OnMouseMove(UINT nFlags, CPoint point); 00101 afx_msg void OnLButtonUp(UINT nFlags, CPoint point); 00102 afx_msg BOOL OnQueryNewPalette(); 00103 afx_msg void OnPaletteChanged(CWnd* pFocusWnd); 00104 //}}AFX_MSG 00105 DECLARE_MESSAGE_MAP() 00106 00107 // Overrides 00108 // ClassWizard generated virtual function overrides 00109 //{{AFX_VIRTUAL(CColourPopup) 00110 public: 00111 virtual void EndDialog(int nResult); 00112 virtual BOOL PreTranslateMessage(MSG* pMsg); 00113 //}}AFX_VIRTUAL 00114 00115 }; 00116 00118 00119 //{{AFX_INSERT_LOCATION}} 00120 // Microsoft Developer Studio will insert additional declarations immediately before the previous line. 00121 00122 #endif // !defined(AFX_COLOURPOPUP_H__D0B75902_9830_11D1_9C0F_00A0243D1382__INCLUDED_)