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.

183 lines
4.2 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // ColItem.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CColumnItem class.
  10. //
  11. // Author:
  12. // David Potter (davidp) May 7, 1996
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "ColItem.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CColumnItem
  28. IMPLEMENT_DYNCREATE(CColumnItem, CObject)
  29. /////////////////////////////////////////////////////////////////////////////
  30. //++
  31. //
  32. // CColumnItem::CColumnItem
  33. //
  34. // Routine Description:
  35. // Default constructor.
  36. //
  37. // Arguments:
  38. // None.
  39. //
  40. // Return Value:
  41. // None.
  42. //
  43. //--
  44. /////////////////////////////////////////////////////////////////////////////
  45. CColumnItem::CColumnItem(void)
  46. {
  47. m_colid = 0;
  48. m_nDefaultWidth = COLI_WIDTH_DEFAULT;
  49. m_nWidth = COLI_WIDTH_DEFAULT;
  50. } //*** CColumnItem::CColumnItem()
  51. /////////////////////////////////////////////////////////////////////////////
  52. //++
  53. //
  54. // CColumnItem::CColumnItem
  55. //
  56. // Routine Description:
  57. // Constructor.
  58. //
  59. // Arguments:
  60. // rstrText [IN] Text that appears on the column header.
  61. // colid [IN] Column ID for identifying data relating to this column.
  62. // nDefaultWidth [IN] Default width of the column. Defaults to COLI_WIDTH_DEFAULT if -1.
  63. // nWidth [IN] Initial width of the column. Defaults to nDefaultWidth if -1.
  64. //
  65. // Return Value:
  66. // None.
  67. //
  68. //--
  69. /////////////////////////////////////////////////////////////////////////////
  70. CColumnItem::CColumnItem(
  71. IN const CString & rstrText,
  72. IN COLID colid,
  73. IN int nDefaultWidth, // = -1
  74. IN int nWidth // = -1
  75. )
  76. {
  77. ASSERT(colid != 0);
  78. ASSERT(nDefaultWidth > 0);
  79. ASSERT((nWidth > 0) || (nWidth == -1));
  80. if (nDefaultWidth == -1)
  81. nDefaultWidth = COLI_WIDTH_DEFAULT;
  82. if (nWidth == -1)
  83. nWidth = nDefaultWidth;
  84. m_strText = rstrText;
  85. m_colid = colid;
  86. m_nDefaultWidth = nDefaultWidth;
  87. m_nWidth = nWidth;
  88. } //*** CColumnItem::CColumnItem(pci)
  89. /////////////////////////////////////////////////////////////////////////////
  90. //++
  91. //
  92. // CColumnItem::~CColumnItem
  93. //
  94. // Routine Description:
  95. // Destructor.
  96. //
  97. // Arguments:
  98. // None.
  99. //
  100. // Return Value:
  101. // None.
  102. //
  103. //--
  104. /////////////////////////////////////////////////////////////////////////////
  105. CColumnItem::~CColumnItem(void)
  106. {
  107. } //*** CColumnItem::~CColumnItem()
  108. /////////////////////////////////////////////////////////////////////////////
  109. //++
  110. //
  111. // CColumnItem::PcoliClone
  112. //
  113. // Routine Description:
  114. // Clone the item.
  115. //
  116. // Arguments:
  117. // None.
  118. //
  119. // Return Value:
  120. // pcoli The newly created item that is a clone of this item.
  121. //
  122. //--
  123. /////////////////////////////////////////////////////////////////////////////
  124. CColumnItem * CColumnItem::PcoliClone(void)
  125. {
  126. CColumnItem * pcoli = NULL;
  127. pcoli = new CColumnItem(StrText(), NDefaultWidth(), NWidth());
  128. return pcoli;
  129. } //*** CColumnItem::PcoliClone()
  130. //*************************************************************************//
  131. /////////////////////////////////////////////////////////////////////////////
  132. // Global Functions
  133. /////////////////////////////////////////////////////////////////////////////
  134. /////////////////////////////////////////////////////////////////////////////
  135. //++
  136. //
  137. // DeleteAllItemData
  138. //
  139. // Routine Description:
  140. // Deletes all item data in a CList.
  141. //
  142. // Arguments:
  143. // rlp [IN OUT] Reference to the list whose data is to be deleted.
  144. //
  145. // Return Value:
  146. // None.
  147. //
  148. //--
  149. /////////////////////////////////////////////////////////////////////////////
  150. void DeleteAllItemData(IN OUT CColumnItemList & rlp)
  151. {
  152. POSITION pos;
  153. CColumnItem * pcoli;
  154. // Delete all the items in the Contained list.
  155. pos = rlp.GetHeadPosition();
  156. while (pos != NULL)
  157. {
  158. pcoli = rlp.GetNext(pos);
  159. ASSERT_VALID(pcoli);
  160. delete pcoli;
  161. } // while: more items in the list
  162. } //*** DeleteAllItemData()