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.

301 lines
9.6 KiB

  1. // wvcoord.h : Declaration of the CWebViewCoord
  2. #ifndef __WEBVIEWCOORD_H_
  3. #define __WEBVIEWCOORD_H_
  4. #include "dxmplay.h"
  5. #include "resource.h" // main symbols
  6. #include "evtsink.h"
  7. #include "mshtml.h"
  8. #include "mshtmdid.h"
  9. EXTERN_C const CLSID CLSID_WebViewOld; // retired from service
  10. extern HRESULT FindObjectStyle(IUnknown *punkObject, CComPtr<IHTMLStyle>& spStyle);
  11. extern BOOL IsRTLDocument(CComPtr<IHTMLDocument2>& spHTMLElement);
  12. class CThumbNailWrapper;
  13. class CFileListWrapper;
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CWebViewCoord
  16. class ATL_NO_VTABLE CWebViewCoord :
  17. public CComObjectRootEx<CComSingleThreadModel>,
  18. public CComCoClass<CWebViewCoord, &CLSID_WebView>,
  19. public IDispatchImpl<IWebView, &IID_IWebView, &LIBID_WEBVWLib>,
  20. public IObjectSafetyImpl<CWebViewCoord, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
  21. public IObjectWithSiteImpl<CWebViewCoord>
  22. {
  23. public:
  24. CWebViewCoord();
  25. ~CWebViewCoord();
  26. DECLARE_REGISTRY_RESOURCEID(IDR_WEBVIEWCOORD)
  27. BEGIN_COM_MAP(CWebViewCoord)
  28. COM_INTERFACE_ENTRY(IDispatch)
  29. COM_INTERFACE_ENTRY(IWebView)
  30. COM_INTERFACE_ENTRY(IObjectSafety)
  31. COM_INTERFACE_ENTRY_IMPL(IObjectWithSite)
  32. END_COM_MAP()
  33. // IObjectWithSite overrides
  34. STDMETHOD(SetSite)(IUnknown *pClientSite);
  35. private:
  36. //
  37. // Initialization helpers (including event sinks)
  38. //
  39. HRESULT InitFolderObjects(VOID);
  40. //
  41. // CDispatchEventSink overrides
  42. //
  43. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  44. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  45. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  46. // IWebView methods
  47. STDMETHOD(OnCSCClick)();
  48. STDMETHOD(CSCSynchronize)();
  49. STDMETHOD(OnCSCMouseOver)();
  50. STDMETHOD(OnCSCMouseOut)();
  51. //
  52. // Event handlers
  53. //
  54. STDMETHOD(OnWindowLoad)(VOID);
  55. STDMETHOD(OnWindowUnLoad)(VOID);
  56. STDMETHOD(OnFixSize)(VOID);
  57. private:
  58. HRESULT ReleaseFolderObjects(VOID);
  59. //
  60. // Objects in web view
  61. //
  62. CFileListWrapper *m_pFileListWrapper;
  63. CThumbNailWrapper *m_pThumbNailWrapper;
  64. //
  65. // Host HTML window Dispatch
  66. //
  67. IDispatch * m_pdispWindow;
  68. //
  69. // Some frequently used interfaces
  70. //
  71. CComPtr<IHTMLDocument2> m_spDocument;
  72. CComPtr<IHTMLElementCollection> m_spDocAll;
  73. CComPtr<IHTMLControlElement> m_spDocBody;
  74. CComPtr<IHTMLStyle> m_spFileListStyle;
  75. CComPtr<IHTMLStyle> m_spPanelStyle;
  76. CComPtr<IHTMLStyle> m_spRuleStyle;
  77. CComPtr<IHTMLStyle> m_spHeadingStyle;
  78. CComPtr<IHTMLElement> m_spHeading;
  79. CComPtr<IOleClientSite> m_spClientSite;
  80. //
  81. // Event sink advise cookies
  82. //
  83. DWORD m_dwFileListAdviseCookie;
  84. DWORD m_dwThumbNailAdviseCookie;
  85. DWORD m_dwHtmlWindowAdviseCookie;
  86. DWORD m_dwCSCHotTrackCookie;
  87. BOOL m_bRTLDocument;
  88. };
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CThumbNailWrapper
  91. class CThumbNailWrapper : public CDispatchEventSink {
  92. public:
  93. CThumbNailWrapper();
  94. ~CThumbNailWrapper();
  95. //
  96. // Initialization
  97. //
  98. HRESULT Init(CComPtr<IThumbCtl> spThumbNailCtl,
  99. CComPtr<IHTMLElement> spThumbnailLabel);
  100. //
  101. // CDispatchEventSink overrides
  102. //
  103. STDMETHOD(Invoke)(DISPID dispidMember, REFIID riid,
  104. LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
  105. EXCEPINFO* pexcepinfo, UINT* puArgErr);
  106. //
  107. // Event Handlers
  108. //
  109. HRESULT OnThumbNailReady(VOID);
  110. //
  111. // Cover for properties
  112. //
  113. HRESULT UsedSpace(CComBSTR &bstrUsed);
  114. HRESULT TotalSpace(CComBSTR &bstrTotal);
  115. HRESULT FreeSpace(CComBSTR &bstrFree);
  116. CComPtr<IThumbCtl> Control(VOID) {return m_spThumbNailCtl;};
  117. //
  118. // Methods
  119. //
  120. BOOL UpdateThumbNail(CComPtr<FolderItem> spFolderItems);
  121. HRESULT SetDisplay(CComBSTR &bstrDisplay);
  122. HRESULT SetHeight(int iHeight);
  123. HRESULT ClearThumbNail();
  124. private:
  125. HRESULT _SetThumbnailLabel(CComBSTR& bstrLabel);
  126. // Pointer to the control + style
  127. CComPtr<IThumbCtl> m_spThumbNailCtl;
  128. CComPtr<IHTMLElement> m_spThumbnailLabel;
  129. CComPtr<IHTMLStyle> m_spThumbNailStyle;
  130. };
  131. /////////////////////////////////////////////////////////////////////////////
  132. // CFileListWrapper
  133. class CFileListWrapper : public CDispatchEventSink {
  134. public:
  135. CFileListWrapper();
  136. ~CFileListWrapper();
  137. // Initialization
  138. HRESULT Init(CComPtr<IShellFolderViewDual> spFileList,
  139. CComPtr<IHTMLElement> spInfo,
  140. CComPtr<IHTMLElement> spLinks,
  141. CComPtr<IHTMLStyle> spPanelStyle,
  142. CComPtr<IHTMLElement> spMediaPlayerSpan,
  143. CComPtr<IHTMLElement> spCSCPlusMin,
  144. CComPtr<IHTMLElement> spCSCText,
  145. CComPtr<IHTMLElement> spCSCDetail,
  146. CComPtr<IHTMLElement> spCSCButton,
  147. CComPtr<IHTMLStyle> spCSCStyle,
  148. CComPtr<IHTMLStyle> spCSCDetailStyle,
  149. CComPtr<IHTMLStyle> spCSCButtonStyle,
  150. CComPtr<IHTMLDocument2> spDocument,
  151. CComPtr<IHTMLWindow2> spWindow,
  152. CThumbNailWrapper *pThumbNailWrapper);
  153. // CDispatchEventSink overrides
  154. STDMETHOD(Invoke)(DISPID dispIdMember, REFIID riid, LCID lcid,
  155. WORD wFlags, DISPPARAMS *pDispParams,
  156. VARIANT *pVarResult, EXCEPINFO *pExcepInfo,
  157. UINT *puArgErr);
  158. // Event Handlers
  159. HRESULT OnSelectionChanged(VOID);
  160. // Cover function for properties
  161. CComPtr<IShellFolderViewDual> Control(VOID) {return m_spFileList;};
  162. HRESULT SetDefaultPanelDisplay();
  163. HRESULT OnCSCClick();
  164. HRESULT CSCSynchronize();
  165. HRESULT OnCSCMouseOnOff(BOOL fOn);
  166. // Needs to be called by WVCoord, so public
  167. HRESULT AdviseWebviewLinks( BOOL fAdvise );
  168. private:
  169. //
  170. // Object pointers
  171. //
  172. CComPtr<IShellFolderViewDual> m_spFileList;
  173. CComPtr<IHTMLElement> m_spInfo;
  174. CComPtr<IHTMLElement> m_spLinks;
  175. CComPtr<IHTMLStyle> m_spPanelStyle;
  176. CComPtr<IMediaPlayer> m_spIMediaPlayer;
  177. CComPtr<IHTMLElement> m_spMediaPlayerSpan;
  178. CComPtr<IHTMLStyle> m_spMediaPlayerStyle;
  179. CComPtr<IHTMLElement> m_spCSCPlusMin;
  180. CComPtr<IHTMLElement> m_spCSCText;
  181. CComPtr<IHTMLElement> m_spCSCDetail;
  182. CComPtr<IHTMLElement> m_spCSCButton;
  183. CComPtr<IHTMLStyle> m_spCSCStyle;
  184. CComPtr<IHTMLStyle> m_spCSCDetailStyle;
  185. CComPtr<IHTMLStyle> m_spCSCButtonStyle;
  186. CComPtr<IHTMLDocument2> m_spDocument;
  187. CComPtr<IHTMLWindow2> m_spWindow;
  188. CThumbNailWrapper *m_pThumbNailWrapper;
  189. CComPtr<Folder2> m_spFolder2;
  190. CComPtr<FolderItem> m_spFolderItem;
  191. CComPtr<FolderItem2> m_spFolderItem2;
  192. CComPtr<FolderItems> m_spFolderItems;
  193. CComBSTR m_bstrInfoHTML;
  194. CComBSTR m_bstrCrossLinksHTML;
  195. BOOL m_bFoundAuthor;
  196. BOOL m_bFoundComment;
  197. BOOL m_bCSCDisplayed;
  198. BOOL m_bNeverGotPanelInfo;
  199. BOOL m_bExpanded;
  200. BOOL m_bHotTracked;
  201. DWORD m_dwDateFlags;
  202. BOOL m_bRTLDocument;
  203. BOOL m_bPathIsSlow;
  204. //
  205. // Helper functions
  206. //
  207. HRESULT ClearThumbNail();
  208. HRESULT StopMediaPlayer();
  209. HRESULT ClearMediaPlayer();
  210. HRESULT NoneSelected();
  211. HRESULT MultipleSelected(long cSelection);
  212. HRESULT OneSelected();
  213. HRESULT GetItemNameForDisplay();
  214. HRESULT GetItemType();
  215. HRESULT GetItemDateTime();
  216. HRESULT GetItemSize();
  217. HRESULT GetItemAttributes();
  218. HRESULT GetItemAuthor();
  219. HRESULT GetItemComment();
  220. HRESULT GetItemHTMLInfoTip();
  221. HRESULT GetOtherItemDetails();
  222. HRESULT GetItemInfoTip();
  223. HRESULT DealWithDriveInfo();
  224. HRESULT GetCrossLink(int nFolder, UINT uIDToolTip);
  225. HRESULT GetCrossLinks();
  226. HRESULT FormatCrossLink(LPCWSTR pwszDisplayName, LPCWSTR pwszUrlPath, UINT uIDToolTip);
  227. HRESULT DisplayInfoHTML();
  228. HRESULT DisplayCrossLinksHTML();
  229. HRESULT GetItemInfo(long lResId, LPWSTR wszInfoDescCanonical, CComBSTR& bstrInfoDesc, CComBSTR& bstrInfo);
  230. HRESULT IsItThisFolder(int nFolder, BOOL& bResult, LPWSTR pwszDisplayName, DWORD cchDisplayName, LPWSTR pwszPath, DWORD cchPath);
  231. HRESULT GetIMediaPlayer(CComPtr<IMediaPlayer>& spIMediaPlayer);
  232. // CSC functions
  233. HRESULT CSCGetStatusText(LONG lStatus, CComBSTR& bstrCSCText);
  234. HRESULT CSCGetStatusDetail(LONG lStatus, CComBSTR& bstrCSCDetail);
  235. HRESULT CSCGetStatusButton(LONG lStatus, CComBSTR& bstrCSCButton);
  236. HRESULT GetCSCFolderStatus(LONG* plStatus);
  237. HRESULT CSCShowStatusInfo();
  238. HRESULT CSCShowStatus_FoldExpand_Toggle();
  239. // Event handlers for setting status bar text
  240. HRESULT OnWebviewLinkEvent( BOOL fEnter );
  241. HRESULT GetEventAnchorElement(IHTMLEventObj *pEvent, IHTMLElement **ppElt);
  242. HRESULT GetWVLinksCollection( IHTMLElementCollection **ppCollection, long *pcLinks );
  243. };
  244. #endif //__WEBVIEWCOORD_H_