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.

247 lines
7.5 KiB

  1. // Copyright (C) 1997 Microsoft Corporation
  2. //
  3. // Scope Node class
  4. //
  5. // 9-4-97 sburns
  6. #ifndef SCOPNODE_HPP_INCLUDED
  7. #define SCOPNODE_HPP_INCLUDED
  8. #include "node.hpp"
  9. // Struct used by BuildResultColumns. Should be nested in ScopeNode, but vc++
  10. // templates seem to have trouble with nested classes as parameters.
  11. struct ResultColumn
  12. {
  13. int colTextResID; // header text string resource ID
  14. int colWidthResID; // string with decimal integer pixel width
  15. };
  16. // ScopeNode instances represent items appearing in the scope pane. An
  17. // instance of ScopeNode "owns" the items (which are ResultNode instances) to
  18. // be displayed in the result pane when that instance is expanded in the scope
  19. // pane.
  20. class ScopeNode : public Node
  21. {
  22. public:
  23. // Returns the text to be displayed in the description bar of the result
  24. // pane when the node is shown. The default implementation returns the
  25. // empty string.
  26. virtual
  27. String
  28. GetDescriptionBarText();
  29. // Returns the number of scope children that will be inserted by
  30. // InsertScopeChildren. The default implementation returns 0. If you
  31. // don't know how many children you will have, return 1.
  32. virtual
  33. int
  34. GetNumberOfScopeChildren();
  35. // Returns the image index of the icon image for this node to be used then
  36. // the node is shown in the "open" or expanded state. This is the index of
  37. // the image that was registered with MMC by IComponent in response to the
  38. // MMCN_ADD_IMAGES notification. This should always return the same index
  39. // for all invocations.
  40. virtual
  41. int
  42. GetOpenImageIndex() = 0;
  43. // The default implementation returns MMC_VIEW_OPTIONS_NONE;
  44. virtual
  45. long
  46. GetViewOptions();
  47. // Called from IComponentData::Notify upon receipt of a MMCN_EXPAND
  48. // notification. Derived classes should override this function to insert
  49. // any subordinate ScopeNodes (*not* ResultNodes). The default
  50. // implementation does nothing, and returns S_OK.
  51. //
  52. // nameSpace - The console's IConsoleNameSpace2 interface, obtained upon
  53. // IComponentData::Initialize.
  54. //
  55. // scopeID - The HSCOPEITEM passed as the param argument to the MMCN_EXPAND
  56. // notification.
  57. virtual
  58. HRESULT
  59. InsertScopeChildren(
  60. IConsoleNameSpace2& nameSpace,
  61. HSCOPEITEM scopeID);
  62. // Called by IComponent::Notify upon receipt of a MMCN_SHOW notification.
  63. // Derived classes should provide an implementation which inserts columns
  64. // for each of the columns supported by the node's owned items; that is,
  65. // for each column for which the owned node's GetColumnText method will
  66. // support.
  67. //
  68. // headerCtrl - The console's IHeaderCtrl interface, obtained upon
  69. // IComponentData::Initialize
  70. virtual
  71. HRESULT
  72. InsertResultColumns(IHeaderCtrl& headerCtrl) = 0;
  73. // Called by IComponent::Notify upon receipt of a MMCN_SHOW notification,
  74. // or MMCN_VIEW_CHANGE notification (where the arg indicates that the
  75. // result pane is to be re-populated). Derived classes should iterate
  76. // through their dependent ResultNodes, calling InsertIntoResultPane for
  77. // each.
  78. //
  79. // resultData - The console's IResultData interface, obtained upon
  80. // IComponentData::Initialize.
  81. virtual
  82. HRESULT
  83. InsertResultItems(IResultData& resultData) = 0;
  84. // Inserts self into the scope pane. Typically called from a parent
  85. // ScopeNode's implementation of InsertScopeChildren.
  86. //
  87. // nameSpace - The console's IConsoleNameSpace2 interface, obtained upon
  88. // IComponentData::Initialize.
  89. //
  90. // parentScopeID - The HSCOPEITEM passed as the param argument to the
  91. // MMCN_EXPAND notification received by the parent ScopeNode, then passed
  92. // to the parent ScopeNode's InsertScopeChildren
  93. HRESULT
  94. InsertIntoScopePane(
  95. IConsoleNameSpace2& nameSpace,
  96. HSCOPEITEM parentScopeID);
  97. // Called by IComponent::Notify upon receipt of a MMCN_REFRESH
  98. // notification, if the node's implementation of UpdateVerbs has enabled
  99. // the MMC_VERB_REFERESH verb.
  100. //
  101. // Derived classes should release any dependent data, then rebuild it.
  102. //
  103. // The refresh cycle works like this:
  104. // MMCN_REFRESH received for the ScopeNode
  105. // - UpdateAllViews is called to clear the result pane of any view for
  106. // which the current selected node is the same ScopeNode. This is
  107. // done by comparing nodes and using IResultData::DeleteAllRsltItems.
  108. // - ScopeNode::RebuildResultItems is called for the ScopeNode.
  109. // - UpdateAllViews is called to repopulate the result pane of any view
  110. // for which the current selected node is the same ScopeNode. This
  111. // is done by comparing nodes and calling InsertResultItems for the
  112. // ScopeNode.
  113. virtual
  114. HRESULT
  115. RebuildResultItems();
  116. // Removes self from the scope pane. Typically called from a parent
  117. // ScopeNode's implementation of RemoveScopeChildren on it's children.
  118. //
  119. // If this node has scope pane children, then this call will cause
  120. // MMCN_REMOVE_CHILDREN to be fired for this node, which will call
  121. // RemoveScopeChildren for this node.
  122. //
  123. // nameSpace - the console's IConsoleNameSpace2 interface, obtained upon
  124. // IComponentData::Initialize.
  125. HRESULT
  126. RemoveFromScopePane(IConsoleNameSpace2& nameSpace);
  127. // Called from IComponentData::Notify upon receipt of a
  128. // MMCN_REMOVE_CHILDREN notification. Derived classes should override this
  129. // function to remove any subordinate ScopeNodes (*not* ResultNodes). The
  130. // default implementation does nothing, and returns S_OK.
  131. //
  132. // nameSpace - The console's IConsoleNameSpace2 interface, obtained upon
  133. // IComponentData::Initialize.
  134. //
  135. // parentScopeID - The HSCOPEITEM passed as the param argument to the
  136. // MMCN_REMOVE_CHILDREN notification.
  137. virtual
  138. HRESULT
  139. RemoveScopeChildren(
  140. IConsoleNameSpace2& nameSpace,
  141. HSCOPEITEM parentScopeID);
  142. protected:
  143. // Constructs a new instance. Declared protected to allow this class to
  144. // only be a base class.
  145. //
  146. // owner - supplied to base class contructor
  147. //
  148. // nodeType - NodeType GUID supplied to the base class constructor.
  149. ScopeNode(
  150. const SmartInterface<ComponentData>& owner,
  151. const NodeType& nodeType);
  152. virtual ~ScopeNode();
  153. // Helper function used to implement InsertResultColumns.
  154. //
  155. // begin - Iterator positioned to the beginning ResultColumn instance.
  156. //
  157. // end - Iterator positioned just beyond the last ResultColumn instance.
  158. //
  159. // headerCtrl - the IHeaderCtrl instance passed to InsertResultColumns.
  160. template <class InputIterator>
  161. HRESULT
  162. BuildResultColumns(
  163. InputIterator begin,
  164. InputIterator end,
  165. IHeaderCtrl& headerCtrl)
  166. {
  167. int col = 0;
  168. HRESULT hr = S_OK;
  169. for (
  170. ;
  171. begin != end;
  172. ++begin)
  173. {
  174. int width = 0;
  175. String::load((*begin).colWidthResID).convert(width);
  176. // minimum width is 100 units.
  177. width = max(100, width);
  178. hr =
  179. headerCtrl.InsertColumn(
  180. col++,
  181. String::load((*begin).colTextResID).c_str(),
  182. LVCFMT_LEFT,
  183. width);
  184. BREAK_ON_FAILED_HRESULT(hr);
  185. }
  186. return hr;
  187. }
  188. private:
  189. HSCOPEITEM item_id;
  190. // not implemented: no copying allowed
  191. ScopeNode(const ScopeNode&);
  192. const ScopeNode& operator=(const ScopeNode&);
  193. };
  194. #endif // SCOPNODE_HPP_INCLUDED