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.

1045 lines
37 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999 - 1999
  6. //
  7. // File: amcview.h
  8. //
  9. //--------------------------------------------------------------------------
  10. // AMCView.h : interface of the CAMCView class
  11. //
  12. /////////////////////////////////////////////////////////////////////////////
  13. #ifndef __AMCVIEW_H__
  14. #define __AMCVIEW_H__
  15. #ifndef __CONTROLS_H__
  16. #include "controls.h"
  17. #endif
  18. // this is needed for inline CAMCView::GetScopeTreePtr below
  19. #ifndef AMCDOC_H__
  20. #include "amcdoc.h"
  21. #endif
  22. // this is needed for CAMCView::GetParentFrame below
  23. #ifndef CHILDFRM_H
  24. #include "childfrm.h"
  25. #endif
  26. #include "amcpriv.h"
  27. #include "cclvctl.h"
  28. #include "amcnav.h"
  29. #include "conview.h" // for CConsoleView
  30. #include "treeobsv.h"
  31. #include "stdbar.h"
  32. #define UNINIT_VALUE -1 // Unitialised value
  33. #define BORDERPADDING 4 // Some multiple that stops the splitter from
  34. // being pushed into the right border
  35. #define AMC_LISTCTRL_CLSID _T("{1B3C1394-D68B-11CF-8C2B-00AA003CA9F6}")
  36. // REVIEW embed this in the class so it's hidden
  37. // NOTE struct added to protected section
  38. // Forward declarations
  39. class CAMCDoc;
  40. class CAMCTreeView;
  41. class CAMCGenericOcxCtrl;
  42. class CAMCWebViewCtrl;
  43. class CAMCView;
  44. class CListViewSub;
  45. class CCCListViewCtrl;
  46. class COCXHostView;
  47. class CHistoryList;
  48. class CChildFrame;
  49. class CViewTracker;
  50. class CBookmark;
  51. class CTaskPadHost;
  52. class CMemento;
  53. class CViewSettings;
  54. class CFolderTabView;
  55. class CMMCToolBar;
  56. class CAMCViewToolbars;
  57. class CStandardToolbar;
  58. struct NMFOLDERTAB;
  59. struct TRACKER_INFO;
  60. struct SViewUpdateInfo;
  61. typedef CList<HMTNODE, HMTNODE> CHMTNODEList;
  62. #ifdef DBG
  63. extern CTraceTag tagSplitterTracking;
  64. #endif
  65. //____________________________________________________________________________
  66. //
  67. // class: ViewSettings
  68. //____________________________________________________________________________
  69. //
  70. class ViewSettings
  71. {
  72. public:
  73. struct ScopeSettings
  74. {
  75. int cxWidth;
  76. int cxMin;
  77. };
  78. explicit ViewSettings(CAMCView* v);
  79. ~ViewSettings()
  80. {
  81. }
  82. int GetViewID() const
  83. {
  84. return m_nViewID;
  85. }
  86. BOOL IsDescriptionbarVisible() const
  87. {
  88. return m_bDescriptionbarVisible;
  89. }
  90. int GetViewMode() const
  91. {
  92. return m_nViewMode;
  93. }
  94. long GetListViewStyle() const
  95. {
  96. return m_nListViewStyle;
  97. }
  98. const ScopeSettings& GetScopeSettings() const
  99. {
  100. return m_Scope;
  101. }
  102. BOOL IsScopePaneVisible() const
  103. {
  104. return m_bScopePaneVisible;
  105. }
  106. void GetDefaultColumnWidths(int w[2])
  107. {
  108. w[0] = m_DefaultColumnWidths[0];
  109. w[1] = m_DefaultColumnWidths[1];
  110. }
  111. long GetDefaultLVStyle()
  112. {
  113. return m_DefaultLVStyle;
  114. }
  115. private:
  116. int m_nViewID;
  117. BOOL m_bDescriptionbarVisible;
  118. int m_nViewMode;
  119. long m_nListViewStyle;
  120. ScopeSettings m_Scope;
  121. BOOL m_bScopePaneVisible;
  122. long m_DefaultLVStyle;
  123. int m_DefaultColumnWidths[2];
  124. };
  125. /*+-------------------------------------------------------------------------*
  126. * class CAMCView
  127. *
  128. *
  129. * PURPOSE: The console view UI class
  130. *
  131. *+-------------------------------------------------------------------------*/
  132. class CAMCView: public CView, public CConsoleView, public CTiedObject,
  133. public CXMLObject, public CEventSource<CAMCViewObserver>,
  134. public CTreeViewObserver, public CListViewActivationObserver,
  135. public COCXHostActivationObserver, public CAMCDocumentObserver,
  136. public CListViewObserver
  137. {
  138. friend class CMainFrame;
  139. friend void CALLBACK TrackerCallback(TRACKER_INFO* pinfo, bool bAcceptChange, bool fSyncLayout);
  140. // Object model related
  141. private:
  142. ViewPtr m_spView;
  143. public:
  144. // View interface
  145. //#######################################################################
  146. //#######################################################################
  147. //
  148. // Item and item collection related methods
  149. //
  150. //#######################################################################
  151. //#######################################################################
  152. SC Scget_ActiveScopeNode( PPNODE ppNode);
  153. SC Scput_ActiveScopeNode( PNODE pNode);
  154. SC Scget_Selection( PPNODES ppNodes);
  155. SC Scget_ListItems( PPNODES ppNodes);
  156. SC ScSnapinScopeObject( VARIANT& varScopeNode, PPDISPATCH ScopeNodeObject);
  157. SC ScSnapinSelectionObject( PPDISPATCH SelectedObject);
  158. //#######################################################################
  159. //#######################################################################
  160. SC ScIs (PVIEW pView, VARIANT_BOOL *pbTheSame);
  161. SC Scget_Document( PPDOCUMENT ppDocument );
  162. //#######################################################################
  163. //#######################################################################
  164. //
  165. // Selection changing methods
  166. //
  167. //#######################################################################
  168. //#######################################################################
  169. SC ScSelectAll();
  170. SC ScSelect( PNODE pNode);
  171. SC ScDeselect( PNODE pNode);
  172. SC ScIsSelected( PNODE pNode, PBOOL pIsSelected);
  173. //#######################################################################
  174. //#######################################################################
  175. //
  176. // Verb and selection related methods
  177. //
  178. //#######################################################################
  179. //#######################################################################
  180. SC ScDisplayScopeNodePropertySheet(VARIANT& varScopeNode);
  181. SC ScDisplaySelectionPropertySheet();
  182. SC ScCopyScopeNode( VARIANT& varScopeNode);
  183. SC ScCopySelection();
  184. SC ScDeleteScopeNode( VARIANT& varScopeNode);
  185. SC ScDeleteSelection();
  186. SC ScRenameScopeNode( BSTR bstrNewName, VARIANT& varScopeNode);
  187. SC ScRenameSelectedItem( BSTR bstrNewName);
  188. SC Scget_ScopeNodeContextMenu( VARIANT& varScopeNode, PPCONTEXTMENU ppContextMenu, bool bMatchGivenNode = false);
  189. SC Scget_SelectionContextMenu( PPCONTEXTMENU ppContextMenu);
  190. SC ScRefreshScopeNode( VARIANT& varScopeNode);
  191. SC ScRefreshSelection();
  192. SC ScExecuteSelectionMenuItem(BSTR MenuItemPath);
  193. SC ScExecuteScopeNodeMenuItem(BSTR MenuItemPath, VARIANT& varScopeNode /* = ActiveScopeNode */);
  194. SC ScExecuteShellCommand(BSTR Command, BSTR Directory, BSTR Parameters, BSTR WindowState);
  195. //#######################################################################
  196. //#######################################################################
  197. //
  198. // Frame and view related methods
  199. //
  200. //#######################################################################
  201. //#######################################################################
  202. SC Scget_Frame( PPFRAME ppFrame);
  203. SC ScClose();
  204. SC Scget_ScopeTreeVisible( PBOOL pbVisible );
  205. SC Scput_ScopeTreeVisible( BOOL bVisible );
  206. SC ScBack();
  207. SC ScForward();
  208. SC Scput_StatusBarText(BSTR StatusBarText);
  209. SC Scget_Memento(PBSTR Memento);
  210. SC ScViewMemento(BSTR Memento);
  211. //#######################################################################
  212. //#######################################################################
  213. //
  214. // List related methods
  215. //
  216. //#######################################################################
  217. //#######################################################################
  218. SC Scget_Columns( PPCOLUMNS Columns);
  219. SC Scget_CellContents( PNODE Node, long Column, PBSTR CellContents);
  220. SC ScExportList( BSTR bstrFile, ExportListOptions exportoptions /* = ExportListOptions_Default*/);
  221. SC Scget_ListViewMode( PLISTVIEWMODE pMode);
  222. SC Scput_ListViewMode( ListViewMode mode);
  223. //#######################################################################
  224. //#######################################################################
  225. //
  226. // ActiveX control related methods
  227. //
  228. //#######################################################################
  229. //#######################################################################
  230. SC Scget_ControlObject( PPDISPATCH Control);
  231. // helper functions
  232. SC ScGetOptionalScopeNodeParameter(VARIANT &varScopeNode, PPNODE ppNode, bool& bMatchedGivenNode);
  233. SC ScExecuteMenuItem(PCONTEXTMENU pContextMenu, BSTR MenuItemPath);
  234. SC ScGetMMCView(View **ppView);
  235. // Frame interface
  236. SC ScMaximize ();
  237. SC ScMinimize ();
  238. SC ScRestore ();
  239. SC Scget_Left ( LPINT pCoord );
  240. SC Scput_Left ( INT coord );
  241. SC Scget_Right ( LPINT pCoord);
  242. SC Scput_Right ( INT coord );
  243. SC Scget_Top ( LPINT pCoord);
  244. SC Scput_Top ( INT coord );
  245. SC Scget_Bottom ( LPINT pCoord);
  246. SC Scput_Bottom ( INT coord );
  247. // Frame interface for the view extension hosted frame
  248. SC ScSetViewExtensionFrame(bool bShowListView, INT top, INT left, INT bottom, INT right);
  249. // Frame int helpers
  250. enum coord_t { LEFT, TOP, RIGHT, BOTTOM };
  251. SC ScGetFrameCoord (LPINT pCoord, coord_t eCoord );
  252. SC ScSetFrameCoord (INT coord, coord_t eCoord );
  253. SC ScGetRectCoord (const RECT& rect, LPINT pCoord, coord_t eCoord );
  254. SC ScSetRectCoord (RECT& rect, INT coord, coord_t eCoord );
  255. // Node locating helpers (used from view control)
  256. SC ScFindResultItemForScopeNode( PNODE pNode, HRESULTITEM &itm );
  257. SC ScGetScopeNode( HNODE hNode, PPNODE ppNode );
  258. SC ScNotifySelect (INodeCallback* pCallback, HNODE hNode, bool fMultiSelect,
  259. bool fSelect, SELECTIONINFO* pSelInfo);
  260. protected: // create from serialization only
  261. CAMCView();
  262. DECLARE_DYNCREATE(CAMCView);
  263. // Helper methods.
  264. private:
  265. enum EListSaveErrorType {LSaveReadOnly, LSaveCantCreate, LSaveCantWrite};
  266. bool Write2File(HANDLE hfile, TCHAR const * strwrite, int type);
  267. void ListSaveErrorMes(EListSaveErrorType etype, HANDLE hfile = NULL, LPCTSTR lpFileName = NULL);
  268. SC ScExportListWorker();
  269. SC ScGetExportListFile (CString& strFileName, bool& bUnicode,
  270. bool& bTabDelimited, bool& bSelectedRowsOnly);
  271. SC ScCreateExportListFile(const CString& strFileName, bool bUnicode,
  272. bool bShowErrorDialogs, HANDLE& hFile);
  273. SC ScWriteExportListData (const CString& strFileName, bool bUnicode,
  274. bool bTabDelimited, bool bSelectedRowsOnly,
  275. bool bShowErrorDialogs = true);
  276. SC ScUpdateStandardbarMMCButtons();
  277. void SetScopePaneVisible(bool bVisible);
  278. // tree observer methods
  279. virtual SC ScOnItemDeselected(HNODE hNode);
  280. virtual SC ScOnTreeViewActivated ();
  281. // ListViewActivationObserver methods.
  282. virtual SC ScOnListViewActivated ();
  283. virtual SC ScOnListViewItemUpdated (int nIndex); // called when an item is updated
  284. // OCX or Web HostActivationObserver mthods.
  285. virtual SC ScOnOCXHostActivated ();
  286. // AMCDoc observer
  287. virtual SC ScDocumentLoadCompleted (CAMCDoc *pDoc);
  288. // Persistence related methods.
  289. public:
  290. DEFINE_XML_TYPE(XML_TAG_VIEW);
  291. virtual void Persist(CPersistor& persistor);
  292. // Loads all of the local data previously saved by Save(). Restores
  293. // the window to the original state.
  294. // Returns true if the data and window state is successfully restored.
  295. bool Load(IStream& stream);
  296. bool IsDirty();
  297. void SetDirty (bool bDirty = true)
  298. {
  299. m_bDirty = bDirty;
  300. // m_pDocument->SetModifiedFlag (bDirty);
  301. }
  302. // Information set and get methods
  303. public:
  304. // Enum types for args
  305. // NOTE: Enum values are relevant!
  306. enum EUIStyleType {uiClientEdge,uiNoClientEdge};
  307. CAMCDoc* GetDocument();
  308. CHistoryList* GetHistoryList() { return m_pHistoryList; }
  309. void GetPaneInfo(ViewPane ePane, int* pcxCur,int* pcxMin);
  310. void SetPaneInfo(ViewPane ePane, int cxCur, int cxMin);
  311. CView* GetPaneView(ViewPane ePane);
  312. // what's in the view?
  313. bool HasList () const { return m_ViewData.HasList(); }
  314. bool HasOCX () const { return m_ViewData.HasOCX(); }
  315. bool HasWebBrowser () const { return m_ViewData.HasWebBrowser(); }
  316. bool HasListPad () const;
  317. bool HasListOrListPad () const;
  318. DWORD GetListOptions() const { return m_ViewData.GetListOptions();}
  319. DWORD GetHTMLOptions() const { return m_ViewData.GetHTMLOptions();}
  320. DWORD GetOCXOptions() const { return m_ViewData.GetOCXOptions();}
  321. DWORD GetMiscOptions() const { return m_ViewData.GetMiscOptions();}
  322. CDescriptionCtrl& GetRightDescCtrl(void) { return m_RightDescCtrl; }
  323. BOOL IsVerbEnabled(MMC_CONSOLE_VERB verb);
  324. void GetDefaultColumnWidths(int columnWidth[2]);
  325. void SetDefaultColumnWidths(int columnWidth[2], BOOL fUpdate = TRUE);
  326. CStandardToolbar* GetStdToolbar() const;
  327. INodeCallback* GetNodeCallback(); // returns a reference to view's callback interface
  328. IScopeTreeIter* GetScopeIterator(); // returns a reference to view's scope tree interator
  329. IScopeTree* GetScopeTree(); // returns a reference to scope tree
  330. friend ViewSettings;
  331. void GetTaskpadID(GUID &guidID);
  332. ViewSettings* GetViewSettings()
  333. {
  334. ViewSettings* pVS = new ViewSettings(this);
  335. ASSERT(pVS != NULL);
  336. return pVS;
  337. }
  338. CAMCTreeView* GetTreeCtrl() { return m_pTreeCtrl; }
  339. void SetUsingDefColumns(bool bDefColumns) { m_bDefColumns = bDefColumns; }
  340. bool UsingDefColumns() { return m_bDefColumns; }
  341. bool IsScopePaneVisible(void) const;
  342. UINT GetViewID(void);
  343. void SetViewID(UINT id) { m_nViewID = m_ViewData.m_nViewID = id; }
  344. SViewData* GetViewData() { return &m_ViewData; }
  345. bool IsVirtualList() { return (m_ViewData.IsVirtualList()); }
  346. bool AreStdToolbarsAllowed() const
  347. {
  348. return !(m_ViewData.m_lWindowOptions & MMC_NW_OPTION_NOTOOLBARS);
  349. }
  350. bool IsScopePaneAllowed() const
  351. {
  352. return !(m_ViewData.m_lWindowOptions & MMC_NW_OPTION_NOSCOPEPANE);
  353. }
  354. bool HasCustomTitle() const
  355. {
  356. return (m_ViewData.m_lWindowOptions & MMC_NW_OPTION_CUSTOMTITLE);
  357. }
  358. bool IsPersisted() const
  359. {
  360. return (!(m_ViewData.m_lWindowOptions & MMC_NW_OPTION_NOPERSIST) &&
  361. !m_fRootedAtNonPersistedDynamicNode);
  362. }
  363. bool IsAuthorModeView() const
  364. {
  365. return m_bAuthorModeView;
  366. }
  367. void SetAuthorModeView(bool fAuthorMode)
  368. {
  369. m_bAuthorModeView = fAuthorMode;
  370. }
  371. static CAMCView* CAMCView::GetActiveView();
  372. // Returns the most recently activated CAMCView.
  373. bool IsTracking() const;
  374. long GetDefaultListViewStyle() const;
  375. void SetDefaultListViewStyle(long style);
  376. int GetViewMode() const;
  377. private:
  378. BOOL IsSelectingNode() { return (m_nSelectNestLevel > 0); }
  379. SC ScSpecialResultpaneSelectionActivate(bool bActivate);
  380. SC ScTreeViewSelectionActivate(bool bActivate);
  381. SC ScListViewSelectionActivate(bool bActivate);
  382. bool CanInsertScopeItemInResultPane();
  383. // Operations
  384. public:
  385. SC ScUpdateWindowTitle();
  386. SC ScActivate();
  387. SC ScOnMinimize(bool fMinimized);
  388. SC ScOnSize(UINT nType, int cx, int cy);
  389. SC ScApplyViewExtension (LPCTSTR pszURL);
  390. // Scope Pane : Tree View.
  391. UINT GetTreeItem(CHMTNODEList* pNodeList, HTREEITEM* phItem);
  392. HTREEITEM FindChildNode(HTREEITEM hti, DWORD dwItemDataKey);
  393. HTREEITEM FindHTreeItem(HMTNODE hMTNode, HTREEITEM htiFirst);
  394. BOOL QueryForReName(TV_DISPINFO* ptvdi, LRESULT* pResult);
  395. void SetRootNode(HMTNODE hMTNode);
  396. HNODE GetRootNode(void);
  397. HRESULT GetNodePath(HTREEITEM hti, HTREEITEM htiRoot, CBookmark* pbm);
  398. HRESULT GetRootNodePath(CBookmark* pbm);
  399. HRESULT GetSelectedNodePath(CBookmark* pbm);
  400. void SelectNode(MTNODEID ID, GUID &guidTaskpad);
  401. // Result Pane.
  402. SC ScInitDefListView(LPUNKNOWN pUnkResultsPane);
  403. SC ScAddDefaultColumns();
  404. SC ScOnSelectNode(HNODE hNode, BOOL &bAddSubFolders);
  405. SC ScSetResultPane(HNODE hNode, CResultViewType rvt, int viewMode, bool bUsingHistory);
  406. SC ScGetProperty(int iIndex, BSTR bstrPropertyName, PBSTR pbstrPropertyValue);
  407. SC ScGetNodetype(int iIndex, PBSTR Nodetype);
  408. LPUNKNOWN GetPaneUnknown(ViewPane ePane);
  409. void OpenResultItem(HNODE hNode);
  410. BOOL OnListCtrlItemDblClk(void);
  411. BOOL DispatchListCtrlNotificationMsg(LPARAM lParam, LRESULT* pResult);
  412. BOOL CreateListCtrl(int nID, CCreateContext* pContext);
  413. void SetListViewOptions(DWORD dwListOptions);
  414. SC ScAttachListViewAsResultPane();
  415. SC ScAttachWebViewAsResultPane();
  416. SC ScAttachOCXAsResultPane(HNODE hNode);
  417. void ShowResultPane(CView * pWnd, EUIStyleType nStyle);
  418. long GetListViewStyle();
  419. CView* GetResultView () const;
  420. void SetListViewMultiSelect(BOOL bMultiSelect);
  421. bool CanDoDragDrop();
  422. void DeSelectResultPane(HNODE hNodeSel);
  423. HRESULT NotifyListPad (BOOL b);
  424. // General (both) view related.
  425. LPCTSTR GetWindowTitle(void);
  426. BOOL RenameItem(HNODE hNode, BOOL bScopeItem, MMC_COOKIE lResultItemCookie, LPWSTR pszText, LRESULT* pResult);
  427. void CloseView();
  428. void DeleteView();
  429. // REVIEW int's are not enum!
  430. void SetPane(ViewPane ePane, CView* pView, EUIStyleType nStyle=uiClientEdge);
  431. bool DeflectActivation (BOOL fActivate, CView* pDeactivatingView);
  432. void SetChildFrameWnd(HWND m_hChildFrameWnd);
  433. void SetPaneFocus();
  434. void SetPaneWithFocus(UINT pane);
  435. SC ScDeferSettingFocusToResultPane();
  436. SC ScSetFocusToResultPane();
  437. // Other helpers.
  438. void OnActionMenu(CPoint pt, LPCRECT prcExclude);
  439. void OnViewMenu(CPoint pt, LPCRECT prcExclude);
  440. void OnFavoritesMenu(CPoint point, LPCRECT prcExclude);
  441. void UpdateSnapInHelpMenus(CMenu* pMenu);
  442. void OnRefresh();
  443. void OnUpdatePasteBtn();
  444. SC ScShowScopePane (bool fShow, bool fForce = false);
  445. SC ScConsoleVerb (int nVerb);
  446. SC ScProcessConsoleVerb (HNODE hNode, bool bScope, LPARAM lResultCookie, int nVerb);
  447. SC ScUpOneLevel ();
  448. SC ScWebCommand (WebCommand eCommand);
  449. SC ScAddPageBreakAndNavigate (bool fAddPageBreak, bool fNavigate, LPCTSTR szURL);
  450. void OnDeleteEmptyView();
  451. SC ScUpdateMMCMenus();
  452. // Columns helpers
  453. SC ScColumnInfoListChanged(const CColumnInfoList& colInfoList);
  454. SC ScGetPersistedColumnInfoList(CColumnInfoList *pColInfoList);
  455. SC ScDeletePersistedColumnData();
  456. /*
  457. * Message Handlers.
  458. */
  459. // Overrides
  460. // ClassWizard generated virtual function overrides
  461. //{{AFX_VIRTUAL(CAMCView)
  462. public:
  463. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  464. virtual void OnInitialUpdate();
  465. protected:
  466. virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
  467. virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
  468. virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
  469. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  470. virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);
  471. virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
  472. virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
  473. //}}AFX_VIRTUAL
  474. virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult );
  475. // Generated message map functions
  476. protected:
  477. //{{AFX_MSG(CAMCView)
  478. afx_msg void OnLButtonDown(UINT nFlags, CPoint pt);
  479. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  480. afx_msg void OnSetFocus(CWnd* pOldWnd);
  481. afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
  482. afx_msg void OnDestroy();
  483. afx_msg void OnUpdateFileSnapinmanager(CCmdUI* pCmdUI);
  484. afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
  485. afx_msg void OnNextPane();
  486. afx_msg void OnPrevPane();
  487. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  488. afx_msg void OnContextHelp();
  489. afx_msg void OnSnapInHelp();
  490. afx_msg void OnSnapinAbout();
  491. afx_msg void OnHelpTopics();
  492. afx_msg void OnSize(UINT nType, int cx, int cy);
  493. afx_msg void OnPaletteChanged(CWnd* pwndFocus);
  494. afx_msg BOOL OnQueryNewPalette( );
  495. afx_msg void OnSysColorChange();
  496. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  497. //}}AFX_MSG
  498. // keep these outside the AFX_MSG markers so ClassWizard won't munge them
  499. afx_msg void OnUpdateNextPane(CCmdUI* pCmdUI);
  500. afx_msg void OnUpdatePrevPane(CCmdUI* pCmdUI);
  501. afx_msg void OnUpdateShiftF10(CCmdUI* pCmdUI);
  502. afx_msg void OnVerbAccelKey(UINT nID);
  503. afx_msg void OnShiftF10();
  504. afx_msg void OnAmcNodeNew(UINT nID);
  505. afx_msg void OnAmcNodeNewUpdate(CCmdUI* pCmdUI);
  506. afx_msg void OnDrawClipboard();
  507. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  508. afx_msg LRESULT OnProcessMultiSelectionChanges(WPARAM, LPARAM);
  509. afx_msg LRESULT OnJiggleListViewFocus (WPARAM, LPARAM);
  510. afx_msg LRESULT OnDeferRecalcLayout (WPARAM, LPARAM);
  511. afx_msg LRESULT OnConnectToCIC (WPARAM wParam, LPARAM lParam);
  512. afx_msg LRESULT OnConnectToTPLV(WPARAM wParam, LPARAM lParam) {return ScOnConnectToTPLV(wParam, lParam).ToHr();}
  513. SC ScOnConnectToTPLV(WPARAM wParam, LPARAM lParam);
  514. afx_msg LRESULT OnShowWebContextMenu (WPARAM wParam, LPARAM lParam);
  515. afx_msg LRESULT OnSetDescriptionBarText (WPARAM wParam, LPARAM lParam);
  516. afx_msg LRESULT OnAddPageBreakAndNavigate(WPARAM wParam, LPARAM lParam);
  517. afx_msg LRESULT OnGetIconInfoForSelectedNode(WPARAM wParam, LPARAM lParam);
  518. afx_msg LRESULT OnAppCommand(WPARAM wParam, LPARAM lParam);
  519. afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
  520. // result based tabs.
  521. afx_msg void OnChangedResultTab(NMHDR *nmhdr, LRESULT *pRes);
  522. public:
  523. DECLARE_MESSAGE_MAP()
  524. // Implementation
  525. public:
  526. virtual ~CAMCView();
  527. #ifdef _DEBUG
  528. virtual void AssertValid() const;
  529. virtual void Dump(CDumpContext& dc) const;
  530. #endif
  531. protected:
  532. int m_nSelectNestLevel;
  533. UINT m_nViewID;
  534. HMTNODE m_hMTNode; // root node for this view
  535. IScopeTreeIterPtr m_spScopeTreeIter; // view's iterator to scope tree
  536. INodeCallbackPtr m_spNodeCallback; // view's callback interface
  537. bool m_bAuthorModeView; // Saved in author mode (user can't close)
  538. bool m_bDefColumns;
  539. long m_DefaultLVStyle;
  540. int m_columnWidth[2];
  541. // Last selection
  542. bool m_bLastSelWasMultiSel;
  543. enum eCurrentActivePane
  544. {
  545. eActivePaneNone, // No pane is active.
  546. eActivePaneScope,
  547. eActivePaneResult,
  548. };
  549. eCurrentActivePane m_eCurrentActivePane; // Tells if scope or result was the active pane.
  550. // Check for sel-change data
  551. bool m_bProcessMultiSelectionChanges;
  552. CDescriptionCtrl m_RightDescCtrl; // control bar embedded members
  553. IScopeTree* GetScopeTreePtr();
  554. // The document may release the scope tree without notifying the view.
  555. // The view should always go through this function to obtain a pointer
  556. // to the the scope tree.
  557. private:
  558. HNODE m_ListPadNode;
  559. int m_iFocusedLV;
  560. bool m_bLVItemSelected;
  561. int m_nReleaseViews;
  562. // Attributes
  563. protected:
  564. //---------------------------------------------------------------------
  565. // NOTE: ePane_Tasks is defined to have a pane identifier for the
  566. // task view pane. Currently no task view information is stored
  567. // in the pane info array, so the use of ePane_Tasks as an index is
  568. // of limited value.
  569. //----------------------------------------------------------------------
  570. // Pane information implementation structure
  571. struct PaneInfo
  572. {
  573. CView* pView; // Pointer to the view
  574. int cx; // 0 means hidden
  575. int cxIdeal; // user set size or size before hidden
  576. int cxMin; // below that try not to show
  577. };
  578. // child window IDs
  579. enum
  580. {
  581. /*
  582. * Bug 344422: these IDs should be maintained for compatibility
  583. * with automated tests
  584. */
  585. IDC_TreeView = 12785,
  586. IDC_ListView = 12786,
  587. IDC_GenericOCXCtrl = 12787,
  588. IDC_WebViewCtrl = 12788,
  589. IDC_OCXHostView,
  590. IDC_TaskView,
  591. IDC_RightDescBar,
  592. IDC_TaskpadTitle,
  593. IDC_ListCaption,
  594. IDC_ResultTabCtrl,
  595. IDC_ViewExtensionView,
  596. };
  597. // Pointers to actual controls
  598. CAMCTreeView * m_pTreeCtrl; // Tree control
  599. CCCListViewCtrl * m_pListCtrl; // Default list control
  600. CAMCWebViewCtrl * m_pWebViewCtrl; // Private web view control
  601. CAMCWebViewCtrl * m_pViewExtensionCtrl; // Private web view control for view extensions
  602. COCXHostView * m_pOCXHostView; // host for OCX's
  603. CFolderTabView * m_pResultFolderTabView;
  604. // current state information
  605. PaneInfo m_PaneInfo[ePane_Count]; // Array of panes
  606. int m_nViewMode; // current listview mode for all node that use listviews in this view
  607. bool m_bRenameListPadItem;
  608. protected:
  609. CChildFrame* GetParentFrame() const;
  610. void SetDescBarVisible(bool b)
  611. { m_ViewData.SetDescBarVisible (b); }
  612. bool IsDescBarVisible(void) const
  613. { return m_ViewData.IsDescBarVisible(); }
  614. void SetStatusBarVisible(bool bVisible)
  615. {
  616. if (bVisible)
  617. m_ViewData.m_dwToolbarsDisplayed |= STATUS_BAR;
  618. else
  619. m_ViewData.m_dwToolbarsDisplayed &= ~STATUS_BAR;
  620. }
  621. bool IsStatusBarVisible(void) const
  622. { return ((m_ViewData.m_dwToolbarsDisplayed & STATUS_BAR) != 0); }
  623. void SetTaskpadTabsAllowed(bool b)
  624. { m_ViewData.SetTaskpadTabsAllowed(b); }
  625. bool AreTaskpadTabsAllowed(void) const
  626. { return m_ViewData.AreTaskpadTabsAllowed(); }
  627. // implementation attributes which control layout of the splitter
  628. static const CSize m_sizEdge; // 3-D edge
  629. static const int m_cxSplitter; // amount of space between panes
  630. // splitter bar and hit test enums
  631. enum ESplitType {splitBox, splitBar, splitIntersection, splitBorder};
  632. enum HitTestValue {hitNo, hitSplitterBox, hitSplitterBar};
  633. bool m_bDirty;
  634. HTREEITEM m_htiStartingSelectedNode;
  635. bool m_fRootedAtNonPersistedDynamicNode;
  636. bool m_fSnapinDisplayedHelp;
  637. bool m_fActivatingSpecialResultPane;
  638. bool m_fViewExtended;
  639. HTREEITEM m_htiCut;
  640. // implementation routines
  641. public:
  642. void AdjustTracker (int cx, int cy);
  643. void SaveStartingSelectedNode();
  644. bool HasNodeSelChanged();
  645. // layout methods
  646. void DeferRecalcLayout(bool fUseIdleTaskQueue = true, bool bArrangeIcons = false);
  647. void RecalcLayout(void);
  648. void LayoutResultFolderTabView (CDeferWindowPos& dwp, CRect& rectRemaining);
  649. void LayoutScopePane (CDeferWindowPos& dwp, CRect& rectRemaining);
  650. void LayoutResultPane (CDeferWindowPos& dwp, CRect& rectRemaining);
  651. void LayoutResultDescriptionBar (CDeferWindowPos& dwp, CRect& rectRemaining);
  652. void LayoutResultView (CDeferWindowPos& dwp, const CRect& rectRemaining);
  653. public:
  654. // CConsoleView methods
  655. virtual SC ScCut (HTREEITEM htiCut);
  656. virtual SC ScPaste ();
  657. virtual SC ScToggleStatusBar ();
  658. virtual SC ScToggleDescriptionBar ();
  659. virtual SC ScToggleScopePane ();
  660. virtual SC ScToggleTaskpadTabs ();
  661. virtual SC ScContextHelp ();
  662. virtual SC ScHelpTopics ();
  663. virtual SC ScShowSnapinHelpTopic (LPCTSTR pszTopic);
  664. virtual SC ScSaveList ();
  665. virtual SC ScGetFocusedItem (HNODE& hNode, LPARAM& lCookie, bool& fScope);
  666. virtual SC ScSetFocusToPane (ViewPane ePane);
  667. virtual SC ScSelectNode (MTNODEID id, bool bSelectExactNode = false); // Select the given node.
  668. virtual SC ScExpandNode (MTNODEID id, bool fExpand, bool fExpandVisually);
  669. virtual SC ScShowWebContextMenu ();
  670. virtual SC ScSetDescriptionBarText (LPCTSTR pszDescriptionText);
  671. virtual SC ScViewMemento (CMemento* pMemento);
  672. virtual SC ScChangeViewMode (int nNewMode);
  673. virtual SC ScJiggleListViewFocus ();
  674. virtual SC ScRenameListPadItem ();
  675. virtual SC ScOrganizeFavorites (); // bring up the "Organize Favorites" dialog.
  676. virtual SC ScLineUpIcons (); // line up the icons in the list
  677. virtual SC ScAutoArrangeIcons (); // auto arrange the icons in the list
  678. virtual SC ScOnRefresh (HNODE hNode, bool bScope, LPARAM lResultItemParam); // refreshes the view
  679. virtual SC ScOnRename (CContextMenuInfo *pContextInfo); // allows the user to rename the specified item
  680. virtual SC ScRenameScopeNode (HMTNODE hMTNode); // put the specified scope node into rename mode.
  681. virtual SC ScGetStatusBar (CConsoleStatusBar **ppStatusBar);
  682. virtual SC ScAddViewExtension (const CViewExtensionData& ved);
  683. virtual ViewPane GetFocusedPane ();
  684. virtual int GetListSize ();
  685. virtual HNODE GetSelectedNode ();
  686. virtual HWND CreateFavoriteObserver (HWND hwndParent, int nID);
  687. private:
  688. /*
  689. * CDeferredLayout - deferred layout object
  690. */
  691. class CDeferredLayout : public CIdleTask
  692. {
  693. public:
  694. CDeferredLayout(CAMCView* pAMCView);
  695. ~CDeferredLayout();
  696. // IIdleTask methods
  697. SC ScDoWork();
  698. SC ScGetTaskID(ATOM* pID);
  699. SC ScMerge(CIdleTask* pitMergeFrom);
  700. bool Attach (CAMCView* pwndAMCView);
  701. private:
  702. typedef std::set<HWND> WindowCollection;
  703. WindowCollection m_WindowsToLayout;
  704. const ATOM m_atomTask;
  705. };
  706. protected:
  707. // Tracking and and hit testing methods
  708. int HitTestPane(CPoint& pointTreeCtrlCoord);
  709. void OnTreeContextMenu(CPoint& point, CPoint& pointTreeCtrlCoord, HTREEITEM htiRClicked);
  710. void OnListContextMenu(CPoint& point);
  711. void OnContextMenuForTreeItem(int iIndex, HNODE hNode, CPoint& point,
  712. DATA_OBJECT_TYPES type_of_pane = CCT_SCOPE,
  713. HTREEITEM htiRClicked = NULL,
  714. MMC_CONTEXT_MENU_TYPES eMenuType = MMC_CONTEXT_MENU_DEFAULT,
  715. LPCRECT prcExclude = NULL,
  716. bool bAllowDefaultItem = true);
  717. void OnContextMenuForListItem(int iIndex, HRESULTITEM hHitTestItem,
  718. CPoint& point,
  719. MMC_CONTEXT_MENU_TYPES eMenuType = MMC_CONTEXT_MENU_DEFAULT,
  720. LPCRECT prcExclude = NULL,
  721. bool bAllowDefaultItem = true);
  722. // Internal functions and data
  723. private:
  724. UINT ClipPath(CHMTNODEList* pNodeList, POSITION& rpos, HNODE hNode);
  725. SC ScInitializeMemento(CMemento &memento);
  726. void OnAddToFavorites();
  727. void OnAdd(SViewUpdateInfo *pvui);
  728. void OnUpdateSelectionForDelete(SViewUpdateInfo* pvui);
  729. void OnDelete(SViewUpdateInfo *pvui);
  730. void OnModify(SViewUpdateInfo *pvui);
  731. void OnUpdateTaskpadNavigation(SViewUpdateInfo *pvui);
  732. void ChangePane(AMCNavDir eDir);
  733. int _GetLVItemData(LPARAM *lParam, UINT flags);
  734. int _GetLVSelectedItemData(LPARAM *lParam);
  735. int _GetLVFocusedItemData(LPARAM *lParam);
  736. HRESULT SendGenericNotify(NCLBK_NOTIFY_TYPE nclbk);
  737. void IdentifyRootNode();
  738. void CalcMaxHostedFrameRect (CRect& rect);
  739. void MapViewPtToHostedFramePt (CPoint& pt);
  740. void MapHostedFramePtToViewPt (CPoint& pt);
  741. void PointMapperWorker (CPoint& pt, bool fViewToHostedFrame);
  742. SC ScOnLeftOrRightMouseClickInListView();
  743. bool OnListItemChanged (NM_LISTVIEW* pnmlv);
  744. int OnVirtualListItemsStateChanged(LPNMLVODSTATECHANGE lpStateChange );
  745. SC ScPostMultiSelectionChangesMessage();
  746. SC ScCompleteInitialization();
  747. HMTNODE GetHMTNode(HTREEITEM hti);
  748. BOOL OwnsResultList(HTREEITEM hti);
  749. void OnContextMenuForTreeBackground(CPoint& point, LPCRECT prcExclude = NULL, bool bAllowDefaultItem = true);
  750. void ArrangeIcon(long style);
  751. void PrivateChangeListViewMode(int nMode);
  752. BOOL CommonListViewUpdate()
  753. {
  754. if (!HasList())
  755. return FALSE;
  756. if (m_pListCtrl == NULL)
  757. {
  758. TRACE(_T("View is supposed to be a listview but the member is NULL!"));
  759. ASSERT(FALSE);
  760. return FALSE;
  761. }
  762. return TRUE;
  763. }
  764. //LRESULT OnLVDeleteKeyPressed(WPARAM wParam, LPARAM lParam);
  765. LRESULT HandleLVMessage(UINT message, WPARAM wParam, LPARAM lParam);
  766. BOOL OnSharedKeyDown(WORD mVKey);
  767. CView* CreateView (CCreateContext* pContext, int nID, DWORD dwStyle);
  768. bool CreateView (int nID);
  769. bool CreateFolderCtrls();
  770. SC ScCreateToolbarObjects ();
  771. typedef std::vector<TREEITEMID> TIDVector;
  772. void AddFavItemsToCMenu(CMenu& menu, CFavorites* pFavs, TREEITEMID tid, TIDVector& vItemIDs);
  773. SC ScHelpWorker (LPCTSTR pszHelpTopic);
  774. SC ScGetSelectedLVItem(LPARAM& lvData);
  775. SC ScGetHNodeFromPNode(const PNODE& pNode, HNODE& hNode);
  776. SC ScExecuteScopeItemVerb (MMC_CONSOLE_VERB verb, VARIANT& varScopeNode, BSTR bstrNewName);
  777. SC ScExecuteResultItemVerb(MMC_CONSOLE_VERB verb, BSTR bstrNewName);
  778. SC ScAddFolderTabs( HNODE hNode , const CLSID& tabToSelect );
  779. SC ScCreateTaskpadHost(); // for snapin taskpads
  780. private:
  781. CString m_strWindowTitle;
  782. SViewData m_ViewData;
  783. CRect m_rectResultFrame;
  784. CRect m_rectVSplitter;
  785. CHistoryList* m_pHistoryList;
  786. CViewTracker* m_pTracker;
  787. ITaskPadHostPtr m_spTaskPadHost;
  788. FramePtr m_spFrame;
  789. FramePtr m_spViewExtFrame; // a frame pointer for the internal view extension hosted frame containing the primary snapin's view.
  790. // Toolbars related to this view.
  791. std::auto_ptr<CAMCViewToolbars> m_spAMCViewToolbars;
  792. std::auto_ptr<CStandardToolbar> m_spStandardToolbar;
  793. // map with view extension URL addresses
  794. typedef std::map<GUID, tstring> CViewExtensionURLs;
  795. CViewExtensionURLs m_ViewExtensionURLs;
  796. private:
  797. /*
  798. * private, registered window messages
  799. */
  800. static const UINT m_nShowWebContextMenuMsg;
  801. static const UINT m_nProcessMultiSelectionChangesMsg;
  802. static const UINT m_nAddPageBreakAndNavigateMsg;
  803. static const UINT m_nJiggleListViewFocusMsg;
  804. static const UINT m_nDeferRecalcLayoutMsg;
  805. };
  806. #ifndef _DEBUG // debug version in AMCView.cpp
  807. inline CAMCDoc* CAMCView::GetDocument()
  808. {
  809. return (CAMCDoc*)m_pDocument;
  810. }
  811. #endif
  812. CAMCView* GetAMCView (CWnd* pwnd);
  813. /*+-------------------------------------------------------------------------*
  814. * class CViewTemplateList
  815. *
  816. *
  817. * PURPOSE: Used as the helper to persist CAMCView objects, when loading
  818. * Since CAMCView need small ammount of data to be known prior to
  819. * creating it (and thus prior to persisting CAMCView),
  820. * we persist a CViewTemplateList to collect all data.
  821. * Afterwards we create views using that list and persist them
  822. *
  823. *+-------------------------------------------------------------------------*/
  824. class CViewTemplateList : public XMLListCollectionBase
  825. {
  826. public:
  827. // defines data to be stored as std::pair objects
  828. typedef std::pair< CBookmark, CPersistor > ViewTemplB_Type;
  829. typedef std::pair< int /*nViewID*/, ViewTemplB_Type > ViewTempl_Type;
  830. // defines collection to be used for storing data about views
  831. typedef std::vector< ViewTempl_Type > List_Type;
  832. // creator must provide a XML type
  833. CViewTemplateList(LPCTSTR strXmlType) : m_strXmlType(strXmlType) {}
  834. // accessory to get the list of gathered data
  835. inline List_Type& GetList() { return m_ViewsList; }
  836. // Pesistence staff used from CPersistor
  837. virtual void Persist(CPersistor& persistor);
  838. virtual void OnNewElement(CPersistor& persistor);
  839. virtual LPCTSTR GetXMLType() { return m_strXmlType; }
  840. private:
  841. List_Type m_ViewsList;
  842. LPCTSTR m_strXmlType;
  843. };
  844. /*+-------------------------------------------------------------------------*
  845. * class CXMLWindowPlacement
  846. *
  847. *
  848. * PURPOSE: class persists WINDOWPLACEMENT to xml
  849. *
  850. *+-------------------------------------------------------------------------*/
  851. class CXMLWindowPlacement : public CXMLObject
  852. {
  853. WINDOWPLACEMENT& m_rData;
  854. public:
  855. CXMLWindowPlacement(WINDOWPLACEMENT& rData) : m_rData(rData) {}
  856. protected:
  857. DEFINE_XML_TYPE(XML_TAG_WINDOW_PLACEMENT);
  858. virtual void Persist(CPersistor &persistor);
  859. };
  860. #include "amcview.inl"
  861. #endif // __AMCVIEW_H__