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.

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