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.

212 lines
5.0 KiB

  1. // ResltObj.h The classes for result objects.
  2. //
  3. // Copyright (c) 1998-1999 Microsoft Corporation
  4. #pragma once
  5. #define MSINFO_RESLTOBJ_H
  6. #include <afxtempl.h>
  7. #include "DataSrc.h"
  8. #include "StrList.h"
  9. #include "resource.h"
  10. #include "resrc1.h"
  11. /*
  12. * CViewObject - A single view item (scope or result).
  13. *
  14. * History: a-jsari 10/3/97 Initial version
  15. */
  16. class CViewObject {
  17. public:
  18. virtual ~CViewObject() {}
  19. enum ViewType { CATEGORY, DATUM, EXTENSION_ROOT };
  20. virtual LPCWSTR GetTextItem(int nCol = 0) = 0;
  21. virtual ViewType GetType() const = 0;
  22. virtual CFolder *Parent() const = 0;
  23. CFolder *Category() const { return m_pCategory; }
  24. protected:
  25. CViewObject(CFolder *pfolSelection) :m_pCategory(pfolSelection) { }
  26. CFolder *m_pCategory;
  27. };
  28. /*
  29. * CCategoryObject - A single category.
  30. *
  31. * History: a-jsari 10/3/97 Initial version
  32. */
  33. class CCategoryObject : public CViewObject {
  34. public:
  35. CCategoryObject(CFolder *pfolSelection) :CViewObject(pfolSelection) { }
  36. virtual ~CCategoryObject() {}
  37. virtual LPCWSTR GetTextItem(int nCol = 0);
  38. virtual ViewType GetType() const { return CATEGORY; }
  39. virtual CFolder *Parent() const { return m_pCategory->GetParentNode(); }
  40. private:
  41. CCategoryObject();
  42. CString m_strElement;
  43. };
  44. /*
  45. * CDatumObject - A single datum item.
  46. *
  47. * History: a-jsari 10/3/97 Initial version
  48. */
  49. class CDatumObject : public CViewObject {
  50. public:
  51. CDatumObject(CFolder *pfolSelection, int nIndex)
  52. :CViewObject(pfolSelection), m_nRow(nIndex) { ASSERT(pfolSelection->GetType() != CDataSource::OCX); }
  53. virtual ~CDatumObject() {}
  54. virtual LPCWSTR GetTextItem(int nCol = 0);
  55. virtual ViewType GetType() const { return DATUM; }
  56. virtual CFolder *Parent() const { return m_pCategory; }
  57. virtual DWORD GetSortIndex(int nCol = 0) const;
  58. private:
  59. CStringValues m_szValues;
  60. int m_nRow;
  61. };
  62. /*
  63. * CExtensionRootObject - The unique
  64. *
  65. * History: a-jsari 1/7/98 Initial version.
  66. */
  67. class CExtensionRootObject : public CViewObject {
  68. public:
  69. CExtensionRootObject(CFolder *pfolSelection);
  70. virtual LPCWSTR GetTextItem(int nCol = 0);
  71. virtual ViewType GetType() const { return EXTENSION_ROOT; }
  72. virtual CFolder *Parent() const { return NULL; }
  73. private:
  74. CString m_strTitle;
  75. };
  76. /*
  77. * GetTextItem - Return the text result value for a result field item.
  78. *
  79. * History: a-jsari 10/5/97 Initial version
  80. */
  81. inline LPCWSTR CDatumObject::GetTextItem(int nCol)
  82. {
  83. BOOL fReturn;
  84. // OCX Folders should not have this called for them.
  85. ASSERT(m_pCategory->GetType() != CDataSource::OCX);
  86. fReturn = dynamic_cast<CListViewFolder *>(m_pCategory)->GetSubElement(m_nRow, nCol,
  87. m_szValues[nCol]);
  88. return fReturn ? (LPCWSTR)m_szValues[nCol] : NULL;
  89. }
  90. /*
  91. * GetSortIndex - Return the sort index associated with the current row and column.
  92. *
  93. * History: a-jsari 12/1/97 Initial version
  94. */
  95. inline DWORD CDatumObject::GetSortIndex(int nCol) const
  96. {
  97. DWORD iSort;
  98. CString szValue;
  99. ASSERT(m_pCategory->GetType() != CDataSource::OCX);
  100. iSort = dynamic_cast<CListViewFolder *>(m_pCategory)->GetSortIndex(m_nRow, nCol);
  101. return iSort;
  102. }
  103. /*
  104. * GetTextItem - Return the text result values for a category item.
  105. *
  106. * History: a-jsari 10/5/97 Initial version
  107. */
  108. inline LPCWSTR CCategoryObject::GetTextItem(int nCol)
  109. {
  110. BOOL fReturn;
  111. if (nCol > 0) {
  112. return L"";
  113. } else {
  114. fReturn = m_pCategory->GetName(m_strElement);
  115. return m_strElement;
  116. }
  117. }
  118. /*
  119. * CExtensionRootObject - Load the extension root node name from the resources.
  120. *
  121. * History: a-jsari 1/7/98 Initial version.
  122. */
  123. inline CExtensionRootObject::CExtensionRootObject(CFolder *pfolSelection)
  124. :CViewObject(pfolSelection)
  125. {
  126. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  127. VERIFY(m_strTitle.LoadString(IDS_EXTENSIONNODENAME));
  128. }
  129. /*
  130. * GetTextItem - Return the root extension object's text value.
  131. *
  132. * History: a-jsari 1/7/98 Initial version.
  133. */
  134. inline LPCWSTR CExtensionRootObject::GetTextItem(int nCol)
  135. {
  136. AFX_MANAGE_STATE(::AfxGetStaticModuleState());
  137. USES_CONVERSION;
  138. static CString strCaption(_T(""));
  139. switch (nCol)
  140. {
  141. case 0:
  142. strCaption = m_strTitle;
  143. break;
  144. case 1:
  145. strCaption.LoadString(IDS_ROOT_NODE_TYPE);
  146. break;
  147. case 2:
  148. strCaption.LoadString(IDS_ROOT_NODE_DESCRIPTION);
  149. break;
  150. default:
  151. ASSERT(FALSE);
  152. }
  153. return T2CW((LPCTSTR)strCaption);
  154. }
  155. /*
  156. * CViewObjectList - A list of CViewObject items.
  157. *
  158. * History: a-jsari 10/8/97 Initial version
  159. */
  160. class CViewObjectList {
  161. public:
  162. // 60 is the size of a resize unit; when it resizes, it does it in
  163. // increments of 60
  164. CViewObjectList() :m_lstViewObjects(60) {}
  165. ~CViewObjectList() { Clear(); }
  166. void Add(CViewObject *pvoNode) { (void) m_lstViewObjects.AddHead(pvoNode); }
  167. void Clear();
  168. private:
  169. CList<CViewObject *, CViewObject * &> m_lstViewObjects;
  170. };
  171. /*
  172. * ~CViewObjectList - Delete all CViewObject pointers.
  173. *
  174. * History: a-jsari 10/8/97 Initial version
  175. */
  176. inline void CViewObjectList::Clear()
  177. {
  178. CViewObject *pvoIterator;
  179. while (!m_lstViewObjects.IsEmpty()) {
  180. pvoIterator = m_lstViewObjects.RemoveHead();
  181. delete pvoIterator;
  182. }
  183. }