coloredbutton.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // ColoredButton.h : header file
  13. //
  14. #ifndef COLOREDBUTTON_H
  15. #define COLOREDBUTTON_H 1
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CColoredButton window
  18. class CColoredButton : public CButton
  19. {
  20. // Construction
  21. public:
  22. enum PickerType {
  23. PT_CUSTOM = 0,
  24. PT_MFC,
  25. };
  26. CColoredButton();
  27. // Attributes
  28. public:
  29. COLOR m_colColor;
  30. COLOR m_colLastColor;
  31. UBYTE m_ubComponents[2][4];
  32. BOOL m_bMixedColor;
  33. enum PickerType m_ptPickerType;
  34. CWnd *m_pwndParentDialog;
  35. RECT m_rectButton;
  36. PIX m_dx;
  37. PIX m_dy;
  38. INDEX m_iColorIndex;
  39. INDEX m_iComponentIndex;
  40. CPoint m_ptStarting;
  41. CPoint m_ptCenter;
  42. // Operations
  43. public:
  44. void SetColor(COLOR clrNew);
  45. inline void SetDialogPtr(CWnd *pwndParentDialog){ m_pwndParentDialog = pwndParentDialog;};
  46. inline void SetMixedColor(void){ m_bMixedColor = TRUE;};
  47. inline void SetPickerType( enum PickerType ptPickerType) { m_ptPickerType = ptPickerType;};
  48. inline COLOR GetColor(void) { return m_colColor;};
  49. inline BOOL IsColorValid(void) { return !m_bMixedColor;};
  50. void SetOverButtonInfo( CPoint point);
  51. void ColorToComponents(void);
  52. int OnToolHitTest( CPoint point, TOOLINFO* pTI ) const;
  53. // Overrides
  54. // ClassWizard generated virtual function overrides
  55. //{{AFX_VIRTUAL(CColoredButton)
  56. public:
  57. virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
  58. //}}AFX_VIRTUAL
  59. // Implementation
  60. public:
  61. virtual ~CColoredButton();
  62. // Generated message map functions
  63. protected:
  64. //{{AFX_MSG(CColoredButton)
  65. afx_msg void OnClicked();
  66. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  67. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  68. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  69. afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  70. afx_msg void OnCopyColor();
  71. afx_msg void OnPasteColor();
  72. afx_msg void OnNumericAlpha();
  73. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  74. afx_msg void OnKillFocus(CWnd* pNewWnd);
  75. //}}AFX_MSG
  76. DECLARE_MESSAGE_MAP()
  77. };
  78. /////////////////////////////////////////////////////////////////////////////
  79. #endif // COLOREDBUTTON_H