SPPropertyGridItemSize.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /********************************************
  2. ** 工作室:S&P工作室
  3. ** 作者 :张东斌
  4. ** 日期 :2007年6月
  5. *********************************************/
  6. #if !defined(__SPPROPERTYGRIDITEMSIZE_H__)
  7. #define __SPPROPERTYGRIDITEMSIZE_H__
  8. #if _MSC_VER > 1000
  9. #pragma once
  10. #endif // _MSC_VER > 1000
  11. //===========================================================================
  12. // Summary:
  13. // CSPPropertyGridItemSize is a CSPPropertyGridItem derived class.
  14. // It is used to create a size value item in a Property Grid control.
  15. //===========================================================================
  16. class CSPPropertyGridItemSize : public CSPPropertyGridItem
  17. {
  18. public:
  19. //-----------------------------------------------------------------------
  20. // Summary:
  21. // Constructs a CSPPropertyGridItemSize object.
  22. // Parameters:
  23. // strCaption - Caption of the item.
  24. // nID - Identifier of the item.
  25. // size - Initial value of item.
  26. // pBindSize - If not NULL, then the value of this item
  27. // is bound the value of this variable.
  28. // Remarks:
  29. // Class CSPPropertyGridItemSize has no default constructor.
  30. //
  31. // When using the second constructor, the Identifier (nID) of the
  32. // second constructor can be linked with a STRINGTABLE resource
  33. // with the same id in such form "Caption\\nDescription".
  34. //
  35. // BINDING:
  36. // Variables can be bound to an item in two ways, the first is
  37. // to pass in a variable at the time of creation, the second allows
  38. // variables to be bound to an item after creation with the
  39. // BindToSize member.
  40. //
  41. // Bound variables store the values of the property grid items
  42. // and can be accessed without using the property grid methods
  43. // and properties. Bound variables allow the property grid to
  44. // store data in variables. When the value of a PropertyGridItem
  45. // is changed, the value of the bound variable will be changed to
  46. // the PropertyGridItem value. The advantage of binding is that
  47. // the variable can be used and manipulated without using
  48. // PropertyGridItem methods and properties.
  49. //
  50. // NOTE: If the value of the variable is changed without using
  51. // the PropertyGrid, the PropertyGridItem value will not be
  52. // updated until you call CSPPropertyGrid::Refresh.
  53. // See Also: BindToSize
  54. //-----------------------------------------------------------------------
  55. CSPPropertyGridItemSize( CString strCaption , CSize size = 0 , CSize * pBindSize = NULL );
  56. CSPPropertyGridItemSize( UINT nID , CSize size = 0 , CSize * pBindSize = NULL ); //<COMBINE CSPPropertyGridItemSize::CSPPropertyGridItemSize@CString@CSize@CSize*>
  57. //-----------------------------------------------------------------------
  58. // Summary:
  59. // Destroys a CSPPropertyGridItemSize object.
  60. //-----------------------------------------------------------------------
  61. virtual ~CSPPropertyGridItemSize();
  62. public:
  63. //-----------------------------------------------------------------------
  64. // Summary:
  65. // Call this method to change the item's value.
  66. // Parameters:
  67. // size - The new size value of the item.
  68. //-----------------------------------------------------------------------
  69. void SetSize( CSize size );
  70. //-----------------------------------------------------------------------
  71. // Summary:
  72. // Call this method to get the size value of the item.
  73. // Returns:
  74. // A CSize object representing the size value of the item.
  75. //-----------------------------------------------------------------------
  76. CSize GetSize();
  77. //-----------------------------------------------------------------------
  78. // Summary:
  79. // Call this method to bind an item to a CSize object.
  80. // Parameters:
  81. // pBindSize - CSize object to bind to item.
  82. // Remarks:
  83. // Variables can be bound to an item in two ways, the first is
  84. // to pass in a variable at the time of creation, the second allows
  85. // variables to be bound to an item after creation with the
  86. // BindToSize member.
  87. //
  88. // Bound variables store the values of the property grid items
  89. // and can be accessed without using the property grid methods
  90. // and properties. Bound variables allow the property grid to
  91. // store data in variables. When the value of a PropertyGridItem
  92. // is changed, the value of the bound variable will be changed to
  93. // the PropertyGridItem value. The advantage of binding is that
  94. // the variable can be used and manipulated without using
  95. // PropertyGridItem methods and properties.
  96. //
  97. // NOTE: If the value of the variable is changed without using
  98. // the PropertyGrid, the PropertyGridItem value will not be
  99. // updated until you call CSPPropertyGrid::Refresh.
  100. //-----------------------------------------------------------------------
  101. void BindToSize( CSize * pBindSize );
  102. protected:
  103. //-------------------------------------------------------------------------
  104. // Summary:
  105. // This member is called before the item becomes visible in the
  106. // property grid.
  107. // Remarks:
  108. // Before the item is inserted, it is first check to see if it
  109. // is bound to a variable, if it is, then the value of the item
  110. // is updated with the value stored in the bound variable.
  111. //
  112. // OnBeforeInsert is called when an item is inserted,
  113. // when a category is inserted, when a category or item is
  114. // expanded, and when the sort property has changed.
  115. //-------------------------------------------------------------------------
  116. void OnBeforeInsert();
  117. private:
  118. void SetWidth( CString strWidth );
  119. void SetHeight( CString strHeight );
  120. CString SizeToString( CSize size );
  121. CSize StringToSize( CString str );
  122. virtual void OnAddChildItem();
  123. virtual void SetValue( CString strValue );
  124. void UpdateChilds();
  125. private:
  126. class CSPPropertyGridItemSizeWidth;
  127. class CSPPropertyGridItemSizeHeight;
  128. CSize m_szValue;
  129. CSPPropertyGridItemSizeWidth * m_itemWidth;
  130. CSPPropertyGridItemSizeHeight * m_itemHeight;
  131. CSize * m_pBindSize;
  132. private:
  133. DECLARE_DYNAMIC( CSPPropertyGridItemSize )
  134. friend class CSPPropertyGridItemSizeWidth;
  135. friend class CSPPropertyGridItemSizeHeight;
  136. };
  137. //////////////////////////////////////////////////////////////////////
  138. AFX_INLINE CSize CSPPropertyGridItemSize::GetSize()
  139. {
  140. return m_szValue;
  141. }
  142. #endif // #if !defined(__SPPROPERTYGRIDITEMSIZE_H__)