SPPropertyGridItemFont.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /********************************************
  2. ** 工作室:S&P工作室
  3. ** 作者 :张东斌
  4. ** 日期 :2007年6月
  5. *********************************************/
  6. #if !defined(__SPPROPERTYGRIDITEMFONT_H__)
  7. #define __SPPROPERTYGRIDITEMFONT_H__
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11. //===========================================================================
  12. // Summary:
  13. // CSPPropertyGridItemFont is a CSPPropertyGridItem derived class.
  14. // It is used to create a Font value item in a Property Grid control.
  15. //===========================================================================
  16. class CSPPropertyGridItemFont : public CSPPropertyGridItem
  17. {
  18. public:
  19. //-----------------------------------------------------------------------
  20. // Summary:
  21. // Constructs a CSPPropertyGridItemFont object.
  22. // Parameters:
  23. // strCaption - Caption of the item.
  24. // nID - Identifier of the item.
  25. // font - Initial font value.
  26. //-----------------------------------------------------------------------
  27. CSPPropertyGridItemFont( CString strCaption , LOGFONT & font );
  28. CSPPropertyGridItemFont( UINT nID , LOGFONT & font ); // <COMBINE CSPPropertyGridItemFont::CSPPropertyGridItemFont@CString@LOGFONT&>
  29. //-----------------------------------------------------------------------
  30. // Summary:
  31. // Destroys a CSPPropertyGridItemFont object.
  32. //-----------------------------------------------------------------------
  33. virtual ~CSPPropertyGridItemFont();
  34. public:
  35. //-----------------------------------------------------------------------
  36. // Summary:
  37. // Call this method to change the item's value.
  38. // Parameters:
  39. // font - The new value of the item.
  40. //-----------------------------------------------------------------------
  41. void SetFont( LOGFONT & font );
  42. //-----------------------------------------------------------------------
  43. // Summary:
  44. // Call this method to get the LOGFONT value of the item.
  45. // Parameters:
  46. // lf - Pointer to the LOGFONT structure to receive the font information.
  47. //-----------------------------------------------------------------------
  48. void GetFont( LOGFONT * lf );
  49. //-----------------------------------------------------------------------
  50. // Summary:
  51. // Call this method to change the item's value.
  52. // Parameters:
  53. // clr - The new COLORREF value of the item.
  54. //-----------------------------------------------------------------------
  55. void SetColor( COLORREF clr );
  56. //-----------------------------------------------------------------------
  57. // Summary:
  58. // Call the member to get the COLORREF value of this item.
  59. // Returns:
  60. // The COLORREF value of the item.
  61. //-----------------------------------------------------------------------
  62. COLORREF GetColor();
  63. protected:
  64. //-----------------------------------------------------------------------
  65. // Summary:
  66. // This method is called when the user presses the in-place button.
  67. // Override the method to show an item-specific dialog.
  68. // Remarks:
  69. // The in-place button is the button that the user presses to
  70. // display the font picker dialog.
  71. //-----------------------------------------------------------------------
  72. virtual void OnInplaceButtonDown();
  73. //-----------------------------------------------------------------------
  74. // Summary:
  75. // This method is called when an item is drawn. Override this function if
  76. // needed.
  77. // Parameters:
  78. // dc - Pointer to a valid device context.
  79. // rcValue - Bounding rectangle of the item.
  80. // Returns:
  81. // TRUE if the item is self-drawn.
  82. //-----------------------------------------------------------------------
  83. BOOL OnDrawItemValue( CDC & dc , CRect rcValue );
  84. //-----------------------------------------------------------------------
  85. // Summary:
  86. // Retrieves the bounding rectangle of the item value's text.
  87. // Override this member function to change it.
  88. // Returns:
  89. // A CRect object that represents the bounding rectangle of the
  90. // item value's text.
  91. //-----------------------------------------------------------------------
  92. CRect GetValueRect();
  93. private:
  94. static UINT CALLBACK FontDlgProc( HWND hWnd , UINT message , WPARAM wParam , LPARAM lParam );
  95. protected:
  96. LOGFONT m_lfValue; // Value of the item, this holds the current font value.
  97. COLORREF m_clrValue; // Font color.
  98. protected:
  99. DECLARE_DYNAMIC( CSPPropertyGridItemFont )
  100. };
  101. //////////////////////////////////////////////////////////////////////
  102. #endif // #if !defined(__SPPROPERTYGRIDITEMFONT_H__)