OptionTreeColorPopUp.h
Upload User: kairuinn
Upload Date: 2009-02-07
Package Size: 2922k
Code Size: 4k
Category:

Graph program

Development Platform:

Visual C++

  1. // COptionTree
  2. //
  3. // License
  4. // -------
  5. // This code is provided "as is" with no expressed or implied warranty.
  6. // 
  7. // You may use this code in a commercial product with or without acknowledgement.
  8. // However you may not sell this code or any modification of this code, this includes 
  9. // commercial libraries and anything else for profit.
  10. //
  11. // I would appreciate a notification of any bugs or bug fixes to help the control grow.
  12. //
  13. // History:
  14. // --------
  15. // See License.txt for full history information.
  16. //
  17. //
  18. // Copyright (c) 1999-2002 
  19. // ComputerSmarts.net 
  20. // mattrmiller@computersmarts.net
  21. #ifndef OT_COLORPOPUP
  22. #define OT_COLORPOPUP
  23. #pragma once 
  24. #if _MSC_VER >= 1000
  25. #pragma once
  26. #endif // _MSC_VER >= 1000
  27. // OptionTreeColorPopUp.h : header file
  28. //
  29. // Added Headers
  30. #include "OptionTreeDef.h"
  31. #include "OptionTreeItem.h"
  32. // Classes
  33. class COptionTree;
  34. // Structures
  35. typedef struct 
  36. {
  37.     COLORREF crColor;
  38.     TCHAR    *szName;
  39. } OT_COLOR_ITEM;
  40. /////////////////////////////////////////////////////////////////////////////
  41. // COptionTreeColorPopUp window
  42. class COptionTreeColorPopUp : public CWnd
  43. {
  44. // Construction
  45. public:
  46.     COptionTreeColorPopUp();
  47.     COptionTreeColorPopUp(CPoint pPoint, COLORREF crColor, COLORREF crDefault, CWnd* pParentWnd, LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL);
  48.     void Initialize();
  49. // Attributes
  50. public:
  51. // Operations
  52. public:
  53.     BOOL Create(CPoint pPoint, COLORREF crColor, CWnd* pParentWnd, LPCTSTR szDefaultText = NULL, LPCTSTR szCustomText = NULL);
  54. // Overrides
  55.     // ClassWizard generated virtual function overrides
  56.     //{{AFX_VIRTUAL(COptionTreeColorPopUp)
  57.     public:
  58.     virtual BOOL PreTranslateMessage(MSG* pMsg);
  59.     //}}AFX_VIRTUAL
  60. // Implementation
  61. public:
  62.     virtual ~COptionTreeColorPopUp();
  63. protected:
  64.     BOOL GetCellRect(int nIndex, const LPRECT& rect);
  65.     void FindCellFromColor(COLORREF crColor);
  66.     void SetWindowSize();
  67.     void CreateToolTips();
  68.     void ChangeSelection(int nIndex);
  69.     void EndSelection(int nMessage);
  70.     void DrawCell(CDC* pDC, int nIndex);
  71.     COLORREF GetColor(int nIndex)              { return m_crColors[nIndex].crColor; }
  72.     LPCTSTR GetColorName(int nIndex)           { return m_crColors[nIndex].szName; }
  73.     int  GetIndex(int nRow, int nCol) const;
  74.     int  GetRow(int nIndex) const;
  75.     int  GetColumn(int nIndex) const;
  76. // protected attributes
  77. protected:
  78.     static OT_COLOR_ITEM m_crColors[];
  79.     int m_nNumColors;
  80.     int m_nNumColumns, m_nNumRows;
  81.     int m_nBoxSize, m_nMargin;
  82.     int m_nCurrentSel;
  83.     int m_nChosenColorSel;
  84.     CString m_strDefaultText;
  85.     CString m_strCustomText;
  86.     CRect m_rcCustomTextRect, m_rcDefaultTextRect, m_rcWindowRect;
  87.     CFont m_fFont;
  88.     CPalette m_plPalette;
  89.     COLORREF m_crInitialColor, m_crColor, m_crDefault;
  90.     CToolTipCtrl m_ttToolTip;
  91.     CWnd* m_wndParent;
  92.     BOOL m_bChildWindowVisible;
  93.     // Generated message map functions
  94. protected:
  95.     //{{AFX_MSG(COptionTreeColorPopUp)
  96.     afx_msg void OnNcDestroy();
  97.     afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  98.     afx_msg void OnPaint();
  99.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  100.     afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  101.     afx_msg BOOL OnQueryNewPalette();
  102.     afx_msg void OnPaletteChanged(CWnd* pFocusWnd);
  103. afx_msg void OnKillFocus(CWnd* pNewWnd);
  104. afx_msg void OnActivateApp(BOOL bActive, DWORD hTask);
  105. //}}AFX_MSG
  106.     DECLARE_MESSAGE_MAP()
  107. };
  108. /////////////////////////////////////////////////////////////////////////////
  109. //{{AFX_INSERT_LOCATION}}
  110. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  111. #endif // !OT_COLORPOPUP