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.

497 lines
12 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1999 - 1999
  5. *
  6. * File: amcview.inl
  7. *
  8. * Contents: Inline functions for CAMCView class.
  9. *
  10. * History: 29-Oct-99 AnandhaG Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #ifndef AMCVIEW_INL
  14. #define AMCVIEW_INL
  15. #pragma once
  16. //+-------------------------------------------------------------------
  17. //
  18. // Member: SetScopePaneVisible
  19. //
  20. // Synopsis: Sets the flag in the view data that indicates whether
  21. // the scope pane is visible or not. The window is
  22. // physically shown by ScShowScopePane.
  23. //
  24. // Arguments: [bVisible] -
  25. //
  26. // Returns: None
  27. //
  28. //--------------------------------------------------------------------
  29. inline void CAMCView::SetScopePaneVisible(bool bVisible)
  30. {
  31. /*
  32. * we should only be marking the scope pane visible if it is
  33. * allowed on this view
  34. */
  35. ASSERT (!bVisible || IsScopePaneAllowed());
  36. m_ViewData.SetScopePaneVisible (bVisible);
  37. }
  38. /*+-------------------------------------------------------------------------*
  39. * CAMCView::IsScopePaneVisible
  40. *
  41. * Returns true if the scope pane is visible in this view, false otherwise
  42. *--------------------------------------------------------------------------*/
  43. inline bool CAMCView::IsScopePaneVisible(void) const
  44. {
  45. bool fVisible = m_ViewData.IsScopePaneVisible();
  46. /*
  47. * the scope pane should only be visible if it is
  48. * permitted on this view
  49. */
  50. ASSERT (IsScopePaneAllowed() || !fVisible);
  51. return (fVisible);
  52. }
  53. //+-------------------------------------------------------------------
  54. //
  55. // Member: SetRootNode
  56. //
  57. // Synopsis: Set the root node.
  58. //
  59. // Arguments:
  60. //
  61. // Returns:
  62. //
  63. //--------------------------------------------------------------------
  64. inline void CAMCView::SetRootNode(HMTNODE hMTNode)
  65. {
  66. ASSERT(hMTNode != 0);
  67. ASSERT(m_hMTNode == 0);
  68. m_hMTNode = hMTNode;
  69. }
  70. //+-------------------------------------------------------------------
  71. //
  72. // Member: GetNodeCallback
  73. //
  74. // Synopsis:
  75. //
  76. // Arguments:
  77. //
  78. // Returns:
  79. //
  80. //--------------------------------------------------------------------
  81. inline INodeCallback* CAMCView::GetNodeCallback()
  82. {
  83. return m_spNodeCallback;
  84. }
  85. //+-------------------------------------------------------------------
  86. //
  87. // Member: GetScopeIterator
  88. //
  89. // Synopsis:
  90. //
  91. // Arguments:
  92. //
  93. // Returns:
  94. //
  95. //--------------------------------------------------------------------
  96. inline IScopeTreeIter* CAMCView::GetScopeIterator()
  97. {
  98. return m_spScopeTreeIter;
  99. }
  100. //+-------------------------------------------------------------------
  101. //
  102. // Member: DeleteView
  103. //
  104. // Synopsis:
  105. //
  106. // Arguments:
  107. //
  108. // Returns:
  109. //
  110. //--------------------------------------------------------------------
  111. inline void CAMCView::DeleteView()
  112. {
  113. GetParentFrame()->PostMessage(WM_SYSCOMMAND, SC_CLOSE, 0);
  114. }
  115. //+-------------------------------------------------------------------
  116. //
  117. // Member: GetScopeTreePtr
  118. //
  119. // Synopsis:
  120. //
  121. // Arguments:
  122. //
  123. // Returns:
  124. //
  125. //
  126. // Note: The document may release the scope tree without
  127. // notifying the view. The view should always go
  128. // through this function to obtain a pointer to the
  129. // the scope tree.
  130. //
  131. //--------------------------------------------------------------------
  132. inline IScopeTree* CAMCView::GetScopeTreePtr()
  133. {
  134. CAMCDoc* const pDoc = GetDocument();
  135. ASSERT(pDoc);
  136. if (!pDoc)
  137. return NULL;
  138. IScopeTree* const pScopeTree = pDoc->GetScopeTree();
  139. return pScopeTree;
  140. }
  141. //+-------------------------------------------------------------------
  142. //
  143. // Member: GetScopeTree
  144. //
  145. // Synopsis:
  146. //
  147. // Arguments:
  148. //
  149. // Returns:
  150. //
  151. //--------------------------------------------------------------------
  152. inline IScopeTree* CAMCView::GetScopeTree()
  153. {
  154. IScopeTree* const pScopeTree = GetScopeTreePtr();
  155. return pScopeTree;
  156. }
  157. //+-------------------------------------------------------------------
  158. //
  159. // Member: SetChildFrameWnd
  160. //
  161. // Synopsis:
  162. //
  163. // Arguments:
  164. //
  165. // Returns:
  166. //
  167. //--------------------------------------------------------------------
  168. inline void CAMCView::SetChildFrameWnd(HWND hwndChildFrame)
  169. {
  170. if (hwndChildFrame == NULL || !::IsWindow(hwndChildFrame))
  171. {
  172. ASSERT(FALSE); // Invalid Arguments
  173. return;
  174. }
  175. m_ViewData.m_hwndChildFrame = hwndChildFrame;
  176. }
  177. //+-------------------------------------------------------------------
  178. //
  179. // Member: GetParentFrame
  180. //
  181. // Synopsis:
  182. //
  183. // Arguments:
  184. //
  185. // Returns:
  186. //
  187. //--------------------------------------------------------------------
  188. inline CChildFrame* CAMCView::GetParentFrame () const
  189. {
  190. CChildFrame* pFrame = dynamic_cast<CChildFrame*>(CView::GetParentFrame());
  191. ASSERT (pFrame != NULL);
  192. ASSERT_VALID (pFrame);
  193. ASSERT_KINDOF (CChildFrame, pFrame);
  194. return (pFrame);
  195. }
  196. //+-------------------------------------------------------------------
  197. //
  198. // Member: IsTracking
  199. //
  200. // Synopsis:
  201. //
  202. // Arguments:
  203. //
  204. // Returns:
  205. //
  206. //--------------------------------------------------------------------
  207. inline bool CAMCView::IsTracking () const
  208. {
  209. return (m_pTracker != NULL);
  210. }
  211. //+-------------------------------------------------------------------
  212. //
  213. // Member: IsVerbEnabled
  214. //
  215. // Synopsis:
  216. //
  217. // Arguments:
  218. //
  219. // Returns:
  220. //
  221. //--------------------------------------------------------------------
  222. inline BOOL CAMCView::IsVerbEnabled(MMC_CONSOLE_VERB verb)
  223. {
  224. BOOL bFlag = FALSE;
  225. if (m_ViewData.m_spVerbSet != NULL)
  226. {
  227. HRESULT hr = m_ViewData.m_spVerbSet->GetVerbState(verb, ENABLED, &bFlag);
  228. if (FAILED(hr))
  229. bFlag = FALSE;
  230. }
  231. return bFlag;
  232. }
  233. //+-------------------------------------------------------------------
  234. //
  235. // Member: GetDefaultColumnWidths
  236. //
  237. // Synopsis:
  238. //
  239. // Arguments:
  240. //
  241. // Returns:
  242. //
  243. //--------------------------------------------------------------------
  244. inline void CAMCView::GetDefaultColumnWidths(int columnWidth[2])
  245. {
  246. columnWidth[0] = m_columnWidth[0];
  247. columnWidth[1] = m_columnWidth[1];
  248. }
  249. //+-------------------------------------------------------------------
  250. //
  251. // Member: SetDefaultColumnWidths
  252. //
  253. // Synopsis:
  254. //
  255. // Arguments:
  256. //
  257. // Returns:
  258. //
  259. //--------------------------------------------------------------------
  260. inline void CAMCView::SetDefaultColumnWidths(int columnWidth[2], BOOL fUpdate)
  261. {
  262. // Bug 157408: remove the "Type" column for static nodes
  263. columnWidth[1] = 0;
  264. m_columnWidth[0] = columnWidth[0];
  265. m_columnWidth[1] = columnWidth[1];
  266. if (fUpdate == TRUE && m_pListCtrl != NULL)
  267. {
  268. CListCtrl& lc = m_pListCtrl->GetListCtrl();
  269. lc.SetColumnWidth(0, m_columnWidth[0]);
  270. lc.SetColumnWidth(1, m_columnWidth[1]);
  271. }
  272. SetDirty();
  273. }
  274. //+-------------------------------------------------------------------
  275. //
  276. // Member: GetDefaultListViewStyle
  277. //
  278. // Synopsis:
  279. //
  280. //--------------------------------------------------------------------
  281. inline long CAMCView::GetDefaultListViewStyle() const
  282. {
  283. return m_DefaultLVStyle;
  284. }
  285. //+-------------------------------------------------------------------
  286. //
  287. // Member: SetDefaultListViewStyle
  288. //
  289. // Synopsis:
  290. //
  291. //--------------------------------------------------------------------
  292. inline void CAMCView::SetDefaultListViewStyle(long style)
  293. {
  294. m_DefaultLVStyle = style;
  295. }
  296. //+-------------------------------------------------------------------
  297. //
  298. // Member: GetViewMode
  299. //
  300. // Synopsis:
  301. //
  302. //--------------------------------------------------------------------
  303. inline int CAMCView::GetViewMode() const
  304. {
  305. return m_nViewMode;
  306. }
  307. //+-------------------------------------------------------------------
  308. //
  309. // Member: CanDoDragDrop
  310. //
  311. // Synopsis: if there are posted messages for multiselection changes
  312. // to be processed then do not do drag&drop.
  313. //
  314. //--------------------------------------------------------------------
  315. inline bool CAMCView::CanDoDragDrop()
  316. {
  317. if (m_pListCtrl && m_pListCtrl->IsListPad())
  318. return false;
  319. return !m_bProcessMultiSelectionChanges;
  320. }
  321. //+-------------------------------------------------------------------
  322. //
  323. // Member: HasListOrListPad
  324. //
  325. // Synopsis:
  326. //
  327. //--------------------------------------------------------------------
  328. inline bool CAMCView::HasListOrListPad() const
  329. {
  330. return (HasList() || HasListPad());
  331. }
  332. //+-------------------------------------------------------------------
  333. //
  334. // Member: HasListPad
  335. //
  336. // Synopsis:
  337. //
  338. //--------------------------------------------------------------------
  339. inline bool CAMCView::HasListPad() const
  340. {
  341. if (m_pListCtrl)
  342. return m_pListCtrl->IsListPad();
  343. return false;
  344. }
  345. //+-------------------------------------------------------------------
  346. //
  347. // Member: GetStdToolbar
  348. //
  349. // Synopsis:
  350. //
  351. //--------------------------------------------------------------------
  352. inline CStandardToolbar* CAMCView::GetStdToolbar() const
  353. {
  354. return dynamic_cast<CStandardToolbar*>(m_ViewData.GetStdVerbButtons());
  355. }
  356. //+-------------------------------------------------------------------
  357. //
  358. // Member: CAMCView::ScColumnInfoListChanged
  359. //
  360. // Synopsis: The column-info-list (width/order/hiddeness) for currently
  361. // selected node has changed ask nodemgr to persist the new data.
  362. //
  363. // Arguments: [colInfoList] - new data
  364. //
  365. // Returns: SC
  366. //
  367. //--------------------------------------------------------------------
  368. inline SC CAMCView::ScColumnInfoListChanged (const CColumnInfoList& colInfoList)
  369. {
  370. DECLARE_SC(sc, _T("CAMCView::ScColumnInfoListChanged"));
  371. INodeCallback* spNodeCallback = GetNodeCallback();
  372. HNODE hNode = GetSelectedNode();
  373. sc = ScCheckPointers(spNodeCallback, hNode, E_UNEXPECTED);
  374. if(sc)
  375. return sc;
  376. sc = spNodeCallback->SaveColumnInfoList(hNode, colInfoList);
  377. return (sc);
  378. }
  379. //+-------------------------------------------------------------------
  380. //
  381. // Member: CAMCView::ScGetPersistedColumnInfoList
  382. //
  383. // Synopsis: The list-view requests the column-data (no sort data) to setup the headers
  384. // before any items are inserted into the list-view. Forward this
  385. // request to nodemgr.
  386. //
  387. // Arguments: [pColInfoList] - [out param]
  388. //
  389. // Returns: SC
  390. //
  391. //--------------------------------------------------------------------
  392. inline SC CAMCView::ScGetPersistedColumnInfoList (CColumnInfoList *pColInfoList)
  393. {
  394. DECLARE_SC(sc, _T("CAMCView::ScGetPersistedColumnInfoList"));
  395. INodeCallback* spNodeCallback = GetNodeCallback();
  396. HNODE hNode = GetSelectedNode();
  397. sc = ScCheckPointers(spNodeCallback, hNode, E_UNEXPECTED);
  398. if(sc)
  399. return sc;
  400. sc = spNodeCallback->GetPersistedColumnInfoList(hNode, pColInfoList);
  401. return (sc);
  402. }
  403. //+-------------------------------------------------------------------
  404. //
  405. // Member: CAMCView::ScDeletePersistedColumnData
  406. //
  407. // Synopsis: The column data for currently selected node is invalid,
  408. // ask nodemgr to remove it.
  409. //
  410. // Returns: SC
  411. //
  412. //--------------------------------------------------------------------
  413. inline SC CAMCView::ScDeletePersistedColumnData ()
  414. {
  415. DECLARE_SC(sc, _T("CAMCView::ScDeletePersistedColumnData"));
  416. INodeCallback* spNodeCallback = GetNodeCallback();
  417. HNODE hNode = GetSelectedNode();
  418. sc = ScCheckPointers(spNodeCallback, hNode, E_UNEXPECTED);
  419. if(sc)
  420. return sc;
  421. sc = spNodeCallback->DeletePersistedColumnData(hNode);
  422. return (sc);
  423. }
  424. //+-------------------------------------------------------------------
  425. //
  426. // Member: CanInsertScopeItemInResultPane
  427. //
  428. // Synopsis: Can we insert child scope items of currently selected scope
  429. // item in the listview.
  430. //
  431. //--------------------------------------------------------------------
  432. inline bool CAMCView::CanInsertScopeItemInResultPane()
  433. {
  434. // Can insert only if
  435. // a) it is a non-virtual result list,
  436. // b) Don't add the item if a node select is in progress
  437. // because the tree control will automatically add all
  438. // scope items as part of the select procedure.
  439. // c) view-option to exclude scope items in result pane is not specified.
  440. return (!IsVirtualList() && !IsSelectingNode() && !(GetListOptions() & RVTI_LIST_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST) );
  441. }
  442. #endif // AMCVIEW_INL