Source code of Windows XP (NT5)
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.

154 lines
4.4 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1999
  5. //
  6. // File: columninfo.h
  7. //
  8. // Contents: Classes related to column persistence.
  9. //
  10. //
  11. // Note: The classes in this file (CColumnInfo, CColumnInfoList)
  12. // were in nodemgr/colwidth.h. They are moved here so that
  13. // if columns change conui can ask nodemgr to persist data
  14. // or conui can set headers by asking nodemgr for data.
  15. //
  16. // History: 04-Apr-00 AnandhaG Created
  17. //
  18. //--------------------------------------------------------------------
  19. #ifndef COLUMNINFO_H_
  20. #define COLUMNINFO_H_
  21. #pragma once
  22. using namespace std;
  23. //+-------------------------------------------------------------------
  24. //
  25. // Class: CColumnInfo
  26. //
  27. // Purpose: The minimum information about a column that will be
  28. // persisted. (Width, order, format which can be hidden status)
  29. //
  30. // History: 10-27-1998 AnandhaG Created
  31. //
  32. //--------------------------------------------------------------------
  33. class CColumnInfo : public CSerialObject, public CXMLObject
  34. {
  35. public:
  36. CColumnInfo () : m_nCol(-1), m_nWidth(-1), m_nFormat(0)
  37. {}
  38. CColumnInfo (INT nCol, INT nWidth, INT nFormat)
  39. : m_nCol(nCol), m_nWidth(nWidth), m_nFormat(nFormat)
  40. {}
  41. CColumnInfo(const CColumnInfo& colInfo)
  42. {
  43. m_nFormat = colInfo.m_nFormat;
  44. m_nWidth = colInfo.m_nWidth;
  45. m_nCol = colInfo.m_nCol;
  46. }
  47. CColumnInfo& operator=(const CColumnInfo& colInfo)
  48. {
  49. if (this != &colInfo)
  50. {
  51. m_nCol = colInfo.m_nCol;
  52. m_nFormat = colInfo.m_nFormat;
  53. m_nWidth = colInfo.m_nWidth;
  54. }
  55. return (*this);
  56. }
  57. bool operator ==(const CColumnInfo &colinfo) const
  58. {
  59. return ( (m_nCol == colinfo.m_nCol) &&
  60. (m_nFormat == colinfo.m_nFormat) &&
  61. (m_nWidth == colinfo.m_nWidth) );
  62. }
  63. // Temp members so that CNode can access & modify data. Should be removed soon.
  64. public:
  65. INT GetColIndex () const {return m_nCol;}
  66. INT GetColWidth () const {return m_nWidth;}
  67. bool IsColHidden () const {return (m_nFormat & HDI_HIDDEN);}
  68. void SetColIndex (INT nCol) {m_nCol = nCol;}
  69. void SetColWidth (INT nWidth) {m_nWidth = nWidth;}
  70. void SetColHidden(bool bHidden = true)
  71. {
  72. if (bHidden)
  73. m_nFormat |= HDI_HIDDEN;
  74. else
  75. m_nFormat &= ~HDI_HIDDEN;
  76. }
  77. protected:
  78. INT m_nCol; // The index supplied when snapin inserted the column.
  79. // This is not the index viewed by the user.
  80. INT m_nWidth;
  81. INT m_nFormat;
  82. protected:
  83. // CSerialObject methods
  84. virtual UINT GetVersion() {return 1;}
  85. virtual HRESULT ReadSerialObject (IStream &stm, UINT nVersion /*,LARGE_INTEGER nBytes*/);
  86. protected:
  87. DEFINE_XML_TYPE(XML_TAG_COLUMN_INFO);
  88. virtual void Persist(CPersistor &persistor);
  89. };
  90. //+-------------------------------------------------------------------
  91. //
  92. // Class: ColPosCompare
  93. //
  94. // Purpose: Compare the column position in CColumnInfo and the given position.
  95. // This is used to reorder/search the columns.
  96. //
  97. // History: 10-27-1998 AnandhaG Created
  98. //
  99. //--------------------------------------------------------------------
  100. struct ColPosCompare : public std::binary_function<const CColumnInfo, INT, bool>
  101. {
  102. bool operator() (const CColumnInfo colinfo, INT nCol) const
  103. {
  104. return (nCol == colinfo.GetColIndex());
  105. }
  106. };
  107. //+-------------------------------------------------------------------
  108. //
  109. // Class: CColumnInfoList
  110. //
  111. // Purpose: linked list with CColumnInfo's.
  112. //
  113. // History: 02-11-1999 AnandhaG Created
  114. //
  115. //--------------------------------------------------------------------
  116. typedef list<CColumnInfo> CIL_base;
  117. class CColumnInfoList : public XMLListCollectionImp<CIL_base>, public CSerialObject
  118. {
  119. public:
  120. friend class CColumnSetData;
  121. public:
  122. CColumnInfoList ()
  123. {
  124. }
  125. ~CColumnInfoList()
  126. {
  127. }
  128. protected:
  129. DEFINE_XML_TYPE(XML_TAG_COLUMN_INFO_LIST);
  130. // CSerialObject methods
  131. virtual UINT GetVersion() {return 1;}
  132. virtual HRESULT ReadSerialObject (IStream &stm, UINT nVersion /*,LARGE_INTEGER nBytes*/);
  133. };
  134. #endif // COLUMNINFO_H_