Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
4.1 KiB

  1. /*****************************************************************************\
  2. FILE: ColorCtrl.h
  3. DESCRIPTION:
  4. This code will display a ColorPicking control. It will preview a color
  5. and have a drop down arrow. When dropped down, it will show 16 or so common
  6. colors with a "Other..." option for a full color picker.
  7. BryanSt 7/25/2000 Converted from the Display Control Panel.
  8. Copyright (C) Microsoft Corp 2000-2000. All rights reserved.
  9. \*****************************************************************************/
  10. #ifndef _COLORCONTROL_H
  11. #define _COLORCONTROL_H
  12. #include <cowsite.h>
  13. #define NUM_COLORSMAX 64
  14. #define NUM_COLORSPERROW 4
  15. class CColorControl : public CObjectWithSite
  16. , public CObjectWindow
  17. {
  18. public:
  19. //////////////////////////////////////////////////////
  20. // Public Interfaces
  21. //////////////////////////////////////////////////////
  22. // *** IUnknown ***
  23. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  24. virtual STDMETHODIMP_(ULONG) AddRef(void);
  25. virtual STDMETHODIMP_(ULONG) Release(void);
  26. // *** IColorControl ***
  27. virtual STDMETHODIMP Initialize(IN HWND hwnd, IN COLORREF rgbColor);
  28. virtual STDMETHODIMP GetColor(IN COLORREF * pColor);
  29. virtual STDMETHODIMP SetColor(IN COLORREF color);
  30. virtual STDMETHODIMP OnCommand(IN HWND hDlg, IN UINT message, IN WPARAM wParam, IN LPARAM lParam);
  31. virtual STDMETHODIMP OnDrawItem(IN HWND hDlg, IN UINT message, IN WPARAM wParam, IN LPARAM lParam);
  32. virtual STDMETHODIMP ChangeTheme(IN HWND hDlg);
  33. CColorControl();
  34. virtual ~CColorControl(void);
  35. protected:
  36. private:
  37. // Private Member Variables
  38. int m_cRef;
  39. COLORREF m_rbgColor; // Our current color
  40. HBRUSH m_brColor; // Our brush in our color that we use to paint the control.
  41. int m_cxEdgeSM; // Cached SM_CXEDGE system metric
  42. int m_cyEdgeSM; // Cached SM_CYEDGE system metric
  43. HTHEME m_hTheme; // theme the ownerdrawn color picker button
  44. // Used when display the control UI.
  45. HWND m_hwndParent;
  46. COLORREF m_rbgCustomColors[16]; // This is the user customized palette.
  47. BOOL m_fCursorHidden; // Did we hide the cursor?
  48. BOOL m_fCapturing; // Are we capturing the mouse?
  49. BOOL m_fJustDropped; //
  50. int m_iNumColors;
  51. COLORREF m_rbgColors[NUM_COLORSMAX];
  52. int m_dxColor;
  53. int m_dyColor;
  54. int m_nCurColor;
  55. DWORD m_dwFlags;
  56. COLORREF m_rbgColorTemp; // The color we may start to use
  57. BOOL m_fPalette;
  58. HPALETTE m_hpalVGA; // only exist if palette device
  59. HPALETTE m_hpal3D; // only exist if palette device
  60. // Private Member Functions
  61. void _InitDialog(HWND hDlg);
  62. HRESULT _SaveCustomColors(void);
  63. BOOL _UseColorPicker(void);
  64. BOOL _ChooseColorMini(void);
  65. HRESULT _InitColorAndPalette(void);
  66. COLORREF _NearestColor(COLORREF rgb);
  67. void _TrackMouse(HWND hDlg, POINT pt);
  68. void _FocusColor(HWND hDlg, int iNewColor);
  69. void _DrawColorSquare(HDC hdc, int iColor);
  70. void _DrawItem(HWND hDlg, LPDRAWITEMSTRUCT lpdis);
  71. void _DrawDownArrow(HDC hdc, LPRECT lprc, BOOL bDisabled);
  72. INT_PTR _ColorPickDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  73. static INT_PTR CALLBACK ColorPickDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
  74. };
  75. #endif // _COLORCONTROL_H